@@ -1777,22 +1777,32 @@ static bool missing_user_signatures(const struct peer *peer,
17771777 return false;
17781778}
17791779
1780- static void check_tx_abort (struct peer * peer , const u8 * msg )
1780+ /* `txid` is which tx to abort (aka remove inflight). NULL means just restart
1781+ * channeld and dont abort any specific inflight. */
1782+ static void check_tx_abort (struct peer * peer , const u8 * msg , struct bitcoin_txid * txid )
17811783{
1782- struct inflight * inflight = last_inflight (peer );
1783- struct bitcoin_outpoint * outpoint ;
1784+ struct inflight * inflight ;
17841785 struct channel_id channel_id ;
17851786 u8 * data ;
17861787 char * reason ;
17871788
17881789 if (fromwire_peektype (msg ) != WIRE_TX_ABORT )
17891790 return ;
17901791
1791- if (have_i_signed_inflight (peer , inflight )) {
1792- peer_failed_err (peer -> pps , & peer -> channel_id , "tx_abort"
1793- " is not allowed after I have sent my"
1794- " signature. msg: %s" ,
1795- tal_hex (tmpctx , msg ));
1792+ inflight = NULL ;
1793+ for (size_t i = 0 ; txid && i < tal_count (peer -> splice_state -> inflights ); i ++ ) {
1794+ struct inflight * itr = peer -> splice_state -> inflights [i ];
1795+ if (!bitcoin_txid_eq (& itr -> outpoint .txid , txid ))
1796+ continue ;
1797+ if (have_i_signed_inflight (peer , inflight )) {
1798+ peer_failed_err (peer -> pps , & peer -> channel_id , "tx_abort"
1799+ " is not allowed after I have sent my"
1800+ " signature. msg: %s txid: %s" ,
1801+ tal_hex (tmpctx , msg ),
1802+ fmt_bitcoin_txid (tmpctx ,
1803+ & itr -> outpoint .txid ));
1804+ }
1805+ inflight = itr ;
17961806 }
17971807
17981808 if (!fromwire_tx_abort (tmpctx , msg , & channel_id , & data ))
@@ -1804,10 +1814,6 @@ static void check_tx_abort(struct peer *peer, const u8 *msg)
18041814 peer_write (peer -> pps ,
18051815 take (towire_tx_abort (NULL , & peer -> channel_id , NULL )));
18061816
1807- outpoint = NULL ;
1808- if (inflight )
1809- outpoint = & inflight -> outpoint ;
1810-
18111817 status_info ("Send tx_abort to master" );
18121818
18131819 reason = sanitize_error (tmpctx , msg , & peer -> channel_id );
@@ -1816,7 +1822,9 @@ static void check_tx_abort(struct peer *peer, const u8 *msg)
18161822
18171823 wire_sync_write (MASTER_FD ,
18181824 take (towire_channeld_splice_abort (NULL , false,
1819- outpoint ,
1825+ inflight
1826+ ? & inflight -> outpoint
1827+ : NULL ,
18201828 tal_fmt (tmpctx ,
18211829 "Peer aborted"
18221830 " for reason: %s" ,
@@ -2297,7 +2305,7 @@ static struct commitsig_info *handle_peer_commit_sig_batch(struct peer *peer,
22972305 struct tlv_commitment_signed_tlvs * sub_cs_tlv
22982306 = tlv_commitment_signed_tlvs_new (tmpctx );
22992307 u8 * sub_msg = peer_read (tmpctx , peer -> pps );
2300- check_tx_abort (peer , sub_msg );
2308+ check_tx_abort (peer , sub_msg , NULL );
23012309
23022310 /* Check type for cleaner failure message */
23032311 type = fromwire_peektype (sub_msg );
@@ -2960,7 +2968,7 @@ static struct commitsig *interactive_send_commitments(struct peer *peer,
29602968 WIRE_TX_SIGNATURES ,
29612969 WIRE_TX_ABORT );
29622970
2963- check_tx_abort (peer , msg );
2971+ check_tx_abort (peer , msg , & inflight -> outpoint . txid );
29642972
29652973 if (msg_received )
29662974 * msg_received = msg ;
@@ -3538,7 +3546,7 @@ static void resume_splice_negotiation(struct peer *peer,
35383546 recv_commitments ,
35393547 & msg_received );
35403548
3541- check_tx_abort (peer , msg_received );
3549+ check_tx_abort (peer , msg_received , & inflight -> outpoint . txid );
35423550
35433551 if (their_commit ) {
35443552 if (inflight -> last_tx != their_commit -> tx )
@@ -3654,7 +3662,7 @@ static void resume_splice_negotiation(struct peer *peer,
36543662
36553663 type = fromwire_peektype (msg );
36563664
3657- check_tx_abort (peer , msg );
3665+ check_tx_abort (peer , msg , & inflight -> outpoint . txid );
36583666
36593667 if (handle_peer_error_or_warning (peer -> pps , msg ))
36603668 return ;
@@ -4018,7 +4026,7 @@ static void splice_accepter(struct peer *peer, const u8 *inmsg)
40184026 peer_failed_err (peer -> pps , & peer -> channel_id ,
40194027 "Interactive splicing error: %s" , error );
40204028
4021- check_tx_abort (peer , abort_msg );
4029+ check_tx_abort (peer , abort_msg , NULL );
40224030
40234031 assert (ictx -> pause_when_complete == false);
40244032 peer -> splicing -> sent_tx_complete = true;
@@ -4270,7 +4278,7 @@ static void splice_initiator_user_finalized(struct peer *peer)
42704278 peer_failed_warn (peer -> pps , & peer -> channel_id ,
42714279 "Splice interactivetx error: %s" , error );
42724280
4273- check_tx_abort (peer , abort_msg );
4281+ check_tx_abort (peer , abort_msg , NULL );
42744282
42754283 /* With pause_when_complete fase, this assert should never fail */
42764284 assert (peer -> splicing -> received_tx_complete );
@@ -4436,7 +4444,7 @@ static void splice_initiator_user_update(struct peer *peer, const u8 *inmsg)
44364444 peer_failed_warn (peer -> pps , & peer -> channel_id ,
44374445 "Splice update error: %s" , error );
44384446
4439- check_tx_abort (peer , abort_msg );
4447+ check_tx_abort (peer , abort_msg , NULL );
44404448
44414449 peer -> splicing -> tx_add_input_count = ictx -> tx_add_input_count ;
44424450 peer -> splicing -> tx_add_output_count = ictx -> tx_add_output_count ;
@@ -4747,7 +4755,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
47474755 if (handle_peer_error_or_warning (peer -> pps , msg ))
47484756 return ;
47494757
4750- check_tx_abort (peer , msg );
4758+ check_tx_abort (peer , msg , NULL );
47514759
47524760 /* If we're in STFU mode and aren't waiting for a STFU mode
47534761 * specific message, the only valid message was tx_abort */
@@ -4846,7 +4854,7 @@ static void peer_in(struct peer *peer, const u8 *msg)
48464854 handle_peer_splice_locked (peer , msg );
48474855 return ;
48484856 case WIRE_TX_ABORT :
4849- check_tx_abort (peer , msg );
4857+ check_tx_abort (peer , msg , NULL );
48504858 return ;
48514859 case WIRE_INIT :
48524860 case WIRE_OPEN_CHANNEL :
@@ -6434,7 +6442,6 @@ static void req_in(struct peer *peer, const u8 *msg)
64346442 case WIRE_CHANNELD_SPLICE_FEERATE_ERROR :
64356443 case WIRE_CHANNELD_SPLICE_FUNDING_ERROR :
64366444 case WIRE_CHANNELD_SPLICE_ABORT :
6437- check_tx_abort (peer , msg );
64386445 case WIRE_CHANNELD_CONFIRMED_STFU :
64396446 break ;
64406447 case WIRE_CHANNELD_DEV_REENABLE_COMMIT :
0 commit comments