@@ -1349,7 +1349,7 @@ macro_rules! convert_chan_err {
1349
1349
}
1350
1350
1351
1351
macro_rules! break_chan_entry {
1352
- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1352
+ ( $self: ident, $res: expr, $entry: expr) => {
1353
1353
match $res {
1354
1354
Ok ( res) => res,
1355
1355
Err ( e) => {
@@ -1364,7 +1364,7 @@ macro_rules! break_chan_entry {
1364
1364
}
1365
1365
1366
1366
macro_rules! try_chan_entry {
1367
- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1367
+ ( $self: ident, $res: expr, $entry: expr) => {
1368
1368
match $res {
1369
1369
Ok ( res) => res,
1370
1370
Err ( e) => {
@@ -1379,7 +1379,7 @@ macro_rules! try_chan_entry {
1379
1379
}
1380
1380
1381
1381
macro_rules! remove_channel {
1382
- ( $self: expr, $channel_state : expr , $ entry: expr) => {
1382
+ ( $self: expr, $entry: expr) => {
1383
1383
{
1384
1384
let channel = $entry. remove_entry( ) . 1 ;
1385
1385
update_maps_on_chan_removal!( $self, channel) ;
@@ -1901,7 +1901,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1901
1901
let ( result, is_permanent) =
1902
1902
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
1903
1903
if is_permanent {
1904
- remove_channel ! ( self , channel_state , chan_entry) ;
1904
+ remove_channel ! ( self , chan_entry) ;
1905
1905
break result;
1906
1906
}
1907
1907
}
@@ -1912,7 +1912,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
1912
1912
} ) ;
1913
1913
1914
1914
if chan_entry. get ( ) . is_shutdown ( ) {
1915
- let channel = remove_channel ! ( self , channel_state , chan_entry) ;
1915
+ let channel = remove_channel ! ( self , chan_entry) ;
1916
1916
if let Ok ( channel_update) = self . get_channel_update_for_broadcast ( & channel) {
1917
1917
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
1918
1918
msg : channel_update
@@ -2013,7 +2013,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2013
2013
} else {
2014
2014
self . issue_channel_close_events ( chan. get ( ) , ClosureReason :: HolderForceClosed ) ;
2015
2015
}
2016
- remove_channel ! ( self , channel_state , chan)
2016
+ remove_channel ! ( self , chan)
2017
2017
} else {
2018
2018
return Err ( APIError :: ChannelUnavailable { err : "No such channel" . to_owned ( ) } ) ;
2019
2019
}
@@ -2514,7 +2514,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2514
2514
payment_secret: payment_secret. clone( ) ,
2515
2515
payment_params: payment_params. clone( ) ,
2516
2516
} , onion_packet, & self . logger) ,
2517
- channel_state , chan)
2517
+ chan)
2518
2518
} {
2519
2519
Some ( ( update_add, commitment_signed, monitor_update) ) => {
2520
2520
let update_err = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor_update) ;
@@ -3249,7 +3249,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3249
3249
}
3250
3250
ChannelError :: Close ( msg) => {
3251
3251
log_trace ! ( self . logger, "Closing channel {} due to Close-required error: {}" , log_bytes!( chan. key( ) [ ..] ) , msg) ;
3252
- let mut channel = remove_channel ! ( self , channel_state , chan) ;
3252
+ let mut channel = remove_channel ! ( self , chan) ;
3253
3253
// ChannelClosed event is generated by handle_error for us.
3254
3254
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 ( ) ) )
3255
3255
} ,
@@ -4453,7 +4453,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4453
4453
}
4454
4454
} ;
4455
4455
channel_state. pending_msg_events . push ( send_msg_err_event) ;
4456
- let _ = remove_channel ! ( self , channel_state , channel) ;
4456
+ let _ = remove_channel ! ( self , channel) ;
4457
4457
return Err ( APIError :: APIMisuseError { err : "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations." . to_owned ( ) } ) ;
4458
4458
}
4459
4459
@@ -4533,7 +4533,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4533
4533
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4534
4534
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4535
4535
}
4536
- try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , channel_state , chan) ;
4536
+ try_chan_entry ! ( self , chan. get_mut( ) . accept_channel( & msg, & self . default_configuration. channel_handshake_limits, & their_features) , chan) ;
4537
4537
( chan. get ( ) . get_value_satoshis ( ) , chan. get ( ) . get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get ( ) . get_user_id ( ) )
4538
4538
} ,
4539
4539
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
@@ -4560,7 +4560,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4560
4560
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4561
4561
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
4562
4562
}
4563
- ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , channel_state , chan) , chan. remove ( ) )
4563
+ ( try_chan_entry ! ( self , chan. get_mut( ) . funding_created( msg, best_block, & self . logger) , chan) , chan. remove ( ) )
4564
4564
} ,
4565
4565
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
4566
4566
}
@@ -4633,7 +4633,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4633
4633
}
4634
4634
let ( monitor, funding_tx, channel_ready) = match chan. get_mut ( ) . funding_signed ( & msg, best_block, & self . logger ) {
4635
4635
Ok ( update) => update,
4636
- Err ( e) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
4636
+ Err ( e) => try_chan_entry ! ( self , Err ( e) , chan) ,
4637
4637
} ;
4638
4638
match self . chain_monitor . watch_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor) {
4639
4639
ChannelMonitorUpdateStatus :: Completed => { } ,
@@ -4672,7 +4672,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4672
4672
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4673
4673
}
4674
4674
let announcement_sigs_opt = try_chan_entry ! ( self , chan. get_mut( ) . channel_ready( & msg, self . get_our_node_id( ) ,
4675
- self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , channel_state , chan) ;
4675
+ self . genesis_hash. clone( ) , & self . best_block. read( ) . unwrap( ) , & self . logger) , chan) ;
4676
4676
if let Some ( announcement_sigs) = announcement_sigs_opt {
4677
4677
log_trace ! ( self . logger, "Sending announcement_signatures for channel {}" , log_bytes!( chan. get( ) . channel_id( ) ) ) ;
4678
4678
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendAnnouncementSignatures {
@@ -4717,7 +4717,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4717
4717
if chan_entry. get( ) . sent_shutdown( ) { " after we initiated shutdown" } else { "" } ) ;
4718
4718
}
4719
4719
4720
- let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , channel_state , chan_entry) ;
4720
+ let ( shutdown, monitor_update, htlcs) = try_chan_entry ! ( self , chan_entry. get_mut( ) . shutdown( & self . keys_manager, & their_features, & msg) , chan_entry) ;
4721
4721
dropped_htlcs = htlcs;
4722
4722
4723
4723
// Update the monitor with the shutdown script if necessary.
@@ -4726,7 +4726,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4726
4726
let ( result, is_permanent) =
4727
4727
handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
4728
4728
if is_permanent {
4729
- remove_channel ! ( self , channel_state , chan_entry) ;
4729
+ remove_channel ! ( self , chan_entry) ;
4730
4730
break result;
4731
4731
}
4732
4732
}
@@ -4761,7 +4761,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4761
4761
if chan_entry. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4762
4762
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4763
4763
}
4764
- let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , channel_state , chan_entry) ;
4764
+ let ( closing_signed, tx) = try_chan_entry ! ( self , chan_entry. get_mut( ) . closing_signed( & self . fee_estimator, & msg) , chan_entry) ;
4765
4765
if let Some ( msg) = closing_signed {
4766
4766
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendClosingSigned {
4767
4767
node_id : counterparty_node_id. clone ( ) ,
@@ -4774,7 +4774,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4774
4774
// also implies there are no pending HTLCs left on the channel, so we can
4775
4775
// fully delete it from tracking (the channel monitor is still around to
4776
4776
// watch for old state broadcasts)!
4777
- ( tx, Some ( remove_channel ! ( self , channel_state , chan_entry) ) )
4777
+ ( tx, Some ( remove_channel ! ( self , chan_entry) ) )
4778
4778
} else { ( tx, None ) }
4779
4779
} ,
4780
4780
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -4838,7 +4838,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4838
4838
_ => pending_forward_info
4839
4839
}
4840
4840
} ;
4841
- try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , channel_state , chan) ;
4841
+ try_chan_entry ! ( self , chan. get_mut( ) . update_add_htlc( & msg, pending_forward_info, create_pending_htlc_status, & self . logger) , chan) ;
4842
4842
} ,
4843
4843
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4844
4844
}
@@ -4854,7 +4854,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4854
4854
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4855
4855
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4856
4856
}
4857
- try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , channel_state , chan)
4857
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fulfill_htlc( & msg) , chan)
4858
4858
} ,
4859
4859
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4860
4860
}
@@ -4871,7 +4871,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4871
4871
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
4872
4872
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
4873
4873
}
4874
- try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , channel_state , chan) ;
4874
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_htlc( & msg, HTLCFailReason :: LightningError { err: msg. reason. clone( ) } ) , chan) ;
4875
4875
} ,
4876
4876
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
4877
4877
}
@@ -4888,9 +4888,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4888
4888
}
4889
4889
if ( msg. failure_code & 0x8000 ) == 0 {
4890
4890
let chan_err: ChannelError = ChannelError :: Close ( "Got update_fail_malformed_htlc with BADONION not set" . to_owned ( ) ) ;
4891
- try_chan_entry ! ( self , Err ( chan_err) , channel_state , chan) ;
4891
+ try_chan_entry ! ( self , Err ( chan_err) , chan) ;
4892
4892
}
4893
- 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) ;
4893
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fail_malformed_htlc( & msg, HTLCFailReason :: Reason { failure_code: msg. failure_code, data: Vec :: new( ) } ) , chan) ;
4894
4894
Ok ( ( ) )
4895
4895
} ,
4896
4896
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
@@ -4907,11 +4907,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4907
4907
}
4908
4908
let ( revoke_and_ack, commitment_signed, monitor_update) =
4909
4909
match chan. get_mut ( ) . commitment_signed ( & msg, & self . logger ) {
4910
- Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , channel_state , chan) ,
4910
+ Err ( ( None , e) ) => try_chan_entry ! ( self , Err ( e) , chan) ,
4911
4911
Err ( ( Some ( update) , e) ) => {
4912
4912
assert ! ( chan. get( ) . is_awaiting_monitor_update( ) ) ;
4913
4913
let _ = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , update) ;
4914
- try_chan_entry ! ( self , Err ( e) , channel_state , chan) ;
4914
+ try_chan_entry ! ( self , Err ( e) , chan) ;
4915
4915
unreachable ! ( ) ;
4916
4916
} ,
4917
4917
Ok ( res) => res
@@ -4994,7 +4994,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4994
4994
}
4995
4995
let was_paused_for_mon_update = chan. get ( ) . is_awaiting_monitor_update ( ) ;
4996
4996
let raa_updates = break_chan_entry ! ( self ,
4997
- chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , channel_state , chan) ;
4997
+ chan. get_mut( ) . revoke_and_ack( & msg, & self . logger) , chan) ;
4998
4998
htlcs_to_fail = raa_updates. holding_cell_failed_htlcs ;
4999
4999
let update_res = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , raa_updates. monitor_update ) ;
5000
5000
if was_paused_for_mon_update {
@@ -5054,7 +5054,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5054
5054
if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
5055
5055
return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
5056
5056
}
5057
- try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , channel_state , chan) ;
5057
+ try_chan_entry ! ( self , chan. get_mut( ) . update_fee( & self . fee_estimator, & msg) , chan) ;
5058
5058
} ,
5059
5059
hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
5060
5060
}
@@ -5076,7 +5076,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5076
5076
5077
5077
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelAnnouncement {
5078
5078
msg : try_chan_entry ! ( self , chan. get_mut( ) . announcement_signatures(
5079
- self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , channel_state , chan) ,
5079
+ self . get_our_node_id( ) , self . genesis_hash. clone( ) , self . best_block. read( ) . unwrap( ) . height( ) , msg) , chan) ,
5080
5080
// Note that announcement_signatures fails if the channel cannot be announced,
5081
5081
// so get_channel_update_for_broadcast will never fail by the time we get here.
5082
5082
update_msg : self . get_channel_update_for_broadcast ( chan. get ( ) ) . unwrap ( ) ,
@@ -5115,7 +5115,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5115
5115
return Ok ( NotifyOption :: SkipPersist ) ;
5116
5116
} else {
5117
5117
log_debug ! ( self . logger, "Received channel_update for channel {}." , log_bytes!( chan_id) ) ;
5118
- try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , channel_state , chan) ;
5118
+ try_chan_entry ! ( self , chan. get_mut( ) . channel_update( & msg) , chan) ;
5119
5119
}
5120
5120
} ,
5121
5121
hash_map:: Entry :: Vacant ( _) => unreachable ! ( )
@@ -5140,7 +5140,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5140
5140
// add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
5141
5141
let responses = try_chan_entry ! ( self , chan. get_mut( ) . channel_reestablish(
5142
5142
msg, & self . logger, self . our_network_pubkey. clone( ) , self . genesis_hash,
5143
- & * self . best_block. read( ) . unwrap( ) ) , channel_state , chan) ;
5143
+ & * self . best_block. read( ) . unwrap( ) ) , chan) ;
5144
5144
let mut channel_update = None ;
5145
5145
if let Some ( msg) = responses. shutdown_msg {
5146
5146
channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendShutdown {
@@ -5204,7 +5204,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
5204
5204
let by_id = & mut channel_state. by_id ;
5205
5205
let pending_msg_events = & mut channel_state. pending_msg_events ;
5206
5206
if let hash_map:: Entry :: Occupied ( chan_entry) = by_id. entry ( funding_outpoint. to_channel_id ( ) ) {
5207
- let mut chan = remove_channel ! ( self , channel_state , chan_entry) ;
5207
+ let mut chan = remove_channel ! ( self , chan_entry) ;
5208
5208
failed_channels. push ( chan. force_shutdown ( false ) ) ;
5209
5209
if let Ok ( update) = self . get_channel_update_for_broadcast ( & chan) {
5210
5210
pending_msg_events. push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
0 commit comments