@@ -1002,8 +1002,9 @@ impl HolderCommitment {
10021002 self . tx . nondust_htlcs ( ) . iter ( ) . chain ( self . dust_htlcs . iter ( ) . map ( |( htlc, _) | htlc) )
10031003 }
10041004
1005- #[ rustfmt:: skip]
1006- fn htlcs_with_sources ( & self ) -> impl Iterator < Item = ( & HTLCOutputInCommitment , Option < & HTLCSource > ) > {
1005+ fn htlcs_with_sources (
1006+ & self ,
1007+ ) -> impl Iterator < Item = ( & HTLCOutputInCommitment , Option < & HTLCSource > ) > {
10071008 let mut sources = self . nondust_htlc_sources . iter ( ) ;
10081009 let nondust_htlcs = self . tx . nondust_htlcs ( ) . iter ( ) . map ( move |htlc| {
10091010 let mut source = None ;
@@ -1526,8 +1527,9 @@ impl<'a, L: Deref> WithChannelMonitor<'a, L>
15261527where
15271528 L :: Target : Logger ,
15281529{
1529- #[ rustfmt:: skip]
1530- pub ( crate ) fn from < S : EcdsaChannelSigner > ( logger : & ' a L , monitor : & ChannelMonitor < S > , payment_hash : Option < PaymentHash > ) -> Self {
1530+ pub ( crate ) fn from < S : EcdsaChannelSigner > (
1531+ logger : & ' a L , monitor : & ChannelMonitor < S > , payment_hash : Option < PaymentHash > ,
1532+ ) -> Self {
15311533 Self :: from_impl ( logger, & * monitor. inner . lock ( ) . unwrap ( ) , payment_hash)
15321534 }
15331535
@@ -1696,10 +1698,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
16961698 ///
16971699 /// This is used to provide the counterparty commitment transaction directly to the monitor
16981700 /// before the initial persistence of a new channel.
1699- #[ rustfmt:: skip]
17001701 pub ( crate ) fn provide_initial_counterparty_commitment_tx < L : Deref > (
17011702 & self , commitment_tx : CommitmentTransaction , logger : & L ,
1702- ) where L :: Target : Logger
1703+ ) where
1704+ L :: Target : Logger ,
17031705 {
17041706 let mut inner = self . inner . lock ( ) . unwrap ( ) ;
17051707 let logger = WithChannelMonitor :: from_impl ( logger, & * inner, None ) ;
@@ -1771,13 +1773,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
17711773 /// itself.
17721774 ///
17731775 /// panics if the given update is not the next update by update_id.
1774- #[ rustfmt:: skip]
17751776 pub fn update_monitor < B : Deref , F : Deref , L : Deref > (
1776- & self ,
1777- updates : & ChannelMonitorUpdate ,
1778- broadcaster : & B ,
1779- fee_estimator : & F ,
1780- logger : & L ,
1777+ & self , updates : & ChannelMonitorUpdate , broadcaster : & B , fee_estimator : & F , logger : & L ,
17811778 ) -> Result < ( ) , ( ) >
17821779 where
17831780 B :: Target : BroadcasterInterface ,
@@ -1873,23 +1870,30 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
18731870 ///
18741871 /// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs
18751872 /// [`BumpTransaction`]: crate::events::Event::BumpTransaction
1876- #[ rustfmt:: skip]
1877- pub fn process_pending_events < H : Deref , L : Deref > ( & self , handler : & H , logger : & L )
1878- -> Result < ( ) , ReplayEvent > where H :: Target : EventHandler , L :: Target : Logger {
1873+ pub fn process_pending_events < H : Deref , L : Deref > (
1874+ & self , handler : & H , logger : & L ,
1875+ ) -> Result < ( ) , ReplayEvent >
1876+ where
1877+ H :: Target : EventHandler ,
1878+ L :: Target : Logger ,
1879+ {
18791880 let mut ev;
18801881 process_events_body ! ( Some ( self ) , logger, ev, handler. handle_event( ev) )
18811882 }
18821883
18831884 /// Processes any events asynchronously.
18841885 ///
18851886 /// See [`Self::process_pending_events`] for more information.
1886- #[ rustfmt:: skip]
18871887 pub async fn process_pending_events_async <
1888- Future : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > , H : Fn ( Event ) -> Future ,
1888+ Future : core:: future:: Future < Output = Result < ( ) , ReplayEvent > > ,
1889+ H : Fn ( Event ) -> Future ,
18891890 L : Deref ,
18901891 > (
18911892 & self , handler : & H , logger : & L ,
1892- ) -> Result < ( ) , ReplayEvent > where L :: Target : Logger {
1893+ ) -> Result < ( ) , ReplayEvent >
1894+ where
1895+ L :: Target : Logger ,
1896+ {
18931897 let mut ev;
18941898 process_events_body ! ( Some ( self ) , logger, ev, { handler( ev) . await } )
18951899 }
@@ -1939,8 +1943,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
19391943 /// may have been created prior to upgrading.
19401944 ///
19411945 /// [`Persist::update_persisted_channel`]: crate::chain::chainmonitor::Persist::update_persisted_channel
1942- #[ rustfmt:: skip]
1943- pub fn counterparty_commitment_txs_from_update ( & self , update : & ChannelMonitorUpdate ) -> Vec < CommitmentTransaction > {
1946+ pub fn counterparty_commitment_txs_from_update (
1947+ & self , update : & ChannelMonitorUpdate ,
1948+ ) -> Vec < CommitmentTransaction > {
19441949 self . inner . lock ( ) . unwrap ( ) . counterparty_commitment_txs_from_update ( update)
19451950 }
19461951
@@ -2021,9 +2026,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
20212026 /// to bypass HolderCommitmentTransaction state update lockdown after signature and generate
20222027 /// revoked commitment transaction.
20232028 #[ cfg( any( test, feature = "_test_utils" , feature = "unsafe_revoked_tx_signing" ) ) ]
2024- #[ rustfmt:: skip]
20252029 pub fn unsafe_get_latest_holder_commitment_txn < L : Deref > ( & self , logger : & L ) -> Vec < Transaction >
2026- where L :: Target : Logger {
2030+ where
2031+ L :: Target : Logger ,
2032+ {
20272033 let mut inner = self . inner . lock ( ) . unwrap ( ) ;
20282034 let logger = WithChannelMonitor :: from_impl ( logger, & * inner, None ) ;
20292035 inner. unsafe_get_latest_holder_commitment_txn ( & logger)
@@ -2213,9 +2219,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
22132219 }
22142220
22152221 /// Returns true if the monitor has pending claim requests that are not fully confirmed yet.
2216- #[ rustfmt:: skip]
2217- pub fn has_pending_claims ( & self ) -> bool
2218- {
2222+ pub fn has_pending_claims ( & self ) -> bool {
22192223 self . inner . lock ( ) . unwrap ( ) . onchain_tx_handler . has_pending_claims ( )
22202224 }
22212225
@@ -2898,8 +2902,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
28982902 res
28992903 }
29002904
2901- #[ rustfmt:: skip]
2902- pub ( crate ) fn get_stored_preimages ( & self ) -> HashMap < PaymentHash , ( PaymentPreimage , Vec < PaymentClaimDetails > ) > {
2905+ pub ( crate ) fn get_stored_preimages (
2906+ & self ,
2907+ ) -> HashMap < PaymentHash , ( PaymentPreimage , Vec < PaymentClaimDetails > ) > {
29032908 self . inner . lock ( ) . unwrap ( ) . payment_preimages . clone ( )
29042909 }
29052910}
@@ -4147,8 +4152,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41474152 /// revoked using data in holder_claimable_outpoints.
41484153 /// Should not be used if check_spend_revoked_transaction succeeds.
41494154 /// Returns None unless the transaction is definitely one of our commitment transactions.
4150- #[ rustfmt:: skip]
4151- fn check_spend_holder_transaction < L : Deref > ( & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash , logger : & L ) -> Option < ( Vec < PackageTemplate > , TransactionOutputs ) > where L :: Target : Logger {
4155+ fn check_spend_holder_transaction < L : Deref > (
4156+ & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash , logger : & L ,
4157+ ) -> Option < ( Vec < PackageTemplate > , TransactionOutputs ) >
4158+ where
4159+ L :: Target : Logger ,
4160+ {
41524161 let commitment_txid = tx. compute_txid ( ) ;
41534162 let mut claim_requests = Vec :: new ( ) ;
41544163 let mut watch_outputs = Vec :: new ( ) ;
@@ -4168,12 +4177,20 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41684177 if self . funding . current_holder_commitment . tx . trust ( ) . txid ( ) == commitment_txid {
41694178 is_holder_tx = true ;
41704179 log_info ! ( logger, "Got broadcast of latest holder commitment tx {}, searching for available HTLCs to claim" , commitment_txid) ;
4171- let res = self . get_broadcasted_holder_claims ( & self . funding . current_holder_commitment . tx , height) ;
4172- let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & self . funding . current_holder_commitment . tx ) ;
4180+ let res = self
4181+ . get_broadcasted_holder_claims ( & self . funding . current_holder_commitment . tx , height) ;
4182+ let mut to_watch = self
4183+ . get_broadcasted_holder_watch_outputs ( & self . funding . current_holder_commitment . tx ) ;
41734184 append_onchain_update ! ( res, to_watch) ;
41744185 fail_unbroadcast_htlcs ! (
4175- self , "latest holder" , commitment_txid, tx, height, block_hash,
4176- self . funding. current_holder_commitment. htlcs_with_sources( ) , logger
4186+ self ,
4187+ "latest holder" ,
4188+ commitment_txid,
4189+ tx,
4190+ height,
4191+ block_hash,
4192+ self . funding. current_holder_commitment. htlcs_with_sources( ) ,
4193+ logger
41774194 ) ;
41784195 } else if let & Some ( ref holder_commitment) = & self . funding . prev_holder_commitment {
41794196 if holder_commitment. tx . trust ( ) . txid ( ) == commitment_txid {
@@ -4183,8 +4200,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41834200 let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & holder_commitment. tx ) ;
41844201 append_onchain_update ! ( res, to_watch) ;
41854202 fail_unbroadcast_htlcs ! (
4186- self , "previous holder" , commitment_txid, tx, height, block_hash,
4187- holder_commitment. htlcs_with_sources( ) , logger
4203+ self ,
4204+ "previous holder" ,
4205+ commitment_txid,
4206+ tx,
4207+ height,
4208+ block_hash,
4209+ holder_commitment. htlcs_with_sources( ) ,
4210+ logger
41884211 ) ;
41894212 }
41904213 }
@@ -4873,10 +4896,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
48734896
48744897 /// Check if any transaction broadcasted is resolving HTLC output by a success or timeout on a holder
48754898 /// or counterparty commitment tx, if so send back the source, preimage if found and payment_hash of resolved HTLC
4876- #[ rustfmt:: skip]
48774899 fn is_resolving_htlc_output < L : Deref > (
4878- & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash , logger : & WithChannelMonitor < L > ,
4879- ) where L :: Target : Logger {
4900+ & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash ,
4901+ logger : & WithChannelMonitor < L > ,
4902+ ) where
4903+ L :: Target : Logger ,
4904+ {
48804905 ' outer_loop: for input in & tx. input {
48814906 let mut payment_data = None ;
48824907 let htlc_claim = HTLCClaim :: from_witness ( & input. witness ) ;
@@ -4985,8 +5010,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
49855010 }
49865011 }
49875012
4988- if input. previous_output . txid == self . funding . current_holder_commitment . tx . trust ( ) . txid ( ) {
4989- let htlcs_with_sources = self . funding . current_holder_commitment . htlcs_with_sources ( ) ;
5013+ if input. previous_output . txid
5014+ == self . funding . current_holder_commitment . tx . trust ( ) . txid ( )
5015+ {
5016+ let htlcs_with_sources =
5017+ self . funding . current_holder_commitment . htlcs_with_sources ( ) ;
49905018 scan_commitment ! ( htlcs_with_sources, "our latest holder commitment tx" , true ) ;
49915019 }
49925020 if let Some ( ref prev_holder_commitment) = self . funding . prev_holder_commitment {
@@ -4995,17 +5023,29 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
49955023 scan_commitment ! ( htlcs_with_sources, "our previous holder commitment tx" , true ) ;
49965024 }
49975025 }
4998- if let Some ( ref htlc_outputs) = self . funding . counterparty_claimable_outpoints . get ( & input. previous_output . txid ) {
4999- scan_commitment ! ( htlc_outputs. iter( ) . map( |& ( ref a, ref b) | ( a, b. as_ref( ) . map( |boxed| & * * boxed) ) ) ,
5000- "counterparty commitment tx" , false ) ;
5026+ if let Some ( ref htlc_outputs) =
5027+ self . funding . counterparty_claimable_outpoints . get ( & input. previous_output . txid )
5028+ {
5029+ scan_commitment ! (
5030+ htlc_outputs
5031+ . iter( )
5032+ . map( |& ( ref a, ref b) | ( a, b. as_ref( ) . map( |boxed| & * * boxed) ) ) ,
5033+ "counterparty commitment tx" ,
5034+ false
5035+ ) ;
50015036 }
50025037
50035038 // Check that scan_commitment, above, decided there is some source worth relaying an
50045039 // HTLC resolution backwards to and figure out whether we learned a preimage from it.
50055040 if let Some ( ( source, payment_hash, amount_msat) ) = payment_data {
50065041 if accepted_preimage_claim {
5007- if !self . pending_monitor_events . iter ( ) . any (
5008- |update| if let & MonitorEvent :: HTLCEvent ( ref upd) = update { upd. source == source } else { false } ) {
5042+ if !self . pending_monitor_events . iter ( ) . any ( |update| {
5043+ if let & MonitorEvent :: HTLCEvent ( ref upd) = update {
5044+ upd. source == source
5045+ } else {
5046+ false
5047+ }
5048+ } ) {
50095049 self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
50105050 txid : tx. compute_txid ( ) ,
50115051 height,
@@ -5025,10 +5065,13 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
50255065 } ) ) ;
50265066 }
50275067 } else if offered_preimage_claim {
5028- if !self . pending_monitor_events . iter ( ) . any (
5029- |update| if let & MonitorEvent :: HTLCEvent ( ref upd) = update {
5068+ if !self . pending_monitor_events . iter ( ) . any ( |update| {
5069+ if let & MonitorEvent :: HTLCEvent ( ref upd) = update {
50305070 upd. source == source
5031- } else { false } ) {
5071+ } else {
5072+ false
5073+ }
5074+ } ) {
50325075 self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
50335076 txid : tx. compute_txid ( ) ,
50345077 transaction : Some ( tx. clone ( ) ) ,
@@ -5049,7 +5092,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
50495092 }
50505093 } else {
50515094 self . onchain_events_awaiting_threshold_conf . retain ( |ref entry| {
5052- if entry. height != height { return true ; }
5095+ if entry. height != height {
5096+ return true ;
5097+ }
50535098 match entry. event {
50545099 OnchainEvent :: HTLCUpdate { source : ref htlc_source, .. } => {
50555100 * htlc_source != source
0 commit comments