Skip to content

Commit 64bb44c

Browse files
committed
Always broadcast closing txn in monitor manually broadcast
In 6c5ef04 we prevented broadcast of the commitment transactions if the funding transaction has not yet appeared on-chain for manual-broadcast channels to avoid spurious bumps or unbroadcastable transactions. It also updated the documentation on `ChanelMonitor::broadcast_latest_holder_commitment_txn` to explicitly state that it will override the manual-broadcast state and broadcast the latest commitment anyway. However, 4131680 accidentally reverted this behavior by updating `generate_claimable_outpoints_and_watch_outputs`, which is caled by `broadcast_latest_holder_commitment_txn` to also refuse to broadcast if funding has not been seen on chain. Here we fix this, passing through the `require_funding_seen` bool to allow `broadcast_latest_holder_commitment_txn` to broadcast immediately.
1 parent 17f7858 commit 64bb44c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
39333933
#[rustfmt::skip]
39343934
fn generate_claimable_outpoints_and_watch_outputs(
39353935
&mut self, generate_monitor_event_with_reason: Option<ClosureReason>,
3936+
require_funding_seen: bool,
39363937
) -> (Vec<PackageTemplate>, Vec<TransactionOutputs>) {
39373938
let funding = get_confirmed_funding_scope!(self);
39383939
let holder_commitment_tx = &funding.current_holder_commitment_tx;
@@ -3987,7 +3988,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
39873988
}
39883989
// In manual-broadcast mode, if we have not yet observed the funding transaction on-chain,
39893990
// return empty vectors.
3990-
if self.is_manual_broadcast && !self.funding_seen_onchain {
3991+
if require_funding_seen && self.is_manual_broadcast && !self.funding_seen_onchain {
39913992
return (Vec::new(), Vec::new());
39923993
} else {
39933994
(claimable_outpoints, watch_outputs)
@@ -4004,7 +4005,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40044005
///
40054006
/// [`ChannelMonitor::broadcast_latest_holder_commitment_txn`]: crate::chain::channelmonitor::ChannelMonitor::broadcast_latest_holder_commitment_txn
40064007
pub(crate) fn queue_latest_holder_commitment_txn_for_broadcast<B: Deref, F: Deref, L: Deref>(
4007-
&mut self, broadcaster: &B, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &WithChannelMonitor<L>, require_funding_seen: bool,
4008+
&mut self, broadcaster: &B, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &WithChannelMonitor<L>,
4009+
require_funding_seen: bool,
40084010
)
40094011
where
40104012
B::Target: BroadcasterInterface,
@@ -4015,7 +4017,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40154017
broadcasted_latest_txn: Some(true),
40164018
message: "ChannelMonitor-initiated commitment transaction broadcast".to_owned(),
40174019
};
4018-
let (claimable_outpoints, _) = self.generate_claimable_outpoints_and_watch_outputs(Some(reason));
4020+
let (claimable_outpoints, _) =
4021+
self.generate_claimable_outpoints_and_watch_outputs(Some(reason), require_funding_seen);
40194022
// In manual-broadcast mode, if `require_funding_seen` is true and we have not yet observed
40204023
// the funding transaction on-chain, do not queue any transactions.
40214024
if require_funding_seen && self.is_manual_broadcast && !self.funding_seen_onchain {
@@ -5618,7 +5621,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
56185621

56195622
if should_broadcast_commitment {
56205623
let (mut claimables, mut outputs) =
5621-
self.generate_claimable_outpoints_and_watch_outputs(None);
5624+
self.generate_claimable_outpoints_and_watch_outputs(None, false);
56225625
claimable_outpoints.append(&mut claimables);
56235626
watch_outputs.append(&mut outputs);
56245627
}
@@ -5660,7 +5663,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
56605663
if let Some(payment_hash) = should_broadcast {
56615664
let reason = ClosureReason::HTLCsTimedOut { payment_hash: Some(payment_hash) };
56625665
let (mut new_outpoints, mut new_outputs) =
5663-
self.generate_claimable_outpoints_and_watch_outputs(Some(reason));
5666+
self.generate_claimable_outpoints_and_watch_outputs(Some(reason), false);
56645667
claimable_outpoints.append(&mut new_outpoints);
56655668
watch_outputs.append(&mut new_outputs);
56665669
}

0 commit comments

Comments
 (0)