@@ -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
} ,
@@ -4558,7 +4558,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4558
4558
}
4559
4559
} ;
4560
4560
channel_state. pending_msg_events . push ( send_msg_err_event) ;
4561
- let _ = remove_channel ! ( self , channel_state , channel) ;
4561
+ let _ = remove_channel ! ( self , channel) ;
4562
4562
return Err ( APIError :: APIMisuseError { err : "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations." . to_owned ( ) } ) ;
4563
4563
}
4564
4564
@@ -4638,7 +4638,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4638
4638
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4639
4639
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4640
4640
}
4641
- try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , channel_state , chan) ;
4641
+ try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , chan) ;
4642
4642
( chan. get ( ) . get_value_satoshis ( ) , chan. get ( ) . get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get ( ) . get_user_id ( ) )
4643
4643
} ,
4644
4644
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
@@ -4665,7 +4665,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4665
4665
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4666
4666
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4667
4667
}
4668
- ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , channel_state , chan) , chan. remove ( ) )
4668
+ ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , chan) , chan. remove ( ) )
4669
4669
} ,
4670
4670
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
4671
4671
}
@@ -4738,7 +4738,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4738
4738
}
4739
4739
let ( monitor, funding_tx, channel_ready) = match chan. get_mut ( ) . funding_signed ( & msg, best_block, & self . logger ) {
4740
4740
Ok ( update) => update,
4741
- Err ( e) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
4741
+ Err ( e) => try_chan_entry ! ( self , Err ( e) , chan) ,
4742
4742
} ;
4743
4743
match self . chain_monitor . watch_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor) {
4744
4744
ChannelMonitorUpdateStatus :: Completed => { } ,
@@ -4777,7 +4777,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4777
4777
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4778
4778
}
4779
4779
let announcement_sigs_opt = try_chan_entry ! ( self , chan. get_mut( ) . channel_ready( & msg, self . get_our_node_id( ) ,
4780
- self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , channel_state , chan) ;
4780
+ self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , chan) ;
4781
4781
if let Some ( announcement_sigs) = announcement_sigs_opt {
4782
4782
log_trace ! ( self . logger, "Sending announcement_signatures for channel {}" , log_bytes!( chan. get( ) . channel_id( ) ) ) ;
4783
4783
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
@@ -4825,7 +4825,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4825
4825
if chan_entry. get( ) . sent_shutdown( ) { " after we initiated shutdown" } else { "" } ) ;
4826
4826
}
4827
4827
4828
- let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , channel_state , chan_entry) ;
4828
+ let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , chan_entry) ;
4829
4829
dropped_htlcs = htlcs;
4830
4830
4831
4831
// Update the monitor with the shutdown script if necessary.
@@ -4834,7 +4834,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4834
4834
let ( result, is_permanent) =
4835
4835
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
4836
4836
if is_permanent {
4837
- remove_channel ! ( self , channel_state , chan_entry) ;
4837
+ remove_channel ! ( self , chan_entry) ;
4838
4838
break result;
4839
4839
}
4840
4840
}
@@ -4869,7 +4869,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4869
4869
if chan_entry. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4870
4870
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4871
4871
}
4872
- let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , channel_state , chan_entry) ;
4872
+ let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , chan_entry) ;
4873
4873
if let Some ( msg) = closing_signed {
4874
4874
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendClosingSigned {
4875
4875
node_id : counterparty_node_id. clone ( ) ,
@@ -4882,7 +4882,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4882
4882
// also implies there are no pending HTLCs left on the channel, so we can
4883
4883
// fully delete it from tracking (the channel monitor is still around to
4884
4884
// watch for old state broadcasts)!
4885
- ( tx, Some ( remove_channel ! ( self , channel_state , chan_entry) ) )
4885
+ ( tx, Some ( remove_channel ! ( self , chan_entry) ) )
4886
4886
} else { ( tx, None ) }
4887
4887
} ,
4888
4888
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -4946,7 +4946,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4946
4946
_ => pending_forward_info
4947
4947
}
4948
4948
} ;
4949
- try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , channel_state , chan) ;
4949
+ try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , chan) ;
4950
4950
} ,
4951
4951
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4952
4952
}
@@ -4962,7 +4962,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4962
4962
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4963
4963
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4964
4964
}
4965
- try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , channel_state , chan)
4965
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , chan)
4966
4966
} ,
4967
4967
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4968
4968
}
@@ -4979,7 +4979,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4979
4979
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4980
4980
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4981
4981
}
4982
- try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , channel_state , chan) ;
4982
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , chan) ;
4983
4983
} ,
4984
4984
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4985
4985
}
@@ -4996,9 +4996,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4996
4996
}
4997
4997
if ( msg. failure_code & 0x8000 ) == 0 {
4998
4998
let chan_err: ChannelError = ChannelError :: Close ( "Got update_fail_malformed_htlc with BADONION not set" . to_owned ( ) ) ;
4999
- try_chan_entry ! ( self , Err ( chan_err) , channel_state , chan) ;
4999
+ try_chan_entry ! ( self , Err ( chan_err) , chan) ;
5000
5000
}
5001
- 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) ;
5001
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_malformed_htlc( & msg, HTLCFailReason :: Reason { failure_code: msg. failure_code, data: Vec :: new( ) } ) , chan) ;
5002
5002
Ok ( ( ) )
5003
5003
} ,
5004
5004
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -5015,11 +5015,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5015
5015
}
5016
5016
let ( revoke_and_ack, commitment_signed, monitor_update) =
5017
5017
match chan. get_mut ( ) . commitment_signed ( & msg, & self . logger ) {
5018
- Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
5018
+ Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , chan) ,
5019
5019
Err ( ( Some ( update) , e) ) => {
5020
5020
assert ! ( chan. get( ) . is_awaiting_monitor_update( ) ) ;
5021
5021
let _ = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , update) ;
5022
- try_chan_entry ! ( self , Err ( e) , channel_state , chan) ;
5022
+ try_chan_entry ! ( self , Err ( e) , chan) ;
5023
5023
unreachable ! ( ) ;
5024
5024
} ,
5025
5025
Ok ( res) => res
@@ -5102,7 +5102,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5102
5102
}
5103
5103
let was_paused_for_mon_update = chan. get ( ) . is_awaiting_monitor_update ( ) ;
5104
5104
let raa_updates = break_chan_entry ! ( self ,
5105
- chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , channel_state , chan) ;
5105
+ chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , chan) ;
5106
5106
htlcs_to_fail = raa_updates. holding_cell_failed_htlcs ;
5107
5107
let update_res = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , raa_updates. monitor_update ) ;
5108
5108
if was_paused_for_mon_update {
@@ -5162,7 +5162,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5162
5162
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
5163
5163
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
5164
5164
}
5165
- try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , channel_state , chan) ;
5165
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , chan) ;
5166
5166
} ,
5167
5167
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5168
5168
}
@@ -5184,7 +5184,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5184
5184
5185
5185
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelAnnouncement {
5186
5186
msg : try_chan_entry ! ( self , chan. get_mut( ) . announcement_signatures(
5187
- self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , channel_state , chan) ,
5187
+ self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , chan) ,
5188
5188
// Note that announcement_signatures fails if the channel cannot be announced,
5189
5189
// so get_channel_update_for_broadcast will never fail by the time we get here.
5190
5190
update_msg : self . get_channel_update_for_broadcast ( chan. get ( ) ) . unwrap ( ) ,
@@ -5223,7 +5223,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5223
5223
return Ok ( NotifyOption :: SkipPersist ) ;
5224
5224
} else {
5225
5225
log_debug ! ( self . logger, "Received channel_update for channel {}." , log_bytes!( chan_id) ) ;
5226
- try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , channel_state , chan) ;
5226
+ try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , chan) ;
5227
5227
}
5228
5228
} ,
5229
5229
hash_map:: Entry :: Vacant ( _) => unreachable ! ( )
@@ -5248,7 +5248,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5248
5248
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
5249
5249
let responses = try_chan_entry ! ( self , chan. get_mut( ) . channel_reestablish(
5250
5250
msg, & self . logger, self . our_network_pubkey. clone( ) , self . genesis_hash,
5251
- & * self . best_block. read( ) . unwrap( ) ) , channel_state , chan) ;
5251
+ & * self . best_block. read( ) . unwrap( ) ) , chan) ;
5252
5252
let mut channel_update = None ;
5253
5253
if let Some ( msg) = responses. shutdown_msg {
5254
5254
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendShutdown {
@@ -5312,7 +5312,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5312
5312
let by_id = & mut channel_state. by_id ;
5313
5313
let pending_msg_events = & mut channel_state. pending_msg_events ;
5314
5314
if let hash_map:: Entry :: Occupied ( chan_entry) = by_id. entry ( funding_outpoint. to_channel_id ( ) ) {
5315
- let mut chan = remove_channel ! ( self , channel_state , chan_entry) ;
5315
+ let mut chan = remove_channel ! ( self , chan_entry) ;
5316
5316
failed_channels. push ( chan. force_shutdown ( false ) ) ;
5317
5317
if let Ok ( update) = self . get_channel_update_for_broadcast ( & chan) {
5318
5318
pending_msg_events. push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
0 commit comments