Skip to content

Commit 4ae43b8

Browse files
fixup: move manual broadcast check into generate_claimable_outpoints_and_watch_outputs
1 parent 2646567 commit 4ae43b8

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,6 +3930,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
39303930
fn generate_claimable_outpoints_and_watch_outputs(
39313931
&mut self, generate_monitor_event_with_reason: Option<ClosureReason>,
39323932
) -> (Vec<PackageTemplate>, Vec<TransactionOutputs>) {
3933+
// In manual-broadcast mode, if we have not yet observed the funding transaction on-chain,
3934+
// return empty vectors.
3935+
if self.is_manual_broadcast && !self.funding_seen_onchain {
3936+
return (Vec::new(), Vec::new());
3937+
}
3938+
39333939
let funding = get_confirmed_funding_scope!(self);
39343940
let holder_commitment_tx = &funding.current_holder_commitment_tx;
39353941
let funding_outp = HolderFundingOutput::build(
@@ -4005,9 +4011,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
40054011
message: "ChannelMonitor-initiated commitment transaction broadcast".to_owned(),
40064012
};
40074013
let (claimable_outpoints, _) = self.generate_claimable_outpoints_and_watch_outputs(Some(reason));
4008-
// In manual-broadcast mode, if `require_funding_seen` is true and we have not yet observed
4009-
// the funding transaction on-chain, do not queue any transactions.
4010-
if require_funding_seen && self.is_manual_broadcast && !self.funding_seen_onchain {
4014+
// In manual-broadcast mode with `require_funding_seen` set, if we have not yet observed
4015+
// the funding transaction on-chain, `generate_claimable_outpoints_and_watch_outputs` will
4016+
// return empty vectors and we won't queue any transactions.
4017+
if require_funding_seen && claimable_outpoints.is_empty() {
40114018
log_info!(logger, "Not broadcasting holder commitment for manual-broadcast channel before funding appears on-chain");
40124019
return;
40134020
}
@@ -5600,10 +5607,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
56005607
if should_broadcast_commitment {
56015608
let (mut claimables, mut outputs) =
56025609
self.generate_claimable_outpoints_and_watch_outputs(None);
5603-
if !self.is_manual_broadcast || self.funding_seen_onchain {
5604-
claimable_outpoints.append(&mut claimables);
5605-
watch_outputs.append(&mut outputs);
5606-
}
5610+
claimable_outpoints.append(&mut claimables);
5611+
watch_outputs.append(&mut outputs);
56075612
}
56085613

56095614
self.block_confirmed(height, block_hash, txn_matched, watch_outputs, claimable_outpoints, &broadcaster, &fee_estimator, logger)
@@ -5644,10 +5649,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
56445649
let reason = ClosureReason::HTLCsTimedOut { payment_hash: Some(payment_hash) };
56455650
let (mut new_outpoints, mut new_outputs) =
56465651
self.generate_claimable_outpoints_and_watch_outputs(Some(reason));
5647-
if !self.is_manual_broadcast || self.funding_seen_onchain {
5648-
claimable_outpoints.append(&mut new_outpoints);
5649-
watch_outputs.append(&mut new_outputs);
5650-
}
5652+
claimable_outpoints.append(&mut new_outpoints);
5653+
watch_outputs.append(&mut new_outputs);
56515654
}
56525655
}
56535656

0 commit comments

Comments
 (0)