Skip to content

Commit f6c286f

Browse files
committed
Introduce LatestCounterpartyCommitment monitor update variant
This new variant is a backwards-incompatible successor to `LatestCounterpartyCommitmentTXInfo` that is capable of handling counterparty commitment updates while a splice is pending. Since all counterparty commitment candidates share the same set of non-dust and dust HTLCs (though each non-dust HTLC can have differing output indices), we can share the same set of HTLC source data across all candidates. Unfortunately, each `FundingScope` tracks its own set of `counterparty_claimable_outpoints`, which includes the HTLC source data (though only for the current and previous counterparty commitments), so we end up duplicating it (both in memory and on disk) temporarily.
1 parent c2e16d2 commit f6c286f

File tree

2 files changed

+155
-82
lines changed

2 files changed

+155
-82
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 107 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,9 @@ pub(crate) enum ChannelMonitorUpdateStep {
649649
to_broadcaster_value_sat: Option<u64>,
650650
to_countersignatory_value_sat: Option<u64>,
651651
},
652-
LatestCounterpartyCommitmentTX {
653-
// The dust and non-dust htlcs for that commitment
654-
htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>,
655-
// Contains only the non-dust htlcs
656-
commitment_tx: CommitmentTransaction,
652+
LatestCounterpartyCommitment {
653+
commitment_txs: Vec<CommitmentTransaction>,
654+
htlc_data: CommitmentHTLCData,
657655
},
658656
PaymentPreimage {
659657
payment_preimage: PaymentPreimage,
@@ -689,7 +687,7 @@ impl ChannelMonitorUpdateStep {
689687
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { .. } => "LatestHolderCommitmentTXInfo",
690688
ChannelMonitorUpdateStep::LatestHolderCommitment { .. } => "LatestHolderCommitment",
691689
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { .. } => "LatestCounterpartyCommitmentTXInfo",
692-
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTX { .. } => "LatestCounterpartyCommitmentTX",
690+
ChannelMonitorUpdateStep::LatestCounterpartyCommitment { .. } => "LatestCounterpartyCommitment",
693691
ChannelMonitorUpdateStep::PaymentPreimage { .. } => "PaymentPreimage",
694692
ChannelMonitorUpdateStep::CommitmentSecret { .. } => "CommitmentSecret",
695693
ChannelMonitorUpdateStep::ChannelForceClosed { .. } => "ChannelForceClosed",
@@ -729,9 +727,9 @@ impl_writeable_tlv_based_enum_upgradable!(ChannelMonitorUpdateStep,
729727
(5, ShutdownScript) => {
730728
(0, scriptpubkey, required),
731729
},
732-
(6, LatestCounterpartyCommitmentTX) => {
733-
(0, htlc_outputs, required_vec),
734-
(2, commitment_tx, required),
730+
(6, LatestCounterpartyCommitment) => {
731+
(1, commitment_txs, required_vec),
732+
(3, htlc_data, required),
735733
},
736734
(8, LatestHolderCommitment) => {
737735
(1, commitment_txs, required_vec),
@@ -1847,34 +1845,29 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
18471845
///
18481846
/// This is used to provide the counterparty commitment transaction directly to the monitor
18491847
/// before the initial persistence of a new channel.
1850-
pub(crate) fn provide_initial_counterparty_commitment_tx<L: Deref>(
1851-
&self, commitment_tx: CommitmentTransaction, logger: &L,
1852-
) where
1853-
L::Target: Logger,
1854-
{
1848+
pub(crate) fn provide_initial_counterparty_commitment_tx(
1849+
&self, commitment_tx: CommitmentTransaction,
1850+
) {
18551851
let mut inner = self.inner.lock().unwrap();
1856-
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
1857-
inner.provide_initial_counterparty_commitment_tx(commitment_tx, &logger);
1852+
inner.provide_initial_counterparty_commitment_tx(commitment_tx);
18581853
}
18591854

18601855
/// Informs this monitor of the latest counterparty (ie non-broadcastable) commitment transaction.
18611856
/// The monitor watches for it to be broadcasted and then uses the HTLC information (and
18621857
/// possibly future revocation/preimage information) to claim outputs where possible.
18631858
/// We cache also the mapping hash:commitment number to lighten pruning of old preimages by watchtowers.
18641859
#[cfg(test)]
1865-
#[rustfmt::skip]
1866-
fn provide_latest_counterparty_commitment_tx<L: Deref>(
1867-
&self,
1868-
txid: Txid,
1869-
htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>,
1870-
commitment_number: u64,
1871-
their_per_commitment_point: PublicKey,
1872-
logger: &L,
1873-
) where L::Target: Logger {
1860+
fn provide_latest_counterparty_commitment_tx(
1861+
&self, txid: Txid, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>,
1862+
commitment_number: u64, their_per_commitment_point: PublicKey,
1863+
) {
18741864
let mut inner = self.inner.lock().unwrap();
1875-
let logger = WithChannelMonitor::from_impl(logger, &*inner, None);
18761865
inner.provide_latest_counterparty_commitment_tx(
1877-
txid, htlc_outputs, commitment_number, their_per_commitment_point, &logger)
1866+
txid,
1867+
htlc_outputs,
1868+
commitment_number,
1869+
their_per_commitment_point,
1870+
)
18781871
}
18791872

18801873
#[cfg(test)]
@@ -3261,9 +3254,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32613254
}
32623255

32633256
#[rustfmt::skip]
3264-
fn provide_initial_counterparty_commitment_tx<L: Deref>(
3265-
&mut self, commitment_tx: CommitmentTransaction, logger: &WithChannelMonitor<L>,
3266-
) where L::Target: Logger {
3257+
fn provide_initial_counterparty_commitment_tx(
3258+
&mut self, commitment_tx: CommitmentTransaction,
3259+
) {
32673260
// We populate this field for downgrades
32683261
self.initial_counterparty_commitment_info = Some((commitment_tx.per_commitment_point(),
32693262
commitment_tx.feerate_per_kw(), commitment_tx.to_broadcaster_value_sat(), commitment_tx.to_countersignatory_value_sat()));
@@ -3274,17 +3267,16 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32743267
}
32753268

32763269
self.provide_latest_counterparty_commitment_tx(commitment_tx.trust().txid(), Vec::new(), commitment_tx.commitment_number(),
3277-
commitment_tx.per_commitment_point(), logger);
3270+
commitment_tx.per_commitment_point());
32783271
// Soon, we will only populate this field
32793272
self.initial_counterparty_commitment_tx = Some(commitment_tx);
32803273
}
32813274

32823275
#[rustfmt::skip]
3283-
fn provide_latest_counterparty_commitment_tx<L: Deref>(
3284-
&mut self, txid: Txid,
3285-
htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>,
3286-
commitment_number: u64, their_per_commitment_point: PublicKey, logger: &WithChannelMonitor<L>,
3287-
) where L::Target: Logger {
3276+
fn provide_latest_counterparty_commitment_tx(
3277+
&mut self, txid: Txid, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>,
3278+
commitment_number: u64, their_per_commitment_point: PublicKey,
3279+
) {
32883280
// TODO: Encrypt the htlc_outputs data with the single-hash of the commitment transaction
32893281
// so that a remote monitor doesn't learn anything unless there is a malicious close.
32903282
// (only maybe, sadly we cant do the same for local info, as we need to be aware of
@@ -3293,11 +3285,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32933285
self.counterparty_hash_commitment_number.insert(htlc.payment_hash, commitment_number);
32943286
}
32953287

3296-
log_trace!(logger, "Tracking new counterparty commitment transaction with txid {} at commitment number {} with {} HTLC outputs", txid, commitment_number, htlc_outputs.len());
32973288
self.funding.prev_counterparty_commitment_txid = self.funding.current_counterparty_commitment_txid.take();
32983289
self.funding.current_counterparty_commitment_txid = Some(txid);
3299-
self.funding.counterparty_claimable_outpoints.insert(txid, htlc_outputs.clone());
3290+
self.funding.counterparty_claimable_outpoints.insert(txid, htlc_outputs);
33003291
self.current_counterparty_commitment_number = commitment_number;
3292+
33013293
//TODO: Merge this into the other per-counterparty-transaction output storage stuff
33023294
match self.their_cur_per_commitment_points {
33033295
Some(old_points) => {
@@ -3319,6 +3311,57 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
33193311
}
33203312
}
33213313

3314+
fn update_counterparty_commitment_data(
3315+
&mut self, commitment_txs: &[CommitmentTransaction], htlc_data: &CommitmentHTLCData,
3316+
) -> Result<(), &'static str> {
3317+
self.verify_matching_commitment_transactions(commitment_txs.iter())?;
3318+
3319+
let htlcs_for_commitment = |commitment: &CommitmentTransaction| {
3320+
debug_assert!(htlc_data.nondust_htlc_sources.len() <= commitment.nondust_htlcs().len());
3321+
let mut nondust_htlcs = commitment.nondust_htlcs().iter();
3322+
let mut sources = htlc_data.nondust_htlc_sources.iter();
3323+
let nondust_htlcs = core::iter::from_fn(move || {
3324+
let htlc = nondust_htlcs.next()?.clone();
3325+
let source = (!htlc.offered).then(|| {
3326+
let source = sources
3327+
.next()
3328+
.expect("Every inbound non-dust HTLC should have a corresponding source")
3329+
.clone();
3330+
Box::new(source)
3331+
});
3332+
Some((htlc, source))
3333+
});
3334+
3335+
let dust_htlcs = htlc_data.dust_htlcs.iter().map(|(htlc, source)| {
3336+
(htlc.clone(), source.as_ref().map(|source| Box::new(source.clone())))
3337+
});
3338+
3339+
nondust_htlcs.chain(dust_htlcs).collect::<Vec<_>>()
3340+
};
3341+
3342+
let current_funding_commitment_tx = commitment_txs.first().unwrap();
3343+
self.provide_latest_counterparty_commitment_tx(
3344+
current_funding_commitment_tx.trust().txid(),
3345+
htlcs_for_commitment(current_funding_commitment_tx),
3346+
current_funding_commitment_tx.commitment_number(),
3347+
current_funding_commitment_tx.per_commitment_point(),
3348+
);
3349+
3350+
for (pending_funding, commitment_tx) in
3351+
self.pending_funding.iter_mut().zip(commitment_txs.iter().skip(1))
3352+
{
3353+
let commitment_txid = commitment_tx.trust().txid();
3354+
pending_funding.prev_counterparty_commitment_txid =
3355+
pending_funding.current_counterparty_commitment_txid.take();
3356+
pending_funding.current_counterparty_commitment_txid = Some(commitment_txid);
3357+
pending_funding
3358+
.counterparty_claimable_outpoints
3359+
.insert(commitment_txid, htlcs_for_commitment(commitment_tx));
3360+
}
3361+
3362+
Ok(())
3363+
}
3364+
33223365
/// Informs this monitor of the latest holder (ie broadcastable) commitment transaction. The
33233366
/// monitor watches for timeouts and may broadcast it if we approach such a timeout. Thus, it
33243367
/// is important that any clones of this channel monitor (including remote clones) by kept
@@ -3851,14 +3894,24 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
38513894
},
38523895
// Soon we will drop the `LatestCounterpartyCommitmentTXInfo` variant in favor of `LatestCounterpartyCommitment`.
38533896
// For now we just add the code to handle the new updates.
3854-
// Next step: in channel, switch channel monitor updates to use the `LatestCounterpartyCommitmentTX` variant.
3897+
// Next step: in channel, switch channel monitor updates to use the `LatestCounterpartyCommitment` variant.
38553898
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { commitment_txid, htlc_outputs, commitment_number, their_per_commitment_point, .. } => {
38563899
log_trace!(logger, "Updating ChannelMonitor with latest counterparty commitment transaction info");
3857-
self.provide_latest_counterparty_commitment_tx(*commitment_txid, htlc_outputs.clone(), *commitment_number, *their_per_commitment_point, logger)
3900+
if self.pending_funding.is_empty() {
3901+
self.provide_latest_counterparty_commitment_tx(*commitment_txid, htlc_outputs.clone(), *commitment_number, *their_per_commitment_point)
3902+
} else {
3903+
log_error!(logger, "Received unexpected non-splice counterparty commitment monitor update");
3904+
ret = Err(());
3905+
}
38583906
},
3859-
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTX { htlc_outputs, commitment_tx } => {
3860-
log_trace!(logger, "Updating ChannelMonitor with latest counterparty commitment transaction info");
3861-
self.provide_latest_counterparty_commitment_tx(commitment_tx.trust().txid(), htlc_outputs.clone(), commitment_tx.commitment_number(), commitment_tx.per_commitment_point(), logger)
3907+
ChannelMonitorUpdateStep::LatestCounterpartyCommitment {
3908+
commitment_txs, htlc_data,
3909+
} => {
3910+
log_trace!(logger, "Updating ChannelMonitor with {} latest counterparty commitments", commitment_txs.len());
3911+
if let Err(e) = self.update_counterparty_commitment_data(commitment_txs, htlc_data) {
3912+
log_error!(logger, "Failed updating latest counterparty commitment state: {}", e);
3913+
ret = Err(());
3914+
}
38623915
},
38633916
ChannelMonitorUpdateStep::PaymentPreimage { payment_preimage, payment_info } => {
38643917
log_trace!(logger, "Updating ChannelMonitor with payment preimage");
@@ -3934,7 +3987,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
39343987
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { .. }
39353988
|ChannelMonitorUpdateStep::LatestHolderCommitment { .. }
39363989
|ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { .. }
3937-
|ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTX { .. }
3990+
|ChannelMonitorUpdateStep::LatestCounterpartyCommitment { .. }
39383991
|ChannelMonitorUpdateStep::ShutdownScript { .. }
39393992
|ChannelMonitorUpdateStep::CommitmentSecret { .. }
39403993
|ChannelMonitorUpdateStep::RenegotiatedFunding { .. } =>
@@ -4094,7 +4147,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40944147
update.updates.iter().filter_map(|update| {
40954148
// Soon we will drop the first branch here in favor of the second.
40964149
// In preparation, we just add the second branch without deleting the first.
4097-
// Next step: in channel, switch channel monitor updates to use the `LatestCounterpartyCommitmentTX` variant.
4150+
// Next step: in channel, switch channel monitor updates to use the `LatestCounterpartyCommitment` variant.
40984151
match update {
40994152
&ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { commitment_txid,
41004153
ref htlc_outputs, commitment_number, their_per_commitment_point,
@@ -4112,19 +4165,17 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41124165

41134166
debug_assert_eq!(commitment_tx.trust().txid(), commitment_txid);
41144167

4115-
Some(commitment_tx)
4168+
Some(vec![commitment_tx])
41164169
},
4117-
&ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTX {
4118-
htlc_outputs: _, ref commitment_tx,
4119-
} => {
4120-
Some(commitment_tx.clone())
4170+
&ChannelMonitorUpdateStep::LatestCounterpartyCommitment { ref commitment_txs, .. } => {
4171+
Some(commitment_txs.clone())
41214172
},
41224173
&ChannelMonitorUpdateStep::RenegotiatedFunding { ref counterparty_commitment_tx, .. } => {
4123-
Some(counterparty_commitment_tx.clone())
4174+
Some(vec![counterparty_commitment_tx.clone()])
41244175
},
41254176
_ => None,
41264177
}
4127-
}).collect()
4178+
}).flatten().collect()
41284179
}
41294180

41304181
#[rustfmt::skip]
@@ -6248,9 +6299,9 @@ mod tests {
62486299
monitor.provide_latest_holder_commitment_tx(dummy_commitment_tx.clone(),
62496300
&nondust_htlcs.iter().map(|htlc| (htlc.clone(), Some(dummy_sig), Some(dummy_source.clone()))).collect::<Vec<_>>());
62506301
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"1").to_byte_array()),
6251-
preimages_slice_to_htlc_outputs!(preimages[5..15]), 281474976710655, dummy_key, &logger);
6302+
preimages_slice_to_htlc_outputs!(preimages[5..15]), 281474976710655, dummy_key);
62526303
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"2").to_byte_array()),
6253-
preimages_slice_to_htlc_outputs!(preimages[15..20]), 281474976710654, dummy_key, &logger);
6304+
preimages_slice_to_htlc_outputs!(preimages[15..20]), 281474976710654, dummy_key);
62546305
for &(ref preimage, ref hash) in preimages.iter() {
62556306
let bounded_fee_estimator = LowerBoundedFeeEstimator::new(&fee_estimator);
62566307
monitor.provide_payment_preimage_unsafe_legacy(
@@ -6267,7 +6318,7 @@ mod tests {
62676318
test_preimages_exist!(&preimages[15..20], monitor);
62686319

62696320
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"3").to_byte_array()),
6270-
preimages_slice_to_htlc_outputs!(preimages[17..20]), 281474976710653, dummy_key, &logger);
6321+
preimages_slice_to_htlc_outputs!(preimages[17..20]), 281474976710653, dummy_key);
62716322

