Skip to content

Commit 9d77391

Browse files
ddustinrustyrussell
authored andcommitted
splice: Eclair Interop — reestablish corner case
Handle a specific corner case where Eclair expects us to re-send splice_locked. Changelog-None
1 parent b76c0c1 commit 9d77391

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

channeld/channeld.c

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
23142314
enum peer_wire type;
23152315
struct tlv_commitment_signed_tlvs *cs_tlv
23162316
= tlv_commitment_signed_tlvs_new(tmpctx);
2317-
status_info("fromwire_commitment_signed(%p) primary", msg);
2317+
status_debug("fromwire_commitment_signed(%p) primary", msg);
23182318
if (!fromwire_commitment_signed(tmpctx, msg,
23192319
&channel_id, &commit_sig.s, &raw_sigs,
23202320
&cs_tlv))
@@ -5339,7 +5339,8 @@ static void peer_reconnect(struct peer *peer,
53395339
bool dataloss_protect, check_extra_fields;
53405340
const u8 **premature_msgs = tal_arr(peer, const u8 *, 0);
53415341
struct inflight *inflight;
5342-
struct bitcoin_txid *local_next_funding, *remote_next_funding;
5342+
struct bitcoin_txid *local_next_funding, *remote_next_funding,
5343+
*remote_your_last_funding;
53435344
u64 send_next_commitment_number;
53445345

53455346
struct tlv_channel_reestablish_tlvs *send_tlvs, *recv_tlvs;
@@ -5636,10 +5637,14 @@ static void peer_reconnect(struct peer *peer,
56365637
&inflight->outpoint.txid));
56375638
}
56385639
} else if (remote_next_funding) { /* No current inflight */
5640+
/* If our peer is trying to negotiate details about a splice
5641+
* that is already onchain, jump ahead to sending splice_lock */
56395642
if (bitcoin_txid_eq(remote_next_funding,
56405643
&peer->channel->funding.txid)) {
56415644
status_info("We have no pending splice but peer"
5642-
" expects one; resending splice_lock");
5645+
" is negotiating one; resending"
5646+
" splice_lock %s",
5647+
fmt_bitcoin_outpoint(tmpctx, &peer->channel->funding));
56435648
peer_write(peer->pps,
56445649
take(towire_splice_locked(NULL,
56455650
&peer->channel_id,
@@ -5657,13 +5662,43 @@ static void peer_reconnect(struct peer *peer,
56575662
if (!itr->locked_scid)
56585663
continue;
56595664

5665+
status_info("Resending splice_locked because an inflight %s is"
5666+
" locked",
5667+
fmt_bitcoin_outpoint(tmpctx, &itr->outpoint));
56605668
peer_write(peer->pps,
56615669
take(towire_splice_locked(NULL,
56625670
&peer->channel_id,
56635671
&itr->outpoint.txid)));
56645672
peer->splice_state->locked_ready[LOCAL] = true;
56655673
}
56665674

5675+
/* If no inflight, no splice negotiation, but
5676+
`your_last_funding_locked_txid is stale, re-send `splice_locked`. */
5677+
if (!inflight && !remote_next_funding
5678+
&& feature_negotiated(peer->our_features, peer->their_features,
5679+
OPT_SPLICE)) {
5680+
remote_your_last_funding = recv_tlvs
5681+
? recv_tlvs->your_last_funding_locked_txid : NULL;
5682+
if (remote_your_last_funding
5683+
&& !bitcoin_txid_eq(&peer->channel->funding.txid,
5684+
remote_your_last_funding)) {
5685+
status_info("Resending splice_locked with no inflight,"
5686+
" no splice negotation, but we did recv"
5687+
" remote_your_last_funding value of %s"
5688+
" instead of %s. Our sent splice_locked"
5689+
" value is %s.",
5690+
remote_your_last_funding
5691+
? fmt_bitcoin_txid(tmpctx, remote_your_last_funding)
5692+
: "NULL",
5693+
fmt_bitcoin_outpoint(tmpctx, &peer->channel->funding),
5694+
fmt_bitcoin_txid(tmpctx, &peer->channel->funding.txid));
5695+
peer_write(peer->pps,
5696+
take(towire_splice_locked(NULL,
5697+
&peer->channel_id,
5698+
&peer->channel->funding.txid)));
5699+
}
5700+
}
5701+
56675702
/* BOLT #2:
56685703
*
56695704
* - if `next_commitment_number` is 1 in both the

0 commit comments

Comments
 (0)