From 49af210d70466f53356511d24d7b3f0a897bfd54 Mon Sep 17 00:00:00 2001 From: tompro Date: Wed, 24 Sep 2025 14:11:27 +0200 Subject: [PATCH] Add list channels to lnd api. --- payday_node_lnd/src/wrapper.rs | 19 +++++++++++++++++-- payday_postgres/src/offset.rs | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/payday_node_lnd/src/wrapper.rs b/payday_node_lnd/src/wrapper.rs index b857ccc..a96e339 100644 --- a/payday_node_lnd/src/wrapper.rs +++ b/payday_node_lnd/src/wrapper.rs @@ -12,8 +12,9 @@ use bitcoin::{hex::DisplayHex, Address, Amount, Network, PublicKey}; use fedimint_tonic_lnd::{ lnrpc::{ payment::PaymentStatus, ChannelBalanceRequest, ChannelBalanceResponse, GetInfoRequest, - GetTransactionsRequest, Invoice, ListInvoiceRequest, ListInvoiceResponse, SendCoinsRequest, - SendManyRequest, Transaction, WalletBalanceRequest, WalletBalanceResponse, + GetTransactionsRequest, Invoice, ListChannelsRequest, ListChannelsResponse, + ListInvoiceRequest, ListInvoiceResponse, SendCoinsRequest, SendManyRequest, Transaction, + WalletBalanceRequest, WalletBalanceResponse, }, Client, }; @@ -47,6 +48,9 @@ pub trait LndApi: Send + Sync { /// Get the current balances (onchain and lightning) of the wallet. async fn get_balances(&self) -> Result<(WalletBalanceResponse, ChannelBalanceResponse)>; + /// List channels of this node. + async fn list_channels(&self, request: ListChannelsRequest) -> Result; + /// Get a new onchain address for the wallet. Address is parsed and /// validated for the configure network. async fn new_address(&self) -> Result
; @@ -191,6 +195,17 @@ impl LndApi for LndRpcWrapper { Ok((on_chain, lightning)) } + /// List channels of this node filtered by given parameters. + async fn list_channels(&self, request: ListChannelsRequest) -> Result { + let mut lnd = self.client().await; + Ok(lnd + .lightning() + .list_channels(request) + .await + .map_err(|e| Error::NodeApi(e.to_string()))? + .into_inner()) + } + /// Get a new onchain address for the wallet. Address is parsed and /// validated for the configure network. async fn new_address(&self) -> Result
{ diff --git a/payday_postgres/src/offset.rs b/payday_postgres/src/offset.rs index 2018961..fe84a5f 100644 --- a/payday_postgres/src/offset.rs +++ b/payday_postgres/src/offset.rs @@ -122,6 +122,7 @@ mod tests { use crate::test_utils::get_postgres_pool; #[tokio::test] + #[ignore = "integration test"] async fn test_get_set_offset_non_existant() { let db = get_postgres_pool().await; let store = OffsetStore::new(db, None, None); @@ -133,6 +134,7 @@ mod tests { } #[tokio::test] + #[ignore = "integration test"] async fn test_get_set_offset() { let id = "test_get_set_offset"; let db = get_postgres_pool().await;