@@ -164,6 +164,7 @@ const DEFAULT_CLTV_EXPIRY_DELTA: u32 = 144;
164
164
const DEFAULT_BDK_WALLET_SYNC_INTERVAL_SECS : u64 = 80 ;
165
165
const DEFAULT_LDK_WALLET_SYNC_INTERVAL_SECS : u64 = 30 ;
166
166
const DEFAULT_FEE_RATE_CACHE_UPDATE_INTERVAL_SECS : u64 = 60 * 10 ;
167
+ const DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER : u64 = 3 ;
167
168
const DEFAULT_LOG_LEVEL : LogLevel = LogLevel :: Debug ;
168
169
169
170
// The 'stop gap' parameter used by BDK's wallet sync. This seems to configure the threshold
@@ -210,6 +211,7 @@ const WALLET_KEYS_SEED_LEN: usize = 64;
210
211
/// | `wallet_sync_interval_secs` | 30 |
211
212
/// | `fee_rate_cache_update_interval_secs` | 600 |
212
213
/// | `trusted_peers_0conf` | [] |
214
+ /// | `probing_liquidity_limit_multiplier` | 3 |
213
215
/// | `log_level` | Debug |
214
216
///
215
217
pub struct Config {
@@ -243,6 +245,8 @@ pub struct Config {
243
245
/// funding transaction ends up never being confirmed on-chain. Zero-confirmation channels
244
246
/// should therefore only be accepted from trusted peers.
245
247
pub trusted_peers_0conf : Vec < PublicKey > ,
248
+ /// The liquidity factor by which we pre-filter the outgoing channels used for sending probes.
249
+ pub probing_liquidity_limit_multiplier : u64 ,
246
250
/// The level at which we log messages.
247
251
///
248
252
/// Any messages below this level will be excluded from the logs.
@@ -261,6 +265,7 @@ impl Default for Config {
261
265
wallet_sync_interval_secs : DEFAULT_LDK_WALLET_SYNC_INTERVAL_SECS ,
262
266
fee_rate_cache_update_interval_secs : DEFAULT_FEE_RATE_CACHE_UPDATE_INTERVAL_SECS ,
263
267
trusted_peers_0conf : Vec :: new ( ) ,
268
+ probing_liquidity_limit_multiplier : DEFAULT_PROBING_LIQUIDITY_LIMIT_MULTIPLIER ,
264
269
log_level : DEFAULT_LOG_LEVEL ,
265
270
}
266
271
}
@@ -1306,6 +1311,10 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
1306
1311
/// liquidity needed to complete the actual payment. Users should therefore be cautious and
1307
1312
/// might avoid sending probes if liquidity is scarce and/or they don't expect the probe to
1308
1313
/// return before they send the payment.
1314
+ ///
1315
+ /// To somewhat mitigate this issue, channels whose available liquidity is less than the
1316
+ /// `invoice` amount times [`Config::probing_liquidity_limit_multiplier`] won't be used to send
1317
+ /// pre-flight probes.
1309
1318
pub fn send_payment_probe ( & self , invoice : & Bolt11Invoice ) -> Result < ( ) , Error > {
1310
1319
let rt_lock = self . runtime . read ( ) . unwrap ( ) ;
1311
1320
if rt_lock. is_none ( ) {
@@ -1347,6 +1356,10 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
1347
1356
/// liquidity needed to complete the actual payment. Users should therefore be cautious and
1348
1357
/// might avoid sending probes if liquidity is scarce and/or they don't expect the probe to
1349
1358
/// return before they send the payment.
1359
+ ///
1360
+ /// To somewhat mitigate this issue, channels whose available liquidity is less than
1361
+ /// `amount_msat` times [`Config::probing_liquidity_limit_multiplier`] won't be used to send
1362
+ /// pre-flight probes.
1350
1363
pub fn send_spontaneous_payment_probe (
1351
1364
& self , amount_msat : u64 , node_id : PublicKey ,
1352
1365
) -> Result < ( ) , Error > {
@@ -1365,17 +1378,21 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
1365
1378
1366
1379
fn send_payment_probe_internal ( & self , route_params : RouteParameters ) -> Result < ( ) , Error > {
1367
1380
let payer = self . channel_manager . get_our_node_id ( ) ;
1368
- let first_hops = self . channel_manager . list_usable_channels ( ) ;
1381
+ let usable_channels = self . channel_manager . list_usable_channels ( ) ;
1382
+ let first_hops = usable_channels
1383
+ . iter ( )
1384
+ . filter ( |c| {
1385
+ c. next_outbound_htlc_limit_msat
1386
+ >= route_params
1387
+ . final_value_msat
1388
+ . saturating_mul ( self . config . probing_liquidity_limit_multiplier )
1389
+ } )
1390
+ . collect :: < Vec < _ > > ( ) ;
1369
1391
let inflight_htlcs = self . channel_manager . compute_inflight_htlcs ( ) ;
1370
1392
1371
1393
let route = self
1372
1394
. router
1373
- . find_route (
1374
- & payer,
1375
- & route_params,
1376
- Some ( & first_hops. iter ( ) . collect :: < Vec < _ > > ( ) ) ,
1377
- inflight_htlcs,
1378
- )
1395
+ . find_route ( & payer, & route_params, Some ( & first_hops) , inflight_htlcs)
1379
1396
. map_err ( |e| {
1380
1397
log_error ! ( self . logger, "Failed to find path for payment probe: {:?}" , e) ;
1381
1398
Error :: ProbeSendingFailed
0 commit comments