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