Skip to content

Commit 9f83aea

Browse files
committed
Add new splice tlvs for channel_reestablish
1 parent d956405 commit 9f83aea

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

channeld/channeld.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5122,6 +5122,35 @@ static void peer_reconnect(struct peer *peer,
51225122
}
51235123

51245124
inflight = last_inflight(peer);
5125+
5126+
if (feature_negotiated(peer->our_features, peer->their_features, OPT_SPLICE)) {
5127+
/* Subtle: we free tmpctx below as we loop, so tal off peer */
5128+
send_tlvs = tlv_channel_reestablish_tlvs_new(peer);
5129+
5130+
/* BOLT- #2: channel_reestablish
5131+
* your_last_funding_locked tlv:
5132+
* - as a sender, you just set it to the last splice_locked you received from your peer
5133+
* - as a receiver, this tells you if your peer received your last splice_locked or not
5134+
*/
5135+
if (peer->splice_state->locked_ready[REMOTE] && peer->splice_state->remote_locked_txid != NULL) {
5136+
send_tlvs->your_last_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, peer->splice_state->remote_locked_txid);
5137+
}
5138+
else {
5139+
send_tlvs->your_last_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, &peer->channel->funding.txid);
5140+
}
5141+
5142+
/*
5143+
* my_current_funding_locked tlv:
5144+
* - as a sender, you just send it to your latest locally locked (ie deeply confirmed) splice transaction
5145+
* - as a receiver, this tells you whether your peer will be sending a splice_locked that you haven't received yet
5146+
*/
5147+
if (peer->splice_state->locked_ready[LOCAL]) {
5148+
send_tlvs->my_current_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, &peer->splice_state->locked_txid);
5149+
}
5150+
else {
5151+
send_tlvs->my_current_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, &peer->channel->funding.txid);
5152+
}
5153+
}
51255154

51265155
if (inflight && (!inflight->last_tx || !inflight->remote_tx_sigs)) {
51275156
if (missing_user_signatures(peer,

wire/peer_wire.csv

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,17 @@ tlvtype,channel_reestablish_tlvs,next_funding,0
292292
tlvdata,channel_reestablish_tlvs,next_funding,next_funding_txid,sha256,
293293
tlvtype,channel_reestablish_tlvs,next_funding,0
294294
tlvdata,channel_reestablish_tlvs,next_funding,next_funding_txid,sha256,
295-
tlvtype,channel_reestablish_tlvs,next_to_send,1
295+
tlvtype,channel_reestablish_tlvs,your_last_funding_locked,1
296+
tlvdata,channel_reestablish_tlvs,your_last_funding_locked,your_last_funding_locked,bitcoin_txid,
297+
tlvtype,channel_reestablish_tlvs,my_current_funding_locked,3
298+
tlvdata,channel_reestablish_tlvs,my_current_funding_locked,my_current_funding_locked,bitcoin_txid,
299+
tlvtype,channel_reestablish_tlvs,next_to_send,5
296300
tlvdata,channel_reestablish_tlvs,next_to_send,commitment_number,tu64,
297-
tlvtype,channel_reestablish_tlvs,desired_channel_type,3
301+
tlvtype,channel_reestablish_tlvs,desired_channel_type,7
298302
tlvdata,channel_reestablish_tlvs,desired_channel_type,type,byte,...
299-
tlvtype,channel_reestablish_tlvs,current_channel_type,5
303+
tlvtype,channel_reestablish_tlvs,current_channel_type,9
300304
tlvdata,channel_reestablish_tlvs,current_channel_type,type,byte,...
301-
tlvtype,channel_reestablish_tlvs,upgradable_channel_type,7
305+
tlvtype,channel_reestablish_tlvs,upgradable_channel_type,11
302306
tlvdata,channel_reestablish_tlvs,upgradable_channel_type,type,byte,...
303307
msgtype,peer_storage,7
304308
msgdata,peer_storage,len,u16,

0 commit comments

Comments
 (0)