Skip to content

Commit 717365f

Browse files
committed
Provide simple interface to query est. liquidity
1 parent abf6564 commit 717365f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lightning/src/routing/scoring.rs

+17
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,23 @@ impl<G: Deref<Target = NetworkGraph<L>>, L: Deref, T: Time> ProbabilisticScorerU
434434
}
435435
}
436436
}
437+
438+
/// Query the estimated minimum and maximum liquidity available for sending a payment over the
439+
/// channel with `scid` towards the given `target` node.
440+
pub fn estimated_channel_liquidity_range(&self, scid: u64, target: &NodeId) -> Option<(u64, u64)> {
441+
let graph = self.network_graph.read_only();
442+
443+
if let Some(chan) = graph.channels().get(&scid) {
444+
if let Some(liq) = self.channel_liquidities.get(&scid) {
445+
if let Some((directed_info, source)) = chan.as_directed_to(target) {
446+
let amt = directed_info.effective_capacity().as_msat();
447+
let dir_liq = liq.as_directed(source, target, amt, self.params.liquidity_offset_half_life);
448+
return Some((dir_liq.min_liquidity_msat(), dir_liq.max_liquidity_msat()));
449+
}
450+
}
451+
}
452+
None
453+
}
437454
}
438455

439456
impl ProbabilisticScoringParameters {

0 commit comments

Comments
 (0)