@@ -6833,7 +6833,7 @@ impl<SP: Deref> FundedChannel<SP> where
6833
6833
log_trace!(logger, "Regenerating latest commitment update in channel {} with{} {} update_adds, {} update_fulfills, {} update_fails, and {} update_fail_malformeds",
6834
6834
&self.context.channel_id(), if update_fee.is_some() { " update_fee," } else { "" },
6835
6835
update_add_htlcs.len(), update_fulfill_htlcs.len(), update_fail_htlcs.len(), update_fail_malformed_htlcs.len());
6836
- let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger).map(|(cu, _)| cu) {
6836
+ let commitment_signed = if let Ok(update) = self.send_commitment_no_state_update(logger) {
6837
6837
if self.context.signer_pending_commitment_update {
6838
6838
log_trace!(logger, "Commitment update generated: clearing signer_pending_commitment_update");
6839
6839
self.context.signer_pending_commitment_update = false;
@@ -8747,7 +8747,7 @@ impl<SP: Deref> FundedChannel<SP> where
8747
8747
8748
8748
/// Only fails in case of signer rejection. Used for channel_reestablish commitment_signed
8749
8749
/// generation when we shouldn't change HTLC/channel state.
8750
- fn send_commitment_no_state_update<L: Deref>(&self, logger: &L) -> Result<( msgs::CommitmentSigned, (Txid, Vec<(HTLCOutputInCommitment, Option<&HTLCSource>)>)) , ChannelError> where L::Target: Logger {
8750
+ fn send_commitment_no_state_update<L: Deref>(&self, logger: &L) -> Result<msgs::CommitmentSigned, ChannelError> where L::Target: Logger {
8751
8751
// Get the fee tests from `build_commitment_no_state_update`
8752
8752
#[cfg(any(test, fuzzing))]
8753
8753
self.build_commitment_no_state_update(logger);
@@ -8760,11 +8760,6 @@ impl<SP: Deref> FundedChannel<SP> where
8760
8760
let (signature, htlc_signatures);
8761
8761
8762
8762
{
8763
- let mut htlcs = Vec::with_capacity(commitment_stats.htlcs_included.len());
8764
- for &(ref htlc, _) in commitment_stats.htlcs_included.iter() {
8765
- htlcs.push(htlc);
8766
- }
8767
-
8768
8763
let res = ecdsa.sign_counterparty_commitment(
8769
8764
&self.funding.channel_transaction_parameters,
8770
8765
&commitment_stats.tx,
@@ -8781,7 +8776,8 @@ impl<SP: Deref> FundedChannel<SP> where
8781
8776
log_bytes!(signature.serialize_compact()[..]), &self.context.channel_id());
8782
8777
8783
8778
let counterparty_keys = commitment_stats.tx.trust().keys();
8784
- for (ref htlc_sig, ref htlc) in htlc_signatures.iter().zip(htlcs) {
8779
+ debug_assert_eq!(htlc_signatures.len(), commitment_stats.tx.htlcs().len());
8780
+ for (ref htlc_sig, ref htlc) in htlc_signatures.iter().zip(commitment_stats.tx.htlcs()) {
8785
8781
log_trace!(logger, "Signed remote HTLC tx {} with redeemscript {} with pubkey {} -> {} in channel {}",
8786
8782
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)),
8787
8783
encode::serialize_hex(&chan_utils::get_htlc_redeemscript(&htlc, &self.context.channel_type, &counterparty_keys)),
@@ -8790,14 +8786,14 @@ impl<SP: Deref> FundedChannel<SP> where
8790
8786
}
8791
8787
}
8792
8788
8793
- Ok(( msgs::CommitmentSigned {
8789
+ Ok(msgs::CommitmentSigned {
8794
8790
channel_id: self.context.channel_id,
8795
8791
signature,
8796
8792
htlc_signatures,
8797
8793
batch: None,
8798
8794
#[cfg(taproot)]
8799
8795
partial_signature_with_nonce: None,
8800
- }, (counterparty_commitment_txid, commitment_stats.htlcs_included)) )
8796
+ })
8801
8797
},
8802
8798
// TODO (taproot|arik)
8803
8799
#[cfg(taproot)]
@@ -11888,14 +11884,8 @@ mod tests {
11888
11884
( $counterparty_sig_hex: expr, $sig_hex: expr, $tx_hex: expr, $opt_anchors: expr, {
11889
11885
$( { $htlc_idx: expr, $counterparty_htlc_sig_hex: expr, $htlc_sig_hex: expr, $htlc_tx_hex: expr } ), *
11890
11886
} ) => { {
11891
- let (commitment_tx, htlcs): (_, Vec<HTLCOutputInCommitment>) = {
11892
- let mut commitment_stats = chan.context.build_commitment_transaction(&chan.funding, 0xffffffffffff - 42, &per_commitment_point, true, false, &logger);
11893
-
11894
- let htlcs = commitment_stats.htlcs_included.drain(..)
11895
- .filter_map(|(htlc, _)| if htlc.transaction_output_index.is_some() { Some(htlc) } else { None })
11896
- .collect();
11897
- (commitment_stats.tx, htlcs)
11898
- };
11887
+ let commitment_stats = chan.context.build_commitment_transaction(&chan.funding, 0xffffffffffff - 42, &per_commitment_point, true, false, &logger);
11888
+ let commitment_tx = commitment_stats.tx;
11899
11889
let trusted_tx = commitment_tx.trust();
11900
11890
let unsigned_tx = trusted_tx.built_transaction();
11901
11891
let redeemscript = chan.funding.get_funding_redeemscript();
@@ -11910,10 +11900,10 @@ mod tests {
11910
11900
counterparty_htlc_sigs.clear(); // Don't warn about excess mut for no-HTLC calls
11911
11901
$({
11912
11902
let remote_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_htlc_sig_hex).unwrap()[..]).unwrap();
11913
- per_htlc.push((htlcs[$htlc_idx].clone(), Some(remote_signature)));
11903
+ per_htlc.push((commitment_tx. htlcs() [$htlc_idx].clone(), Some(remote_signature)));
11914
11904
counterparty_htlc_sigs.push(remote_signature);
11915
11905
})*
11916
- assert_eq!(htlcs.len(), per_htlc.len());
11906
+ assert_eq!(commitment_tx. htlcs() .len(), per_htlc.len());
11917
11907
11918
11908
let holder_commitment_tx = HolderCommitmentTransaction::new(
11919
11909
commitment_tx.clone(),
@@ -11936,7 +11926,7 @@ mod tests {
11936
11926
log_trace!(logger, "verifying htlc {}", $htlc_idx);
11937
11927
let remote_signature = Signature::from_der(&<Vec<u8>>::from_hex($counterparty_htlc_sig_hex).unwrap()[..]).unwrap();
11938
11928
11939
- let ref htlc = htlcs[$htlc_idx];
11929
+ let ref htlc = commitment_tx. htlcs() [$htlc_idx];
11940
11930
let keys = commitment_tx.trust().keys();
11941
11931
let mut htlc_tx = chan_utils::build_htlc_transaction(&unsigned_tx.txid, chan.context.feerate_per_kw,
11942
11932
chan.funding.get_counterparty_selected_contest_delay().unwrap(),
0 commit comments