Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightningd: test that hsm_secret is as expected, at startup. #5425

Merged
merged 2 commits into from
Jul 20, 2022

Conversation

rustyrussell
Copy link
Contributor

If you get the wrong hsm_secret, your node_id will change, and
peers won't know who you are, bitcoind will reject your transaction
signatures, and other madness.

Catch this as soon as it happens, by storing our node_id in the db.

Suggested-by: @cdecker

Copy link
Member

@cdecker cdecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 26542c1

* We also check that our node_id is what we expect: otherwise a change
* in hsm_secret will have strange consequences! */
if (!wallet_sanity_check(ld->wallet))
errx(1, "Wallet sanity check failed.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errx(1, "Wallet sanity check failed.");
errx(WALLET_MISMATCH, "Wallet sanity check failed.");

What do you think to add a more accurate error here? this use case looks like a use case that can happens during some scripting stuff (raspiblitz stuff are usually happy with specific error on the cmd)

But maybe there are other reason to return a generic one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement! I'll add another commit...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this is a cleanup which deserves its own (not 0.12) branch....

@niftynei
Copy link
Collaborator

*and Suggested-By: @fiatjaf!

@niftynei niftynei added this to the v0.12 milestone Jul 14, 2022
@rustyrussell
Copy link
Contributor Author

Trivial rebase on master, added Changelog-Changed line.

@rustyrussell
Copy link
Contributor Author

*and Suggested-By: @fiatjaf!

Didn't know/remember that, but I've credited him too!

If you get the wrong hsm_secret, your node_id will change, and
peers won't know who you are, bitcoind will reject your transaction
signatures, and other madness.

Catch this as soon as it happens, by storing our node_id in the db.

Suggested-by: @cdecker, @fiatjaf
Signed-off-by: Rusty Russell <[email protected]>
Changelog-Changed: Config: `lightningd` will refuse to start with the wrong node_id (i.e. hsm_secret changes).
Most unexpected ones are still 1, but there are a few recognizable error codes
worth documenting.

Rename the HSM ones to put ERRCODE_ at the front, since we have non-HSM ones
too now.

Signed-off-by: Rusty Russell <[email protected]>
@rustyrussell
Copy link
Contributor Author

rustyrussell commented Jul 20, 2022

Fixed hsm generation test, which barfed because we change secret...

Ack 57da410

@rustyrussell rustyrussell merged commit 5979a77 into ElementsProject:master Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants