lightning-cli getinfo outputs my node's id, which is its public key. How can I get its underlying private key?

1 Answer 1


c-lightning uses this code to obtain the node's private key from the hsm_secret.

I've came up with a way to do the same using Python and posted my highly-commented tutorial-like code in this gist.

Basically you have to call an hkdf function with the hsm_secret contents, a salt which will usually be zero, \x00, and the label "nodeid".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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