3

I'm studying Lightning network and I use c-lightning. I can Get a new address with newaddr method, but I can't find private key. My address is bcrt1qmckts70jsq2u5886lgcq2yn7xjmp97t09zlrg, how can I retrieve it's public key? Where Can I find it's private key?

$ bitcoin-cli validateaddress bcrt1qmckts70jsq2u5886lgcq2yn7xjmp97t09zlrgj                                                              │
{                                                                                                                                       │
  "isvalid": true,                                                                                                                      │
  "address": "bcrt1qmckts70jsq2u5886lgcq2yn7xjmp97t09zlrgj",                                                                            │
  "scriptPubKey": "0014de2cb879f28015ca1cfafa3005127e34b612f96f",                                                                       │
  "isscript": false,                                                                                                                    │
  "iswitness": true,                                                                                                                    │
  "witness_version": 0,                                                                                                                 │
  "witness_program": "de2cb879f28015ca1cfafa3005127e34b612f96f"                                                                         │
} 

1 Answer 1

3

lightningd doesn't offer simple RPC commands to dump keys.

If you really need to access the keys the simplest way would be to derive them directly from the hsm_secret.

Keys for onchain transactions (since you mentioned newaddr. The other derivations are more involved) are derived using BIP32 unhardened derivation from m/0/0.
The root seed is derived from the hsm_secret with :

root_seed = hkdf_sha256(hsm_secret, salt=NULL, info="bip32 seed")

There exist tools such as the hsmtools (which currently only derive keys for the commitment transactions but might be extended in the furure) or jb55's clightning-dumpkeys which take care of the derivation for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.