From 32b4d7e98d5275fa20a010791f8448a9fa30413c Mon Sep 17 00:00:00 2001 From: joschisan Date: Thu, 16 Jul 2026 14:42:59 +0200 Subject: [PATCH] Expose the probe amount range on ProbingConfigBuilder The bounds each probe's amount is drawn from were baked-in crate defaults (1k - 10k sats). Nodes that mostly send larger payments want larger probes, since knowing a route passes 10k sats says little about whether it passes 500k - add amount_range_msat to the builder (plus the uniffi Arced variant and UDL) and thread it into both built-in strategies. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_013fi458uGXp51nh5wMNhwWY --- bindings/ldk_node.udl | 1 + src/builder.rs | 11 +++++------ src/probing.rs | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/bindings/ldk_node.udl b/bindings/ldk_node.udl index 4c4c1a438a..e52045d882 100644 --- a/bindings/ldk_node.udl +++ b/bindings/ldk_node.udl @@ -40,6 +40,7 @@ interface ProbingConfigBuilder { void set_max_locked_msat(u64 max_msat); void set_diversity_penalty_msat(u64 penalty_msat); void set_cooldown(u64 secs); + void set_amount_range_msat(u64 min_msat, u64 max_msat); ProbingConfig build(); }; diff --git a/src/builder.rs b/src/builder.rs index c6b3bd02fc..9d658dc4ba 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -58,8 +58,7 @@ use crate::config::BitcoindRestClientConfig; use crate::config::{ default_user_config, may_announce_channel, AnnounceError, AsyncPaymentsRole, Config, ElectrumSyncConfig, EsploraSyncConfig, HRNResolverConfig, TorConfig, - DEFAULT_ESPLORA_SERVER_URL, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, - DEFAULT_MAX_PROBE_AMOUNT_MSAT, DEFAULT_MIN_PROBE_AMOUNT_MSAT, PAYMENT_CACHE_CAPACITY, + DEFAULT_ESPLORA_SERVER_URL, DEFAULT_LOG_FILENAME, DEFAULT_LOG_LEVEL, PAYMENT_CACHE_CAPACITY, PAYMENT_CACHE_WARMUP_COUNT, }; use crate::connection::ConnectionManager; @@ -2429,8 +2428,8 @@ fn build_with_store_internal( Arc::clone(&channel_manager), probing_router, *top_node_count, - DEFAULT_MIN_PROBE_AMOUNT_MSAT, - DEFAULT_MAX_PROBE_AMOUNT_MSAT, + probing_cfg.min_amount_msat, + probing_cfg.max_amount_msat, probing_cfg.cooldown, config.probing_liquidity_limit_multiplier, )) @@ -2439,8 +2438,8 @@ fn build_with_store_internal( Arc::clone(&network_graph), Arc::clone(&channel_manager), *max_hops, - DEFAULT_MIN_PROBE_AMOUNT_MSAT, - DEFAULT_MAX_PROBE_AMOUNT_MSAT, + probing_cfg.min_amount_msat, + probing_cfg.max_amount_msat, )), ProbingStrategyKind::Custom(s) => Arc::clone(s), }; diff --git a/src/probing.rs b/src/probing.rs index 7a17cd2fad..793855315f 100644 --- a/src/probing.rs +++ b/src/probing.rs @@ -79,8 +79,8 @@ use lightning_invoice::DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA; use lightning_types::features::{ChannelFeatures, NodeFeatures}; use crate::config::{ - DEFAULT_MAX_PROBE_LOCKED_MSAT, DEFAULT_PROBED_NODE_COOLDOWN_SECS, - DEFAULT_PROBING_INTERVAL_SECS, MIN_PROBING_INTERVAL, + DEFAULT_MAX_PROBE_AMOUNT_MSAT, DEFAULT_MAX_PROBE_LOCKED_MSAT, DEFAULT_MIN_PROBE_AMOUNT_MSAT, + DEFAULT_PROBED_NODE_COOLDOWN_SECS, DEFAULT_PROBING_INTERVAL_SECS, MIN_PROBING_INTERVAL, }; use crate::logger::{log_debug, LdkLogger, Logger}; use crate::types::{ChannelManager, Graph, Router}; @@ -165,6 +165,8 @@ pub struct ProbingConfig { pub(crate) max_locked_msat: u64, pub(crate) diversity_penalty_msat: Option, pub(crate) cooldown: Duration, + pub(crate) min_amount_msat: u64, + pub(crate) max_amount_msat: u64, } /// Builder for [`ProbingConfig`]. @@ -183,6 +185,8 @@ pub struct ProbingConfigBuilder { max_locked_msat: u64, diversity_penalty_msat: Option, cooldown: Duration, + min_amount_msat: u64, + max_amount_msat: u64, } impl ProbingConfigBuilder { @@ -193,6 +197,8 @@ impl ProbingConfigBuilder { max_locked_msat: DEFAULT_MAX_PROBE_LOCKED_MSAT, diversity_penalty_msat: None, cooldown: Duration::from_secs(DEFAULT_PROBED_NODE_COOLDOWN_SECS), + min_amount_msat: DEFAULT_MIN_PROBE_AMOUNT_MSAT, + max_amount_msat: DEFAULT_MAX_PROBE_AMOUNT_MSAT, } } @@ -256,6 +262,21 @@ impl ProbingConfigBuilder { self } + /// Overrides the bounds each probe's amount is uniformly drawn from. + /// + /// Only applies to the built-in strategies; custom strategies choose their + /// own probe amounts when building paths. Larger amounts teach the scorer + /// about liquidity in the range of larger payments, at the cost of locking + /// more liquidity per in-flight probe — size `max_locked_msat` accordingly. + /// + /// Defaults to 1 000 000 - 10 000 000 msat (1k - 10k sats). + pub fn amount_range_msat(&mut self, min_msat: u64, max_msat: u64) -> &mut Self { + debug_assert!(min_msat <= max_msat, "min_msat must not exceed max_msat"); + self.min_amount_msat = min_msat; + self.max_amount_msat = max_msat; + self + } + /// Builds the [`ProbingConfig`]. pub fn build(&self) -> ProbingConfig { ProbingConfig { @@ -264,6 +285,8 @@ impl ProbingConfigBuilder { max_locked_msat: self.max_locked_msat, diversity_penalty_msat: self.diversity_penalty_msat, cooldown: self.cooldown, + min_amount_msat: self.min_amount_msat, + max_amount_msat: self.max_amount_msat, } } } @@ -335,6 +358,16 @@ impl ArcedProbingConfigBuilder { self.inner.write().expect("lock").cooldown(Duration::from_secs(secs)); } + /// Overrides the bounds each probe's amount is uniformly drawn from. + /// + /// Only applies to the built-in strategies; custom strategies choose their + /// own probe amounts when building paths. + /// + /// Defaults to 1 000 000 - 10 000 000 msat (1k - 10k sats). + pub fn set_amount_range_msat(&self, min_msat: u64, max_msat: u64) { + self.inner.write().expect("lock").amount_range_msat(min_msat, max_msat); + } + /// Builds the [`ProbingConfig`]. pub fn build(&self) -> Arc { Arc::new(self.inner.read().expect("lock").build())