mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-25 00:34:19 +01:00
lightningd: test that hsm_secret is as expected, at startup.
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 <rusty@rustcorp.com.au> Changelog-Changed: Config: `lightningd` will refuse to start with the wrong node_id (i.e. hsm_secret changes).
This commit is contained in:
@@ -1048,9 +1048,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
/*~ Our default names, eg. for the database file, are not dependent on
|
||||
* the network. Instead, the db knows what chain it belongs to, and we
|
||||
* simple barf here if it's wrong. */
|
||||
if (!wallet_network_check(ld->wallet))
|
||||
errx(1, "Wallet network check failed.");
|
||||
* simple barf here if it's wrong.
|
||||
*
|
||||
* 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.");
|
||||
|
||||
/*~ Initialize the transaction filter with our pubkeys. */
|
||||
init_txfilter(ld->wallet, ld->owned_txfilter);
|
||||
|
||||
@@ -223,13 +223,13 @@ void waitblockheight_notify_new_block(struct lightningd *ld UNNEEDED,
|
||||
/* Generated stub for wallet_blocks_heights */
|
||||
void wallet_blocks_heights(struct wallet *w UNNEEDED, u32 def UNNEEDED, u32 *min UNNEEDED, u32 *max UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_blocks_heights called!\n"); abort(); }
|
||||
/* Generated stub for wallet_network_check */
|
||||
bool wallet_network_check(struct wallet *w UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_network_check called!\n"); abort(); }
|
||||
/* Generated stub for wallet_new */
|
||||
struct wallet *wallet_new(struct lightningd *ld UNNEEDED, struct timers *timers UNNEEDED,
|
||||
struct ext_key *bip32_base UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_new called!\n"); abort(); }
|
||||
/* Generated stub for wallet_sanity_check */
|
||||
bool wallet_sanity_check(struct wallet *w UNNEEDED)
|
||||
{ fprintf(stderr, "wallet_sanity_check called!\n"); abort(); }
|
||||
/* AUTOGENERATED MOCKS END */
|
||||
|
||||
struct log *crashlog;
|
||||
|
||||
Reference in New Issue
Block a user