@@ -1235,7 +1235,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
12351235 channel_parameters. clone ( ) , initial_holder_commitment_tx, secp_ctx
12361236 ) ;
12371237
1238- let mut outputs_to_watch = HashMap :: new ( ) ;
1238+ let mut outputs_to_watch = new_hash_map ( ) ;
12391239 outputs_to_watch. insert ( funding_info. 0 . txid , vec ! [ ( funding_info. 0 . index as u32 , funding_info. 1 . clone( ) ) ] ) ;
12401240
12411241 Self :: from_impl ( ChannelMonitorImpl {
@@ -1262,17 +1262,17 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
12621262 on_holder_tx_csv : counterparty_channel_parameters. selected_contest_delay ,
12631263
12641264 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 ( ) ,
12691269
12701270 prev_holder_signed_commitment_tx : None ,
12711271 current_holder_commitment_tx : holder_commitment_tx,
12721272 current_counterparty_commitment_number : 1 << 48 ,
12731273 current_holder_commitment_number,
12741274
1275- payment_preimages : HashMap :: new ( ) ,
1275+ payment_preimages : new_hash_map ( ) ,
12761276 pending_monitor_events : Vec :: new ( ) ,
12771277 pending_events : Vec :: new ( ) ,
12781278 is_processing_pending_events : false ,
@@ -2174,7 +2174,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
21742174 /// HTLCs which were resolved on-chain (i.e. where the final HTLC resolution was done by an
21752175 /// event from this `ChannelMonitor`).
21762176 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 ( ) ;
21782178 // Just examine the available counterparty commitment transactions. See docs on
21792179 // `fail_unbroadcast_htlcs`, below, for justification.
21802180 let us = self . inner . lock ( ) . unwrap ( ) ;
@@ -2226,7 +2226,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
22262226 return self . get_all_current_outbound_htlcs ( ) ;
22272227 }
22282228
2229- let mut res = HashMap :: new ( ) ;
2229+ let mut res = new_hash_map ( ) ;
22302230 macro_rules! walk_htlcs {
22312231 ( $holder_commitment: expr, $htlc_iter: expr) => {
22322232 for ( htlc, source) in $htlc_iter {
@@ -3172,7 +3172,11 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
31723172 ( htlc, htlc_source. as_ref( ) . map( |htlc_source| htlc_source. as_ref( ) ) )
31733173 ) , logger) ;
31743174 } 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" ) ;
31763180 fail_unbroadcast_htlcs ! ( self , "revoked counterparty" , commitment_txid, tx, height,
31773181 block_hash, [ ] . iter( ) . map( |reference| * reference) , logger) ;
31783182 }
@@ -3679,6 +3683,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36793683 claimable_outpoints. append ( & mut new_outpoints) ;
36803684 if new_outpoints. is_empty ( ) {
36813685 if let Some ( ( mut new_outpoints, new_outputs) ) = self . check_spend_holder_transaction ( & tx, height, & block_hash, & logger) {
3686+ #[ cfg( not( fuzzing) ) ]
36823687 debug_assert ! ( commitment_tx_to_counterparty_output. is_none( ) ,
36833688 "A commitment transaction matched as both a counterparty and local commitment tx?" ) ;
36843689 if !new_outputs. 1 . is_empty ( ) {
@@ -3935,7 +3940,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
39353940 /// Filters a block's `txdata` for transactions spending watched outputs or for any child
39363941 /// transactions thereof.
39373942 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 ( ) ;
39393944 txdata. iter ( ) . filter ( |& & ( _, tx) | {
39403945 let mut matches = self . spends_watched_output ( tx) ;
39413946 for input in tx. input . iter ( ) {
@@ -4450,7 +4455,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
44504455 }
44514456
44524457 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 ) ) ;
44544459 for _ in 0 ..counterparty_claimable_outpoints_len {
44554460 let txid: Txid = Readable :: read ( reader) ?;
44564461 let htlcs_count: u64 = Readable :: read ( reader) ?;
@@ -4464,7 +4469,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
44644469 }
44654470
44664471 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 ) ) ;
44684473 for _ in 0 ..counterparty_commitment_txn_on_chain_len {
44694474 let txid: Txid = Readable :: read ( reader) ?;
44704475 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
44744479 }
44754480
44764481 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 ) ) ;
44784483 for _ in 0 ..counterparty_hash_commitment_number_len {
44794484 let payment_hash: PaymentHash = Readable :: read ( reader) ?;
44804485 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
44974502 let current_holder_commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
44984503
44994504 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 ) ) ;
45014506 for _ in 0 ..payment_preimages_len {
45024507 let preimage: PaymentPreimage = Readable :: read ( reader) ?;
45034508 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
45374542 }
45384543
45394544 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 > > ( ) ) ) ) ;
45414546 for _ in 0 ..outputs_to_watch_len {
45424547 let txid = Readable :: read ( reader) ?;
45434548 let outputs_len: u64 = Readable :: read ( reader) ?;
@@ -4579,7 +4584,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
45794584 let mut counterparty_node_id = None ;
45804585 let mut confirmed_commitment_tx_counterparty_output = None ;
45814586 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 ( ) ) ;
45834588 let mut initial_counterparty_commitment_info = None ;
45844589 let mut channel_id = None ;
45854590 read_tlv_fields ! ( reader, {
0 commit comments