Skip to content

Commit c475214

Browse files
committed
splice: Update to Eclair style of reestablish
Update to use Eclair’s spec’d version of reestablish. Changelog-None
1 parent f35503c commit c475214

File tree

1 file changed

+33
-20
lines changed

1 file changed

+33
-20
lines changed

channeld/channeld.c

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5278,6 +5278,26 @@ static void peer_reconnect(struct peer *peer,
52785278
}
52795279
}
52805280

5281+
if (feature_negotiated(peer->our_features, peer->their_features,
5282+
OPT_SPLICE)) {
5283+
if (!send_tlvs) {
5284+
/* Subtle: we free tmpctx below as we loop, so
5285+
* tal off peer */
5286+
send_tlvs = tlv_channel_reestablish_tlvs_new(peer);
5287+
}
5288+
5289+
if (peer->channel_ready[REMOTE])
5290+
send_tlvs->your_last_funding_locked_txid = &peer->channel->funding.txid;
5291+
5292+
send_tlvs->my_current_funding_locked_txid = &peer->channel->funding.txid;
5293+
5294+
for (size_t i = 0; i < tal_count(peer->splice_state->inflights); i++) {
5295+
struct inflight *inflight = peer->splice_state->inflights[i];
5296+
if (inflight->locked_scid)
5297+
send_tlvs->my_current_funding_locked_txid = &inflight->outpoint.txid;
5298+
}
5299+
}
5300+
52815301
/* BOLT #2:
52825302
*
52835303
* - upon reconnection:
@@ -5390,26 +5410,6 @@ static void peer_reconnect(struct peer *peer,
53905410
true,
53915411
false,
53925412
true);
5393-
} else if (inflight->is_locked
5394-
&& bitcoin_txid_eq(remote_next_funding,
5395-
&inflight->outpoint.txid)) {
5396-
if (!bitcoin_txid_eq(&inflight->outpoint.txid,
5397-
&peer->splice_state->locked_txid))
5398-
peer_failed_err(peer->pps,
5399-
&peer->channel_id,
5400-
"Invalid splice was resumed %s,"
5401-
" should be %s",
5402-
fmt_bitcoin_txid(tmpctx,
5403-
&inflight->outpoint.txid),
5404-
fmt_bitcoin_txid(tmpctx,
5405-
&peer->splice_state->locked_txid));
5406-
status_info("Splice is not confirmed but locked on"
5407-
" chain -- resending splice_locked");
5408-
peer_write(peer->pps,
5409-
take(towire_splice_locked(NULL,
5410-
&peer->channel_id,
5411-
&inflight->outpoint.txid)));
5412-
peer->splice_state->locked_ready[LOCAL] = true;
54135413
} else if (bitcoin_txid_eq(remote_next_funding,
54145414
&inflight->outpoint.txid)) {
54155415
/* Don't send sigs unless we have theirs */
@@ -5464,6 +5464,19 @@ static void peer_reconnect(struct peer *peer,
54645464
}
54655465
}
54665466

5467+
/* Re-send `splice_locked` if an inflight is locked */
5468+
for (size_t i = 0; i < tal_count(peer->splice_state->inflights); i++) {
5469+
struct inflight *inflight = peer->splice_state->inflights[i];
5470+
if (!inflight->locked_scid)
5471+
continue;
5472+
5473+
peer_write(peer->pps,
5474+
take(towire_splice_locked(NULL,
5475+
&peer->channel_id,
5476+
&inflight->outpoint.txid)));
5477+
peer->splice_state->locked_ready[LOCAL] = true;
5478+
}
5479+
54675480
/* BOLT #2:
54685481
*
54695482
* - if `next_commitment_number` is 1 in both the

0 commit comments

Comments
 (0)