@@ -1235,7 +1235,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
1235
1235
channel_parameters. clone ( ) , initial_holder_commitment_tx, secp_ctx
1236
1236
) ;
1237
1237
1238
- let mut outputs_to_watch = HashMap :: new ( ) ;
1238
+ let mut outputs_to_watch = new_hash_map ( ) ;
1239
1239
outputs_to_watch. insert ( funding_info. 0 . txid , vec ! [ ( funding_info. 0 . index as u32 , funding_info. 1 . clone( ) ) ] ) ;
1240
1240
1241
1241
Self :: from_impl ( ChannelMonitorImpl {
@@ -1262,17 +1262,17 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
1262
1262
on_holder_tx_csv : counterparty_channel_parameters. selected_contest_delay ,
1263
1263
1264
1264
commitment_secrets : CounterpartyCommitmentSecrets :: new ( ) ,
1265
- counterparty_claimable_outpoints : HashMap :: new ( ) ,
1266
- counterparty_commitment_txn_on_chain : HashMap :: new ( ) ,
1267
- counterparty_hash_commitment_number : HashMap :: new ( ) ,
1268
- counterparty_fulfilled_htlcs : HashMap :: new ( ) ,
1265
+ counterparty_claimable_outpoints : new_hash_map ( ) ,
1266
+ counterparty_commitment_txn_on_chain : new_hash_map ( ) ,
1267
+ counterparty_hash_commitment_number : new_hash_map ( ) ,
1268
+ counterparty_fulfilled_htlcs : new_hash_map ( ) ,
1269
1269
1270
1270
prev_holder_signed_commitment_tx : None ,
1271
1271
current_holder_commitment_tx : holder_commitment_tx,
1272
1272
current_counterparty_commitment_number : 1 << 48 ,
1273
1273
current_holder_commitment_number,
1274
1274
1275
- payment_preimages : HashMap :: new ( ) ,
1275
+ payment_preimages : new_hash_map ( ) ,
1276
1276
pending_monitor_events : Vec :: new ( ) ,
1277
1277
pending_events : Vec :: new ( ) ,
1278
1278
is_processing_pending_events : false ,
@@ -2174,7 +2174,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2174
2174
/// HTLCs which were resolved on-chain (i.e. where the final HTLC resolution was done by an
2175
2175
/// event from this `ChannelMonitor`).
2176
2176
pub ( crate ) fn get_all_current_outbound_htlcs ( & self ) -> HashMap < HTLCSource , ( HTLCOutputInCommitment , Option < PaymentPreimage > ) > {
2177
- let mut res = HashMap :: new ( ) ;
2177
+ let mut res = new_hash_map ( ) ;
2178
2178
// Just examine the available counterparty commitment transactions. See docs on
2179
2179
// `fail_unbroadcast_htlcs`, below, for justification.
2180
2180
let us = self . inner . lock ( ) . unwrap ( ) ;
@@ -2226,7 +2226,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
2226
2226
return self . get_all_current_outbound_htlcs ( ) ;
2227
2227
}
2228
2228
2229
- let mut res = HashMap :: new ( ) ;
2229
+ let mut res = new_hash_map ( ) ;
2230
2230
macro_rules! walk_htlcs {
2231
2231
( $holder_commitment: expr, $htlc_iter: expr) => {
2232
2232
for ( htlc, source) in $htlc_iter {
@@ -3172,7 +3172,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3172
3172
( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
3173
3173
) , logger) ;
3174
3174
} else {
3175
- debug_assert ! ( false , "We should have per-commitment option for any recognized old commitment txn" ) ;
3175
+ // Our fuzzers aren't contrained by pesky things like valid signatures, so can
3176
+ // spend our funding output with a transaction which doesn't match our past
3177
+ // commitment transactions. Thus, we can only debug-assert here when not
3178
+ // fuzzing.
3179
+ debug_assert ! ( cfg!( fuzzing) , "We should have per-commitment option for any recognized old commitment txn" ) ;
3176
3180
fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, tx, height,
3177
3181
block_hash, [ ] . iter( ) . map( |reference| * reference) , logger) ;
3178
3182
}
@@ -3679,6 +3683,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3679
3683
claimable_outpoints. append ( & mut new_outpoints) ;
3680
3684
if new_outpoints. is_empty ( ) {
3681
3685
if let Some ( ( mut new_outpoints, new_outputs) ) = self . check_spend_holder_transaction ( & tx, height, & block_hash, & logger) {
3686
+ #[ cfg( not( fuzzing) ) ]
3682
3687
debug_assert ! ( commitment_tx_to_counterparty_output. is_none( ) ,
3683
3688
"A commitment transaction matched as both a counterparty and local commitment tx?" ) ;
3684
3689
if !new_outputs. 1 . is_empty ( ) {
@@ -3935,7 +3940,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3935
3940
/// Filters a block's `txdata` for transactions spending watched outputs or for any child
3936
3941
/// transactions thereof.
3937
3942
fn filter_block < ' a > ( & self , txdata : & TransactionData < ' a > ) -> Vec < & ' a Transaction > {
3938
- let mut matched_txn = HashSet :: new ( ) ;
3943
+ let mut matched_txn = new_hash_set ( ) ;
3939
3944
txdata. iter ( ) . filter ( |& & ( _, tx) | {
3940
3945
let mut matches = self . spends_watched_output ( tx) ;
3941
3946
for input in tx. input . iter ( ) {
@@ -4450,7 +4455,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4450
4455
}
4451
4456
4452
4457
let counterparty_claimable_outpoints_len: u64 = Readable :: read ( reader) ?;
4453
- let mut counterparty_claimable_outpoints = HashMap :: with_capacity ( cmp:: min ( counterparty_claimable_outpoints_len as usize , MAX_ALLOC_SIZE / 64 ) ) ;
4458
+ let mut counterparty_claimable_outpoints = hash_map_with_capacity ( cmp:: min ( counterparty_claimable_outpoints_len as usize , MAX_ALLOC_SIZE / 64 ) ) ;
4454
4459
for _ in 0 ..counterparty_claimable_outpoints_len {
4455
4460
let txid: Txid = Readable :: read ( reader) ?;
4456
4461
let htlcs_count: u64 = Readable :: read ( reader) ?;
@@ -4464,7 +4469,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4464
4469
}
4465
4470
4466
4471
let counterparty_commitment_txn_on_chain_len: u64 = Readable :: read ( reader) ?;
4467
- let mut counterparty_commitment_txn_on_chain = HashMap :: with_capacity ( cmp:: min ( counterparty_commitment_txn_on_chain_len as usize , MAX_ALLOC_SIZE / 32 ) ) ;
4472
+ let mut counterparty_commitment_txn_on_chain = hash_map_with_capacity ( cmp:: min ( counterparty_commitment_txn_on_chain_len as usize , MAX_ALLOC_SIZE / 32 ) ) ;
4468
4473
for _ in 0 ..counterparty_commitment_txn_on_chain_len {
4469
4474
let txid: Txid = Readable :: read ( reader) ?;
4470
4475
let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
@@ -4474,7 +4479,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4474
4479
}
4475
4480
4476
4481
let counterparty_hash_commitment_number_len: u64 = Readable :: read ( reader) ?;
4477
- let mut counterparty_hash_commitment_number = HashMap :: with_capacity ( cmp:: min ( counterparty_hash_commitment_number_len as usize , MAX_ALLOC_SIZE / 32 ) ) ;
4482
+ let mut counterparty_hash_commitment_number = hash_map_with_capacity ( cmp:: min ( counterparty_hash_commitment_number_len as usize , MAX_ALLOC_SIZE / 32 ) ) ;
4478
4483
for _ in 0 ..counterparty_hash_commitment_number_len {
4479
4484
let payment_hash: PaymentHash = Readable :: read ( reader) ?;
4480
4485
let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
@@ -4497,7 +4502,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4497
4502
let current_holder_commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
4498
4503
4499
4504
let payment_preimages_len: u64 = Readable :: read ( reader) ?;
4500
- let mut payment_preimages = HashMap :: with_capacity ( cmp:: min ( payment_preimages_len as usize , MAX_ALLOC_SIZE / 32 ) ) ;
4505
+ let mut payment_preimages = hash_map_with_capacity ( cmp:: min ( payment_preimages_len as usize , MAX_ALLOC_SIZE / 32 ) ) ;
4501
4506
for _ in 0 ..payment_preimages_len {
4502
4507
let preimage: PaymentPreimage = Readable :: read ( reader) ?;
4503
4508
let hash = PaymentHash ( Sha256 :: hash ( & preimage. 0 [ ..] ) . to_byte_array ( ) ) ;
@@ -4537,7 +4542,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4537
4542
}
4538
4543
4539
4544
let outputs_to_watch_len: u64 = Readable :: read ( reader) ?;
4540
- let mut outputs_to_watch = HashMap :: with_capacity ( cmp:: min ( outputs_to_watch_len as usize , MAX_ALLOC_SIZE / ( mem:: size_of :: < Txid > ( ) + mem:: size_of :: < u32 > ( ) + mem:: size_of :: < Vec < ScriptBuf > > ( ) ) ) ) ;
4545
+ let mut outputs_to_watch = hash_map_with_capacity ( cmp:: min ( outputs_to_watch_len as usize , MAX_ALLOC_SIZE / ( mem:: size_of :: < Txid > ( ) + mem:: size_of :: < u32 > ( ) + mem:: size_of :: < Vec < ScriptBuf > > ( ) ) ) ) ;
4541
4546
for _ in 0 ..outputs_to_watch_len {
4542
4547
let txid = Readable :: read ( reader) ?;
4543
4548
let outputs_len: u64 = Readable :: read ( reader) ?;
@@ -4579,7 +4584,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
4579
4584
let mut counterparty_node_id = None ;
4580
4585
let mut confirmed_commitment_tx_counterparty_output = None ;
4581
4586
let mut spendable_txids_confirmed = Some ( Vec :: new ( ) ) ;
4582
- let mut counterparty_fulfilled_htlcs = Some ( HashMap :: new ( ) ) ;
4587
+ let mut counterparty_fulfilled_htlcs = Some ( new_hash_map ( ) ) ;
4583
4588
let mut initial_counterparty_commitment_info = None ;
4584
4589
let mut channel_id = None ;
4585
4590
read_tlv_fields ! ( reader, {
0 commit comments