@@ -2506,8 +2506,6 @@ impl Channel {
2506
2506
}
2507
2507
/// Only fails in case of bad keys
2508
2508
fn send_commitment_no_status_check ( & mut self ) -> Result < ( msgs:: CommitmentSigned , ChannelMonitor ) , HandleError > {
2509
- let funding_script = self . get_funding_redeemscript ( ) ;
2510
-
2511
2509
// We can upgrade the status of some HTLCs that are waiting on a commitment, even if we
2512
2510
// fail to generate this, we still are at least at a position where upgrading their status
2513
2511
// is acceptable.
@@ -2522,6 +2520,22 @@ impl Channel {
2522
2520
}
2523
2521
}
2524
2522
2523
+ match self . send_commitment_no_state_update ( ) {
2524
+ Ok ( ( res, remote_commitment_tx) ) => {
2525
+ // Update state now that we've passed all the can-fail calls...
2526
+ self . channel_monitor . provide_latest_remote_commitment_tx_info ( & remote_commitment_tx. 0 , remote_commitment_tx. 1 , self . cur_remote_commitment_transaction_number ) ;
2527
+ self . channel_state |= ChannelState :: AwaitingRemoteRevoke as u32 ;
2528
+ Ok ( ( res, self . channel_monitor . clone ( ) ) )
2529
+ } ,
2530
+ Err ( e) => Err ( e) ,
2531
+ }
2532
+ }
2533
+
2534
+ /// Only fails in case of bad keys. Used for channel_reestablish commitment_signed generation
2535
+ /// when we shouldn't change HTLC/channel state.
2536
+ fn send_commitment_no_state_update ( & self ) -> Result < ( msgs:: CommitmentSigned , ( Transaction , Vec < HTLCOutputInCommitment > ) ) , HandleError > {
2537
+ let funding_script = self . get_funding_redeemscript ( ) ;
2538
+
2525
2539
let remote_keys = self . build_remote_transaction_keys ( ) ?;
2526
2540
let remote_commitment_tx = self . build_commitment_transaction ( self . cur_remote_commitment_transaction_number , & remote_keys, false , true ) ;
2527
2541
let remote_commitment_txid = remote_commitment_tx. 0 . txid ( ) ;
@@ -2538,15 +2552,11 @@ impl Channel {
2538
2552
htlc_sigs. push ( self . secp_ctx . sign ( & htlc_sighash, & our_htlc_key) ) ;
2539
2553
}
2540
2554
2541
- // Update state now that we've passed all the can-fail calls...
2542
- self . channel_monitor . provide_latest_remote_commitment_tx_info ( & remote_commitment_tx. 0 , remote_commitment_tx. 1 , self . cur_remote_commitment_transaction_number ) ;
2543
- self . channel_state |= ChannelState :: AwaitingRemoteRevoke as u32 ;
2544
-
2545
2555
Ok ( ( msgs:: CommitmentSigned {
2546
2556
channel_id : self . channel_id ,
2547
2557
signature : our_sig,
2548
2558
htlc_signatures : htlc_sigs,
2549
- } , self . channel_monitor . clone ( ) ) )
2559
+ } , remote_commitment_tx ) )
2550
2560
}
2551
2561
2552
2562
/// Adds a pending outbound HTLC to this channel, and creates a signed commitment transaction
0 commit comments