@@ -1169,7 +1169,11 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
1169
1169
funding : FundingScope ,
1170
1170
pending_funding : Vec < FundingScope > ,
1171
1171
1172
+ /// True if this channel was configured for manual funding broadcasts. Monitors written by
1173
+ /// versions prior to introducing the flag will load with `false` until a new update persists it.
1172
1174
is_manual_broadcast : bool ,
1175
+ /// True once we've observed either funding transaction on-chain. Older monitors assume this is
1176
+ /// `true` when absent during upgrade so holder broadcasts aren't gated unexpectedly.
1173
1177
funding_seen_onchain : bool ,
1174
1178
1175
1179
latest_update_id : u64 ,
@@ -1701,8 +1705,8 @@ pub(crate) fn write_chanmon_internal<Signer: EcdsaChannelSigner, W: Writer>(
1701
1705
( 31 , channel_monitor. funding. channel_parameters, required) ,
1702
1706
( 32 , channel_monitor. pending_funding, optional_vec) ,
1703
1707
( 34 , channel_monitor. alternative_funding_confirmed, option) ,
1704
- ( 36 , channel_monitor. is_manual_broadcast, required) ,
1705
- ( 38 , channel_monitor. funding_seen_onchain, required) ,
1708
+ ( 35 , channel_monitor. is_manual_broadcast, required) ,
1709
+ ( 37 , channel_monitor. funding_seen_onchain, required) ,
1706
1710
} ) ;
1707
1711
1708
1712
Ok ( ( ) )
@@ -2298,8 +2302,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2298
2302
/// [`crate::ln::channelmanager::ChannelManager::funding_transaction_generated_manual_broadcast`]),
2299
2303
/// automatic broadcasts are suppressed until the funding transaction has been observed on-chain.
2300
2304
/// Calling this method overrides that suppression and queues the latest holder commitment
2301
- /// transaction for broadcast even if the funding has not yet been seen on-chain. This is unsafe
2302
- /// and may result in unconfirmable transactions.
2305
+ /// transaction for broadcast even if the funding has not yet been seen on-chain. This may result
2306
+ /// in unconfirmable transactions being broadcast or [`Event::BumpTransaction`] notifications for
2307
+ /// transactions that cannot be confirmed until the funding transaction is visible.
2308
+ ///
2309
+ /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
2303
2310
#[ rustfmt:: skip]
2304
2311
pub fn broadcast_latest_holder_commitment_txn < B : Deref , F : Deref , L : Deref > (
2305
2312
& self , broadcaster : & B , fee_estimator : & F , logger : & L
@@ -5246,14 +5253,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5246
5253
F :: Target : FeeEstimator ,
5247
5254
L :: Target : Logger ,
5248
5255
{
5249
- for & ( _, tx) in txdata. iter ( ) {
5250
- let txid = tx. compute_txid ( ) ;
5251
- if txid == self . funding . funding_txid ( ) ||
5252
- self . pending_funding . iter ( ) . any ( |f| f. funding_txid ( ) == txid)
5253
- {
5254
- self . funding_seen_onchain = true ;
5255
- }
5256
- }
5257
5256
let txn_matched = self . filter_block ( txdata) ;
5258
5257
for tx in & txn_matched {
5259
5258
let mut output_val = Amount :: ZERO ;
@@ -5833,10 +5832,17 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5833
5832
5834
5833
/// Filters a block's `txdata` for transactions spending watched outputs or for any child
5835
5834
/// transactions thereof.
5835
+ /// While iterating, this also tracks whether we observed the funding transaction.
5836
5836
#[ rustfmt:: skip]
5837
- fn filter_block < ' a > ( & self , txdata : & TransactionData < ' a > ) -> Vec < & ' a Transaction > {
5837
+ fn filter_block < ' a > ( & mut self , txdata : & TransactionData < ' a > ) -> Vec < & ' a Transaction > {
5838
5838
let mut matched_txn = new_hash_set ( ) ;
5839
5839
txdata. iter ( ) . filter ( |& & ( _, tx) | {
5840
+ let txid = tx. compute_txid ( ) ;
5841
+ if !self . funding_seen_onchain && ( txid == self . funding . funding_txid ( ) ||
5842
+ self . pending_funding . iter ( ) . any ( |f| f. funding_txid ( ) == txid) )
5843
+ {
5844
+ self . funding_seen_onchain = true ;
5845
+ }
5840
5846
let mut matches = self . spends_watched_output ( tx) ;
5841
5847
for input in tx. input . iter ( ) {
5842
5848
if matches { break ; }
@@ -5845,7 +5851,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5845
5851
}
5846
5852
}
5847
5853
if matches {
5848
- matched_txn. insert ( tx . compute_txid ( ) ) ;
5854
+ matched_txn. insert ( txid ) ;
5849
5855
}
5850
5856
matches
5851
5857
} ) . map ( |( _, tx) | * tx) . collect ( )
@@ -6506,8 +6512,8 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6506
6512
( 31 , channel_parameters, ( option: ReadableArgs , None ) ) ,
6507
6513
( 32 , pending_funding, optional_vec) ,
6508
6514
( 34 , alternative_funding_confirmed, option) ,
6509
- ( 36 , is_manual_broadcast, option) ,
6510
- ( 38 , funding_seen_onchain, option) ,
6515
+ ( 35 , is_manual_broadcast, option) ,
6516
+ ( 37 , funding_seen_onchain, option) ,
6511
6517
} ) ;
6512
6518
// Note that `payment_preimages_with_info` was added (and is always written) in LDK 0.1, so
6513
6519
// we can use it to determine if this monitor was last written by LDK 0.1 or later.
0 commit comments