62726323
// Now provide a further secret, pruning preimages 15-17
62736324
secret[0..32].clone_from_slice(&<Vec<u8>>::from_hex("c7518c8ae4660ed02894df8976fa1a3659c1a8b4b5bec0c4b872abeba4cb8964").unwrap());
@@ -6277,7 +6328,7 @@ mod tests {
62776328
test_preimages_exist!(&preimages[17..20], monitor);
62786329

62796330
monitor.provide_latest_counterparty_commitment_tx(Txid::from_byte_array(Sha256::hash(b"4").to_byte_array()),
6280-
preimages_slice_to_htlc_outputs!(preimages[18..20]), 281474976710652, dummy_key, &logger);
6331+
preimages_slice_to_htlc_outputs!(preimages[18..20]), 281474976710652, dummy_key);
62816332

62826333
// Now update holder commitment tx info, pruning only element 18 as we still care about the
62836334
// previous commitment tx's preimages too

lightning/src/ln/channel.rs

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,7 +2647,7 @@ where
26472647
holder_commitment_tx, best_block, context.counterparty_node_id, context.channel_id(),
26482648
);
26492649
channel_monitor.provide_initial_counterparty_commitment_tx(
2650-
counterparty_initial_commitment_tx.clone(), logger,
2650+
counterparty_initial_commitment_tx.clone(),
26512651
);
26522652

