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