lightningd: make sure we register all addresses at opening if peer doesn't support OPT_SHUTDOWN_ANYSEGWIT.
We select the close key index at opening time, but the non-DF code didn't correctly register the address as possibly used for P2WPKH for older nodes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: wallet: we could miss our own returned outputs on mutual closes if peer doesn't support option_shutdown_anysegwit (you will still need to rescan after update, if this happened to you!) Reported-by: Grubles
This commit is contained in:
@@ -122,8 +122,14 @@ wallet_commit_channel(struct lightningd *ld,
|
||||
/* FIXME: P2TR for elements! */
|
||||
if (chainparams->is_elements)
|
||||
addrtype = ADDR_BECH32;
|
||||
else
|
||||
else if (feature_negotiated(ld->our_features,
|
||||
uc->peer->their_features,
|
||||
OPT_SHUTDOWN_ANYSEGWIT))
|
||||
addrtype = ADDR_P2TR;
|
||||
else
|
||||
/* They *may* update to OPT_SHUTDOWN_ANYSEGWIT by the
|
||||
* time we close, so be prepared for both. */
|
||||
addrtype = ADDR_ALL;
|
||||
|
||||
/* Get a key to use for closing outputs from this tx */
|
||||
final_key_idx = wallet_get_newindex(ld, addrtype);
|
||||
|
||||
Reference in New Issue
Block a user