From a338f8f666a5e6801ba828454422d49803ff6f36 Mon Sep 17 00:00:00 2001 From: YI Date: Mon, 6 Jan 2025 22:51:05 +0800 Subject: [PATCH] Read direct channel info while building payment route --- src/fiber/channel.rs | 8 +++ src/fiber/graph.rs | 168 +++++++++++++++++++++++++++++-------------- 2 files changed, 123 insertions(+), 53 deletions(-) diff --git a/src/fiber/channel.rs b/src/fiber/channel.rs index 68013c4e1..03fcbd82d 100644 --- a/src/fiber/channel.rs +++ b/src/fiber/channel.rs @@ -4043,6 +4043,14 @@ impl ChannelActorState { self.to_local_amount + self.to_remote_amount } + pub(crate) fn get_total_capacity(&self) -> u128 { + if self.funding_udt_type_script.is_some() { + self.get_total_udt_amount() + } else { + self.get_total_ckb_amount() as u128 + } + } + // Get the total liquid capacity of the channel, which will exclude the reserved ckb amount. // This is the capacity used for gossiping channel information. fn get_liquid_capacity(&self) -> u128 { diff --git a/src/fiber/graph.rs b/src/fiber/graph.rs index b9d30de8b..adbbb20e9 100644 --- a/src/fiber/graph.rs +++ b/src/fiber/graph.rs @@ -169,6 +169,24 @@ impl From<(u64, ChannelAnnouncement)> for ChannelInfo { } } +pub struct DirectedGraphEdge { + pub channel_outpoint: OutPoint, + + pub from: Pubkey, + pub to: Pubkey, + + // The total capacity of the channel. + pub capacity: u128, + // UDT script + pub udt_type_script: Option