@@ -1131,7 +1131,11 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
1131
1131
funding : FundingScope ,
1132
1132
pending_funding : Vec < FundingScope > ,
1133
1133
1134
+ /// True if this channel was configured for manual funding broadcasts. Monitors written by
1135
+ /// versions prior to introducing the flag will load with `false` until a new update persists it.
1134
1136
is_manual_broadcast : bool ,
1137
+ /// True once we've observed either funding transaction on-chain. Older monitors assume this is
1138
+ /// `true` when absent during upgrade so holder broadcasts aren't gated unexpectedly.
1135
1139
funding_seen_onchain : bool ,
1136
1140
1137
1141
latest_update_id : u64 ,
@@ -1663,8 +1667,8 @@ pub(crate) fn write_chanmon_internal<Signer: EcdsaChannelSigner, W: Writer>(
1663
1667
( 31 , channel_monitor. funding. channel_parameters, required) ,
1664
1668
( 32 , channel_monitor. pending_funding, optional_vec) ,
1665
1669
( 34 , channel_monitor. alternative_funding_confirmed, option) ,
1666
- ( 36 , channel_monitor. is_manual_broadcast, required) ,
1667
- ( 38 , channel_monitor. funding_seen_onchain, required) ,
1670
+ ( 35 , channel_monitor. is_manual_broadcast, required) ,
1671
+ ( 37 , channel_monitor. funding_seen_onchain, required) ,
1668
1672
} ) ;
1669
1673
1670
1674
Ok ( ( ) )
@@ -2260,8 +2264,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
2260
2264
/// [`crate::ln::channelmanager::ChannelManager::funding_transaction_generated_manual_broadcast`]),
2261
2265
/// automatic broadcasts are suppressed until the funding transaction has been observed on-chain.
2262
2266
/// 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.
2267
+ /// transaction for broadcast even if the funding has not yet been seen on-chain. This may result
2268
+ /// in unconfirmable transactions being broadcast or [`Event::BumpTransaction`] notifications for
2269
+ /// transactions that cannot be confirmed until the funding transaction is visible.
2270
+ ///
2271
+ /// [`Event::BumpTransaction`]: crate::events::Event::BumpTransaction
2265
2272
#[ rustfmt:: skip]
2266
2273
pub fn broadcast_latest_holder_commitment_txn < B : Deref , F : Deref , L : Deref > (
2267
2274
& self , broadcaster : & B , fee_estimator : & F , logger : & L
@@ -5180,14 +5187,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5180
5187
F :: Target : FeeEstimator ,
5181
5188
L :: Target : Logger ,
5182
5189
{
5183
- for & ( _, tx) in txdata. iter ( ) {
5184
- let txid = tx. compute_txid ( ) ;
5185
- if txid == self . funding . funding_txid ( ) ||
5186
- self . pending_funding . iter ( ) . any ( |f| f. funding_txid ( ) == txid)
5187
- {
5188
- self . funding_seen_onchain = true ;
5189
- }
5190
- }
5191
5190
let txn_matched = self . filter_block ( txdata) ;
5192
5191
for tx in & txn_matched {
5193
5192
let mut output_val = Amount :: ZERO ;
@@ -5767,10 +5766,17 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5767
5766
5768
5767
/// Filters a block's `txdata` for transactions spending watched outputs or for any child
5769
5768
/// transactions thereof.
5769
+ /// While iterating, this also tracks whether we observed the funding transaction.
5770
5770
#[ rustfmt:: skip]
5771
- fn filter_block < ' a > ( & self , txdata : & TransactionData < ' a > ) -> Vec < & ' a Transaction > {
5771
+ fn filter_block < ' a > ( & mut self , txdata : & TransactionData < ' a > ) -> Vec < & ' a Transaction > {
5772
5772
let mut matched_txn = new_hash_set ( ) ;
5773
5773
txdata. iter ( ) . filter ( |& & ( _, tx) | {
5774
+ let txid = tx. compute_txid ( ) ;
5775
+ if !self . funding_seen_onchain && ( txid == self . funding . funding_txid ( ) ||
5776
+ self . pending_funding . iter ( ) . any ( |f| f. funding_txid ( ) == txid) )
5777
+ {
5778
+ self . funding_seen_onchain = true ;
5779
+ }
5774
5780
let mut matches = self . spends_watched_output ( tx) ;
5775
5781
for input in tx. input . iter ( ) {
5776
5782
if matches { break ; }
@@ -5779,7 +5785,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5779
5785
}
5780
5786
}
5781
5787
if matches {
5782
- matched_txn. insert ( tx . compute_txid ( ) ) ;
5788
+ matched_txn. insert ( txid ) ;
5783
5789
}
5784
5790
matches
5785
5791
} ) . map ( |( _, tx) | * tx) . collect ( )
@@ -6440,8 +6446,8 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6440
6446
( 31 , channel_parameters, ( option: ReadableArgs , None ) ) ,
6441
6447
( 32 , pending_funding, optional_vec) ,
6442
6448
( 34 , alternative_funding_confirmed, option) ,
6443
- ( 36 , is_manual_broadcast, option) ,
6444
- ( 38 , funding_seen_onchain, option) ,
6449
+ ( 35 , is_manual_broadcast, option) ,
6450
+ ( 37 , funding_seen_onchain, option) ,
6445
6451
} ) ;
6446
6452
// Note that `payment_preimages_with_info` was added (and is always written) in LDK 0.1, so
6447
6453
// we can use it to determine if this monitor was last written by LDK 0.1 or later.
0 commit comments