@@ -1354,7 +1354,7 @@ macro_rules! convert_chan_err {
1354
1354
}
1355
1355
1356
1356
macro_rules! break_chan_entry {
1357
- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1357
+ ( $self: ident, $res: expr, $entry: expr) => {
1358
1358
match $res {
1359
1359
Ok ( res) => res,
1360
1360
Err ( e) => {
@@ -1369,7 +1369,7 @@ macro_rules! break_chan_entry {
1369
1369
}
1370
1370
1371
1371
macro_rules! try_chan_entry {
1372
- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1372
+ ( $self: ident, $res: expr, $entry: expr) => {
1373
1373
match $res {
1374
1374
Ok ( res) => res,
1375
1375
Err ( e) => {
@@ -1384,7 +1384,7 @@ macro_rules! try_chan_entry {
1384
1384
}
1385
1385
1386
1386
macro_rules! remove_channel {
1387
- ( $self: expr, $channel_state : expr , $ entry: expr) => {
1387
+ ( $self: expr, $entry: expr) => {
1388
1388
{
1389
1389
let channel = $entry. remove_entry( ) . 1 ;
1390
1390
update_maps_on_chan_removal!( $self, channel) ;
@@ -1906,7 +1906,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1906
1906
let ( result, is_permanent) =
1907
1907
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
1908
1908
if is_permanent {
1909
- remove_channel ! ( self , channel_state , chan_entry) ;
1909
+ remove_channel ! ( self , chan_entry) ;
1910
1910
break result;
1911
1911
}
1912
1912
}
@@ -1917,7 +1917,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1917
1917
} ) ;
1918
1918
1919
1919
if chan_entry. get ( ) . is_shutdown ( ) {
1920
- let channel = remove_channel ! ( self , channel_state , chan_entry) ;
1920
+ let channel = remove_channel ! ( self , chan_entry) ;
1921
1921
if let Ok ( channel_update) = self . get_channel_update_for_broadcast ( & channel) {
1922
1922
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
1923
1923
msg : channel_update
@@ -2018,7 +2018,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2018
2018
} else {
2019
2019
self . issue_channel_close_events ( chan. get ( ) , ClosureReason :: HolderForceClosed ) ;
2020
2020
}
2021
- remove_channel ! ( self , channel_state , chan)
2021
+ remove_channel ! ( self , chan)
2022
2022
} else {
2023
2023
return Err ( APIError :: ChannelUnavailable { err : "No such channel" . to_owned ( ) } ) ;
2024
2024
}
@@ -2520,7 +2520,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2520
2520
payment_secret: payment_secret. clone( ) ,
2521
2521
payment_params: payment_params. clone( ) ,
2522
2522
} , onion_packet, & self . logger) ,
2523
- channel_state , chan)
2523
+ chan)
2524
2524
} {
2525
2525
Some ( ( update_add, commitment_signed, monitor_update) ) => {
2526
2526
let update_err = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor_update) ;
@@ -3255,7 +3255,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3255
3255
}
3256
3256
ChannelError :: Close ( msg) => {
3257
3257
log_trace ! ( self . logger, "Closing channel {} due to Close-required error: {}" , log_bytes!( chan. key( ) [ ..] ) , msg) ;
3258
- let mut channel = remove_channel ! ( self , channel_state , chan) ;
3258
+ let mut channel = remove_channel ! ( self , chan) ;
3259
3259
// ChannelClosed event is generated by handle_error for us.
3260
3260
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 ( ) ) )
3261
3261
} ,
@@ -4459,7 +4459,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4459
4459
}
4460
4460
} ;
4461
4461
channel_state. pending_msg_events . push ( send_msg_err_event) ;
4462
- let _ = remove_channel ! ( self , channel_state , channel) ;
4462
+ let _ = remove_channel ! ( self , channel) ;
4463
4463
return Err ( APIError :: APIMisuseError { err : "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations." . to_owned ( ) } ) ;
4464
4464
}
4465
4465
@@ -4539,7 +4539,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4539
4539
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4540
4540
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4541
4541
}
4542
- try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , channel_state , chan) ;
4542
+ try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , chan) ;
4543
4543
( chan. get ( ) . get_value_satoshis ( ) , chan. get ( ) . get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get ( ) . get_user_id ( ) )
4544
4544
} ,
4545
4545
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
@@ -4566,7 +4566,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4566
4566
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4567
4567
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4568
4568
}
4569
- ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , channel_state , chan) , chan. remove ( ) )
4569
+ ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , chan) , chan. remove ( ) )
4570
4570
} ,
4571
4571
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
4572
4572
}
@@ -4639,7 +4639,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4639
4639
}
4640
4640
let ( monitor, funding_tx, channel_ready) = match chan. get_mut ( ) . funding_signed ( & msg, best_block, & self . logger ) {
4641
4641
Ok ( update) => update,
4642
- Err ( e) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
4642
+ Err ( e) => try_chan_entry ! ( self , Err ( e) , chan) ,
4643
4643
} ;
4644
4644
match self . chain_monitor . watch_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor) {
4645
4645
ChannelMonitorUpdateStatus :: Completed => { } ,
@@ -4678,7 +4678,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4678
4678
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4679
4679
}
4680
4680
let announcement_sigs_opt = try_chan_entry ! ( self , chan. get_mut( ) . channel_ready( & msg, self . get_our_node_id( ) ,
4681
- self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , channel_state , chan) ;
4681
+ self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , chan) ;
4682
4682
if let Some ( announcement_sigs) = announcement_sigs_opt {
4683
4683
log_trace ! ( self . logger, "Sending announcement_signatures for channel {}" , log_bytes!( chan. get( ) . channel_id( ) ) ) ;
4684
4684
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
@@ -4723,7 +4723,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4723
4723
if chan_entry. get( ) . sent_shutdown( ) { " after we initiated shutdown" } else { "" } ) ;
4724
4724
}
4725
4725
4726
- let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , channel_state , chan_entry) ;
4726
+ let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , chan_entry) ;
4727
4727
dropped_htlcs = htlcs;
4728
4728
4729
4729
// Update the monitor with the shutdown script if necessary.
@@ -4732,7 +4732,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4732
4732
let ( result, is_permanent) =
4733
4733
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
4734
4734
if is_permanent {
4735
- remove_channel ! ( self , channel_state , chan_entry) ;
4735
+ remove_channel ! ( self , chan_entry) ;
4736
4736
break result;
4737
4737
}
4738
4738
}
@@ -4767,7 +4767,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4767
4767
if chan_entry. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
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
- let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , channel_state , chan_entry) ;
4770
+ let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , chan_entry) ;
4771
4771
if let Some ( msg) = closing_signed {
4772
4772
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendClosingSigned {
4773
4773
node_id : counterparty_node_id. clone ( ) ,
@@ -4780,7 +4780,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4780
4780
// also implies there are no pending HTLCs left on the channel, so we can
4781
4781
// fully delete it from tracking (the channel monitor is still around to
4782
4782
// watch for old state broadcasts)!
4783
- ( tx, Some ( remove_channel ! ( self , channel_state , chan_entry) ) )
4783
+ ( tx, Some ( remove_channel ! ( self , chan_entry) ) )
4784
4784
} else { ( tx, None ) }
4785
4785
} ,
4786
4786
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -4844,7 +4844,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4844
4844
_ => pending_forward_info
4845
4845
}
4846
4846
} ;
4847
- try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , channel_state , chan) ;
4847
+ try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , chan) ;
4848
4848
} ,
4849
4849
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4850
4850
}
@@ -4860,7 +4860,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4860
4860
if chan. 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
- try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , channel_state , chan)
4863
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , chan)
4864
4864
} ,
4865
4865
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4866
4866
}
@@ -4877,7 +4877,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4877
4877
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4878
4878
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4879
4879
}
4880
- try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , channel_state , chan) ;
4880
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , chan) ;
4881
4881
} ,
4882
4882
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4883
4883
}
@@ -4894,9 +4894,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4894
4894
}
4895
4895
if ( msg. failure_code & 0x8000 ) == 0 {
4896
4896
let chan_err: ChannelError = ChannelError :: Close ( "Got update_fail_malformed_htlc with BADONION not set" . to_owned ( ) ) ;
4897
- try_chan_entry ! ( self , Err ( chan_err) , channel_state , chan) ;
4897
+ try_chan_entry ! ( self , Err ( chan_err) , chan) ;
4898
4898
}
4899
- 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) ;
4899
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_malformed_htlc( & msg, HTLCFailReason :: Reason { failure_code: msg. failure_code, data: Vec :: new( ) } ) , chan) ;
4900
4900
Ok ( ( ) )
4901
4901
} ,
4902
4902
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -4913,11 +4913,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4913
4913
}
4914
4914
let ( revoke_and_ack, commitment_signed, monitor_update) =
4915
4915
match chan. get_mut ( ) . commitment_signed ( & msg, & self . logger ) {
4916
- Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
4916
+ Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , chan) ,
4917
4917
Err ( ( Some ( update) , e) ) => {
4918
4918
assert ! ( chan. get( ) . is_awaiting_monitor_update( ) ) ;
4919
4919
let _ = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , update) ;
4920
- try_chan_entry ! ( self , Err ( e) , channel_state , chan) ;
4920
+ try_chan_entry ! ( self , Err ( e) , chan) ;
4921
4921
unreachable ! ( ) ;
4922
4922
} ,
4923
4923
Ok ( res) => res
@@ -5000,7 +5000,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5000
5000
}
5001
5001
let was_paused_for_mon_update = chan. get ( ) . is_awaiting_monitor_update ( ) ;
5002
5002
let raa_updates = break_chan_entry ! ( self ,
5003
- chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , channel_state , chan) ;
5003
+ chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , chan) ;
5004
5004
htlcs_to_fail = raa_updates. holding_cell_failed_htlcs ;
5005
5005
let update_res = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , raa_updates. monitor_update ) ;
5006
5006
if was_paused_for_mon_update {
@@ -5060,7 +5060,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5060
5060
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
5061
5061
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
5062
5062
}
5063
- try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , channel_state , chan) ;
5063
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , chan) ;
5064
5064
} ,
5065
5065
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5066
5066
}
@@ -5082,7 +5082,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5082
5082
5083
5083
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelAnnouncement {
5084
5084
msg : try_chan_entry ! ( self , chan. get_mut( ) . announcement_signatures(
5085
- self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , channel_state , chan) ,
5085
+ self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , chan) ,
5086
5086
// Note that announcement_signatures fails if the channel cannot be announced,
5087
5087
// so get_channel_update_for_broadcast will never fail by the time we get here.
5088
5088
update_msg : self . get_channel_update_for_broadcast ( chan. get ( ) ) . unwrap ( ) ,
@@ -5121,7 +5121,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5121
5121
return Ok ( NotifyOption :: SkipPersist ) ;
5122
5122
} else {
5123
5123
log_debug ! ( self . logger, "Received channel_update for channel {}." , log_bytes!( chan_id) ) ;
5124
- try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , channel_state , chan) ;
5124
+ try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , chan) ;
5125
5125
}
5126
5126
} ,
5127
5127
hash_map:: Entry :: Vacant ( _) => unreachable ! ( )
@@ -5146,7 +5146,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5146
5146
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
5147
5147
let responses = try_chan_entry ! ( self , chan. get_mut( ) . channel_reestablish(
5148
5148
msg, & self . logger, self . our_network_pubkey. clone( ) , self . genesis_hash,
5149
- & * self . best_block. read( ) . unwrap( ) ) , channel_state , chan) ;
5149
+ & * self . best_block. read( ) . unwrap( ) ) , chan) ;
5150
5150
let mut channel_update = None ;
5151
5151
if let Some ( msg) = responses. shutdown_msg {
5152
5152
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendShutdown {
@@ -5210,7 +5210,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5210
5210
let by_id = & mut channel_state. by_id ;
5211
5211
let pending_msg_events = & mut channel_state. pending_msg_events ;
5212
5212
if let hash_map:: Entry :: Occupied ( chan_entry) = by_id. entry ( funding_outpoint. to_channel_id ( ) ) {
5213
- let mut chan = remove_channel ! ( self , channel_state , chan_entry) ;
5213
+ let mut chan = remove_channel ! ( self , chan_entry) ;
5214
5214
failed_channels. push ( chan. force_shutdown ( false ) ) ;
5215
5215
if let Ok ( update) = self . get_channel_update_for_broadcast ( & chan) {
5216
5216
pending_msg_events. push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
0 commit comments