@@ -1190,11 +1190,11 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
1190
1190
/// True if this channel was configured for manual funding broadcasts. Monitors written by
1191
1191
/// versions prior to introducing the flag will load with `false` until a new update persists it.
1192
1192
is_manual_broadcast : bool ,
1193
- /// True once we've observed either funding transaction on-chain. Older monitors assume this is
1194
- /// `true` when absent during upgrade so holder broadcasts aren't gated unexpectedly.
1193
+ /// True once we've observed either funding transaction on-chain. Older monitors assume
1194
+ /// this is `true` when absent during upgrade so holder broadcasts aren't gated unexpectedly.
1195
+ /// In manual-broadcast channels we also use this to trigger deferred holder
1196
+ /// broadcasts once the funding transaction finally appears on-chain.
1195
1197
funding_seen_onchain : bool ,
1196
- /// Tracks whether manual-broadcasting was requested before the funding transaction appeared on-chain.
1197
- manual_broadcast_pending : bool ,
1198
1198
1199
1199
latest_update_id : u64 ,
1200
1200
commitment_transaction_number_obscure_factor : u64 ,
@@ -1736,7 +1736,6 @@ pub(crate) fn write_chanmon_internal<Signer: EcdsaChannelSigner, W: Writer>(
1736
1736
( 34 , channel_monitor. alternative_funding_confirmed, option) ,
1737
1737
( 35 , channel_monitor. is_manual_broadcast, required) ,
1738
1738
( 37 , channel_monitor. funding_seen_onchain, required) ,
1739
- ( 39 , channel_monitor. manual_broadcast_pending, required) ,
1740
1739
} ) ;
1741
1740
1742
1741
Ok ( ( ) )
@@ -1914,7 +1913,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
1914
1913
1915
1914
is_manual_broadcast,
1916
1915
funding_seen_onchain : false ,
1917
- manual_broadcast_pending : false ,
1918
1916
1919
1917
latest_update_id : 0 ,
1920
1918
commitment_transaction_number_obscure_factor,
@@ -3986,7 +3984,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3986
3984
// the funding transaction on-chain, do not queue any transactions.
3987
3985
if require_funding_seen && self . is_manual_broadcast && !self . funding_seen_onchain {
3988
3986
log_info ! ( logger, "Not broadcasting holder commitment for manual-broadcast channel before funding appears on-chain" ) ;
3989
- self . manual_broadcast_pending = true ;
3990
3987
return ;
3991
3988
}
3992
3989
let reason = ClosureReason :: HolderForceClosed {
@@ -3999,7 +3996,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3999
3996
claimable_outpoints, self . best_block . height , self . best_block . height , broadcaster,
4000
3997
conf_target, & self . destination_script , fee_estimator, logger,
4001
3998
) ;
4002
- self . manual_broadcast_pending = false ;
4003
3999
}
4004
4000
4005
4001
fn renegotiated_funding < L : Deref > (
@@ -5259,6 +5255,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5259
5255
F :: Target : FeeEstimator ,
5260
5256
L :: Target : Logger ,
5261
5257
{
5258
+ let funding_seen_before = self . funding_seen_onchain ;
5262
5259
let txn_matched = self . filter_block ( txdata) ;
5263
5260
for tx in & txn_matched {
5264
5261
let mut output_val = Amount :: ZERO ;
@@ -5281,7 +5278,8 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5281
5278
let mut watch_outputs = Vec :: new ( ) ;
5282
5279
let mut claimable_outpoints = Vec :: new ( ) ;
5283
5280
5284
- if self . is_manual_broadcast && self . funding_seen_onchain && self . manual_broadcast_pending {
5281
+ if self . is_manual_broadcast && !funding_seen_before && self . funding_seen_onchain && self . holder_tx_signed
5282
+ {
5285
5283
self . queue_latest_holder_commitment_txn_for_broadcast (
5286
5284
& broadcaster,
5287
5285
fee_estimator,
@@ -5507,12 +5505,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5507
5505
// manual-broadcast mode.
5508
5506
let ( mut claimables, mut outputs) =
5509
5507
self . generate_claimable_outpoints_and_watch_outputs ( None ) ;
5510
- if self . is_manual_broadcast && !self . funding_seen_onchain {
5511
- self . manual_broadcast_pending = true ;
5512
- } else {
5508
+ if !( self . is_manual_broadcast && !self . funding_seen_onchain ) {
5513
5509
claimable_outpoints. append ( & mut claimables) ;
5514
5510
watch_outputs. append ( & mut outputs) ;
5515
- self . manual_broadcast_pending = false ;
5516
5511
}
5517
5512
}
5518
5513
@@ -5552,12 +5547,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
5552
5547
let reason = ClosureReason :: HTLCsTimedOut { payment_hash : Some ( payment_hash) } ;
5553
5548
let ( mut new_outpoints, mut new_outputs) =
5554
5549
self . generate_claimable_outpoints_and_watch_outputs ( Some ( reason) ) ;
5555
- if self . is_manual_broadcast && !self . funding_seen_onchain {
5556
- self . manual_broadcast_pending = true ;
5557
- } else {
5550
+ if !( self . is_manual_broadcast && !self . funding_seen_onchain ) {
5558
5551
claimable_outpoints. append ( & mut new_outpoints) ;
5559
5552
watch_outputs. append ( & mut new_outputs) ;
5560
- self . manual_broadcast_pending = false ;
5561
5553
}
5562
5554
}
5563
5555
@@ -6525,7 +6517,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6525
6517
let mut alternative_funding_confirmed = None ;
6526
6518
let mut is_manual_broadcast = None ;
6527
6519
let mut funding_seen_onchain = None ;
6528
- let mut manual_broadcast_pending = None ;
6529
6520
read_tlv_fields ! ( reader, {
6530
6521
( 1 , funding_spend_confirmed, option) ,
6531
6522
( 3 , htlcs_resolved_on_chain, optional_vec) ,
@@ -6548,7 +6539,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6548
6539
( 34 , alternative_funding_confirmed, option) ,
6549
6540
( 35 , is_manual_broadcast, option) ,
6550
6541
( 37 , funding_seen_onchain, option) ,
6551
- ( 39 , manual_broadcast_pending, option) ,
6552
6542
} ) ;
6553
6543
// Note that `payment_preimages_with_info` was added (and is always written) in LDK 0.1, so
6554
6544
// we can use it to determine if this monitor was last written by LDK 0.1 or later.
@@ -6583,7 +6573,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6583
6573
let channel_parameters = channel_parameters. unwrap_or_else ( || {
6584
6574
onchain_tx_handler. channel_parameters ( ) . clone ( )
6585
6575
} ) ;
6586
- let manual_broadcast_pending = manual_broadcast_pending. unwrap_or ( false ) ;
6587
6576
6588
6577
// Monitors for anchor outputs channels opened in v0.0.116 suffered from a bug in which the
6589
6578
// wrong `counterparty_payment_script` was being tracked. Fix it now on deserialization to
@@ -6670,7 +6659,6 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
6670
6659
is_manual_broadcast : is_manual_broadcast. unwrap_or ( false ) ,
6671
6660
// Assume "seen" when absent to prevent gating holder broadcasts after upgrade.
6672
6661
funding_seen_onchain : funding_seen_onchain. unwrap_or ( true ) ,
6673
- manual_broadcast_pending,
6674
6662
6675
6663
latest_update_id,
6676
6664
commitment_transaction_number_obscure_factor,
@@ -7163,7 +7151,6 @@ mod tests {
7163
7151
{
7164
7152
let inner = monitor. inner . lock ( ) . unwrap ( ) ;
7165
7153
assert ! ( !inner. funding_seen_onchain) ;
7166
- assert ! ( inner. manual_broadcast_pending) ;
7167
7154
}
7168
7155
7169
7156
// Now confirm the funding transaction via transactions_confirmed.
@@ -7180,7 +7167,7 @@ mod tests {
7180
7167
) ;
7181
7168
{
7182
7169
let inner = monitor. inner . lock ( ) . unwrap ( ) ;
7183
- assert ! ( ! inner. manual_broadcast_pending ) ;
7170
+ assert ! ( inner. funding_seen_onchain ) ;
7184
7171
}
7185
7172
7186
7173
// Next height update should allow broadcast.
0 commit comments