@@ -8860,20 +8860,27 @@ impl<SP: Deref> FundedChannel<SP> where
88608860 for funding in core::iter::once(&self.funding).chain(self.pending_funding.iter()) {
88618861 let (mut htlcs_ref, counterparty_commitment_tx) =
88628862 self.build_commitment_no_state_update(funding, logger);
8863- let counterparty_commitment_txid = counterparty_commitment_tx.trust().txid();
8864- let htlcs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)> =
8863+ let htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)> =
88658864 htlcs_ref.drain(..).map(|(htlc, htlc_source)| (htlc, htlc_source.map(|source_ref| Box::new(source_ref.clone())))).collect();
8866- // Soon, we will switch this to `LatestCounterpartyCommitmentTX`,
8867- // and provide the full commit tx instead of the information needed to rebuild it.
8868- updates.push(ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo {
8869- commitment_txid: counterparty_commitment_txid,
8870- htlc_outputs: htlcs.clone(),
8871- commitment_number: self.context.cur_counterparty_commitment_transaction_number,
8872- their_per_commitment_point: self.context.counterparty_cur_commitment_point.unwrap(),
8873- feerate_per_kw: Some(counterparty_commitment_tx.feerate_per_kw()),
8874- to_broadcaster_value_sat: Some(counterparty_commitment_tx.to_broadcaster_value_sat()),
8875- to_countersignatory_value_sat: Some(counterparty_commitment_tx.to_countersignatory_value_sat()),
8876- });
8865+
8866+ if self.pending_funding.is_empty() {
8867+ // Soon, we will switch this to `LatestCounterpartyCommitmentTX`,
8868+ // and provide the full commit tx instead of the information needed to rebuild it.
8869+ updates.push(ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo {
8870+ commitment_txid: counterparty_commitment_tx.trust().txid(),
8871+ htlc_outputs,
8872+ commitment_number: self.context.cur_counterparty_commitment_transaction_number,
8873+ their_per_commitment_point: self.context.counterparty_cur_commitment_point.unwrap(),
8874+ feerate_per_kw: Some(counterparty_commitment_tx.feerate_per_kw()),
8875+ to_broadcaster_value_sat: Some(counterparty_commitment_tx.to_broadcaster_value_sat()),
8876+ to_countersignatory_value_sat: Some(counterparty_commitment_tx.to_countersignatory_value_sat()),
8877+ });
8878+ } else {
8879+ updates.push(ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTX {
8880+ htlc_outputs,
8881+ commitment_tx: counterparty_commitment_tx,
8882+ });
8883+ }
88778884 }
88788885
88798886 if self.context.announcement_sigs_state == AnnouncementSigsState::MessageSent {
0 commit comments