@@ -3483,15 +3483,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
34833483 to_broadcaster_value,
34843484 to_countersignatory_value,
34853485 ) | {
3486- let htlc_outputs = vec ! [ ] ;
3486+ let nondust_htlcs = vec ! [ ] ;
34873487
34883488 let commitment_tx = self . build_counterparty_commitment_tx (
34893489 INITIAL_COMMITMENT_NUMBER ,
34903490 & their_per_commitment_point,
34913491 to_broadcaster_value,
34923492 to_countersignatory_value,
34933493 feerate_per_kw,
3494- htlc_outputs ,
3494+ & nondust_htlcs ,
34953495 ) ;
34963496 // Take the opportunity to populate this recently introduced field
34973497 self . initial_counterparty_commitment_tx = Some ( commitment_tx. clone ( ) ) ;
@@ -3504,11 +3504,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35043504 fn build_counterparty_commitment_tx (
35053505 & self , commitment_number : u64 , their_per_commitment_point : & PublicKey ,
35063506 to_broadcaster_value : u64 , to_countersignatory_value : u64 , feerate_per_kw : u32 ,
3507- mut nondust_htlcs : Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) >
3507+ nondust_htlcs : & Vec < HTLCOutputInCommitment >
35083508 ) -> CommitmentTransaction {
35093509 let channel_parameters = & self . funding . channel_parameters . as_counterparty_broadcastable ( ) ;
3510- CommitmentTransaction :: new_with_auxiliary_htlc_data ( commitment_number, their_per_commitment_point,
3511- to_broadcaster_value, to_countersignatory_value, feerate_per_kw, & mut nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
3510+ CommitmentTransaction :: new ( commitment_number, their_per_commitment_point,
3511+ to_broadcaster_value, to_countersignatory_value, feerate_per_kw, nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
35123512 }
35133513
35143514 fn counterparty_commitment_txs_from_update ( & self , update : & ChannelMonitorUpdate ) -> Vec < CommitmentTransaction > {
@@ -3524,12 +3524,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35243524 to_countersignatory_value_sat : Some ( to_countersignatory_value) } => {
35253525
35263526 let nondust_htlcs = htlc_outputs. iter ( ) . filter_map ( |( htlc, _) | {
3527- htlc. transaction_output_index . map ( |_| ( htlc. clone ( ) , None ) )
3527+ htlc. transaction_output_index . map ( |_| htlc) . cloned ( )
35283528 } ) . collect :: < Vec < _ > > ( ) ;
35293529
35303530 let commitment_tx = self . build_counterparty_commitment_tx ( commitment_number,
35313531 & their_per_commitment_point, to_broadcaster_value,
3532- to_countersignatory_value, feerate_per_kw, nondust_htlcs) ;
3532+ to_countersignatory_value, feerate_per_kw, & nondust_htlcs) ;
35333533
35343534 debug_assert_eq ! ( commitment_tx. trust( ) . txid( ) , commitment_txid) ;
35353535
@@ -5423,21 +5423,21 @@ mod tests {
54235423 {
54245424 let mut res = Vec :: new( ) ;
54255425 for ( idx, preimage) in $preimages_slice. iter( ) . enumerate( ) {
5426- res. push( ( HTLCOutputInCommitment {
5426+ res. push( HTLCOutputInCommitment {
54275427 offered: true ,
54285428 amount_msat: 0 ,
54295429 cltv_expiry: 0 ,
54305430 payment_hash: preimage. 1 . clone( ) ,
54315431 transaction_output_index: Some ( idx as u32 ) ,
5432- } , ( ) ) ) ;
5432+ } ) ;
54335433 }
54345434 res
54355435 }
54365436 }
54375437 }
54385438 macro_rules! preimages_slice_to_htlc_outputs {
54395439 ( $preimages_slice: expr) => {
5440- preimages_slice_to_htlcs!( $preimages_slice) . into_iter( ) . map( |( htlc, _ ) | ( htlc, None ) ) . collect( )
5440+ preimages_slice_to_htlcs!( $preimages_slice) . into_iter( ) . map( |htlc| ( htlc, None ) ) . collect( )
54415441 }
54425442 }
54435443 let dummy_sig = crate :: crypto:: utils:: sign ( & secp_ctx,
@@ -5493,15 +5493,17 @@ mod tests {
54935493 let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
54945494 let monitor = ChannelMonitor :: new (
54955495 Secp256k1 :: new ( ) , keys, Some ( shutdown_script. into_inner ( ) ) , 0 , & ScriptBuf :: new ( ) ,
5496- & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & mut Vec :: new ( ) ) ,
5496+ & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & Vec :: new ( ) ) ,
54975497 best_block, dummy_key, channel_id,
54985498 ) ;
54995499
5500- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..10 ] ) ;
5501- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5500+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..10 ] ) ;
5501+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & nondust_htlcs) ;
5502+ // These htlcs now have their output indices assigned
5503+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
55025504
55035505 monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5504- htlcs . into_iter ( ) . map ( |( htlc, _ ) | ( htlc, Some ( dummy_sig) , None ) ) . collect ( ) ) ;
5506+ nondust_htlcs . into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , None ) ) . collect ( ) ) ;
55055507 monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"1" ) . to_byte_array ( ) ) ,
55065508 preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
55075509 monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"2" ) . to_byte_array ( ) ) ,
@@ -5536,21 +5538,25 @@ mod tests {
55365538
55375539 // Now update holder commitment tx info, pruning only element 18 as we still care about the
55385540 // previous commitment tx's preimages too
5539- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..5 ] ) ;
5540- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5541+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..5 ] ) ;
5542+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & nondust_htlcs) ;
5543+ // These htlcs now have their output indices assigned
5544+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
55415545 monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5542- htlcs . into_iter ( ) . map ( |( htlc, _ ) | ( htlc, Some ( dummy_sig) , None ) ) . collect ( ) ) ;
5546+ nondust_htlcs . into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , None ) ) . collect ( ) ) ;
55435547 secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8" ) . unwrap ( ) ) ;
55445548 monitor. provide_secret ( 281474976710653 , secret. clone ( ) ) . unwrap ( ) ;
55455549 assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 12 ) ;
55465550 test_preimages_exist ! ( & preimages[ 0 ..10 ] , monitor) ;
55475551 test_preimages_exist ! ( & preimages[ 18 ..20 ] , monitor) ;
55485552
55495553 // But if we do it again, we'll prune 5-10
5550- let mut htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..3 ] ) ;
5551- let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & mut htlcs) ;
5552- monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx,
5553- htlcs. into_iter ( ) . map ( |( htlc, _) | ( htlc, Some ( dummy_sig) , None ) ) . collect ( ) ) ;
5554+ let nondust_htlcs = preimages_slice_to_htlcs ! ( preimages[ 0 ..3 ] ) ;
5555+ let dummy_commitment_tx = HolderCommitmentTransaction :: dummy ( 0 , & nondust_htlcs) ;
5556+ // These htlcs now have their output indices assigned
5557+ let nondust_htlcs = dummy_commitment_tx. nondust_htlcs ( ) ;
5558+ monitor. provide_latest_holder_commitment_tx ( dummy_commitment_tx. clone ( ) ,
5559+ nondust_htlcs. into_iter ( ) . map ( |htlc| ( htlc. clone ( ) , Some ( dummy_sig) , None ) ) . collect ( ) ) ;
55545560 secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116" ) . unwrap ( ) ) ;
55555561 monitor. provide_secret ( 281474976710652 , secret. clone ( ) ) . unwrap ( ) ;
55565562 assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 5 ) ;
@@ -5745,7 +5751,7 @@ mod tests {
57455751 let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
57465752 let monitor = ChannelMonitor :: new (
57475753 Secp256k1 :: new ( ) , keys, Some ( shutdown_script. into_inner ( ) ) , 0 , & ScriptBuf :: new ( ) ,
5748- & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & mut Vec :: new ( ) ) ,
5754+ & channel_parameters, true , 0 , HolderCommitmentTransaction :: dummy ( 0 , & Vec :: new ( ) ) ,
57495755 best_block, dummy_key, channel_id,
57505756 ) ;
57515757
0 commit comments