@@ -1002,8 +1002,9 @@ impl HolderCommitment {
1002
1002
self . tx . nondust_htlcs ( ) . iter ( ) . chain ( self . dust_htlcs . iter ( ) . map ( |( htlc, _) | htlc) )
1003
1003
}
1004
1004
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 > ) > {
1007
1008
let mut sources = self . nondust_htlc_sources . iter ( ) ;
1008
1009
let nondust_htlcs = self . tx . nondust_htlcs ( ) . iter ( ) . map ( move |htlc| {
1009
1010
let mut source = None ;
@@ -1526,8 +1527,9 @@ impl<'a, L: Deref> WithChannelMonitor<'a, L>
1526
1527
where
1527
1528
L :: Target : Logger ,
1528
1529
{
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 {
1531
1533
Self :: from_impl ( logger, & * monitor. inner . lock ( ) . unwrap ( ) , payment_hash)
1532
1534
}
1533
1535
@@ -1696,10 +1698,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1696
1698
///
1697
1699
/// This is used to provide the counterparty commitment transaction directly to the monitor
1698
1700
/// before the initial persistence of a new channel.
1699
- #[ rustfmt:: skip]
1700
1701
pub ( crate ) fn provide_initial_counterparty_commitment_tx < L : Deref > (
1701
1702
& self , commitment_tx : CommitmentTransaction , logger : & L ,
1702
- ) where L :: Target : Logger
1703
+ ) where
1704
+ L :: Target : Logger ,
1703
1705
{
1704
1706
let mut inner = self . inner . lock ( ) . unwrap ( ) ;
1705
1707
let logger = WithChannelMonitor :: from_impl ( logger, & * inner, None ) ;
@@ -1771,13 +1773,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1771
1773
/// itself.
1772
1774
///
1773
1775
/// panics if the given update is not the next update by update_id.
1774
- #[ rustfmt:: skip]
1775
1776
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 ,
1781
1778
) -> Result < ( ) , ( ) >
1782
1779
where
1783
1780
B :: Target : BroadcasterInterface ,
@@ -1873,23 +1870,30 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1873
1870
///
1874
1871
/// [`SpendableOutputs`]: crate::events::Event::SpendableOutputs
1875
1872
/// [`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
+ {
1879
1880
let mut ev;
1880
1881
process_events_body ! ( Some ( self ) , logger, ev, handler. handle_event( ev) )
1881
1882
}
1882
1883
1883
1884
/// Processes any events asynchronously.
1884
1885
///
1885
1886
/// See [`Self::process_pending_events`] for more information.
1886
- #[ rustfmt:: skip]
1887
1887
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 ,
1889
1890
L : Deref ,
1890
1891
> (
1891
1892
& self , handler : & H , logger : & L ,
1892
- ) -> Result < ( ) , ReplayEvent > where L :: Target : Logger {
1893
+ ) -> Result < ( ) , ReplayEvent >
1894
+ where
1895
+ L :: Target : Logger ,
1896
+ {
1893
1897
let mut ev;
1894
1898
process_events_body ! ( Some ( self ) , logger, ev, { handler( ev) . await } )
1895
1899
}
@@ -1939,8 +1943,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1939
1943
/// may have been created prior to upgrading.
1940
1944
///
1941
1945
/// [`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 > {
1944
1949
self . inner . lock ( ) . unwrap ( ) . counterparty_commitment_txs_from_update ( update)
1945
1950
}
1946
1951
@@ -2021,9 +2026,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2021
2026
/// to bypass HolderCommitmentTransaction state update lockdown after signature and generate
2022
2027
/// revoked commitment transaction.
2023
2028
#[ cfg( any( test, feature = "_test_utils" , feature = "unsafe_revoked_tx_signing" ) ) ]
2024
- #[ rustfmt:: skip]
2025
2029
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
+ {
2027
2033
let mut inner = self . inner . lock ( ) . unwrap ( ) ;
2028
2034
let logger = WithChannelMonitor :: from_impl ( logger, & * inner, None ) ;
2029
2035
inner. unsafe_get_latest_holder_commitment_txn ( & logger)
@@ -2213,9 +2219,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2213
2219
}
2214
2220
2215
2221
/// 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 {
2219
2223
self . inner . lock ( ) . unwrap ( ) . onchain_tx_handler . has_pending_claims ( )
2220
2224
}
2221
2225
@@ -2898,8 +2902,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2898
2902
res
2899
2903
}
2900
2904
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 > ) > {
2903
2908
self . inner . lock ( ) . unwrap ( ) . payment_preimages . clone ( )
2904
2909
}
2905
2910
}
@@ -4147,8 +4152,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4147
4152
/// revoked using data in holder_claimable_outpoints.
4148
4153
/// Should not be used if check_spend_revoked_transaction succeeds.
4149
4154
/// 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
+ {
4152
4161
let commitment_txid = tx. compute_txid ( ) ;
4153
4162
let mut claim_requests = Vec :: new ( ) ;
4154
4163
let mut watch_outputs = Vec :: new ( ) ;
@@ -4168,12 +4177,20 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4168
4177
if self . funding . current_holder_commitment . tx . trust ( ) . txid ( ) == commitment_txid {
4169
4178
is_holder_tx = true ;
4170
4179
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 ) ;
4173
4184
append_onchain_update ! ( res, to_watch) ;
4174
4185
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
4177
4194
) ;
4178
4195
} else if let & Some ( ref holder_commitment) = & self . funding . prev_holder_commitment {
4179
4196
if holder_commitment. tx . trust ( ) . txid ( ) == commitment_txid {
@@ -4183,8 +4200,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4183
4200
let mut to_watch = self . get_broadcasted_holder_watch_outputs ( & holder_commitment. tx ) ;
4184
4201
append_onchain_update ! ( res, to_watch) ;
4185
4202
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
4188
4211
) ;
4189
4212
}
4190
4213
}
@@ -4873,10 +4896,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4873
4896
4874
4897
/// Check if any transaction broadcasted is resolving HTLC output by a success or timeout on a holder
4875
4898
/// or counterparty commitment tx, if so send back the source, preimage if found and payment_hash of resolved HTLC
4876
- #[ rustfmt:: skip]
4877
4899
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
+ {
4880
4905
' outer_loop: for input in & tx. input {
4881
4906
let mut payment_data = None ;
4882
4907
let htlc_claim = HTLCClaim :: from_witness ( & input. witness ) ;
@@ -4985,8 +5010,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4985
5010
}
4986
5011
}
4987
5012
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 ( ) ;
4990
5018
scan_commitment ! ( htlcs_with_sources, "our latest holder commitment tx" , true ) ;
4991
5019
}
4992
5020
if let Some ( ref prev_holder_commitment) = self . funding . prev_holder_commitment {
@@ -4995,17 +5023,29 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4995
5023
scan_commitment ! ( htlcs_with_sources, "our previous holder commitment tx" , true ) ;
4996
5024
}
4997
5025
}
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
+ ) ;
5001
5036
}
5002
5037
5003
5038
// Check that scan_commitment, above, decided there is some source worth relaying an
5004
5039
// HTLC resolution backwards to and figure out whether we learned a preimage from it.
5005
5040
if let Some ( ( source, payment_hash, amount_msat) ) = payment_data {
5006
5041
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
+ } ) {
5009
5049
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
5010
5050
txid : tx. compute_txid ( ) ,
5011
5051
height,
@@ -5025,10 +5065,13 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5025
5065
} ) ) ;
5026
5066
}
5027
5067
} 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 {
5030
5070
upd. source == source
5031
- } else { false } ) {
5071
+ } else {
5072
+ false
5073
+ }
5074
+ } ) {
5032
5075
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
5033
5076
txid : tx. compute_txid ( ) ,
5034
5077
transaction : Some ( tx. clone ( ) ) ,
@@ -5049,7 +5092,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5049
5092
}
5050
5093
} else {
5051
5094
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
+ }
5053
5098
match entry. event {
5054
5099
OnchainEvent :: HTLCUpdate { source : ref htlc_source, .. } => {
5055
5100
* htlc_source != source
0 commit comments