Skip to content

Commit a3b3200

Browse files
committed
Add new splice tlvs for channel_reestablish
1 parent 6a5891f commit a3b3200

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

channeld/channeld.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,6 +5357,35 @@ static void peer_reconnect(struct peer *peer,
53575357
#endif
53585358

53595359
inflight = last_inflight(peer);
5360+
5361+
if (feature_negotiated(peer->our_features, peer->their_features, OPT_SPLICE)) {
5362+
/* Subtle: we free tmpctx below as we loop, so tal off peer */
5363+
send_tlvs = tlv_channel_reestablish_tlvs_new(peer);
5364+
5365+
/* BOLT- #2: channel_reestablish
5366+
* your_last_funding_locked tlv:
5367+
* - as a sender, you just set it to the last splice_locked you received from your peer
5368+
* - as a receiver, this tells you if your peer received your last splice_locked or not
5369+
*/
5370+
if (peer->splice_state->locked_ready[REMOTE] && peer->splice_state->remote_locked_txid != NULL) {
5371+
send_tlvs->your_last_funding_locked_txid = tal_dup(send_tlvs, struct bitcoin_txid, peer->splice_state->remote_locked_txid);
5372+
}
5373+
else {
5374+
send_tlvs->your_last_funding_locked_txid = tal_dup(send_tlvs, struct bitcoin_txid, &peer->channel->funding.txid);
5375+
}
5376+
5377+
/*
5378+
* my_current_funding_locked tlv:
5379+
* - as a sender, you just send it to your latest locally locked (ie deeply confirmed) splice transaction
5380+
* - as a receiver, this tells you whether your peer will be sending a splice_locked that you haven't received yet
5381+
*/
5382+
if (peer->splice_state->locked_ready[LOCAL]) {
5383+
send_tlvs->my_current_funding_locked_txid = tal_dup(send_tlvs, struct bitcoin_txid, &peer->splice_state->locked_txid);
5384+
}
5385+
else {
5386+
send_tlvs->my_current_funding_locked_txid = tal_dup(send_tlvs, struct bitcoin_txid, &peer->channel->funding.txid);
5387+
}
5388+
}
53605389

53615390
send_next_commitment_number = peer->next_index[LOCAL];
53625391
if (inflight && (!inflight->last_tx || !inflight->remote_tx_sigs)) {

0 commit comments

Comments
 (0)