@@ -1348,7 +1348,7 @@ macro_rules! convert_chan_err {
13481348}
13491349
13501350macro_rules! break_chan_entry {
1351- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1351+ ( $self: ident, $res: expr, $entry: expr) => {
13521352 match $res {
13531353 Ok ( res) => res,
13541354 Err ( e) => {
@@ -1363,7 +1363,7 @@ macro_rules! break_chan_entry {
13631363}
13641364
13651365macro_rules! try_chan_entry {
1366- ( $self: ident, $res: expr, $channel_state : expr , $ entry: expr) => {
1366+ ( $self: ident, $res: expr, $entry: expr) => {
13671367 match $res {
13681368 Ok ( res) => res,
13691369 Err ( e) => {
@@ -1378,7 +1378,7 @@ macro_rules! try_chan_entry {
13781378}
13791379
13801380macro_rules! remove_channel {
1381- ( $self: expr, $channel_state : expr , $ entry: expr) => {
1381+ ( $self: expr, $entry: expr) => {
13821382 {
13831383 let channel = $entry. remove_entry( ) . 1 ;
13841384 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
19191919 let ( result, is_permanent) =
19201920 handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
19211921 if is_permanent {
1922- remove_channel ! ( self , channel_state , chan_entry) ;
1922+ remove_channel ! ( self , chan_entry) ;
19231923 break result;
19241924 }
19251925 }
@@ -1930,7 +1930,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
19301930 } ) ;
19311931
19321932 if chan_entry. get ( ) . is_shutdown ( ) {
1933- let channel = remove_channel ! ( self , channel_state , chan_entry) ;
1933+ let channel = remove_channel ! ( self , chan_entry) ;
19341934 if let Ok ( channel_update) = self . get_channel_update_for_broadcast ( & channel) {
19351935 channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
19361936 msg : channel_update
@@ -2031,7 +2031,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
20312031 } else {
20322032 self . issue_channel_close_events ( chan. get ( ) , ClosureReason :: HolderForceClosed ) ;
20332033 }
2034- remove_channel ! ( self , channel_state , chan)
2034+ remove_channel ! ( self , chan)
20352035 } else {
20362036 return Err ( APIError :: ChannelUnavailable { err : "No such channel" . to_owned ( ) } ) ;
20372037 }
@@ -2506,7 +2506,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
25062506 payment_secret: payment_secret. clone( ) ,
25072507 payment_params: payment_params. clone( ) ,
25082508 } , onion_packet, & self . logger) ,
2509- channel_state , chan)
2509+ chan)
25102510 } {
25112511 Some ( ( update_add, commitment_signed, monitor_update) ) => {
25122512 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
33203320 }
33213321 ChannelError :: Close ( msg) => {
33223322 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) ;
33243324 // ChannelClosed event is generated by handle_error for us.
33253325 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 ( ) ) )
33263326 } ,
@@ -4558,7 +4558,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
45584558 }
45594559 } ;
45604560 channel_state. pending_msg_events . push ( send_msg_err_event) ;
4561- let _ = remove_channel ! ( self , channel_state , channel) ;
4561+ let _ = remove_channel ! ( self , channel) ;
45624562 return Err ( APIError :: APIMisuseError { err : "Please use accept_inbound_channel_from_trusted_peer_0conf to accept channels with zero confirmations." . to_owned ( ) } ) ;
45634563 }
45644564
@@ -4638,7 +4638,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
46384638 if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
46394639 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
46404640 }
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) ;
46424642 ( chan. get ( ) . get_value_satoshis ( ) , chan. get ( ) . get_funding_redeemscript ( ) . to_v0_p2wsh ( ) , chan. get ( ) . get_user_id ( ) )
46434643 } ,
46444644 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
46654665 if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
46664666 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. temporary_channel_id ) ) ;
46674667 }
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 ( ) )
46694669 } ,
46704670 hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. temporary_channel_id ) )
46714671 }
@@ -4738,7 +4738,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
47384738 }
47394739 let ( monitor, funding_tx, channel_ready) = match chan. get_mut ( ) . funding_signed ( & msg, best_block, & self . logger ) {
47404740 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) ,
47424742 } ;
47434743 match self . chain_monitor . watch_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , monitor) {
47444744 ChannelMonitorUpdateStatus :: Completed => { } ,
@@ -4777,7 +4777,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
47774777 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
47784778 }
47794779 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) ;
47814781 if let Some ( announcement_sigs) = announcement_sigs_opt {
47824782 log_trace ! ( self . logger, "Sending announcement_signatures for channel {}" , log_bytes!( chan. get( ) . channel_id( ) ) ) ;
47834783 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
48254825 if chan_entry. get( ) . sent_shutdown( ) { " after we initiated shutdown" } else { "" } ) ;
48264826 }
48274827
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) ;
48294829 dropped_htlcs = htlcs;
48304830
48314831 // 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
48344834 let ( result, is_permanent) =
48354835 handle_monitor_update_res ! ( self , update_res, chan_entry. get_mut( ) , RAACommitmentOrder :: CommitmentFirst , chan_entry. key( ) , NO_UPDATE ) ;
48364836 if is_permanent {
4837- remove_channel ! ( self , channel_state , chan_entry) ;
4837+ remove_channel ! ( self , chan_entry) ;
48384838 break result;
48394839 }
48404840 }
@@ -4869,7 +4869,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
48694869 if chan_entry. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
48704870 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
48714871 }
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) ;
48734873 if let Some ( msg) = closing_signed {
48744874 channel_state. pending_msg_events . push ( events:: MessageSendEvent :: SendClosingSigned {
48754875 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
48824882 // also implies there are no pending HTLCs left on the channel, so we can
48834883 // fully delete it from tracking (the channel monitor is still around to
48844884 // watch for old state broadcasts)!
4885- ( tx, Some ( remove_channel ! ( self , channel_state , chan_entry) ) )
4885+ ( tx, Some ( remove_channel ! ( self , chan_entry) ) )
48864886 } else { ( tx, None ) }
48874887 } ,
48884888 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
49464946 _ => pending_forward_info
49474947 }
49484948 } ;
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) ;
49504950 } ,
49514951 hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
49524952 }
@@ -4962,7 +4962,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
49624962 if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
49634963 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
49644964 }
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)
49664966 } ,
49674967 hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
49684968 }
@@ -4979,7 +4979,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
49794979 if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
49804980 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
49814981 }
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) ;
49834983 } ,
49844984 hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
49854985 }
@@ -4996,9 +4996,9 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
49964996 }
49974997 if ( msg. failure_code & 0x8000 ) == 0 {
49984998 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) ;
50005000 }
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) ;
50025002 Ok ( ( ) )
50035003 } ,
50045004 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
50155015 }
50165016 let ( revoke_and_ack, commitment_signed, monitor_update) =
50175017 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) ,
50195019 Err ( ( Some ( update) , e) ) => {
50205020 assert ! ( chan. get( ) . is_awaiting_monitor_update( ) ) ;
50215021 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) ;
50235023 unreachable ! ( ) ;
50245024 } ,
50255025 Ok ( res) => res
@@ -5102,7 +5102,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
51025102 }
51035103 let was_paused_for_mon_update = chan. get ( ) . is_awaiting_monitor_update ( ) ;
51045104 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) ;
51065106 htlcs_to_fail = raa_updates. holding_cell_failed_htlcs ;
51075107 let update_res = self . chain_monitor . update_channel ( chan. get ( ) . get_funding_txo ( ) . unwrap ( ) , raa_updates. monitor_update ) ;
51085108 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
51625162 if chan. get ( ) . get_counterparty_node_id ( ) != * counterparty_node_id {
51635163 return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Got a message for a channel from the wrong node!" . to_owned ( ) , msg. channel_id ) ) ;
51645164 }
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) ;
51665166 } ,
51675167 hash_map:: Entry :: Vacant ( _) => return Err ( MsgHandleErrInternal :: send_err_msg_no_close ( "Failed to find corresponding channel" . to_owned ( ) , msg. channel_id ) )
51685168 }
@@ -5184,7 +5184,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
51845184
51855185 channel_state. pending_msg_events . push ( events:: MessageSendEvent :: BroadcastChannelAnnouncement {
51865186 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) ,
51885188 // Note that announcement_signatures fails if the channel cannot be announced,
51895189 // so get_channel_update_for_broadcast will never fail by the time we get here.
51905190 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
52235223 return Ok ( NotifyOption :: SkipPersist ) ;
52245224 } else {
52255225 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) ;
52275227 }
52285228 } ,
52295229 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
52485248 // add-HTLCs on disconnect, we may be handed HTLCs to fail backwards here.
52495249 let responses = try_chan_entry ! ( self , chan. get_mut( ) . channel_reestablish(
52505250 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) ;
52525252 let mut channel_update = None ;
52535253 if let Some ( msg) = responses. shutdown_msg {
52545254 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
53125312 let by_id = & mut channel_state. by_id ;
53135313 let pending_msg_events = & mut channel_state. pending_msg_events ;
53145314 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) ;
53165316 failed_channels. push ( chan. force_shutdown ( false ) ) ;
53175317 if let Ok ( update) = self . get_channel_update_for_broadcast ( & chan) {
53185318 pending_msg_events. push ( events:: MessageSendEvent :: BroadcastChannelUpdate {
0 commit comments