@@ -3588,15 +3588,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35883588 to_broadcaster_value,
35893589 to_countersignatory_value,
35903590 ) | {
3591- let htlc_outputs = vec ! [ ] ;
3591+ let nondust_htlcs = vec ! [ ] ;
35923592
35933593 let commitment_tx = self . build_counterparty_commitment_tx (
35943594 INITIAL_COMMITMENT_NUMBER ,
35953595 & their_per_commitment_point,
35963596 to_broadcaster_value,
35973597 to_countersignatory_value,
35983598 feerate_per_kw,
3599- htlc_outputs ,
3599+ nondust_htlcs ,
36003600 ) ;
36013601 // Take the opportunity to populate this recently introduced field
36023602 self . initial_counterparty_commitment_tx = Some ( commitment_tx. clone ( ) ) ;
@@ -3609,11 +3609,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36093609 fn build_counterparty_commitment_tx (
36103610 & self , commitment_number : u64 , their_per_commitment_point : & PublicKey ,
36113611 to_broadcaster_value : u64 , to_countersignatory_value : u64 , feerate_per_kw : u32 ,
3612- mut nondust_htlcs : Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) >
3612+ nondust_htlcs : Vec < HTLCOutputInCommitment >
36133613 ) -> CommitmentTransaction {
36143614 let channel_parameters = & self . funding . channel_parameters . as_counterparty_broadcastable ( ) ;
3615- CommitmentTransaction :: new_with_auxiliary_htlc_data ( commitment_number, their_per_commitment_point,
3616- to_broadcaster_value, to_countersignatory_value, feerate_per_kw, & mut nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
3615+ CommitmentTransaction :: new ( commitment_number, their_per_commitment_point,
3616+ to_broadcaster_value, to_countersignatory_value, feerate_per_kw, nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
36173617 }
36183618
36193619 fn counterparty_commitment_txs_from_update ( & self , update : & ChannelMonitorUpdate ) -> Vec < CommitmentTransaction > {
@@ -3629,7 +3629,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36293629 to_countersignatory_value_sat : Some ( to_countersignatory_value) } => {
36303630
36313631 let nondust_htlcs = htlc_outputs. iter ( ) . filter_map ( |( htlc, _) | {
3632- htlc. transaction_output_index . map ( |_| ( htlc. clone ( ) , None ) )
3632+ htlc. transaction_output_index . map ( |_| htlc) . cloned ( )
36333633 } ) . collect :: < Vec < _ > > ( ) ;
36343634
36353635 let commitment_tx = self . build_counterparty_commitment_tx ( commitment_number,
@@ -5620,21 +5620,21 @@ mod tests {
56205620 {
56215621 let mut res = Vec :: new( ) ;
56225622 for ( idx, preimage) in $preimages_slice. iter( ) . enumerate( ) {
5623- res. push( ( HTLCOutputInCommitment {
5623+ res. push( HTLCOutputInCommitment {
56245624 offered: true ,
56255625 amount_msat: 0 ,
56265626 cltv_expiry: 0 ,
56275627 payment_hash: preimage. 1 . clone( ) ,
56285628 transaction_output_index: Some ( idx as u32 ) ,
5629- } , ( ) ) ) ;
5629+ } ) ;
56305630 }
56315631 res
56325632 }
56335633 }
56345634 }
56355635 macro_rules! preimages_slice_to_htlc_outputs {
56365636 ( $preimages_slice: expr) => {
5637- preimages_slice_to_htlcs!( $preimages_slice) . into_iter( ) . map( |( htlc, _ ) | ( htlc, None ) ) . collect( )
5637+ preimages_slice_to_htlcs!( $preimages_slice) . into_iter( ) . map( |htlc| ( htlc, None ) ) . collect( )
56385638 }
56395639 }
56405640 let dummy_sig = crate :: crypto:: utils:: sign ( & secp_ctx,
@@ -5690,15 +5690,17 @@ mod tests {
56905690 let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
56915691 let monitor = ChannelMonitor :: new (
56925692 Secp256k1 :: new ( ) , keys, Some ( shutdown_script. into_inner ( ) ) , 0 , & ScriptBuf :: new ( ) ,
5693- & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & mut Vec :: new ( ) ) ,
5693+ & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , Vec :: new ( ) ) ,
56945694 best_block, dummy_key, channel_id,
56955695 ) ;
56965696
5697- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..10 ] ) ;
5698- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5697+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..10 ] ) ;
5698+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , nondust_htlcs) ;
5699+ // These HTLCs now have their output indices assigned
5700+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
56995701
57005702 monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5701- htlcs . into_iter ( ) . map ( |( htlc, _ ) | ( htlc, Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
5703+ nondust_htlcs . into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
57025704 monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"1" ) . to_byte_array ( ) ) ,
57035705 preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
57045706 monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"2" ) . to_byte_array ( ) ) ,
@@ -5733,21 +5735,25 @@ mod tests {
57335735
57345736 // Now update holder commitment tx info, pruning only element 18 as we still care about the
57355737 // previous commitment tx's preimages too
5736- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..5 ] ) ;
5737- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5738+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..5 ] ) ;
5739+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , nondust_htlcs) ;
5740+ // These HTLCs now have their output indices assigned
5741+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
57385742 monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5739- htlcs . into_iter ( ) . map ( |( htlc, _ ) | ( htlc, Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
5743+ nondust_htlcs . into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
57405744 secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8" ) . unwrap ( ) ) ;
57415745 monitor. provide_secret ( 281474976710653 , secret. clone ( ) ) . unwrap ( ) ;
57425746 assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 12 ) ;
57435747 test_preimages_exist ! ( & preimages[ 0 ..10 ] , monitor) ;
57445748 test_preimages_exist ! ( & preimages[ 18 ..20 ] , monitor) ;
57455749
57465750 // But if we do it again, we'll prune 5-10
5747- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..3 ] ) ;
5748- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5749- monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx,
5750- htlcs. into_iter ( ) . map ( |( htlc, _) | ( htlc, Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
5751+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..3 ] ) ;
5752+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , nondust_htlcs) ;
5753+ // These HTLCs now have their output indices assigned
5754+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
5755+ monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5756+ nondust_htlcs. into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
57515757 secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116" ) . unwrap ( ) ) ;
57525758 monitor. provide_secret ( 281474976710652 , secret. clone ( ) ) . unwrap ( ) ;
57535759 assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 5 ) ;
@@ -5942,7 +5948,7 @@ mod tests {
59425948 let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
59435949 let monitor = ChannelMonitor :: new (
59445950 Secp256k1 :: new ( ) , keys, Some ( shutdown_script. into_inner ( ) ) , 0 , & ScriptBuf :: new ( ) ,
5945- & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & mut Vec :: new ( ) ) ,
5951+ & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , Vec :: new ( ) ) ,
59465952 best_block, dummy_key, channel_id,
59475953 ) ;
59485954
0 commit comments