@@ -6731,7 +6731,7 @@ impl<SP: Deref> FundedChannel<SP> where
6731
6731
log_trace!(logger, "Regenerating latest commitment update in channel {} with{} {} update_adds, {} update_fulfills, {} update_fails, and {} update_fail_malformeds",
6732
6732
&self.context.channel_id(), if update_fee.is_some() { " update_fee," } else { "" },
6733
6733
update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len(), update_fail_malformed_htlcs.len());
6734
- let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger).map(|(cu, _)| cu) {
6734
+ let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger) {
6735
6735
if self.context.signer_pending_commitment_update {
6736
6736
log_trace!(logger, "Commitment update generated: clearing signer_pending_commitment_update");
6737
6737
self.context.signer_pending_commitment_update = false;
@@ -8508,7 +8508,7 @@ impl<SP: Deref> FundedChannel<SP> where
8508
8508
8509
8509
/// Only fails in case of signer rejection. Used for channel_reestablish commitment_signed
8510
8510
/// generation when we shouldn't change HTLC/channel state.
8511
- fn send_commitment_no_state_update<L: Deref>(&self, logger: &L) -> Result<( msgs::CommitmentSigned, (Txid, Vec<(HTLCOutputInCommitment, Option<&HTLCSource>)>)) , ChannelError> where L::Target: Logger {
8511
+ fn send_commitment_no_state_update<L: Deref>(&self, logger: &L) -> Result<msgs::CommitmentSigned, ChannelError> where L::Target: Logger {
8512
8512
// Get the fee tests from `build_commitment_no_state_update`
8513
8513
#[cfg(any(test, fuzzing))]
8514
8514
self.build_commitment_no_state_update(logger);
@@ -8521,11 +8521,6 @@ impl<SP: Deref> FundedChannel<SP> where
8521
8521
let (signature, htlc_signatures);
8522
8522
8523
8523
{
8524
- let mut htlcs = Vec::with_capacity(commitment_stats.htlcs_included.len());
8525
- for &(ref htlc, _) in commitment_stats.htlcs_included.iter() {
8526
- htlcs.push(htlc);
8527
- }
8528
-
8529
8524
let res = ecdsa.sign_counterparty_commitment(
8530
8525
&self.funding.channel_transaction_parameters,
8531
8526
&commitment_stats.tx,
@@ -8542,7 +8537,7 @@ impl<SP: Deref> FundedChannel<SP> where
8542
8537
log_bytes!(signature.serialize_compact()[..]), &self.context.channel_id());
8543
8538
8544
8539
let counterparty_keys = commitment_stats.tx.trust().keys();
8545
- for (ref htlc_sig, ref htlc) in htlc_signatures.iter().zip(htlcs) {
8540
+ for (ref htlc_sig, ref htlc) in htlc_signatures.iter().zip(commitment_stats.tx. htlcs() ) {
8546
8541
log_trace!(logger, "Signed remote HTLC tx {} with redeemscript {} with pubkey {} -> {} in channel {}",
8547
8542
encode::serialize_hex(&chan_utils::build_htlc_transaction(&counterparty_commitment_txid, commitment_stats.feerate_per_kw, self.funding.get_holder_selected_contest_delay(), htlc, &self.context.channel_type, &counterparty_keys.broadcaster_delayed_payment_key, &counterparty_keys.revocation_key)),
8548
8543
encode::serialize_hex(&chan_utils::get_htlc_redeemscript(&htlc, &self.context.channel_type, &counterparty_keys)),
@@ -8551,14 +8546,14 @@ impl<SP: Deref> FundedChannel<SP> where
8551
8546
}
8552
8547
}
8553
8548
8554
- Ok(( msgs::CommitmentSigned {
8549
+ Ok(msgs::CommitmentSigned {
8555
8550
channel_id: self.context.channel_id,
8556
8551
signature,
8557
8552
htlc_signatures,
8558
8553
batch: None,
8559
8554
#[cfg(taproot)]
8560
8555
partial_signature_with_nonce: None,
8561
- }, (counterparty_commitment_txid, commitment_stats.htlcs_included)) )
8556
+ })
8562
8557
},
8563
8558
// TODO (taproot|arik)
8564
8559
#[cfg(taproot)]
@@ -11609,14 +11604,8 @@ mod tests {
11609
11604
( $counterparty_sig_hex: expr, $sig_hex: expr, $tx_hex: expr, $opt_anchors: expr, {
11610
11605
$( { $htlc_idx: expr, $counterparty_htlc_sig_hex: expr, $htlc_sig_hex: expr, $htlc_tx_hex: expr } ), *
11611
11606
} ) => { {
11612
- let (commitment_tx, htlcs): (_, Vec<HTLCOutputInCommitment>) = {
11613
- let mut commitment_stats = chan.context.build_commitment_transaction(&chan.funding, 0xffffffffffff - 42, &per_commitment_point, true, false, &logger);
11614
-
11615
- let htlcs = commitment_stats.htlcs_included.drain(..)
11616
- .filter_map(|(htlc, _)| if htlc.transaction_output_index.is_some() { Some(htlc) } else { None })
11617
- .collect();
11618
- (commitment_stats.tx, htlcs)
11619
- };
11607
+ let commitment_stats = chan.context.build_commitment_transaction(&chan.funding, 0xffffffffffff - 42, &per_commitment_point, true, false, &logger);
11608
+ let commitment_tx = commitment_stats.tx;
11620
11609
let trusted_tx = commitment_tx.trust();
11621
11610
let unsigned_tx = trusted_tx.built_transaction();
11622
11611
let redeemscript = chan.funding.get_funding_redeemscript();
@@ -11631,10 +11620,10 @@ mod tests {
11631
11620
counterparty_htlc_sigs.clear(); // Don't warn about excess mut for no-HTLC calls
11632
11621
$({
11633
11622
let remote_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_htlc_sig_hex).unwrap()[..]).unwrap();
11634
- per_htlc.push((htlcs[$htlc_idx].clone(), Some(remote_signature)));
11623
+ per_htlc.push((commitment_tx. htlcs() [$htlc_idx].clone(), Some(remote_signature)));
11635
11624
counterparty_htlc_sigs.push(remote_signature);
11636
11625
})*
11637
- assert_eq!(htlcs.len(), per_htlc.len());
11626
+ assert_eq!(commitment_tx. htlcs() .len(), per_htlc.len());
11638
11627
11639
11628
let holder_commitment_tx = HolderCommitmentTransaction::new(
11640
11629
commitment_tx.clone(),
@@ -11657,7 +11646,7 @@ mod tests {
11657
11646
log_trace!(logger, "verifying htlc {}", $htlc_idx);
11658
11647
let remote_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_htlc_sig_hex).unwrap()[..]).unwrap();
11659
11648
11660
- let ref htlc = htlcs[$htlc_idx];
11649
+ let ref htlc = commitment_tx. htlcs() [$htlc_idx];
11661
11650
let keys = commitment_tx.trust().keys();
11662
11651
let mut htlc_tx = chan_utils::build_htlc_transaction(&unsigned_tx.txid, chan.context.feerate_per_kw,
11663
11652
chan.funding.get_counterparty_selected_contest_delay().unwrap(),
0 commit comments