@@ -1348,7 +1348,7 @@ macro_rules! convert_chan_err {
1348
1348
}
1349
1349
1350
1350
macro_rules! break_chan_entry {
1351
- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1351
+ ( $self: ident, $res: expr, $entry: expr) => {
1352
1352
match $res {
1353
1353
Ok ( res) => res,
1354
1354
Err ( e) => {
@@ -1363,7 +1363,7 @@ macro_rules! break_chan_entry {
1363
1363
}
1364
1364
1365
1365
macro_rules! try_chan_entry {
1366
- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1366
+ ( $self: ident, $res: expr, $entry: expr) => {
1367
1367
match $res {
1368
1368
Ok ( res) => res,
1369
1369
Err ( e) => {
@@ -1378,7 +1378,7 @@ macro_rules! try_chan_entry {
1378
1378
}
1379
1379
1380
1380
macro_rules! remove_channel {
1381
- ( $self: expr, $channel_state : expr , $ entry: expr) => {
1381
+ ( $self: expr, $entry: expr) => {
1382
1382
{
1383
1383
let channel = $entry. remove_entry( ) . 1 ;
1384
1384
update_maps_on_chan_removal!( $self, channel) ;
@@ -1919,7 +1919,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1919
1919
let ( result, is_permanent) =
1920
1920
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
1921
1921
if is_permanent {
1922
- remove_channel ! ( self , channel_state , chan_entry) ;
1922
+ remove_channel ! ( self , chan_entry) ;
1923
1923
break result;
1924
1924
}
1925
1925
}
@@ -1930,7 +1930,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1930
1930
} ) ;
1931
1931
1932
1932
if chan_entry. get ( ) . is_shutdown ( ) {
1933
- let channel = remove_channel ! ( self , channel_state , chan_entry) ;
1933
+ let channel = remove_channel ! ( self , chan_entry) ;
1934
1934
if let Ok ( channel_update) = self . get_channel_update_for_broadcast ( & channel) {
1935
1935
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
1936
1936
msg : channel_update
@@ -2031,7 +2031,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2031
2031
} else {
2032
2032
self . issue_channel_close_events ( chan. get ( ) , ClosureReason :: HolderForceClosed ) ;
2033
2033
}
2034
- remove_channel ! ( self , channel_state , chan)
2034
+ remove_channel ! ( self , chan)
2035
2035
} else {
2036
2036
return Err ( APIError :: ChannelUnavailable { err : "No such channel" . to_owned ( ) } ) ;
2037
2037
}
@@ -2506,7 +2506,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2506
2506
payment_secret: payment_secret. clone( ) ,
2507
2507
payment_params: payment_params. clone( ) ,
2508
2508
} , onion_packet, & self . logger) ,
2509
- channel_state , chan)
2509
+ chan)
2510
2510
} {
2511
2511
Some ( ( update_add, commitment_signed, monitor_update) ) => {
2512
2512
let update_err = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor_update) ;
@@ -3320,7 +3320,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3320
3320
}
3321
3321
ChannelError :: Close ( msg) => {
3322
3322
log_trace ! ( self . logger, "Closing channel {} due to Close-required error: {}" , log_bytes!( chan. key( ) [ ..] ) , msg) ;
3323
- let mut channel = remove_channel ! ( self , channel_state , chan) ;
3323
+ let mut channel = remove_channel ! ( self , chan) ;
3324
3324
// ChannelClosed event is generated by handle_error for us.
3325
3325
Err ( MsgHandleErrInternal :: from_finish_shutdown ( msg, channel. channel_id ( ) , channel. get_user_id ( ) , channel. force_shutdown ( true ) , self . get_channel_update_for_broadcast ( & channel) . ok ( ) ) )
3326
3326
} ,
@@ -4549,7 +4549,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4549
4549
}
4550
4550
} ;
4551
4551
channel_state. pending_msg_events . push ( send_msg_err_event) ;
4552
- let _ = remove_channel ! ( self , channel_state , channel) ;
4552
+ let _ = remove_channel ! ( self , channel) ;
4553
4553
return Err ( APIError :: APIMisuseError { err : "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations." . to_owned ( ) } ) ;
4554
4554
}
4555
4555
@@ -4629,7 +4629,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4629
4629
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4630
4630
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4631
4631
}
4632
- try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , channel_state , chan) ;
4632
+ try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , chan) ;
4633
4633
( chan. get ( ) . get_value_satoshis ( ) , chan. get ( ) . get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get ( ) . get_user_id ( ) )
4634
4634
} ,
4635
4635
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
@@ -4656,7 +4656,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4656
4656
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4657
4657
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4658
4658
}
4659
- ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , channel_state , chan) , chan. remove ( ) )
4659
+ ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , chan) , chan. remove ( ) )
4660
4660
} ,
4661
4661
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
4662
4662
}
@@ -4729,7 +4729,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4729
4729
}
4730
4730
let ( monitor, funding_tx, channel_ready) = match chan. get_mut ( ) . funding_signed ( & msg, best_block, & self . logger ) {
4731
4731
Ok ( update) => update,
4732
- Err ( e) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
4732
+ Err ( e) => try_chan_entry ! ( self , Err ( e) , chan) ,
4733
4733
} ;
4734
4734
match self . chain_monitor . watch_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor) {
4735
4735
ChannelMonitorUpdateStatus :: Completed => { } ,
@@ -4768,7 +4768,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4768
4768
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4769
4769
}
4770
4770
let announcement_sigs_opt = try_chan_entry ! ( self , chan. get_mut( ) . channel_ready( & msg, self . get_our_node_id( ) ,
4771
- self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , channel_state , chan) ;
4771
+ self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , chan) ;
4772
4772
if let Some ( announcement_sigs) = announcement_sigs_opt {
4773
4773
log_trace ! ( self . logger, "Sending announcement_signatures for channel {}" , log_bytes!( chan. get( ) . channel_id( ) ) ) ;
4774
4774
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
@@ -4816,7 +4816,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4816
4816
if chan_entry. get( ) . sent_shutdown( ) { " after we initiated shutdown" } else { "" } ) ;
4817
4817
}
4818
4818
4819
- let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , channel_state , chan_entry) ;
4819
+ let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , chan_entry) ;
4820
4820
dropped_htlcs = htlcs;
4821
4821
4822
4822
// Update the monitor with the shutdown script if necessary.
@@ -4825,7 +4825,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4825
4825
let ( result, is_permanent) =
4826
4826
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
4827
4827
if is_permanent {
4828
- remove_channel ! ( self , channel_state , chan_entry) ;
4828
+ remove_channel ! ( self , chan_entry) ;
4829
4829
break result;
4830
4830
}
4831
4831
}
@@ -4860,7 +4860,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4860
4860
if chan_entry. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4861
4861
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4862
4862
}
4863
- let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , channel_state , chan_entry) ;
4863
+ let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , chan_entry) ;
4864
4864
if let Some ( msg) = closing_signed {
4865
4865
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendClosingSigned {
4866
4866
node_id : counterparty_node_id. clone ( ) ,
@@ -4873,7 +4873,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4873
4873
// also implies there are no pending HTLCs left on the channel, so we can
4874
4874
// fully delete it from tracking (the channel monitor is still around to
4875
4875
// watch for old state broadcasts)!
4876
- ( tx, Some ( remove_channel ! ( self , channel_state , chan_entry) ) )
4876
+ ( tx, Some ( remove_channel ! ( self , chan_entry) ) )
4877
4877
} else { ( tx, None ) }
4878
4878
} ,
4879
4879
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -4937,7 +4937,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4937
4937
_ => pending_forward_info
4938
4938
}
4939
4939
} ;
4940
- try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , channel_state , chan) ;
4940
+ try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , chan) ;
4941
4941
} ,
4942
4942
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4943
4943
}
@@ -4953,7 +4953,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4953
4953
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4954
4954
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4955
4955
}
4956
- try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , channel_state , chan)
4956
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , chan)
4957
4957
} ,
4958
4958
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4959
4959
}
@@ -4970,7 +4970,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4970
4970
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4971
4971
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4972
4972
}
4973
- try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , channel_state , chan) ;
4973
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , chan) ;
4974
4974
} ,
4975
4975
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4976
4976
}
@@ -4987,9 +4987,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4987
4987
}
4988
4988
if ( msg. failure_code & 0x8000 ) == 0 {
4989
4989
let chan_err: ChannelError = ChannelError :: Close ( "Got update_fail_malformed_htlc with BADONION not set" . to_owned ( ) ) ;
4990
- try_chan_entry ! ( self , Err ( chan_err) , channel_state , chan) ;
4990
+ try_chan_entry ! ( self , Err ( chan_err) , chan) ;
4991
4991
}
4992
- try_chan_entry ! ( self , chan. get_mut( ) . update_fail_malformed_htlc( & msg, HTLCFailReason :: Reason { failure_code: msg. failure_code, data: Vec :: new( ) } ) , channel_state , chan) ;
4992
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_malformed_htlc( & msg, HTLCFailReason :: Reason { failure_code: msg. failure_code, data: Vec :: new( ) } ) , chan) ;
4993
4993
Ok ( ( ) )
4994
4994
} ,
4995
4995
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -5006,11 +5006,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5006
5006
}
5007
5007
let ( revoke_and_ack, commitment_signed, monitor_update) =
5008
5008
match chan. get_mut ( ) . commitment_signed ( & msg, & self . logger ) {
5009
- Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
5009
+ Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , chan) ,
5010
5010
Err ( ( Some ( update) , e) ) => {
5011
5011
assert ! ( chan. get( ) . is_awaiting_monitor_update( ) ) ;
5012
5012
let _ = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , update) ;
5013
- try_chan_entry ! ( self , Err ( e) , channel_state , chan) ;
5013
+ try_chan_entry ! ( self , Err ( e) , chan) ;
5014
5014
unreachable ! ( ) ;
5015
5015
} ,
5016
5016
Ok ( res) => res
@@ -5093,7 +5093,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5093
5093
}
5094
5094
let was_paused_for_mon_update = chan. get ( ) . is_awaiting_monitor_update ( ) ;
5095
5095
let raa_updates = break_chan_entry ! ( self ,
5096
- chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , channel_state , chan) ;
5096
+ chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , chan) ;
5097
5097
htlcs_to_fail = raa_updates. holding_cell_failed_htlcs ;
5098
5098
let update_res = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , raa_updates. monitor_update ) ;
5099
5099
if was_paused_for_mon_update {
@@ -5153,7 +5153,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5153
5153
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
5154
5154
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
5155
5155
}
5156
- try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , channel_state , chan) ;
5156
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , chan) ;
5157
5157
} ,
5158
5158
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5159
5159
}
@@ -5175,7 +5175,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5175
5175
5176
5176
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelAnnouncement {
5177
5177
msg : try_chan_entry ! ( self , chan. get_mut( ) . announcement_signatures(
5178
- self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , channel_state , chan) ,
5178
+ self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , chan) ,
5179
5179
// Note that announcement_signatures fails if the channel cannot be announced,
5180
5180
// so get_channel_update_for_broadcast will never fail by the time we get here.
5181
5181
update_msg : self . get_channel_update_for_broadcast ( chan. get ( ) ) . unwrap ( ) ,
@@ -5214,7 +5214,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5214
5214
return Ok ( NotifyOption :: SkipPersist ) ;
5215
5215
} else {
5216
5216
log_debug ! ( self . logger, "Received channel_update for channel {}." , log_bytes!( chan_id) ) ;
5217
- try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , channel_state , chan) ;
5217
+ try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , chan) ;
5218
5218
}
5219
5219
} ,
5220
5220
hash_map:: Entry :: Vacant ( _) => unreachable ! ( )
@@ -5239,7 +5239,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5239
5239
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
5240
5240
let responses = try_chan_entry ! ( self , chan. get_mut( ) . channel_reestablish(
5241
5241
msg, & self . logger, self . our_network_pubkey. clone( ) , self . genesis_hash,
5242
- & * self . best_block. read( ) . unwrap( ) ) , channel_state , chan) ;
5242
+ & * self . best_block. read( ) . unwrap( ) ) , chan) ;
5243
5243
let mut channel_update = None ;
5244
5244
if let Some ( msg) = responses. shutdown_msg {
5245
5245
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendShutdown {
@@ -5303,7 +5303,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5303
5303
let by_id = & mut channel_state. by_id ;
5304
5304
let pending_msg_events = & mut channel_state. pending_msg_events ;
5305
5305
if let hash_map:: Entry :: Occupied ( chan_entry) = by_id. entry ( funding_outpoint. to_channel_id ( ) ) {
5306
- let mut chan = remove_channel ! ( self , channel_state , chan_entry) ;
5306
+ let mut chan = remove_channel ! ( self , chan_entry) ;
5307
5307
failed_channels. push ( chan. force_shutdown ( false ) ) ;
5308
5308
if let Ok ( update) = self . get_channel_update_for_broadcast ( & chan) {
5309
5309
pending_msg_events. push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
0 commit comments