@@ -3483,15 +3483,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3483
3483
to_broadcaster_value,
3484
3484
to_countersignatory_value,
3485
3485
) | {
3486
- let htlc_outputs = vec ! [ ] ;
3486
+ let nondust_htlcs = vec ! [ ] ;
3487
3487
3488
3488
let commitment_tx = self . build_counterparty_commitment_tx (
3489
3489
INITIAL_COMMITMENT_NUMBER ,
3490
3490
& their_per_commitment_point,
3491
3491
to_broadcaster_value,
3492
3492
to_countersignatory_value,
3493
3493
feerate_per_kw,
3494
- htlc_outputs ,
3494
+ & nondust_htlcs ,
3495
3495
) ;
3496
3496
// Take the opportunity to populate this recently introduced field
3497
3497
self . initial_counterparty_commitment_tx = Some ( commitment_tx. clone ( ) ) ;
@@ -3504,11 +3504,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3504
3504
fn build_counterparty_commitment_tx (
3505
3505
& self , commitment_number : u64 , their_per_commitment_point : & PublicKey ,
3506
3506
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 >
3508
3508
) -> CommitmentTransaction {
3509
3509
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 )
3512
3512
}
3513
3513
3514
3514
fn counterparty_commitment_txs_from_update ( & self , update : & ChannelMonitorUpdate ) -> Vec < CommitmentTransaction > {
@@ -3524,12 +3524,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3524
3524
to_countersignatory_value_sat : Some ( to_countersignatory_value) } => {
3525
3525
3526
3526
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 ( )
3528
3528
} ) . collect :: < Vec < _ > > ( ) ;
3529
3529
3530
3530
let commitment_tx = self . build_counterparty_commitment_tx ( commitment_number,
3531
3531
& 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) ;
3533
3533
3534
3534
debug_assert_eq ! ( commitment_tx. trust( ) . txid( ) , commitment_txid) ;
3535
3535
@@ -5423,21 +5423,21 @@ mod tests {
5423
5423
{
5424
5424
let mut res = Vec :: new( ) ;
5425
5425
for ( idx, preimage) in $preimages_slice. iter( ) . enumerate( ) {
5426
- res. push( ( HTLCOutputInCommitment {
5426
+ res. push( HTLCOutputInCommitment {
5427
5427
offered: true ,
5428
5428
amount_msat: 0 ,
5429
5429
cltv_expiry: 0 ,
5430
5430
payment_hash: preimage. 1 . clone( ) ,
5431
5431
transaction_output_index: Some ( idx as u32 ) ,
5432
- } , ( ) ) ) ;
5432
+ } ) ;
5433
5433
}
5434
5434
res
5435
5435
}
5436
5436
}
5437
5437
}
5438
5438
macro_rules! preimages_slice_to_htlc_outputs {
5439
5439
( $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( )
5441
5441
}
5442
5442
}
5443
5443
let dummy_sig = crate :: crypto:: utils:: sign ( & secp_ctx,
@@ -5493,15 +5493,17 @@ mod tests {
5493
5493
let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
5494
5494
let monitor = ChannelMonitor :: new (
5495
5495
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 ( ) ) ,
5497
5497
best_block, dummy_key, channel_id,
5498
5498
) ;
5499
5499
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 ( ) ;
5502
5504
5503
5505
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 ( ) ) ;
5505
5507
monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"1" ) . to_byte_array ( ) ) ,
5506
5508
preimages_slice_to_htlc_outputs ! ( preimages[ 5 ..15 ] ) , 281474976710655 , dummy_key, & logger) ;
5507
5509
monitor. provide_latest_counterparty_commitment_tx ( Txid :: from_byte_array ( Sha256 :: hash ( b"2" ) . to_byte_array ( ) ) ,
@@ -5536,21 +5538,25 @@ mod tests {
5536
5538
5537
5539
// Now update holder commitment tx info, pruning only element 18 as we still care about the
5538
5540
// 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 ( ) ;
5541
5545
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 ( ) ) ;
5543
5547
secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8" ) . unwrap ( ) ) ;
5544
5548
monitor. provide_secret ( 281474976710653 , secret. clone ( ) ) . unwrap ( ) ;
5545
5549
assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 12 ) ;
5546
5550
test_preimages_exist ! ( & preimages[ 0 ..10 ] , monitor) ;
5547
5551
test_preimages_exist ! ( & preimages[ 18 ..20 ] , monitor) ;
5548
5552
5549
5553
// 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 ( ) ) ;
5554
5560
secret[ 0 ..32 ] . clone_from_slice ( & <Vec < u8 > >:: from_hex ( "27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116" ) . unwrap ( ) ) ;
5555
5561
monitor. provide_secret ( 281474976710652 , secret. clone ( ) ) . unwrap ( ) ;
5556
5562
assert_eq ! ( monitor. inner. lock( ) . unwrap( ) . payment_preimages. len( ) , 5 ) ;
@@ -5745,7 +5751,7 @@ mod tests {
5745
5751
let best_block = BestBlock :: from_network ( Network :: Testnet ) ;
5746
5752
let monitor = ChannelMonitor :: new (
5747
5753
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 ( ) ) ,
5749
5755
best_block, dummy_key, channel_id,
5750
5756
) ;
5751
5757
0 commit comments