26532653
self.context_mut().cur_counterparty_commitment_transaction_number -= 1;
@@ -10614,32 +10614,54 @@ where
1061410614
}
1061510615
self.context.resend_order = RAACommitmentOrder::RevokeAndACKFirst;
1061610616

10617-
let mut updates = Vec::with_capacity(self.pending_funding.len() + 1);
10618-
for funding in core::iter::once(&self.funding).chain(self.pending_funding.iter()) {
10617+
let update = if self.pending_funding.is_empty() {
1061910618
let (htlcs_ref, counterparty_commitment_tx) =
10620-
self.build_commitment_no_state_update(funding, logger);
10621-
let htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)> =
10622-
htlcs_ref.into_iter().map(|(htlc, htlc_source)| (htlc, htlc_source.map(|source_ref| Box::new(source_ref.clone())))).collect();
10623-
10624-
if self.pending_funding.is_empty() {
10625-
// Soon, we will switch this to `LatestCounterpartyCommitmentTX`,
10626-
// and provide the full commit tx instead of the information needed to rebuild it.
10627-
updates.push(ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo {
10628-
commitment_txid: counterparty_commitment_tx.trust().txid(),
10629-
htlc_outputs,
10630-
commitment_number: self.context.cur_counterparty_commitment_transaction_number,
10631-
their_per_commitment_point: self.context.counterparty_cur_commitment_point.unwrap(),
10632-
feerate_per_kw: Some(counterparty_commitment_tx.feerate_per_kw()),
10633-
to_broadcaster_value_sat: Some(counterparty_commitment_tx.to_broadcaster_value_sat()),
10634-
to_countersignatory_value_sat: Some(counterparty_commitment_tx.to_countersignatory_value_sat()),
10635-
});
10636-
} else {
10637-
updates.push(ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTX {
10638-
htlc_outputs,
10639-
commitment_tx: counterparty_commitment_tx,
10640-
});
10619+
self.build_commitment_no_state_update(&self.funding, logger);
10620+
let htlc_outputs = htlcs_ref.into_iter()
10621+
.map(|(htlc, htlc_source)| (
10622+
htlc, htlc_source.map(|source_ref| Box::new(source_ref.clone()))
10623+
))
10624+
.collect();
10625+
10626+
// Soon, we will switch this to `LatestCounterpartyCommitment`,
10627+
// and provide the full commit tx instead of the information needed to rebuild it.
10628+
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo {
10629+
commitment_txid: counterparty_commitment_tx.trust().txid(),
10630+
htlc_outputs,
10631+
commitment_number: self.context.cur_counterparty_commitment_transaction_number,
10632+
their_per_commitment_point: self.context.counterparty_cur_commitment_point.unwrap(),
10633+
feerate_per_kw: Some(counterparty_commitment_tx.feerate_per_kw()),
10634+
to_broadcaster_value_sat: Some(counterparty_commitment_tx.to_broadcaster_value_sat()),
10635+
to_countersignatory_value_sat: Some(counterparty_commitment_tx.to_countersignatory_value_sat()),
1064110636
}
10642-
}
10637+
} else {
10638+
let mut htlc_data = None;
10639+
let commitment_txs = core::iter::once(&self.funding)
10640+
.chain(self.pending_funding.iter())
10641+
.map(|funding| {
10642+
let (htlcs_ref, counterparty_commitment_tx) =
10643+
self.build_commitment_no_state_update(funding, logger);
10644+
if htlc_data.is_none() {
10645+
let nondust_htlc_sources = htlcs_ref.iter()
10646+
// We check !offered as this is the HTLC from the counterparty's point of view.
10647+
.filter(|(htlc, _)| !htlc.offered && htlc.transaction_output_index.is_some())
10648+
.map(|(_, source)| source.expect("Outbound HTLC must have a source").clone())
10649+
.collect();
10650+
let dust_htlcs = htlcs_ref.into_iter()
10651+
.filter(|(htlc, _)| htlc.transaction_output_index.is_none())
10652+
.map(|(htlc, source)| (htlc, source.cloned()))
10653+
.collect();
10654+
htlc_data = Some(CommitmentHTLCData {
10655+
nondust_htlc_sources,
10656+
dust_htlcs,
10657+
});
10658+
}
10659+
counterparty_commitment_tx
10660+
})
10661+
.collect();
10662+
let htlc_data = htlc_data.unwrap();
10663+
ChannelMonitorUpdateStep::LatestCounterpartyCommitment { commitment_txs, htlc_data }
10664+
};
1064310665

1064410666
if self.context.announcement_sigs_state == AnnouncementSigsState::MessageSent {
1064510667
self.context.announcement_sigs_state = AnnouncementSigsState::Committed;
@@ -10648,7 +10670,7 @@ where
1064810670
self.context.latest_monitor_update_id += 1;
1064910671
let monitor_update = ChannelMonitorUpdate {
1065010672
update_id: self.context.latest_monitor_update_id,
10651-
updates,
10673+
updates: vec![update],
1065210674
channel_id: Some(self.context.channel_id()),
1065310675
};
1065410676
self.context.channel_state.set_awaiting_remote_revoke();

0 commit comments

Comments
 (0)