Skip to content

Commit c04fa5e

Browse files
rustyrussellendothermicdev
authored andcommitted
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 <[email protected]> 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
1 parent e9c58d7 commit c04fa5e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lightningd/opening_control.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,14 @@ wallet_commit_channel(struct lightningd *ld,
122122
/* FIXME: P2TR for elements! */
123123
if (chainparams->is_elements)
124124
addrtype = ADDR_BECH32;
125-
else
125+
else if (feature_negotiated(ld->our_features,
126+
uc->peer->their_features,
127+
OPT_SHUTDOWN_ANYSEGWIT))
126128
addrtype = ADDR_P2TR;
129+
else
130+
/* They *may* update to OPT_SHUTDOWN_ANYSEGWIT by the
131+
* time we close, so be prepared for both. */
132+
addrtype = ADDR_ALL;
127133

128134
/* Get a key to use for closing outputs from this tx */
129135
final_key_idx = wallet_get_newindex(ld, addrtype);

0 commit comments

Comments
 (0)