@@ -29,6 +29,9 @@ const DEFAULT_LDK_WALLET_SYNC_INTERVAL_SECS: u64 = 30;
29
29
const DEFAULT_FEE_RATE_CACHE_UPDATE_INTERVAL_SECS : u64 = 60 * 10 ;
30
30
const DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER : u64 = 3 ;
31
31
const DEFAULT_ANCHOR_PER_CHANNEL_RESERVE_SATS : u64 = 25_000 ;
32
+ const DEFAULT_MIN_REBROADCAST_INTERVAL_SECS : u64 = 300 ;
33
+ const DEFAULT_MAX_BROADCAST_ATTEMPTS : u32 = 24 ;
34
+ const DEFAULT_BACKOFF_FACTOR : f32 = 1.5 ;
32
35
33
36
/// The default log level.
34
37
pub const DEFAULT_LOG_LEVEL : LogLevel = LogLevel :: Debug ;
@@ -94,6 +97,9 @@ pub(crate) const RGS_SYNC_TIMEOUT_SECS: u64 = 5;
94
97
/// The length in bytes of our wallets' keys seed.
95
98
pub const WALLET_KEYS_SEED_LEN : usize = 64 ;
96
99
100
+ // The time in-between unconfirmed transaction broadcasts.
101
+ pub ( crate ) const UNCONFIRMED_TX_BROADCAST_INTERVAL : Duration = Duration :: from_secs ( 300 ) ;
102
+
97
103
#[ derive( Debug , Clone ) ]
98
104
/// Represents the configuration of an [`Node`] instance.
99
105
///
@@ -115,6 +121,7 @@ pub const WALLET_KEYS_SEED_LEN: usize = 64;
115
121
/// | `log_level` | Debug |
116
122
/// | `anchor_channels_config` | Some(..) |
117
123
/// | `sending_parameters` | None |
124
+ /// | `auto_rebroadcast_unconfirmed_tx` | true |
118
125
///
119
126
/// See [`AnchorChannelsConfig`] and [`SendingParameters`] for more information regarding their
120
127
/// respective default values.
@@ -179,6 +186,16 @@ pub struct Config {
179
186
/// **Note:** If unset, default parameters will be used, and you will be able to override the
180
187
/// parameters on a per-payment basis in the corresponding method calls.
181
188
pub sending_parameters : Option < SendingParameters > ,
189
+ /// This will determine whether to automatically rebroadcast unconfirmed transactions
190
+ /// (e.g., channel funding or sweep transactions).
191
+ ///
192
+ /// If enabled, the node will periodically attempt to rebroadcast any unconfirmed transactions to
193
+ /// increase propagation and confirmation likelihood. This is helpful in cases where transactions
194
+ /// were dropped by the mempool or not widely propagated.
195
+ ///
196
+ /// Defaults to `true`. Disabling this may be desired for privacy-sensitive use cases or low-bandwidth
197
+ /// environments, but may result in slower or failed confirmations if transactions are not re-announced.
198
+ pub auto_rebroadcast_unconfirmed_tx : bool ,
182
199
}
183
200
184
201
impl Default for Config {
@@ -193,6 +210,7 @@ impl Default for Config {
193
210
anchor_channels_config : Some ( AnchorChannelsConfig :: default ( ) ) ,
194
211
sending_parameters : None ,
195
212
node_alias : None ,
213
+ auto_rebroadcast_unconfirmed_tx : true ,
196
214
}
197
215
}
198
216
}
@@ -534,6 +552,49 @@ impl From<MaxDustHTLCExposure> for LdkMaxDustHTLCExposure {
534
552
}
535
553
}
536
554
555
+ /// Policy for controlling transaction rebroadcasting behavior.
556
+ ///
557
+ /// Determines the strategy for resending unconfirmed transactions to the network
558
+ /// to ensure they remain in mempools and eventually get confirmed.
559
+ #[ derive( Clone , Debug ) ]
560
+ pub struct RebroadcastPolicy {
561
+ /// Minimum time between rebroadcast attempts in seconds.
562
+ ///
563
+ /// This prevents excessive network traffic by ensuring a minimum delay
564
+ /// between consecutive rebroadcast attempts.
565
+ ///
566
+ /// **Recommended values**: 60-600 seconds (1-10 minutes)
567
+ pub min_rebroadcast_interval_secs : u64 ,
568
+ /// Maximum number of broadcast attempts before giving up.
569
+ ///
570
+ /// After reaching this limit, the transaction will no longer be rebroadcast
571
+ /// automatically. Manual intervention may be required.
572
+ ///
573
+ /// **Recommended values**: 12-48 attempts
574
+ pub max_broadcast_attempts : u32 ,
575
+ /// Exponential backoff factor for increasing intervals between attempts.
576
+ ///
577
+ /// Each subsequent rebroadcast wait time is multiplied by this factor,
578
+ /// creating an exponential backoff pattern.
579
+ ///
580
+ /// - `1.0`: No backoff (constant interval)
581
+ /// - `1.5`: 50% increase each attempt
582
+ /// - `2.0`: 100% increase (doubling) each attempt
583
+ ///
584
+ /// **Recommended values**: 1.2-2.0
585
+ pub backoff_factor : f32 ,
586
+ }
587
+
588
+ impl Default for RebroadcastPolicy {
589
+ fn default ( ) -> Self {
590
+ Self {
591
+ min_rebroadcast_interval_secs : DEFAULT_MIN_REBROADCAST_INTERVAL_SECS ,
592
+ max_broadcast_attempts : DEFAULT_MAX_BROADCAST_ATTEMPTS ,
593
+ backoff_factor : DEFAULT_BACKOFF_FACTOR ,
594
+ }
595
+ }
596
+ }
597
+
537
598
#[ cfg( test) ]
538
599
mod tests {
539
600
use std:: str:: FromStr ;
0 commit comments