Skip to content

Commit 5d2508d

Browse files
committed
f - use LatestCounterpartyCommitmentTX
1 parent f240cc2 commit 5d2508d

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

Diff for: lightning/src/ln/channel.rs

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

88808887
if self.context.announcement_sigs_state == AnnouncementSigsState::MessageSent {

0 commit comments

Comments
 (0)