@@ -439,17 +439,10 @@ macro_rules! try_chan_entry {
439
439
}
440
440
441
441
macro_rules! return_monitor_err {
442
- ( $self: expr , $err: expr, $channel_state: expr, $entry: expr, $action_type: path) => {
443
- return_monitor_err!( $self, $err, $channel_state, $entry, $action_type, Vec :: new( ) , Vec :: new( ) )
442
+ ( $self: ident , $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $resend_raa : expr , $resend_commitment : expr ) => {
443
+ return_monitor_err!( $self, $err, $channel_state, $entry, $action_type, $resend_raa , $resend_commitment , Vec :: new( ) , Vec :: new( ) )
444
444
} ;
445
- ( $self: expr, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $raa_first_dropped_cs: expr) => {
446
- if $action_type != RAACommitmentOrder :: RevokeAndACKFirst { panic!( "Bad return_monitor_err call!" ) ; }
447
- return_monitor_err!( $self, $err, $channel_state, $entry, $action_type, Vec :: new( ) , Vec :: new( ) , $raa_first_dropped_cs)
448
- } ;
449
- ( $self: expr, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $failed_forwards: expr, $failed_fails: expr) => {
450
- return_monitor_err!( $self, $err, $channel_state, $entry, $action_type, $failed_forwards, $failed_fails, false )
451
- } ;
452
- ( $self: expr, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $failed_forwards: expr, $failed_fails: expr, $raa_first_dropped_cs: expr) => {
445
+ ( $self: ident, $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $resend_raa: expr, $resend_commitment: expr, $failed_forwards: expr, $failed_fails: expr) => {
453
446
match $err {
454
447
ChannelMonitorUpdateErr :: PermanentFailure => {
455
448
let ( channel_id, mut chan) = $entry. remove_entry( ) ;
@@ -468,7 +461,7 @@ macro_rules! return_monitor_err {
468
461
return Err ( MsgHandleErrInternal :: from_finish_shutdown( "ChannelMonitor storage failure" , channel_id, chan. force_shutdown( ) , $self. get_channel_update( & chan) . ok( ) ) )
469
462
} ,
470
463
ChannelMonitorUpdateErr :: TemporaryFailure => {
471
- $entry. get_mut( ) . monitor_update_failed( $action_type, $failed_forwards , $failed_fails , $raa_first_dropped_cs ) ;
464
+ $entry. get_mut( ) . monitor_update_failed( $action_type, $resend_raa , $resend_commitment , $failed_forwards , $failed_fails ) ;
472
465
return Err ( MsgHandleErrInternal :: from_chan_no_close( ChannelError :: Ignore ( "Failed to update ChannelMonitor" ) , * $entry. key( ) ) ) ;
473
466
} ,
474
467
}
@@ -477,7 +470,7 @@ macro_rules! return_monitor_err {
477
470
478
471
// Does not break in case of TemporaryFailure!
479
472
macro_rules! maybe_break_monitor_err {
480
- ( $self: expr , $err: expr, $channel_state: expr, $entry: expr, $action_type: path) => {
473
+ ( $self: ident , $err: expr, $channel_state: expr, $entry: expr, $action_type: path, $resend_raa : expr , $resend_commitment : expr ) => {
481
474
match $err {
482
475
ChannelMonitorUpdateErr :: PermanentFailure => {
483
476
let ( channel_id, mut chan) = $entry. remove_entry( ) ;
@@ -487,7 +480,7 @@ macro_rules! maybe_break_monitor_err {
487
480
break Err ( MsgHandleErrInternal :: from_finish_shutdown( "ChannelMonitor storage failure" , channel_id, chan. force_shutdown( ) , $self. get_channel_update( & chan) . ok( ) ) )
488
481
} ,
489
482
ChannelMonitorUpdateErr :: TemporaryFailure => {
490
- $entry. get_mut( ) . monitor_update_failed( $action_type, Vec :: new( ) , Vec :: new( ) , false ) ;
483
+ $entry. get_mut( ) . monitor_update_failed( $action_type, $resend_raa , $resend_commitment , Vec :: new( ) , Vec :: new( ) ) ;
491
484
} ,
492
485
}
493
486
}
@@ -1018,7 +1011,7 @@ impl ChannelManager {
1018
1011
} {
1019
1012
Some ( ( update_add, commitment_signed, chan_monitor) ) => {
1020
1013
if let Err ( e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
1021
- maybe_break_monitor_err ! ( self , e, channel_state, chan, RAACommitmentOrder :: CommitmentFirst ) ;
1014
+ maybe_break_monitor_err ! ( self , e, channel_state, chan, RAACommitmentOrder :: CommitmentFirst , false , true ) ;
1022
1015
// Note that MonitorUpdateFailed here indicates (per function docs)
1023
1016
// that we will resent the commitment update once we unfree monitor
1024
1017
// updating, so we have to take special care that we don't return
@@ -1962,7 +1955,7 @@ impl ChannelManager {
1962
1955
let ( revoke_and_ack, commitment_signed, closing_signed, chan_monitor) =
1963
1956
try_chan_entry ! ( self , chan. get_mut( ) . commitment_signed( & msg, & * self . fee_estimator) , channel_state, chan) ;
1964
1957
if let Err ( e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
1965
- return_monitor_err ! ( self , e, channel_state, chan, RAACommitmentOrder :: RevokeAndACKFirst , commitment_signed. is_some( ) ) ;
1958
+ return_monitor_err ! ( self , e, channel_state, chan, RAACommitmentOrder :: RevokeAndACKFirst , true , commitment_signed. is_some( ) ) ;
1966
1959
//TODO: Rebroadcast closing_signed if present on monitor update restoration
1967
1960
}
1968
1961
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendRevokeAndACK {
@@ -2040,7 +2033,7 @@ impl ChannelManager {
2040
2033
let ( commitment_update, pending_forwards, pending_failures, closing_signed, chan_monitor) =
2041
2034
try_chan_entry ! ( self , chan. get_mut( ) . revoke_and_ack( & msg, & * self . fee_estimator) , channel_state, chan) ;
2042
2035
if let Err ( e) = self . monitor . add_update_monitor ( chan_monitor. get_funding_txo ( ) . unwrap ( ) , chan_monitor) {
2043
- return_monitor_err ! ( self , e, channel_state, chan, RAACommitmentOrder :: CommitmentFirst , pending_forwards, pending_failures) ;
2036
+ return_monitor_err ! ( self , e, channel_state, chan, RAACommitmentOrder :: CommitmentFirst , false , commitment_update . is_some ( ) , pending_forwards, pending_failures) ;
2044
2037
}
2045
2038
if let Some ( updates) = commitment_update {
2046
2039
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: UpdateHTLCs {
@@ -2147,7 +2140,7 @@ impl ChannelManager {
2147
2140
if commitment_update. is_none ( ) {
2148
2141
order = RAACommitmentOrder :: RevokeAndACKFirst ;
2149
2142
}
2150
- return_monitor_err ! ( self , e, channel_state, chan, order) ;
2143
+ return_monitor_err ! ( self , e, channel_state, chan, order, revoke_and_ack . is_some ( ) , commitment_update . is_some ( ) ) ;
2151
2144
//TODO: Resend the funding_locked if needed once we get the monitor running again
2152
2145
}
2153
2146
}
0 commit comments