From e7825665a0c16be8b4f7f77210aa480124576350 Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Thu, 11 Jul 2024 16:06:47 +0200 Subject: [PATCH 1/2] Revert "chore: Upgrade cln-plugin to 0.1.9" This reverts commit 777b56ba7e768f53d8407674d7564b3c490e3fb1. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- libs/gl-plugin/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b6dfe2039..199ee841c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -557,9 +557,9 @@ dependencies = [ [[package]] name = "cln-plugin" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6b096d2f2a7c58c6faaff1b64281a4c30ff078ec3ca746975fb76ac1a6d6e1f" +checksum = "686c36c872fc3186f3c71650df64fdb4627de57291d39bdc80fe452155187391" dependencies = [ "anyhow", "bytes 1.6.0", diff --git a/Cargo.toml b/Cargo.toml index 00be90c9a..190995fb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ anyhow = "1" env_logger = "0.10" cln-grpc = "0.1.9" cln-rpc = "0.1.9" -cln-plugin = "0.1.9" +cln-plugin = "0.1.8" vls-core = "^0.11.0" vls-persist = "^0.11.0" diff --git a/libs/gl-plugin/Cargo.toml b/libs/gl-plugin/Cargo.toml index a48d46b36..fbb2ffc60 100644 --- a/libs/gl-plugin/Cargo.toml +++ b/libs/gl-plugin/Cargo.toml @@ -21,7 +21,7 @@ base64 = "0.21.7" bytes = { version = "1", features = ["serde"] } clightningrpc = "0.2" cln-grpc = { workspace = true, features = ["server"] } -cln-plugin = { workspace = true } +cln-plugin = "^0.1" cln-rpc = { workspace = true } env_logger = "^0.7.1" futures = "0.3" From 3f0e3bfd53b44b1cd8bd3ab5af6e3c80978c554c Mon Sep 17 00:00:00 2001 From: Peter Neuroth Date: Thu, 11 Jul 2024 16:06:47 +0200 Subject: [PATCH 2/2] Revert "chore: Upgrade cln_rpc and cln_grpc to 0.1.9" This reverts commit 6709f2013b8077b8be2a6d4b098f8294bf9fd839. --- Cargo.lock | 13 +- Cargo.toml | 4 +- libs/gl-client-py/glclient/rpc.py | 13 + libs/gl-client/src/signer/model/cln.rs | 1 + libs/gl-client/src/signer/model/mod.rs | 1 + libs/gl-client/src/signer/resolve.rs | 2 +- libs/gl-plugin/src/lib.rs | 26 +- libs/gl-plugin/src/node/mod.rs | 4 - libs/gl-plugin/src/node/wrapper.rs | 934 +++++-------------------- libs/gl-plugin/src/pb.rs | 2 +- 10 files changed, 211 insertions(+), 789 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 199ee841c..61e24f92b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -536,21 +536,17 @@ dependencies = [ [[package]] name = "cln-grpc" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d528ade112e169cbb79ceae2f235b4502fee6e939326bbaa36aafcdfd54cd91c" +checksum = "85b7b9e8de980dba797a0885b99fda797638d8a207089cb98710d94285e871df" dependencies = [ "anyhow", "bitcoin 0.30.2", "cln-rpc", - "futures-core", "hex", "log", "prost 0.11.9", "serde", - "tokio 1.37.0", - "tokio-stream", - "tokio-util 0.7.11", "tonic 0.8.3", "tonic-build 0.8.4", ] @@ -576,9 +572,9 @@ dependencies = [ [[package]] name = "cln-rpc" -version = "0.1.9" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "974dac6f40275b7b828087f4f9973c39658f9b4a46cc589c083a2c6c27cf67cb" +checksum = "2653217d27aee65a670f0c4f340b8f70b1f0b4e1c2fa085afe1b8e24ba12c069" dependencies = [ "anyhow", "bitcoin 0.30.2", @@ -3459,7 +3455,6 @@ dependencies = [ "futures-core", "pin-project-lite 0.2.14", "tokio 1.37.0", - "tokio-util 0.7.11", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 190995fb8..89b429e05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,8 @@ members = [ [workspace.dependencies] anyhow = "1" env_logger = "0.10" -cln-grpc = "0.1.9" -cln-rpc = "0.1.9" +cln-grpc = "=0.1.8" +cln-rpc = "0.1.8" cln-plugin = "0.1.8" vls-core = "^0.11.0" diff --git a/libs/gl-client-py/glclient/rpc.py b/libs/gl-client-py/glclient/rpc.py index a9d81e736..09433da45 100644 --- a/libs/gl-client-py/glclient/rpc.py +++ b/libs/gl-client-py/glclient/rpc.py @@ -282,6 +282,19 @@ def del_datastore( bytes(self.inner.call(uri, bytes(req))) ) + def del_expired_invoice( + self, + maxexpirytime=None + ): + uri = "/cln.Node/DelExpiredInvoice" + req = clnpb.DelexpiredinvoiceRequest( + maxexpirytime=maxexpirytime + ).SerializeToString() + res = clnpb.DelexpiredinvoiceResponse + return res.FromString( + bytes(self.inner.call(uri, bytes(req))) + ) + def del_invoice( self, label, diff --git a/libs/gl-client/src/signer/model/cln.rs b/libs/gl-client/src/signer/model/cln.rs index 2d869ea5a..5138c89af 100644 --- a/libs/gl-client/src/signer/model/cln.rs +++ b/libs/gl-client/src/signer/model/cln.rs @@ -24,6 +24,7 @@ pub fn decode_request(uri: &str, p: &[u8]) -> anyhow::Result { "/cln.Node/Datastore" => Request::Datastore(DatastoreRequest::decode(p)?), "/cln.Node/CreateOnion" => Request::CreateOnion(CreateonionRequest::decode(p)?), "/cln.Node/DelDatastore" => Request::DelDatastore(DeldatastoreRequest::decode(p)?), + "/cln.Node/DelExpiredInvoice" => Request::DelExpiredInvoice(DelexpiredinvoiceRequest::decode(p)?), "/cln.Node/DelInvoice" => Request::DelInvoice(DelinvoiceRequest::decode(p)?), "/cln.Node/Invoice" => Request::Invoice(InvoiceRequest::decode(p)?), "/cln.Node/ListDatastore" => Request::ListDatastore(ListdatastoreRequest::decode(p)?), diff --git a/libs/gl-client/src/signer/model/mod.rs b/libs/gl-client/src/signer/model/mod.rs index b8c9814cb..5bb5758e8 100644 --- a/libs/gl-client/src/signer/model/mod.rs +++ b/libs/gl-client/src/signer/model/mod.rs @@ -38,6 +38,7 @@ pub enum Request { Datastore(cln::DatastoreRequest), CreateOnion(cln::CreateonionRequest), DelDatastore(cln::DeldatastoreRequest), + DelExpiredInvoice(cln::DelexpiredinvoiceRequest), DelInvoice(cln::DelinvoiceRequest), Invoice(cln::InvoiceRequest), ListDatastore(cln::ListdatastoreRequest), diff --git a/libs/gl-client/src/signer/resolve.rs b/libs/gl-client/src/signer/resolve.rs index 1bb404981..9259015fb 100644 --- a/libs/gl-client/src/signer/resolve.rs +++ b/libs/gl-client/src/signer/resolve.rs @@ -99,7 +99,7 @@ impl Resolver { // Manually calling preapproveinvoice should // always be allowed. The bolt11 string have to // match. - l.invstring.0 == r.bolt11.as_bytes() + l.invstring.0 == r.bolt11().as_bytes() } (_, _) => false, }; diff --git a/libs/gl-plugin/src/lib.rs b/libs/gl-plugin/src/lib.rs index f4b86a150..b40aa61b7 100644 --- a/libs/gl-plugin/src/lib.rs +++ b/libs/gl-plugin/src/lib.rs @@ -158,9 +158,12 @@ async fn on_peer_connected(plugin: Plugin, v: serde_json::Value) -> Result Result { debug!("Received an openchannel request: {:?}", v); let mut rpc = cln_rpc::ClnRpc::new(plugin.configuration().rpc_file).await?; - - let req = cln_rpc::model::requests::ListdatastoreRequest { - key: Some(vec!["glconf".to_string(), "request".to_string()]), + + let req = cln_rpc::model::requests::ListdatastoreRequest{ + key: Some(vec![ + "glconf".to_string(), + "request".to_string(), + ]) }; let res = rpc.call_typed(&req).await; @@ -171,17 +174,13 @@ async fn on_openchannel(plugin: Plugin, v: serde_json::Value) -> Result { - match _parse_gl_config_from_serialized_request( - serialized_request.to_string(), - ) { + match _parse_gl_config_from_serialized_request(serialized_request.to_string()) { Some(gl_config) => { - return Ok( - json!({"result": "continue", "close_to": gl_config.close_to_addr}), - ); + return Ok(json!({"result": "continue", "close_to": gl_config.close_to_addr})); } None => { debug!("Failed to parse the GlConfig from the serialized request's payload"); - } + } } } None => { @@ -190,13 +189,10 @@ async fn on_openchannel(plugin: Plugin, v: serde_json::Value) -> Result { - log::debug!( - "An error occurred while searching for a custom close_to address: {}", - e - ); + log::debug!("An error occurred while searching for a custom close_to address: {}", e); Ok(json!({"result": "continue"})) } } diff --git a/libs/gl-plugin/src/node/mod.rs b/libs/gl-plugin/src/node/mod.rs index f77b500bd..675b8ebc7 100644 --- a/libs/gl-plugin/src/node/mod.rs +++ b/libs/gl-plugin/src/node/mod.rs @@ -58,7 +58,6 @@ pub struct PluginNodeServer { pub rpc: Arc>, rpc_path: PathBuf, events: tokio::sync::broadcast::Sender, - notifications: tokio::sync::broadcast::Sender, signer_state: Arc>, grpc_binding: String, signer_state_store: Arc>>, @@ -99,8 +98,6 @@ impl PluginNodeServer { let rrpc = rpc.clone(); - let (notifications, _) = tokio::sync::broadcast::channel(1); - let s = PluginNodeServer { ctx, tls, @@ -111,7 +108,6 @@ impl PluginNodeServer { signer_state: Arc::new(Mutex::new(signer_state)), signer_state_store: Arc::new(Mutex::new(signer_state_store)), grpc_binding: config.node_grpc_binding, - notifications, }; tokio::spawn(async move { diff --git a/libs/gl-plugin/src/node/wrapper.rs b/libs/gl-plugin/src/node/wrapper.rs index 69f55979f..1b944b0eb 100644 --- a/libs/gl-plugin/src/node/wrapper.rs +++ b/libs/gl-plugin/src/node/wrapper.rs @@ -2,8 +2,6 @@ use crate::LightningClient; use anyhow::Error; use cln_grpc::pb::{self, node_server::Node}; use log::debug; -use tokio::sync::mpsc; -use tokio_stream::{wrappers::ReceiverStream, StreamExt}; use tonic::{Request, Response, Status}; use super::PluginNodeServer; @@ -22,8 +20,7 @@ pub struct WrappedNodeServer { // TODO Make node into a module and add the WrappedNodeServer as a submodule. impl WrappedNodeServer { pub async fn new(node_server: PluginNodeServer) -> anyhow::Result { - let inner = - cln_grpc::Server::new(&node_server.rpc_path, node_server.notifications.clone()).await?; + let inner = cln_grpc::Server::new(&node_server.rpc_path).await?; Ok(WrappedNodeServer { inner, node_server }) } } @@ -32,6 +29,73 @@ impl WrappedNodeServer { // already... #[tonic::async_trait] impl Node for WrappedNodeServer { + async fn invoice( + &self, + req: Request, + ) -> Result, Status> { + let req = req.into_inner(); + + use crate::rpc::LightningClient; + let mut rpc = LightningClient::new(self.node_server.rpc_path.clone()); + + // First we get the incoming channels so we can force them to + // be added to the invoice. This is best effort and will be + // left out if the call fails, reverting to the default + // behavior. + let hints: Option>> = self + .get_routehints(&mut rpc) + .await + .map( + // Map Result to Result + |v| { + v.into_iter() + .map( + // map each vector element + |rh| rh.hops, + ) + .collect() + }, + ) + .ok(); + + let mut pbreq: crate::requests::Invoice = match req.clone().try_into() { + Ok(v) => v, + Err(e) => { + return Err(Status::new( + tonic::Code::Internal, + format!( + "could not convert protobuf request into JSON-RPC request: {:?}", + e.to_string() + ), + )); + } + }; + pbreq.dev_routes = hints.map(|v| { + v.into_iter() + .map(|e| e.into_iter().map(|ee| ee.into()).collect()) + .collect() + }); + + pbreq.cltv = match pbreq.cltv { + Some(c) => Some(c), // Keep any set value + None => Some(144), // Use a day if not set + }; + + let res: Result = + rpc.call("invoice", pbreq).await; + + let res: Result = res + .map(|r| cln_grpc::pb::InvoiceResponse::from(r)) + .map_err(|e| { + tonic::Status::new( + tonic::Code::Internal, + format!("converting invoice response to grpc: {}", e), + ) + }); + + res.map(|r| Response::new(r)) + } + async fn getinfo( &self, r: Request, @@ -39,6 +103,27 @@ impl Node for WrappedNodeServer { self.inner.getinfo(r).await } + async fn list_offers( + &self, + r: Request, + ) -> Result, Status> { + self.inner.list_offers(r).await + } + + async fn offer( + &self, + r: Request, + ) -> Result, Status> { + self.inner.offer(r).await + } + + async fn bkpr_list_income( + &self, + r: Request, + ) -> Result, Status> { + self.inner.bkpr_list_income(r).await + } + async fn list_peers( &self, r: Request, @@ -46,6 +131,20 @@ impl Node for WrappedNodeServer { self.inner.list_peers(r).await } + async fn list_peer_channels( + &self, + r: Request, + ) -> Result, Status> { + self.inner.list_peer_channels(r).await + } + + async fn list_closed_channels( + &self, + r: Request, + ) -> Result, Status> { + self.inner.list_closed_channels(r).await + } + async fn list_funds( &self, r: Request, @@ -53,6 +152,47 @@ impl Node for WrappedNodeServer { self.inner.list_funds(r).await } + async fn decode_pay( + &self, + r: Request, + ) -> Result, Status> { + self.inner.decode_pay(r).await + } + + async fn decode( + &self, + r: Request, + ) -> Result, Status> { + self.inner.decode(r).await + } + + async fn sign_invoice( + &self, + r: Request, + ) -> Result, Status> { + self.inner.sign_invoice(r).await + } + async fn pre_approve_keysend( + &self, + r: Request, + ) -> Result, Status> { + self.inner.pre_approve_keysend(r).await + } + + async fn pre_approve_invoice( + &self, + r: Request, + ) -> Result, Status> { + self.inner.pre_approve_invoice(r).await + } + + async fn send_custom_msg( + &self, + r: Request, + ) -> Result, Status> { + self.inner.send_custom_msg(r).await + } + async fn send_pay( &self, r: Request, @@ -74,13 +214,6 @@ impl Node for WrappedNodeServer { self.inner.add_gossip(r).await } - async fn add_psbt_output( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.add_psbt_output(r).await - } - async fn auto_clean_invoice( &self, r: Request, @@ -88,20 +221,6 @@ impl Node for WrappedNodeServer { self.inner.auto_clean_invoice(r).await } - async fn auto_clean_once( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.auto_clean_once(r).await - } - - async fn auto_clean_status( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.auto_clean_status(r).await - } - async fn check_message( &self, r: Request, @@ -115,6 +234,7 @@ impl Node for WrappedNodeServer { ) -> Result, Status> { self.inner.close(r).await } + async fn connect_peer( &self, r: Request, @@ -136,13 +256,6 @@ impl Node for WrappedNodeServer { self.inner.datastore(r).await } - async fn datastore_usage( - &self, - r: Request, - ) -> Result, Status> { - self.inner.datastore_usage(r).await - } - async fn create_onion( &self, r: Request, @@ -157,6 +270,13 @@ impl Node for WrappedNodeServer { self.inner.del_datastore(r).await } + async fn del_expired_invoice( + &self, + r: Request, + ) -> Result, Status> { + self.inner.del_expired_invoice(r).await + } + async fn del_invoice( &self, r: Request, @@ -164,126 +284,6 @@ impl Node for WrappedNodeServer { self.inner.del_invoice(r).await } - /// Is unimplemented as it is a dev command that is dangerous to use. - async fn dev_forget_channel( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "dev commands are not activated on greenlight", - )) - } - - async fn emergency_recover( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.emergency_recover(r).await - } - - async fn recover( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.recover(r).await - } - - async fn recover_channel( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.recover_channel(r).await - } - - async fn invoice( - &self, - req: Request, - ) -> Result, Status> { - let req = req.into_inner(); - - use crate::rpc::LightningClient; - let mut rpc = LightningClient::new(self.node_server.rpc_path.clone()); - - // First we get the incoming channels so we can force them to - // be added to the invoice. This is best effort and will be - // left out if the call fails, reverting to the default - // behavior. - let hints: Option>> = self - .get_routehints(&mut rpc) - .await - .map( - // Map Result to Result - |v| { - v.into_iter() - .map( - // map each vector element - |rh| rh.hops, - ) - .collect() - }, - ) - .ok(); - - let mut pbreq: crate::requests::Invoice = match req.clone().try_into() { - Ok(v) => v, - Err(e) => { - return Err(Status::new( - tonic::Code::Internal, - format!( - "could not convert protobuf request into JSON-RPC request: {:?}", - e.to_string() - ), - )); - } - }; - pbreq.dev_routes = hints.map(|v| { - v.into_iter() - .map(|e| e.into_iter().map(|ee| ee.into()).collect()) - .collect() - }); - - pbreq.cltv = match pbreq.cltv { - Some(c) => Some(c), // Keep any set value - None => Some(144), // Use a day if not set - }; - - let res: Result = - rpc.call("invoice", pbreq).await; - - let res: Result = res - .map(|r| cln_grpc::pb::InvoiceResponse::from(r)) - .map_err(|e| { - tonic::Status::new( - tonic::Code::Internal, - format!("converting invoice response to grpc: {}", e), - ) - }); - - res.map(|r| Response::new(r)) - } - - async fn create_invoice_request( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.create_invoice_request(r).await - } - - async fn disable_invoice_request( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.disable_invoice_request(r).await - } - - async fn list_invoice_requests( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.list_invoice_requests(r).await - } - async fn list_datastore( &self, r: Request, @@ -319,17 +319,6 @@ impl Node for WrappedNodeServer { self.inner.list_transactions(r).await } - // Is unimplemented as greenlight uses a custom signer. - async fn make_secret( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "make_secret is disabled on greenlight", - )) - } - async fn pay(&self, r: Request) -> Result, Status> { self.inner.pay(r).await } @@ -362,6 +351,13 @@ impl Node for WrappedNodeServer { self.inner.wait_send_pay(r).await } + async fn wait_block_height( + &self, + r: Request, + ) -> Result, Status> { + self.inner.wait_block_height(r).await + } + async fn new_addr( &self, r: Request, @@ -432,55 +428,6 @@ impl Node for WrappedNodeServer { self.inner.tx_send(r).await } - async fn list_peer_channels( - &self, - r: Request, - ) -> Result, Status> { - self.inner.list_peer_channels(r).await - } - - async fn list_closed_channels( - &self, - r: Request, - ) -> Result, Status> { - self.inner.list_closed_channels(r).await - } - - async fn decode_pay( - &self, - r: Request, - ) -> Result, Status> { - self.inner.decode_pay(r).await - } - - async fn decode( - &self, - r: Request, - ) -> Result, Status> { - self.inner.decode(r).await - } - - async fn del_pay( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.del_pay(r).await - } - - async fn del_forward( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.del_forward(r).await - } - - async fn disable_offer( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.disable_offer(r).await - } - async fn disconnect( &self, r: Request, @@ -515,27 +462,6 @@ impl Node for WrappedNodeServer { self.inner.feerates(r).await } - async fn fetch_invoice( - &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - self.inner.fetch_invoice(request).await - } - - async fn fund_channel_cancel( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.fund_channel_cancel(r).await - } - - async fn fund_channel_complete( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.fund_channel_complete(r).await - } - async fn fund_channel( &self, r: Request, @@ -543,27 +469,6 @@ impl Node for WrappedNodeServer { self.inner.fund_channel(r).await } - async fn fund_channel_start( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.fund_channel_start(r).await - } - - async fn get_log( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.get_log(r).await - } - - async fn funder_update( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.funder_update(r).await - } - async fn get_route( &self, r: Request, @@ -578,13 +483,6 @@ impl Node for WrappedNodeServer { self.inner.list_forwards(r).await } - async fn list_offers( - &self, - r: Request, - ) -> Result, Status> { - self.inner.list_offers(r).await - } - async fn list_pays( &self, r: Request, @@ -592,69 +490,6 @@ impl Node for WrappedNodeServer { self.inner.list_pays(r).await } - async fn list_htlcs( - &self, - r: Request, - ) -> Result, Status> { - self.inner.list_htlcs(r).await - } - - async fn multi_fund_channel( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.multi_fund_channel(r).await - } - - async fn multi_withdraw( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.multi_withdraw(r).await - } - - async fn offer( - &self, - r: Request, - ) -> Result, Status> { - self.inner.offer(r).await - } - - async fn open_channel_abort( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.open_channel_abort(r).await - } - - async fn open_channel_bump( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.open_channel_bump(r).await - } - - async fn open_channel_init( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.open_channel_init(r).await - } - - async fn open_channel_signed( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.open_channel_signed(r).await - } - - async fn open_channel_update( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.open_channel_update(r).await - } - async fn ping( &self, r: Request, @@ -662,69 +497,6 @@ impl Node for WrappedNodeServer { self.inner.ping(r).await } - /// Is unimplemented as greenlight does not support plugins. - async fn plugin( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "plugins are not supported on greenlight", - )) - } - - /// Is unimplemented as rene_pay is still experimental and under - /// development. - async fn rene_pay_status( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "rene_pay_status is dissabled on greenlight", - )) - } - - /// Is unimplemented as rene_pay is still experimental and under - /// development. - async fn rene_pay( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "rene_pay is dissabled on greenlight", - )) - } - - async fn reserve_inputs( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.reserve_inputs(r).await - } - - async fn send_custom_msg( - &self, - r: Request, - ) -> Result, Status> { - self.inner.send_custom_msg(r).await - } - - async fn send_invoice( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.send_invoice(r).await - } - - async fn send_onion_message( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.send_onion_message(r).await - } - async fn set_channel( &self, r: Request, @@ -732,31 +504,6 @@ impl Node for WrappedNodeServer { self.inner.set_channel(r).await } - /// Is unimplemented as the config is set by greenlight. - async fn set_config( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "set_config is dissabled on greenlight", - )) - } - - async fn set_psbt_version( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.set_psbt_version(r).await - } - - async fn sign_invoice( - &self, - r: Request, - ) -> Result, Status> { - self.inner.sign_invoice(r).await - } - async fn sign_message( &self, r: Request, @@ -764,82 +511,6 @@ impl Node for WrappedNodeServer { self.inner.sign_message(r).await } - /// Is unimplemented as splicing it is still experimental. - async fn splice_init( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "splice_init is dissabled on greenlight", - )) - } - - /// Is unimplemented as splicing it is still experimental. - async fn splice_signed( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "splice_signed is dissabled on greenlight", - )) - } - - /// Is unimplemented as splicing it is still experimental. - async fn splice_update( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "splice_update is dissabled on greenlight", - )) - } - - async fn unreserve_inputs( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.unreserve_inputs(r).await - } - - /// Is unimplemented as greenlight does not have ps2h outputs. - async fn upgrade_wallet( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "upgrade_wallet is dissabled on greenlight", - )) - } - - async fn wait_block_height( - &self, - r: Request, - ) -> Result, Status> { - self.inner.wait_block_height(r).await - } - - async fn wait( - &self, - request: tonic::Request, - ) -> Result, tonic::Status> { - self.inner.wait(request).await - } - - /// Is unimplemented as greenlight sets the config. - async fn list_configs( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "list_configs is dissabled on greenlight", - )) - } - async fn stop( &self, r: Request, @@ -847,27 +518,6 @@ impl Node for WrappedNodeServer { self.inner.stop(r).await } - async fn help( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.help(r).await - } - - async fn pre_approve_keysend( - &self, - r: Request, - ) -> Result, Status> { - self.inner.pre_approve_keysend(r).await - } - - async fn pre_approve_invoice( - &self, - r: Request, - ) -> Result, Status> { - self.inner.pre_approve_invoice(r).await - } - async fn static_backup( &self, r: Request, @@ -875,263 +525,32 @@ impl Node for WrappedNodeServer { self.inner.static_backup(r).await } - async fn bkpr_channels_apy( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.bkpr_channels_apy(r).await - } - - async fn bkpr_dump_income_csv( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.bkpr_dump_income_csv(r).await - } - - async fn bkpr_inspect( - &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.bkpr_inspect(r).await - } - - async fn bkpr_list_account_events( + async fn list_htlcs( &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.bkpr_list_account_events(r).await + r: Request, + ) -> Result, Status> { + self.inner.list_htlcs(r).await } - async fn bkpr_list_balances( + async fn datastore_usage( &self, - r: tonic::Request, - ) -> Result, Status> { - self.inner.bkpr_list_balances(r).await + r: Request, + ) -> Result, Status> { + self.inner.datastore_usage(r).await } - async fn bkpr_list_income( + async fn fetch_invoice( &self, - r: Request, - ) -> Result, Status> { - self.inner.bkpr_list_income(r).await - } - - /// Is unimplemented as runes need to be handled by gl-signer in - /// greenlight. - async fn blacklist_rune( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "blacklist_rune is dissabled on greenlight", - )) - } - - /// Is unimplemented as runes need to be handled by gl-signer in - /// greenlight. - async fn check_rune( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "check_rune is dissabled on greenlight", - )) - } - - /// Is unimplemented as runes need to be handled by gl-signer in - /// greenlight. - async fn create_rune( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "create_rune is dissabled on greenlight", - )) - } - - /// Is unimplemented as runes need to be handled by gl-signer in - /// greenlight. - async fn show_runes( - &self, - _: tonic::Request, - ) -> Result, Status> { - Err(Status::new( - tonic::Code::Unimplemented, - "show_runes is dissabled on greenlight", - )) - } - - type SubscribeBlockAddedStream = - ReceiverStream>; - - async fn subscribe_block_added( - &self, - r: tonic::Request, - ) -> Result, Status> { - // Fixme in cln_grpc (nepet): - // Workaround since the custom type NotificationStream is not - // publically accessible and can not be set as - // `type SubscribeBlockAddedStream`. - let mut inner_stream = self.inner.subscribe_block_added(r).await?.into_inner(); - let (tx, rx) = mpsc::channel(10); - - tokio::spawn(async move { - while let Some(result) = inner_stream.next().await { - let msg = match result { - Ok(note) => Ok(note), - Err(e) => { - debug!("got an error listening to block_added notifications {e}"); - Err(e) - } - }; - if let Err(e) = tx.send(msg.clone()).await { - debug!("failed to send notification {:?} to client {}", msg, e); - return; - }; - } - }); - - Ok(tonic::Response::new(rx.into())) + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.fetch_invoice(request).await } - type SubscribeChannelOpenFailedStream = - ReceiverStream>; - - async fn subscribe_channel_open_failed( + async fn wait( &self, - r: tonic::Request, - ) -> Result, Status> { - // Fixme in cln_grpc (nepet): - // Workaround since the custom type NotificationStream is not - // publically accessible and can not be set as - // `type SubscribeChannelOpenFailedStream`. - let mut inner_stream = self - .inner - .subscribe_channel_open_failed(r) - .await? - .into_inner(); - let (tx, rx) = mpsc::channel(10); - - tokio::spawn(async move { - while let Some(result) = inner_stream.next().await { - let msg = match result { - Ok(note) => Ok(note), - Err(e) => { - debug!("got an error listening to channel_open_failed notifications {e}"); - Err(e) - } - }; - if let Err(e) = tx.send(msg.clone()).await { - debug!("failed to send notification {:?} to client {}", msg, e); - return; - }; - } - }); - - Ok(tonic::Response::new(rx.into())) - } - - type SubscribeChannelOpenedStream = - ReceiverStream>; - - async fn subscribe_channel_opened( - &self, - r: tonic::Request, - ) -> Result, Status> { - // Fixme in cln_grpc (nepet): - // Workaround since the custom type NotificationStream is not - // publically accessible and can not be set as - // `type SubscribeChannelOpenedStream`. - let mut inner_stream = self.inner.subscribe_channel_opened(r).await?.into_inner(); - let (tx, rx) = mpsc::channel(10); - - tokio::spawn(async move { - while let Some(result) = inner_stream.next().await { - let msg = match result { - Ok(note) => Ok(note), - Err(e) => { - debug!("got an error listening to channel_opened notifications {e}"); - Err(e) - } - }; - if let Err(e) = tx.send(msg.clone()).await { - debug!("failed to send notification {:?} to client {}", msg, e); - return; - }; - } - }); - - Ok(tonic::Response::new(rx.into())) - } - - type SubscribeConnectStream = - ReceiverStream>; - - async fn subscribe_connect( - &self, - r: tonic::Request, - ) -> Result, Status> { - // Fixme in cln_grpc (nepet): - // Workaround since the custom type NotificationStream is not - // publically accessible and can not be set as - // `type SubscribeConnectStream`. - let mut inner_stream = self.inner.subscribe_connect(r).await?.into_inner(); - let (tx, rx) = mpsc::channel(10); - - tokio::spawn(async move { - while let Some(result) = inner_stream.next().await { - let msg = match result { - Ok(note) => Ok(note), - Err(e) => { - debug!("got an error listening to connect notifications {e}"); - Err(e) - } - }; - if let Err(e) = tx.send(msg.clone()).await { - debug!("failed to send notification {:?} to client {}", msg, e); - return; - }; - } - }); - - Ok(tonic::Response::new(rx.into())) - } - - type SubscribeCustomMsgStream = - ReceiverStream>; - - async fn subscribe_custom_msg( - &self, - r: tonic::Request, - ) -> Result, Status> { - // Fixme in cln_grpc (nepet): - // Workaround since the custom type NotificationStream is not - // publically accessible and can not be set as - // `type SubscribeCustomMsgStream`. - let mut inner_stream = self.inner.subscribe_custom_msg(r).await?.into_inner(); - let (tx, rx) = mpsc::channel(10); - - tokio::spawn(async move { - while let Some(result) = inner_stream.next().await { - let msg = match result { - Ok(note) => Ok(note), - Err(e) => { - debug!("got an error listening to custom_msg notifications {e}"); - Err(e) - } - }; - if let Err(e) = tx.send(msg.clone()).await { - debug!("failed to send notification {:?} to client {}", msg, e); - return; - }; - } - }); - - Ok(tonic::Response::new(rx.into())) + request: tonic::Request, + ) -> Result, tonic::Status> { + self.inner.wait(request).await } } @@ -1204,7 +623,7 @@ impl WrappedNodeServer { pb::Routehint { hops: vec![pb::RouteHop { id: hex::decode(i.id).expect("hex-decoding node_id"), - scid: aliases + short_channel_id: aliases .get(&i.short_channel_id) .or(Some(&i.short_channel_id)) .unwrap() @@ -1223,6 +642,7 @@ use crate::pb::{ node_server::Node as GlNode, Custommsg, Empty, HsmRequest, HsmResponse, IncomingPayment, LogEntry, StreamCustommsgRequest, StreamIncomingFilter, StreamLogRequest, }; +use tokio_stream::wrappers::ReceiverStream; #[tonic::async_trait] impl GlNode for WrappedNodeServer { diff --git a/libs/gl-plugin/src/pb.rs b/libs/gl-plugin/src/pb.rs index a99ac7db3..1e8886bbb 100644 --- a/libs/gl-plugin/src/pb.rs +++ b/libs/gl-plugin/src/pb.rs @@ -753,7 +753,7 @@ impl From for requests::RoutehintHopDev { fn from(r: RouteHop) -> requests::RoutehintHopDev { requests::RoutehintHopDev { id: hex::encode(r.id), - short_channel_id: r.scid, + short_channel_id: r.short_channel_id, fee_base_msat: r.feebase.map(|f| f.msat).unwrap(), fee_proportional_millionths: r.feeprop, cltv_expiry_delta: r.expirydelta as u16,