@@ -3598,15 +3598,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35983598 to_broadcaster_value,
35993599 to_countersignatory_value,
36003600 ) | {
3601- let htlc_outputs = vec ! [ ] ;
3601+ let nondust_htlcs = vec ! [ ] ;
36023602
36033603 let commitment_tx = self . build_counterparty_commitment_tx (
36043604 INITIAL_COMMITMENT_NUMBER ,
36053605 & their_per_commitment_point,
36063606 to_broadcaster_value,
36073607 to_countersignatory_value,
36083608 feerate_per_kw,
3609- htlc_outputs ,
3609+ & nondust_htlcs ,
36103610 ) ;
36113611 // Take the opportunity to populate this recently introduced field
36123612 self . initial_counterparty_commitment_tx = Some ( commitment_tx. clone ( ) ) ;
@@ -3619,11 +3619,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36193619 fn build_counterparty_commitment_tx (
36203620 & self , commitment_number : u64 , their_per_commitment_point : & PublicKey ,
36213621 to_broadcaster_value : u64 , to_countersignatory_value : u64 , feerate_per_kw : u32 ,
3622- mut nondust_htlcs : Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) >
3622+ nondust_htlcs : & Vec < HTLCOutputInCommitment >
36233623 ) -> CommitmentTransaction {
36243624 let channel_parameters = & self . funding . channel_parameters . as_counterparty_broadcastable ( ) ;
3625- CommitmentTransaction :: new_with_auxiliary_htlc_data ( commitment_number, their_per_commitment_point,
3626- to_broadcaster_value, to_countersignatory_value, feerate_per_kw, & mut nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
3625+ CommitmentTransaction :: new ( commitment_number, their_per_commitment_point,
3626+ to_broadcaster_value, to_countersignatory_value, feerate_per_kw, nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
36273627 }
36283628
36293629 fn counterparty_commitment_txs_from_update ( & self , update : & ChannelMonitorUpdate ) -> Vec < CommitmentTransaction > {
@@ -3639,12 +3639,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
36393639 to_countersignatory_value_sat : Some ( to_countersignatory_value) } => {
36403640
36413641 let nondust_htlcs = htlc_outputs. iter ( ) . filter_map ( |( htlc, _) | {
3642- htlc. transaction_output_index . map ( |_| ( htlc. clone ( ) , None ) )
3642+ htlc. transaction_output_index . map ( |_| htlc) . cloned ( )
36433643 } ) . collect :: < Vec < _ > > ( ) ;
36443644
36453645 let commitment_tx = self . build_counterparty_commitment_tx ( commitment_number,
36463646 & their_per_commitment_point, to_broadcaster_value,
3647- to_countersignatory_value, feerate_per_kw, nondust_htlcs) ;
3647+ to_countersignatory_value, feerate_per_kw, & nondust_htlcs) ;
36483648
36493649 debug_assert_eq ! ( commitment_tx. trust( ) . txid( ) , commitment_txid) ;
36503650
@@ -5595,21 +5595,21 @@ mod tests {
55955595 {
55965596 let mut res = Vec :: new( ) ;
55975597 for ( idx, preimage) in $preimages_slice. iter( ) . enumerate( ) {
5598- res. push( ( HTLCOutputInCommitment {
5598+ res. push( HTLCOutputInCommitment {
55995599 offered: true ,
56005600 amount_msat: 0 ,
56015601 cltv_expiry: 0 ,
56025602 payment_hash: preimage. 1 . clone( ) ,
56035603 transaction_output_index: Some ( idx as u32 ) ,
5604- } , ( ) ) ) ;
5604+ } ) ;
56055605 }
56065606 res
56075607 }
56085608 }
56095609 }
56105610 macro_rules! preimages_slice_to_htlc_outputs {
56115611 ( $preimages_slice: expr) => {
5612- preimages_slice_to_htlcs!( $preimages_slice) . into_iter( ) . map( |( htlc, _ ) | ( htlc, None ) ) . collect( )
5612+ preimages_slice_to_htlcs!( $preimages_slice) . into_iter( ) . map( |htlc| ( htlc, None ) ) . collect( )
56135613 }
56145614 }
56155615 let dummy_sig = crate :: crypto:: utils:: sign ( & secp_ctx,
@@ -5665,15 +5665,17 @@ mod tests {
56655665 let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
56665666 let monitor = ChannelMonitor :: new (
56675667 Secp256k1 :: new ( ) , keys, Some ( shutdown_script. into_inner ( ) ) , 0 , & ScriptBuf :: new ( ) ,
5668- & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & mut Vec :: new ( ) ) ,
5668+ & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & Vec :: new ( ) ) ,
56695669 best_block, dummy_key, channel_id,
56705670 ) ;
56715671
5672- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..10 ] ) ;
5673- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5672+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..10 ] ) ;
5673+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & nondust_htlcs) ;
5674+ // These htlcs now have their output indices assigned
5675+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
56745676
56755677 monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5676- htlcs . into_iter ( ) . map ( |( htlc, _ ) | ( htlc, Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
5678+ nondust_htlcs . into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
56775679 monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"1" ) . to_byte_array ( ) ) ,
56785680 preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
56795681 monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"2" ) . to_byte_array ( ) ) ,
@@ -5708,21 +5710,25 @@ mod tests {
57085710
57095711 // Now update holder commitment tx info, pruning only element 18 as we still care about the
57105712 // previous commitment tx's preimages too
5711- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..5 ] ) ;
5712- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5713+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..5 ] ) ;
5714+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & nondust_htlcs) ;
5715+ // These htlcs now have their output indices assigned
5716+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
57135717 monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5714- htlcs . into_iter ( ) . map ( |( htlc, _ ) | ( htlc, Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
5718+ nondust_htlcs . into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
57155719 secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8" ) . unwrap ( ) ) ;
57165720 monitor. provide_secret ( 281474976710653 , secret. clone ( ) ) . unwrap ( ) ;
57175721 assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 12 ) ;
57185722 test_preimages_exist ! ( & preimages[ 0 ..10 ] , monitor) ;
57195723 test_preimages_exist ! ( & preimages[ 18 ..20 ] , monitor) ;
57205724
57215725 // But if we do it again, we'll prune 5-10
5722- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..3 ] ) ;
5723- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5724- monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx,
5725- htlcs. into_iter ( ) . map ( |( htlc, _) | ( htlc, Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
5726+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..3 ] ) ;
5727+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & nondust_htlcs) ;
5728+ // These htlcs now have their output indices assigned
5729+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
5730+ monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5731+ nondust_htlcs. into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , Some ( dummy_source. clone ( ) ) ) ) . collect ( ) ) ;
57265732 secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116" ) . unwrap ( ) ) ;
57275733 monitor. provide_secret ( 281474976710652 , secret. clone ( ) ) . unwrap ( ) ;
57285734 assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 5 ) ;
@@ -5917,7 +5923,7 @@ mod tests {
59175923 let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
59185924 let monitor = ChannelMonitor :: new (
59195925 Secp256k1 :: new ( ) , keys, Some ( shutdown_script. into_inner ( ) ) , 0 , & ScriptBuf :: new ( ) ,
5920- & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & mut Vec :: new ( ) ) ,
5926+ & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & Vec :: new ( ) ) ,
59215927 best_block, dummy_key, channel_id,
59225928 ) ;
59235929
0 commit comments