@@ -2256,11 +2256,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2256
2256
/// may be to contact the other node operator out-of-band to coordinate other options available
2257
2257
/// to you.
2258
2258
///
2259
- /// Note: For channels where the funding transaction is being manually managed (see
2260
- /// [`crate::ln::channelmanager::ChannelManager::funding_transaction_generated_manual_broadcast`]), this call will be
2261
- /// ignored until the funding transaction has been observed on-chain.
2262
- /// This prevents unconfirmable commitment transactions from being broadcast before funding is
2263
- /// visible.
2259
+ /// Note: For channels using manual funding broadcast (see
2260
+ /// [`crate::ln::channelmanager::ChannelManager::funding_transaction_generated_manual_broadcast`]),
2261
+ /// automatic broadcasts are suppressed until the funding transaction has been observed on-chain.
2262
+ /// Calling this method overrides that suppression and queues the latest holder commitment
2263
+ /// transaction for broadcast even if the funding has not yet been seen on-chain. This is unsafe
2264
+ /// and may result in unconfirmable transactions.
2264
2265
#[ rustfmt:: skip]
2265
2266
pub fn broadcast_latest_holder_commitment_txn < B : Deref , F : Deref , L : Deref > (
2266
2267
& self , broadcaster : & B , fee_estimator : & F , logger : & L
@@ -2273,7 +2274,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2273
2274
let mut inner = self . inner . lock ( ) . unwrap ( ) ;
2274
2275
let fee_estimator = LowerBoundedFeeEstimator :: new ( & * * fee_estimator) ;
2275
2276
let logger = WithChannelMonitor :: from_impl ( logger, & * inner, None ) ;
2276
- inner. queue_latest_holder_commitment_txn_for_broadcast ( broadcaster, & fee_estimator, & logger) ;
2277
+ inner. queue_latest_holder_commitment_txn_for_broadcast ( broadcaster, & fee_estimator, & logger, false ) ;
2277
2278
}
2278
2279
2279
2280
/// Unsafe test-only version of `broadcast_latest_holder_commitment_txn` used by our test framework
@@ -3918,15 +3919,25 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3918
3919
}
3919
3920
3920
3921
#[ rustfmt:: skip]
3922
+ /// Note: For channels where the funding transaction is being manually managed (see
3923
+ /// [`crate::ln::channelmanager::ChannelManager::funding_transaction_generated_manual_broadcast`]),
3924
+ /// this method returns without queuing any transactions until the funding transaction has been
3925
+ /// observed on-chain, unless `require_funding_seen` is `false`. This prevents attempting to
3926
+ /// broadcast unconfirmable holder commitment transactions before the funding is visible.
3927
+ /// See also
3928
+ /// [`crate::chain::channelmonitor::ChannelMonitor::broadcast_latest_holder_commitment_txn`].
3921
3929
pub ( crate ) fn queue_latest_holder_commitment_txn_for_broadcast < B : Deref , F : Deref , L : Deref > (
3922
- & mut self , broadcaster : & B , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & WithChannelMonitor < L >
3930
+ & mut self , broadcaster : & B , fee_estimator : & LowerBoundedFeeEstimator < F > , logger : & WithChannelMonitor < L > ,
3931
+ require_funding_seen : bool ,
3923
3932
)
3924
3933
where
3925
3934
B :: Target : BroadcasterInterface ,
3926
3935
F :: Target : FeeEstimator ,
3927
3936
L :: Target : Logger ,
3928
3937
{
3929
- if self . is_manual_broadcast && !self . funding_seen_onchain {
3938
+ // In manual-broadcast mode, if `require_funding_seen` is true and we have not yet observed
3939
+ // the funding transaction on-chain, do not queue any transactions.
3940
+ if require_funding_seen && self . is_manual_broadcast && !self . funding_seen_onchain {
3930
3941
log_info ! ( logger, "Not broadcasting holder commitment for manual-broadcast channel before funding appears on-chain" ) ;
3931
3942
return ;
3932
3943
}
@@ -4248,7 +4259,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4248
4259
log_trace ! ( logger, "Avoiding commitment broadcast, already detected confirmed spend onchain" ) ;
4249
4260
continue ;
4250
4261
}
4251
- self . queue_latest_holder_commitment_txn_for_broadcast ( broadcaster, & bounded_fee_estimator, logger) ;
4262
+ self . queue_latest_holder_commitment_txn_for_broadcast ( broadcaster, & bounded_fee_estimator, logger, true ) ;
4252
4263
} else if !self . holder_tx_signed {
4253
4264
log_error ! ( logger, "WARNING: You have a potentially-unsafe holder commitment transaction available to broadcast" ) ;
4254
4265
log_error ! ( logger, " in channel monitor for channel {}!" , & self . channel_id( ) ) ;
@@ -5414,11 +5425,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5414
5425
5415
5426
if should_broadcast_commitment {
5416
5427
// Avoid broadcasting in manual-broadcast mode until funding is seen on-chain.
5417
- if !self . is_manual_broadcast || self . funding_seen_onchain {
5418
- let ( mut claimables, mut outputs) =
5419
- self . generate_claimable_outpoints_and_watch_outputs ( None ) ;
5420
- claimable_outpoints. append ( & mut claimables) ;
5421
- watch_outputs. append ( & mut outputs) ;
5428
+ if !self . is_manual_broadcast || self . funding_seen_onchain {
5429
+ let ( mut claimables, mut outputs) =
5430
+ self . generate_claimable_outpoints_and_watch_outputs ( None ) ;
5431
+ claimable_outpoints. append ( & mut claimables) ;
5432
+ watch_outputs. append ( & mut outputs) ;
5422
5433
}
5423
5434
}
5424
5435
@@ -5456,9 +5467,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5456
5467
let should_broadcast = self . should_broadcast_holder_commitment_txn ( logger) ;
5457
5468
if let Some ( payment_hash) = should_broadcast {
5458
5469
let reason = ClosureReason :: HTLCsTimedOut { payment_hash : Some ( payment_hash) } ;
5459
- if self . is_manual_broadcast && !self . funding_seen_onchain {
5460
- let _ = self . generate_claimable_outpoints_and_watch_outputs ( Some ( reason) ) ;
5461
- } else {
5470
+ if !self . is_manual_broadcast || self . funding_seen_onchain {
5462
5471
let ( mut new_outpoints, mut new_outputs) =
5463
5472
self . generate_claimable_outpoints_and_watch_outputs ( Some ( reason) ) ;
5464
5473
claimable_outpoints. append ( & mut new_outpoints) ;
@@ -5690,7 +5699,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5690
5699
// Only attempt to broadcast the new commitment after the `block_disconnected` call above so that
5691
5700
// it doesn't get removed from the set of pending claims.
5692
5701
if should_broadcast_commitment {
5693
- self . queue_latest_holder_commitment_txn_for_broadcast ( & broadcaster, & bounded_fee_estimator, logger) ;
5702
+ self . queue_latest_holder_commitment_txn_for_broadcast ( & broadcaster, & bounded_fee_estimator, logger, true ) ;
5694
5703
}
5695
5704
5696
5705
self . best_block = fork_point;
@@ -5725,12 +5734,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5725
5734
}
5726
5735
5727
5736
debug_assert ! ( !self . onchain_events_awaiting_threshold_conf. iter( ) . any( |ref entry| entry. txid == * txid) ) ;
5728
- if * txid == self . funding . funding_txid ( ) ||
5729
- self . pending_funding . iter ( ) . any ( |f| f. funding_txid ( ) == * txid)
5730
- {
5731
- log_trace ! ( logger, "transaction_unconfirmed removed observed funding. resetting funding_seen_onchain" ) ;
5732
- self . funding_seen_onchain = false ;
5733
- }
5734
5737
5735
5738
// TODO: Replace with `take_if` once our MSRV is >= 1.80.
5736
5739
let mut should_broadcast_commitment = false ;
@@ -5757,7 +5760,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5757
5760
// Only attempt to broadcast the new commitment after the `transaction_unconfirmed` call above so
5758
5761
// that it doesn't get removed from the set of pending claims.
5759
5762
if should_broadcast_commitment {
5760
- self . queue_latest_holder_commitment_txn_for_broadcast ( & broadcaster, fee_estimator, logger) ;
5763
+ self . queue_latest_holder_commitment_txn_for_broadcast ( & broadcaster, fee_estimator, logger, true ) ;
5761
5764
}
5762
5765
}
5763
5766
@@ -6556,7 +6559,8 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6556
6559
} ,
6557
6560
pending_funding : pending_funding. unwrap_or ( vec ! [ ] ) ,
6558
6561
is_manual_broadcast : is_manual_broadcast. unwrap_or ( false ) ,
6559
- funding_seen_onchain : funding_seen_onchain. unwrap_or ( false ) ,
6562
+ // Assume "seen" when absent to prevent gating holder broadcasts after upgrade.
6563
+ funding_seen_onchain : funding_seen_onchain. unwrap_or ( true ) ,
6560
6564
6561
6565
latest_update_id,
6562
6566
commitment_transaction_number_obscure_factor,
0 commit comments