@@ -104,7 +104,7 @@ pub struct ChannelMonitorUpdate {
104
104
105
105
/// LDK prior to 0.1 used this constant as the [`ChannelMonitorUpdate::update_id`] for any
106
106
/// [`ChannelMonitorUpdate`]s which were generated after the channel was closed.
107
- const LEGACY_CLOSED_CHANNEL_UPDATE_ID : u64 = core :: u64:: MAX ;
107
+ const LEGACY_CLOSED_CHANNEL_UPDATE_ID : u64 = u64:: MAX ;
108
108
109
109
impl Writeable for ChannelMonitorUpdate {
110
110
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
@@ -285,7 +285,7 @@ impl_writeable_tlv_based!(HolderSignedTx, {
285
285
( 0 , txid, required) ,
286
286
// Note that this is filled in with data from OnchainTxHandler if it's missing.
287
287
// For HolderSignedTx objects serialized with 0.0.100+, this should be filled in.
288
- ( 1 , to_self_value_sat, ( default_value, u64 :: max_value ( ) ) ) ,
288
+ ( 1 , to_self_value_sat, ( default_value, u64 :: MAX ) ) ,
289
289
( 2 , revocation_key, required) ,
290
290
( 4 , a_htlc_key, required) ,
291
291
( 6 , b_htlc_key, required) ,
@@ -298,7 +298,7 @@ impl_writeable_tlv_based!(HolderSignedTx, {
298
298
impl HolderSignedTx {
299
299
fn non_dust_htlcs ( & self ) -> Vec < HTLCOutputInCommitment > {
300
300
self . htlc_outputs . iter ( ) . filter_map ( |( htlc, _, _) | {
301
- if let Some ( _ ) = htlc. transaction_output_index {
301
+ if htlc. transaction_output_index . is_some ( ) {
302
302
Some ( htlc. clone ( ) )
303
303
} else {
304
304
None
@@ -319,7 +319,7 @@ struct CounterpartyCommitmentParameters {
319
319
320
320
impl Writeable for CounterpartyCommitmentParameters {
321
321
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
322
- w. write_all ( & ( 0 as u64 ) . to_be_bytes ( ) ) ?;
322
+ w. write_all ( & 0u64 . to_be_bytes ( ) ) ?;
323
323
write_tlv_fields ! ( w, {
324
324
( 0 , self . counterparty_delayed_payment_base_key, required) ,
325
325
( 2 , self . counterparty_htlc_base_key, required) ,
@@ -334,7 +334,7 @@ impl Readable for CounterpartyCommitmentParameters {
334
334
// Versions prior to 0.0.100 had some per-HTLC state stored here, which is no longer
335
335
// used. Read it for compatibility.
336
336
let per_htlc_len: u64 = Readable :: read ( r) ?;
337
- for _ in 0 ..per_htlc_len {
337
+ for _ in 0 ..per_htlc_len {
338
338
let _txid: Txid = Readable :: read ( r) ?;
339
339
let htlcs_count: u64 = Readable :: read ( r) ?;
340
340
for _ in 0 ..htlcs_count {
@@ -791,13 +791,13 @@ struct IrrevocablyResolvedHTLC {
791
791
payment_preimage : Option < PaymentPreimage > ,
792
792
}
793
793
794
- // In LDK versions prior to 0.0.111 commitment_tx_output_idx was not Option-al and
795
- // IrrevocablyResolvedHTLC objects only existed for non-dust HTLCs. This was a bug, but to maintain
796
- // backwards compatibility we must ensure we always write out a commitment_tx_output_idx field,
797
- // using `u32::max_value()` as a sentinal to indicate the HTLC was dust.
794
+ /// In LDK versions prior to 0.0.111 commitment_tx_output_idx was not Option-al and
795
+ /// IrrevocablyResolvedHTLC objects only existed for non-dust HTLCs. This was a bug, but to maintain
796
+ /// backwards compatibility we must ensure we always write out a commitment_tx_output_idx field,
797
+ /// using [ `u32::MAX`] as a sentinal to indicate the HTLC was dust.
798
798
impl Writeable for IrrevocablyResolvedHTLC {
799
799
fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > {
800
- let mapped_commitment_tx_output_idx = self . commitment_tx_output_idx . unwrap_or ( u32:: max_value ( ) ) ;
800
+ let mapped_commitment_tx_output_idx = self . commitment_tx_output_idx . unwrap_or ( u32:: MAX ) ;
801
801
write_tlv_fields ! ( writer, {
802
802
( 0 , mapped_commitment_tx_output_idx, required) ,
803
803
( 1 , self . resolving_txid, option) ,
@@ -821,7 +821,7 @@ impl Readable for IrrevocablyResolvedHTLC {
821
821
( 3 , resolving_tx, option) ,
822
822
} ) ;
823
823
Ok ( Self {
824
- commitment_tx_output_idx : if mapped_commitment_tx_output_idx == u32:: max_value ( ) { None } else { Some ( mapped_commitment_tx_output_idx) } ,
824
+ commitment_tx_output_idx : if mapped_commitment_tx_output_idx == u32:: MAX { None } else { Some ( mapped_commitment_tx_output_idx) } ,
825
825
resolving_txid,
826
826
payment_preimage,
827
827
resolving_tx,
@@ -1581,7 +1581,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1581
1581
filter. register_tx ( & lock. get_funding_txo ( ) . 0 . txid , & lock. get_funding_txo ( ) . 1 ) ;
1582
1582
for ( txid, outputs) in lock. get_outputs_to_watch ( ) . iter ( ) {
1583
1583
for ( index, script_pubkey) in outputs. iter ( ) {
1584
- assert ! ( * index <= u16 :: max_value ( ) as u32 ) ;
1584
+ assert ! ( * index <= u16 :: MAX as u32 ) ;
1585
1585
let outpoint = OutPoint { txid : * txid, index : * index as u16 } ;
1586
1586
log_trace ! ( logger, "Registering outpoint {} with the filter for monitoring spends" , outpoint) ;
1587
1587
filter. register_output ( WatchedOutput {
@@ -2002,18 +2002,16 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2002
2002
let current_height = self . current_best_block ( ) . height ;
2003
2003
let mut inner = self . inner . lock ( ) . unwrap ( ) ;
2004
2004
2005
- if is_all_funds_claimed {
2006
- if !inner. funding_spend_seen {
2007
- debug_assert ! ( false , "We should see funding spend by the time a monitor clears out" ) ;
2008
- is_all_funds_claimed = false ;
2009
- }
2005
+ if is_all_funds_claimed && !inner. funding_spend_seen {
2006
+ debug_assert ! ( false , "We should see funding spend by the time a monitor clears out" ) ;
2007
+ is_all_funds_claimed = false ;
2010
2008
}
2011
2009
2012
2010
const BLOCKS_THRESHOLD : u32 = 4032 ; // ~four weeks
2013
2011
match ( inner. balances_empty_height , is_all_funds_claimed) {
2014
2012
( Some ( balances_empty_height) , true ) => {
2015
2013
// Claimed all funds, check if reached the blocks threshold.
2016
- return current_height >= balances_empty_height + BLOCKS_THRESHOLD ;
2014
+ current_height >= balances_empty_height + BLOCKS_THRESHOLD
2017
2015
} ,
2018
2016
( Some ( _) , false ) => {
2019
2017
// previously assumed we claimed all funds, but we have new funds to claim.
@@ -2065,8 +2063,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2065
2063
holder_commitment : bool , counterparty_revoked_commitment : bool ,
2066
2064
confirmed_txid : Option < Txid >
2067
2065
) -> Option < Balance > {
2068
- let htlc_commitment_tx_output_idx =
2069
- if let Some ( v) = htlc. transaction_output_index { v } else { return None ; } ;
2066
+ let htlc_commitment_tx_output_idx = htlc. transaction_output_index ?;
2070
2067
2071
2068
let mut htlc_spend_txid_opt = None ;
2072
2069
let mut htlc_spend_tx_opt = None ;
@@ -2116,14 +2113,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2116
2113
}
2117
2114
}
2118
2115
let htlc_resolved = self . htlcs_resolved_on_chain . iter ( )
2119
- . find ( |v| if v. commitment_tx_output_idx == Some ( htlc_commitment_tx_output_idx) {
2116
+ . any ( |v| if v. commitment_tx_output_idx == Some ( htlc_commitment_tx_output_idx) {
2120
2117
debug_assert ! ( htlc_spend_txid_opt. is_none( ) ) ;
2121
2118
htlc_spend_txid_opt = v. resolving_txid . as_ref ( ) ;
2122
2119
debug_assert ! ( htlc_spend_tx_opt. is_none( ) ) ;
2123
2120
htlc_spend_tx_opt = v. resolving_tx . as_ref ( ) ;
2124
2121
true
2125
2122
} else { false } ) ;
2126
- debug_assert ! ( holder_timeout_spend_pending. is_some( ) as u8 + htlc_spend_pending. is_some( ) as u8 + htlc_resolved. is_some ( ) as u8 <= 1 ) ;
2123
+ debug_assert ! ( holder_timeout_spend_pending. is_some( ) as u8 + htlc_spend_pending. is_some( ) as u8 + htlc_resolved as u8 <= 1 ) ;
2127
2124
2128
2125
let htlc_commitment_outpoint = BitcoinOutPoint :: new ( confirmed_txid. unwrap ( ) , htlc_commitment_tx_output_idx) ;
2129
2126
let htlc_output_to_spend =
@@ -2154,31 +2151,31 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2154
2151
confirmation_height : conf_thresh,
2155
2152
source : BalanceSource :: Htlc ,
2156
2153
} ) ;
2157
- } else if htlc_resolved. is_some ( ) && !htlc_output_spend_pending {
2154
+ } else if htlc_resolved && !htlc_output_spend_pending {
2158
2155
// Funding transaction spends should be fully confirmed by the time any
2159
2156
// HTLC transactions are resolved, unless we're talking about a holder
2160
2157
// commitment tx, whose resolution is delayed until the CSV timeout is
2161
2158
// reached, even though HTLCs may be resolved after only
2162
2159
// ANTI_REORG_DELAY confirmations.
2163
2160
debug_assert ! ( holder_commitment || self . funding_spend_confirmed. is_some( ) ) ;
2164
2161
} else if counterparty_revoked_commitment {
2165
- let htlc_output_claim_pending = self . onchain_events_awaiting_threshold_conf . iter ( ) . find_map ( |event| {
2162
+ let htlc_output_claim_pending = self . onchain_events_awaiting_threshold_conf . iter ( ) . any ( |event| {
2166
2163
if let OnchainEvent :: MaturingOutput {
2167
2164
descriptor : SpendableOutputDescriptor :: StaticOutput { .. }
2168
2165
} = & event. event {
2169
- if event. transaction . as_ref ( ) . map ( |tx| tx. input . iter ( ) . any ( |inp| {
2166
+ event. transaction . as_ref ( ) . map ( |tx| tx. input . iter ( ) . any ( |inp| {
2170
2167
if let Some ( htlc_spend_txid) = htlc_spend_txid_opt {
2171
2168
tx. compute_txid ( ) == * htlc_spend_txid || inp. previous_output . txid == * htlc_spend_txid
2172
2169
} else {
2173
2170
Some ( inp. previous_output . txid ) == confirmed_txid &&
2174
2171
inp. previous_output . vout == htlc_commitment_tx_output_idx
2175
2172
}
2176
- } ) ) . unwrap_or ( false ) {
2177
- Some ( ( ) )
2178
- } else { None }
2179
- } else { None }
2173
+ } ) ) . unwrap_or ( false )
2174
+ } else {
2175
+ false
2176
+ }
2180
2177
} ) ;
2181
- if htlc_output_claim_pending. is_some ( ) {
2178
+ if htlc_output_claim_pending {
2182
2179
// We already push `Balance`s onto the `res` list for every
2183
2180
// `StaticOutput` in a `MaturingOutput` in the revoked
2184
2181
// counterparty commitment transaction case generally, so don't
@@ -2239,7 +2236,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
2239
2236
payment_preimage : * payment_preimage,
2240
2237
} ) ;
2241
2238
}
2242
- } else if htlc_resolved. is_none ( ) {
2239
+ } else if ! htlc_resolved {
2243
2240
return Some ( Balance :: MaybePreimageClaimableHTLC {
2244
2241
amount_satoshis : htlc. amount_msat / 1000 ,
2245
2242
expiry_height : htlc. cltv_expiry ,
@@ -3191,10 +3188,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3191
3188
// confirmed (even with 1 confirmation) as it'll be rejected as
3192
3189
// duplicate/conflicting.
3193
3190
let detected_funding_spend = self . funding_spend_confirmed . is_some ( ) ||
3194
- self . onchain_events_awaiting_threshold_conf . iter ( ) . find ( |event| match event. event {
3195
- OnchainEvent :: FundingSpendConfirmation { .. } => true ,
3196
- _ => false ,
3197
- } ) . is_some ( ) ;
3191
+ self . onchain_events_awaiting_threshold_conf . iter ( ) . any (
3192
+ |event| matches ! ( event. event, OnchainEvent :: FundingSpendConfirmation { .. } ) ) ;
3198
3193
if detected_funding_spend {
3199
3194
log_trace ! ( logger, "Avoiding commitment broadcast, already detected confirmed spend onchain" ) ;
3200
3195
continue ;
@@ -3268,7 +3263,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3268
3263
// If we've detected a counterparty commitment tx on chain, we must include it in the set
3269
3264
// of outputs to watch for spends of, otherwise we're likely to lose user funds. Because
3270
3265
// its trivial to do, double-check that here.
3271
- for ( txid, _ ) in self . counterparty_commitment_txn_on_chain . iter ( ) {
3266
+ for txid in self . counterparty_commitment_txn_on_chain . keys ( ) {
3272
3267
self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
3273
3268
}
3274
3269
& self . outputs_to_watch
@@ -4118,16 +4113,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4118
4113
}
4119
4114
4120
4115
// Find which on-chain events have reached their confirmation threshold.
4121
- let onchain_events_awaiting_threshold_conf =
4122
- self . onchain_events_awaiting_threshold_conf . drain ( ..) . collect :: < Vec < _ > > ( ) ;
4123
- let mut onchain_events_reaching_threshold_conf = Vec :: new ( ) ;
4124
- for entry in onchain_events_awaiting_threshold_conf {
4125
- if entry. has_reached_confirmation_threshold ( & self . best_block ) {
4126
- onchain_events_reaching_threshold_conf. push ( entry) ;
4127
- } else {
4128
- self . onchain_events_awaiting_threshold_conf . push ( entry) ;
4129
- }
4130
- }
4116
+ let ( onchain_events_reaching_threshold_conf, onchain_events_awaiting_threshold_conf) : ( Vec < _ > , Vec < _ > ) =
4117
+ self . onchain_events_awaiting_threshold_conf . drain ( ..) . partition (
4118
+ |entry| entry. has_reached_confirmation_threshold ( & self . best_block ) ) ;
4119
+ self . onchain_events_awaiting_threshold_conf = onchain_events_awaiting_threshold_conf;
4131
4120
4132
4121
// Used to check for duplicate HTLC resolutions.
4133
4122
#[ cfg( debug_assertions) ]
@@ -4142,19 +4131,19 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4142
4131
let mut matured_htlcs = Vec :: new ( ) ;
4143
4132
4144
4133
// Produce actionable events from on-chain events having reached their threshold.
4145
- for entry in onchain_events_reaching_threshold_conf. drain ( .. ) {
4134
+ for entry in onchain_events_reaching_threshold_conf {
4146
4135
match entry. event {
4147
- OnchainEvent :: HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx } => {
4136
+ OnchainEvent :: HTLCUpdate { source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx } => {
4148
4137
// Check for duplicate HTLC resolutions.
4149
4138
#[ cfg( debug_assertions) ]
4150
4139
{
4151
4140
debug_assert ! (
4152
- unmatured_htlcs. iter ( ) . find ( | & htlc| htlc == & source) . is_none ( ) ,
4141
+ ! unmatured_htlcs. contains ( & &source) ,
4153
4142
"An unmature HTLC transaction conflicts with a maturing one; failed to \
4154
4143
call either transaction_unconfirmed for the conflicting transaction \
4155
4144
or block_disconnected for a block containing it.") ;
4156
4145
debug_assert ! (
4157
- matured_htlcs. iter ( ) . find ( | & htlc| htlc == source) . is_none ( ) ,
4146
+ ! matured_htlcs. contains ( & source) ,
4158
4147
"A matured HTLC transaction conflicts with a maturing one; failed to \
4159
4148
call either transaction_unconfirmed for the conflicting transaction \
4160
4149
or block_disconnected for a block containing it.") ;
@@ -4166,7 +4155,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4166
4155
self . pending_monitor_events . push ( MonitorEvent :: HTLCEvent ( HTLCUpdate {
4167
4156
payment_hash,
4168
4157
payment_preimage : None ,
4169
- source : source . clone ( ) ,
4158
+ source,
4170
4159
htlc_value_satoshis,
4171
4160
} ) ) ;
4172
4161
self . htlcs_resolved_on_chain . push ( IrrevocablyResolvedHTLC {
@@ -4211,7 +4200,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4211
4200
} ) ;
4212
4201
#[ cfg( test) ]
4213
4202
{
4214
- // If we see a transaction for which we registered outputs previously,
4203
+ // If we see a transaction for which we registered outputs previously,
4215
4204
// make sure the registered scriptpubkey at the expected index match
4216
4205
// the actual transaction output one. We failed this case before #653.
4217
4206
for tx in & txn_matched {
@@ -4596,7 +4585,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4596
4585
height,
4597
4586
block_hash : Some ( * block_hash) ,
4598
4587
event : OnchainEvent :: HTLCUpdate {
4599
- source, payment_hash,
4588
+ source,
4589
+ payment_hash,
4600
4590
htlc_value_satoshis : Some ( amount_msat / 1000 ) ,
4601
4591
commitment_tx_output_idx : Some ( input. previous_output . vout ) ,
4602
4592
} ,
@@ -4808,7 +4798,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4808
4798
for _ in 0 ..htlcs_count {
4809
4799
htlcs. push ( ( read_htlc_in_commitment ! ( ) , <Option < HTLCSource > as Readable >:: read ( reader) ?. map ( |o : HTLCSource | Box :: new ( o) ) ) ) ;
4810
4800
}
4811
- if let Some ( _ ) = counterparty_claimable_outpoints. insert ( txid, htlcs) {
4801
+ if counterparty_claimable_outpoints. insert ( txid, htlcs) . is_some ( ) {
4812
4802
return Err ( DecodeError :: InvalidValue ) ;
4813
4803
}
4814
4804
}
@@ -4818,7 +4808,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4818
4808
for _ in 0 ..counterparty_commitment_txn_on_chain_len {
4819
4809
let txid: Txid = Readable :: read ( reader) ?;
4820
4810
let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
4821
- if let Some ( _ ) = counterparty_commitment_txn_on_chain. insert ( txid, commitment_number) {
4811
+ if counterparty_commitment_txn_on_chain. insert ( txid, commitment_number) . is_some ( ) {
4822
4812
return Err ( DecodeError :: InvalidValue ) ;
4823
4813
}
4824
4814
}
@@ -4828,17 +4818,15 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4828
4818
for _ in 0 ..counterparty_hash_commitment_number_len {
4829
4819
let payment_hash: PaymentHash = Readable :: read ( reader) ?;
4830
4820
let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
4831
- if let Some ( _ ) = counterparty_hash_commitment_number. insert ( payment_hash, commitment_number) {
4821
+ if counterparty_hash_commitment_number. insert ( payment_hash, commitment_number) . is_some ( ) {
4832
4822
return Err ( DecodeError :: InvalidValue ) ;
4833
4823
}
4834
4824
}
4835
4825
4836
4826
let mut prev_holder_signed_commitment_tx: Option < HolderSignedTx > =
4837
4827
match <u8 as Readable >:: read ( reader) ? {
4838
4828
0 => None ,
4839
- 1 => {
4840
- Some ( Readable :: read ( reader) ?)
4841
- } ,
4829
+ 1 => Some ( Readable :: read ( reader) ?) ,
4842
4830
_ => return Err ( DecodeError :: InvalidValue ) ,
4843
4831
} ;
4844
4832
let mut current_holder_commitment_tx: HolderSignedTx = Readable :: read ( reader) ?;
@@ -4851,7 +4839,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4851
4839
for _ in 0 ..payment_preimages_len {
4852
4840
let preimage: PaymentPreimage = Readable :: read ( reader) ?;
4853
4841
let hash = PaymentHash ( Sha256 :: hash ( & preimage. 0 [ ..] ) . to_byte_array ( ) ) ;
4854
- if let Some ( _ ) = payment_preimages. insert ( hash, ( preimage, Vec :: new ( ) ) ) {
4842
+ if payment_preimages. insert ( hash, ( preimage, Vec :: new ( ) ) ) . is_some ( ) {
4855
4843
return Err ( DecodeError :: InvalidValue ) ;
4856
4844
}
4857
4845
}
@@ -4895,7 +4883,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4895
4883
for _ in 0 ..outputs_len {
4896
4884
outputs. push ( ( Readable :: read ( reader) ?, Readable :: read ( reader) ?) ) ;
4897
4885
}
4898
- if let Some ( _ ) = outputs_to_watch. insert ( txid, outputs) {
4886
+ if outputs_to_watch. insert ( txid, outputs) . is_some ( ) {
4899
4887
return Err ( DecodeError :: InvalidValue ) ;
4900
4888
}
4901
4889
}
@@ -4909,15 +4897,15 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4909
4897
if let Some ( prev_commitment_tx) = prev_holder_signed_commitment_tx. as_mut ( ) {
4910
4898
let prev_holder_value = onchain_tx_handler. get_prev_holder_commitment_to_self_value ( ) ;
4911
4899
if prev_holder_value. is_none ( ) { return Err ( DecodeError :: InvalidValue ) ; }
4912
- if prev_commitment_tx. to_self_value_sat == u64:: max_value ( ) {
4900
+ if prev_commitment_tx. to_self_value_sat == u64:: MAX {
4913
4901
prev_commitment_tx. to_self_value_sat = prev_holder_value. unwrap ( ) ;
4914
4902
} else if prev_commitment_tx. to_self_value_sat != prev_holder_value. unwrap ( ) {
4915
4903
return Err ( DecodeError :: InvalidValue ) ;
4916
4904
}
4917
4905
}
4918
4906
4919
4907
let cur_holder_value = onchain_tx_handler. get_cur_holder_commitment_to_self_value ( ) ;
4920
- if current_holder_commitment_tx. to_self_value_sat == u64:: max_value ( ) {
4908
+ if current_holder_commitment_tx. to_self_value_sat == u64:: MAX {
4921
4909
current_holder_commitment_tx. to_self_value_sat = cur_holder_value;
4922
4910
} else if current_holder_commitment_tx. to_self_value_sat != cur_holder_value {
4923
4911
return Err ( DecodeError :: InvalidValue ) ;
@@ -5259,7 +5247,7 @@ mod tests {
5259
5247
delayed_payment_basepoint : DelayedPaymentBasepoint :: from ( PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 47 ; 32 ] ) . unwrap ( ) ) ) ,
5260
5248
htlc_basepoint : HtlcBasepoint :: from ( PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 48 ; 32 ] ) . unwrap ( ) ) )
5261
5249
} ;
5262
- let funding_outpoint = OutPoint { txid : Txid :: all_zeros ( ) , index : u16:: max_value ( ) } ;
5250
+ let funding_outpoint = OutPoint { txid : Txid :: all_zeros ( ) , index : u16:: MAX } ;
5263
5251
let channel_id = ChannelId :: v1_from_funding_outpoint ( funding_outpoint) ;
5264
5252
let channel_parameters = ChannelTransactionParameters {
5265
5253
holder_pubkeys : keys. holder_channel_pubkeys . clone ( ) ,
@@ -5511,7 +5499,7 @@ mod tests {
5511
5499
delayed_payment_basepoint : DelayedPaymentBasepoint :: from ( PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 47 ; 32 ] ) . unwrap ( ) ) ) ,
5512
5500
htlc_basepoint : HtlcBasepoint :: from ( PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 48 ; 32 ] ) . unwrap ( ) ) ) ,
5513
5501
} ;
5514
- let funding_outpoint = OutPoint { txid : Txid :: all_zeros ( ) , index : u16:: max_value ( ) } ;
5502
+ let funding_outpoint = OutPoint { txid : Txid :: all_zeros ( ) , index : u16:: MAX } ;
5515
5503
let channel_id = ChannelId :: v1_from_funding_outpoint ( funding_outpoint) ;
5516
5504
let channel_parameters = ChannelTransactionParameters {
5517
5505
holder_pubkeys : keys. holder_channel_pubkeys . clone ( ) ,
0 commit comments