@@ -2012,30 +2012,33 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2012
2012
htlc_sigs = unraw_sigs (tmpctx , raw_sigs ,
2013
2013
channel_has_anchors (peer -> channel ));
2014
2014
2015
- if (commit_index ) {
2015
+ // - If `batch` is smaller than or equal to `1`:
2016
+ // - MUST send an `error` and fail the channel.
2017
+ if (cs_tlv && cs_tlv -> splice_info && cs_tlv -> splice_info -> batch_size <= 1 )
2018
+ peer_failed_err (peer -> pps , & peer -> channel_id ,
2019
+ "Must only set batch tlv for batches greater than 1" );
2020
+
2021
+ if (commit_index > 0 ) {
2016
2022
outpoint = peer -> splice_state -> inflights [commit_index - 1 ]-> outpoint ;
2017
2023
funding_sats = peer -> splice_state -> inflights [commit_index - 1 ]-> amnt ;
2024
+ }
2025
+ else {
2026
+ outpoint = peer -> channel -> funding ;
2027
+ funding_sats = peer -> channel -> funding_sats ;
2028
+ }
2018
2029
2019
- if (!cs_tlv || !cs_tlv -> splice_info )
2020
- peer_failed_err (peer -> pps , & peer -> channel_id ,
2021
- "Must set funding_txid for each"
2022
- " extra commitment_signed message." );
2023
-
2024
- status_info ("handle_peer_commit_sig for inflight outpoint %s" , fmt_bitcoin_txid (tmpctx , & peer -> splice_state -> inflights [commit_index - 1 ]-> outpoint .txid ));
2030
+ if (cs_tlv && cs_tlv -> splice_info ) {
2031
+ status_info ("handle_peer_commit_sig for outpoint %s" , fmt_bitcoin_txid (tmpctx , & outpoint .txid ));
2025
2032
status_info ("handle_peer_commit_sig cs_tlv->splice_info->funding_txid %s" , fmt_bitcoin_txid (tmpctx , & cs_tlv -> splice_info -> funding_txid ));
2026
2033
2027
- if (!bitcoin_txid_eq (& peer -> splice_state -> inflights [ commit_index - 1 ] -> outpoint .txid ,
2028
- & cs_tlv -> splice_info -> funding_txid ))
2034
+ if (!bitcoin_txid_eq (& outpoint .txid ,
2035
+ & cs_tlv -> splice_info -> funding_txid ))
2029
2036
peer_failed_err (peer -> pps , & peer -> channel_id ,
2030
2037
"Expected commit sig message for %s but"
2031
2038
" got %s" ,
2032
- fmt_bitcoin_txid (tmpctx , & peer -> splice_state -> inflights [ commit_index - 1 ] -> outpoint .txid ),
2039
+ fmt_bitcoin_txid (tmpctx , & outpoint .txid ),
2033
2040
fmt_bitcoin_txid (tmpctx , & cs_tlv -> splice_info -> funding_txid ));
2034
2041
}
2035
- else {
2036
- outpoint = peer -> channel -> funding ;
2037
- funding_sats = peer -> channel -> funding_sats ;
2038
- }
2039
2042
2040
2043
txs = channel_txs (tmpctx , & outpoint , funding_sats , & htlc_map ,
2041
2044
NULL , & funding_wscript , peer -> channel ,
@@ -2179,7 +2182,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2179
2182
result -> old_secret = old_secret ;
2180
2183
/* Only the parent call continues from here.
2181
2184
* Return for all child calls. */
2182
- if (commit_index )
2185
+ if (commit_index > 0 )
2183
2186
return result ;
2184
2187
2185
2188
if (tal_count (msg_batch ) - 1 < tal_count (peer -> splice_state -> inflights ))
@@ -2205,7 +2208,7 @@ static struct commitsig_info *handle_peer_commit_sig(struct peer *peer,
2205
2208
changed_htlcs , sub_splice_amnt ,
2206
2209
funding_diff - sub_splice_amnt ,
2207
2210
local_index , local_per_commit ,
2208
- allow_empty_commit , NULL );
2211
+ allow_empty_commit , msg_batch );
2209
2212
old_secret = result -> old_secret ;
2210
2213
tal_arr_expand (& commitsigs , result -> commitsig );
2211
2214
tal_steal (commitsigs , result );
@@ -2369,7 +2372,7 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
2369
2372
status_debug ("Sorting the msg_batch of tal_count %d, batch_size: %d" , (int )tal_count (msg_batch ), (int )batch_size );
2370
2373
asort (msg_batch , tal_count (msg_batch ), commit_cmp , peer );
2371
2374
2372
- return handle_peer_commit_sig (peer , msg , commit_index , remote_funding ,
2375
+ return handle_peer_commit_sig (peer , msg_batch [ 0 ] , commit_index , remote_funding ,
2373
2376
changed_htlcs , splice_amnt ,
2374
2377
remote_splice_amnt , local_index ,
2375
2378
local_per_commit , allow_empty_commit ,
@@ -5401,7 +5404,7 @@ static void peer_reconnect(struct peer *peer,
5401
5404
#endif
5402
5405
5403
5406
inflight = last_inflight (peer );
5404
-
5407
+
5405
5408
if (feature_negotiated (peer -> our_features , peer -> their_features , OPT_SPLICE )) {
5406
5409
/* Subtle: we free tmpctx below as we loop, so tal off peer */
5407
5410
send_tlvs = tlv_channel_reestablish_tlvs_new (peer );
@@ -5413,12 +5416,12 @@ static void peer_reconnect(struct peer *peer,
5413
5416
*/
5414
5417
if (peer -> splice_state -> locked_ready [REMOTE ] && peer -> splice_state -> remote_locked_txid != NULL ) {
5415
5418
send_tlvs -> your_last_funding_locked_txid = tal_dup (send_tlvs , struct bitcoin_txid , peer -> splice_state -> remote_locked_txid );
5416
- }
5419
+ }
5417
5420
else {
5418
5421
send_tlvs -> your_last_funding_locked_txid = tal_dup (send_tlvs , struct bitcoin_txid , & peer -> channel -> funding .txid );
5419
5422
}
5420
5423
5421
- /*
5424
+ /*
5422
5425
* my_current_funding_locked tlv:
5423
5426
* - as a sender, you just send it to your latest locally locked (ie deeply confirmed) splice transaction
5424
5427
* - as a receiver, this tells you whether your peer will be sending a splice_locked that you haven't received yet
0 commit comments