@@ -3588,15 +3588,15 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3588
3588
to_broadcaster_value,
3589
3589
to_countersignatory_value,
3590
3590
)| {
3591
- let htlc_outputs = vec![];
3591
+ let nondust_htlcs = vec![];
3592
3592
3593
3593
let commitment_tx = self.build_counterparty_commitment_tx(
3594
3594
INITIAL_COMMITMENT_NUMBER,
3595
3595
&their_per_commitment_point,
3596
3596
to_broadcaster_value,
3597
3597
to_countersignatory_value,
3598
3598
feerate_per_kw,
3599
- htlc_outputs ,
3599
+ nondust_htlcs ,
3600
3600
);
3601
3601
// Take the opportunity to populate this recently introduced field
3602
3602
self.initial_counterparty_commitment_tx = Some(commitment_tx.clone());
@@ -3609,11 +3609,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3609
3609
fn build_counterparty_commitment_tx(
3610
3610
&self, commitment_number: u64, their_per_commitment_point: &PublicKey,
3611
3611
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>
3613
3613
) -> CommitmentTransaction {
3614
3614
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)
3617
3617
}
3618
3618
3619
3619
fn counterparty_commitment_txs_from_update(&self, update: &ChannelMonitorUpdate) -> Vec<CommitmentTransaction> {
@@ -3629,7 +3629,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3629
3629
to_countersignatory_value_sat: Some(to_countersignatory_value) } => {
3630
3630
3631
3631
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( )
3633
3633
}).collect::<Vec<_>>();
3634
3634
3635
3635
let commitment_tx = self.build_counterparty_commitment_tx(commitment_number,
@@ -5620,21 +5620,21 @@ mod tests {
5620
5620
{
5621
5621
let mut res = Vec::new();
5622
5622
for (idx, preimage) in $preimages_slice.iter().enumerate() {
5623
- res.push(( HTLCOutputInCommitment {
5623
+ res.push(HTLCOutputInCommitment {
5624
5624
offered: true,
5625
5625
amount_msat: 0,
5626
5626
cltv_expiry: 0,
5627
5627
payment_hash: preimage.1.clone(),
5628
5628
transaction_output_index: Some(idx as u32),
5629
- }, ()) );
5629
+ });
5630
5630
}
5631
5631
res
5632
5632
}
5633
5633
}
5634
5634
}
5635
5635
macro_rules! preimages_slice_to_htlc_outputs {
5636
5636
($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()
5638
5638
}
5639
5639
}
5640
5640
let dummy_sig = crate::crypto::utils::sign(&secp_ctx,
@@ -5690,15 +5690,17 @@ mod tests {
5690
5690
let best_block = BestBlock::from_network(Network::Testnet);
5691
5691
let monitor = ChannelMonitor::new(
5692
5692
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()),
5694
5694
best_block, dummy_key, channel_id,
5695
5695
);
5696
5696
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();
5699
5701
5700
5702
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());
5702
5704
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"1").to_byte_array()),
5703
5705
preimages_slice_to_htlc_outputs!(preimages[5..15]), 281474976710655, dummy_key, &logger);
5704
5706
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"2").to_byte_array()),
@@ -5733,21 +5735,25 @@ mod tests {
5733
5735
5734
5736
// Now update holder commitment tx info, pruning only element 18 as we still care about the
5735
5737
// 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();
5738
5742
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());
5740
5744
secret[0..32].clone_from_slice(&<Vec<u8>>::from_hex("2273e227a5b7449b6e70f1fb4652864038b1cbf9cd7c043a7d6456b7fc275ad8").unwrap());
5741
5745
monitor.provide_secret(281474976710653, secret.clone()).unwrap();
5742
5746
assert_eq!(monitor.inner.lock().unwrap().payment_preimages.len(), 12);
5743
5747
test_preimages_exist!(&preimages[0..10], monitor);
5744
5748
test_preimages_exist!(&preimages[18..20], monitor);
5745
5749
5746
5750
// 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());
5751
5757
secret[0..32].clone_from_slice(&<Vec<u8>>::from_hex("27cddaa5624534cb6cb9d7da077cf2b22ab21e9b506fd4998a51d54502e99116").unwrap());
5752
5758
monitor.provide_secret(281474976710652, secret.clone()).unwrap();
5753
5759
assert_eq!(monitor.inner.lock().unwrap().payment_preimages.len(), 5);
@@ -5942,7 +5948,7 @@ mod tests {
5942
5948
let best_block = BestBlock::from_network(Network::Testnet);
5943
5949
let monitor = ChannelMonitor::new(
5944
5950
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()),
5946
5952
best_block, dummy_key, channel_id,
5947
5953
);
5948
5954
0 commit comments