Skip to content

Commit a762d4d

Browse files
committed
channeld: detect splice on reestablish via funding_tx_index, not txid
is_splice_active compared the peer's my_current_funding_locked txid against peer->channel->funding.txid, which is wrong: once a splice locks, funding.txid becomes the splice txid, both sides agree on it, the check falls through, and channel_ready is incorrectly retransmitted on reconnect. Resolve the txid to its funding_tx_index (the current channel funding or a pending splice inflight) and treat > 0 as a splice. Changelog-Fixed: channeld: correctly detect splice transactions when deciding whether to retransmit `channel_ready` on reconnect.
1 parent 2c40355 commit a762d4d

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

channeld/channeld.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5645,6 +5645,23 @@ static bool capture_premature_msg(const u8 ***shit_lnd_says, const u8 *msg)
56455645
return true;
56465646
}
56475647

5648+
/* Returns the funding_tx_index of the funding tx with this txid: the current
5649+
* channel funding, or a pending splice inflight. Returns 0 (the original
5650+
* funding) if unknown.
5651+
*/
5652+
static u32 funding_tx_index_for_txid(const struct peer *peer,
5653+
const struct bitcoin_txid *txid)
5654+
{
5655+
if (bitcoin_txid_eq(txid, &peer->channel->funding.txid))
5656+
return peer->channel->funding_tx_index;
5657+
for (size_t i = 0; i < tal_count(peer->splice_state->inflights); i++) {
5658+
const struct inflight *inf = peer->splice_state->inflights[i];
5659+
if (bitcoin_txid_eq(txid, &inf->outpoint.txid))
5660+
return inf->funding_tx_index;
5661+
}
5662+
return 0;
5663+
}
5664+
56485665
static void peer_reconnect(struct peer *peer,
56495666
const struct secret *last_remote_per_commit_secret)
56505667
{
@@ -5974,9 +5991,8 @@ static void peer_reconnect(struct peer *peer,
59745991
|| remote_next_funding
59755992
|| (recv_tlvs
59765993
&& recv_tlvs->my_current_funding_locked
5977-
&& !bitcoin_txid_eq(
5978-
&recv_tlvs->my_current_funding_locked->my_current_funding_locked_txid,
5979-
&peer->channel->funding.txid));
5994+
&& funding_tx_index_for_txid(peer,
5995+
&recv_tlvs->my_current_funding_locked->my_current_funding_locked_txid) > 0);
59805996

59815997
/* BOLT #2:
59825998
*

tests/test_splicing_disconnect.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def test_splice_disconnect_sig(node_factory, bitcoind):
6969
@pytest.mark.openchannel('v1')
7070
@pytest.mark.openchannel('v2')
7171
@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')
72-
@pytest.mark.xfail(strict=True, reason="channel_ready wrongly retransmitted after splice until funding_tx_index detection")
7372
def test_splice_reconnect_after_lock_no_channel_ready(node_factory, bitcoind):
7473
# Once a splice locks, channel funding txid is updated to the splice txid.
7574
# On reconnect we must still recognise the peer's `my_current_funding_locked`
@@ -104,6 +103,9 @@ def test_splice_reconnect_after_lock_no_channel_ready(node_factory, bitcoind):
104103
# the new funding_tx_index columns) and reconnects/reestablishes.
105104
l1.restart()
106105

106+
# Force the reconnect rather than waiting on auto-reconnect backoff.
107+
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
108+
107109
l1.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
108110
l2.daemon.wait_for_log(r'peer_in WIRE_CHANNEL_REESTABLISH')
109111
l1.daemon.wait_for_log(r'billboard: Channel ready for use.')

0 commit comments

Comments
 (0)