Skip to content

Commit d40da2b

Browse files
committed
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
1 parent 46690cb commit d40da2b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
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);

tests/test_closing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4277,7 +4277,6 @@ def censoring_sendrawtx(r):
42774277
l1.daemon.wait_for_log(r"Low-priority anchorspend aiming for block {} \(feerate 7500\)".format(height + 12))
42784278

42794279

4280-
@pytest.mark.xfail(strict=True)
42814280
@unittest.skipIf(TEST_NETWORK != 'regtest', "elementsd doesn't use p2tr anyway")
42824281
def test_onchain_close_no_p2tr(node_factory, bitcoind):
42834282
"""Closing with a peer which doesn't support OPT_SHUTDOWN_ANYSEGWIT"""

0 commit comments

Comments
 (0)