@@ -2431,8 +2431,6 @@ impl Channel {
2431
2431
}
2432
2432
/// Only fails in case of bad keys
2433
2433
fn send_commitment_no_status_check ( & mut self ) -> Result < ( msgs:: CommitmentSigned , ChannelMonitor ) , HandleError > {
2434
- let funding_script = self . get_funding_redeemscript ( ) ;
2435
-
2436
2434
// We can upgrade the status of some HTLCs that are waiting on a commitment, even if we
2437
2435
// fail to generate this, we still are at least at a position where upgrading their status
2438
2436
// is acceptable.
@@ -2447,6 +2445,22 @@ impl Channel {
2447
2445
}
2448
2446
}
2449
2447
2448
+ match self . send_commitment_no_state_update ( ) {
2449
+ Ok ( ( res, remote_commitment_tx) ) => {
2450
+ // Update state now that we've passed all the can-fail calls...
2451
+ self . channel_monitor . provide_latest_remote_commitment_tx_info ( & remote_commitment_tx. 0 , remote_commitment_tx. 1 , self . cur_remote_commitment_transaction_number ) ;
2452
+ self . channel_state |= ChannelState :: AwaitingRemoteRevoke as u32 ;
2453
+ Ok ( ( res, self . channel_monitor . clone ( ) ) )
2454
+ } ,
2455
+ Err ( e) => Err ( e) ,
2456
+ }
2457
+ }
2458
+
2459
+ /// Only fails in case of bad keys. Used for channel_reestablish commitment_signed generation
2460
+ /// when we shouldn't change HTLC/channel state.
2461
+ fn send_commitment_no_state_update ( & self ) -> Result < ( msgs:: CommitmentSigned , ( Transaction , Vec < HTLCOutputInCommitment > ) ) , HandleError > {
2462
+ let funding_script = self . get_funding_redeemscript ( ) ;
2463
+
2450
2464
let remote_keys = self . build_remote_transaction_keys ( ) ?;
2451
2465
let remote_commitment_tx = self . build_commitment_transaction ( self . cur_remote_commitment_transaction_number , & remote_keys, false , true ) ;
2452
2466
let remote_commitment_txid = remote_commitment_tx. 0 . txid ( ) ;
@@ -2463,15 +2477,11 @@ impl Channel {
2463
2477
htlc_sigs. push ( self . secp_ctx . sign ( & htlc_sighash, & our_htlc_key) ) ;
2464
2478
}
2465
2479
2466
- // Update state now that we've passed all the can-fail calls...
2467
- self . channel_monitor . provide_latest_remote_commitment_tx_info ( & remote_commitment_tx. 0 , remote_commitment_tx. 1 , self . cur_remote_commitment_transaction_number ) ;
2468
- self . channel_state |= ChannelState :: AwaitingRemoteRevoke as u32 ;
2469
-
2470
2480
Ok ( ( msgs:: CommitmentSigned {
2471
2481
channel_id : self . channel_id ,
2472
2482
signature : our_sig,
2473
2483
htlc_signatures : htlc_sigs,
2474
- } , self . channel_monitor . clone ( ) ) )
2484
+ } , remote_commitment_tx ) )
2475
2485
}
2476
2486
2477
2487
/// Adds a pending outbound HTLC to this channel, and creates a signed commitment transaction
0 commit comments