Skip to content

Commit 160c30e

Browse files
committed
Add new splice tlvs for channel_reestablish
1 parent 0576425 commit 160c30e

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
@@ -5252,6 +5252,35 @@ static void peer_reconnect(struct peer *peer,
52525252
}
52535253

52545254
inflight = last_inflight(peer);
5255+
5256+
if (feature_negotiated(peer->our_features, peer->their_features, OPT_SPLICE)) {
5257+
/* Subtle: we free tmpctx below as we loop, so tal off peer */
5258+
send_tlvs = tlv_channel_reestablish_tlvs_new(peer);
5259+
5260+
/* BOLT- #2: channel_reestablish
5261+
* your_last_funding_locked tlv:
5262+
* - as a sender, you just set it to the last splice_locked you received from your peer
5263+
* - as a receiver, this tells you if your peer received your last splice_locked or not
5264+
*/
5265+
if (peer->splice_state->locked_ready[REMOTE] && peer->splice_state->remote_locked_txid != NULL) {
5266+
send_tlvs->your_last_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, peer->splice_state->remote_locked_txid);
5267+
}
5268+
else {
5269+
send_tlvs->your_last_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, &peer->channel->funding.txid);
5270+
}
5271+
5272+
/*
5273+
* my_current_funding_locked tlv:
5274+
* - as a sender, you just send it to your latest locally locked (ie deeply confirmed) splice transaction
5275+
* - as a receiver, this tells you whether your peer will be sending a splice_locked that you haven't received yet
5276+
*/
5277+
if (peer->splice_state->locked_ready[LOCAL]) {
5278+
send_tlvs->my_current_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, &peer->splice_state->locked_txid);
5279+
}
5280+
else {
5281+
send_tlvs->my_current_funding_locked = tal_dup(send_tlvs, struct bitcoin_txid, &peer->channel->funding.txid);
5282+
}
5283+
}
52555284

52565285
if (inflight && (!inflight->last_tx || !inflight->remote_tx_sigs)) {
52575286
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)