Skip to content

Commit

Permalink
chore: Upgrade cln_rpc and cln_grpc to 0.1.9
Browse files Browse the repository at this point in the history
We need to upgrade cln_rpc and cln_grpc as they contain the senpay
parameter `payment_metadata` that is needed for future applications.

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed Jun 28, 2024
1 parent 57f404e commit d2f8ac2
Show file tree
Hide file tree
Showing 10 changed files with 789 additions and 211 deletions.
13 changes: 9 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ members = [
[workspace.dependencies]
anyhow = "1"
env_logger = "0.10"
cln-grpc = "=0.1.8"
cln-rpc = "0.1.8"
cln-grpc = "0.1.9"
cln-rpc = "0.1.9"
cln-plugin = "0.1.8"

vls-core = "^0.11.0"
Expand Down
13 changes: 0 additions & 13 deletions libs/gl-client-py/glclient/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,6 @@ 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,
Expand Down
1 change: 0 additions & 1 deletion libs/gl-client/src/signer/model/cln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub fn decode_request(uri: &str, p: &[u8]) -> anyhow::Result<Request> {
"/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)?),
Expand Down
1 change: 0 additions & 1 deletion libs/gl-client/src/signer/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub enum Request {
Datastore(cln::DatastoreRequest),
CreateOnion(cln::CreateonionRequest),
DelDatastore(cln::DeldatastoreRequest),
DelExpiredInvoice(cln::DelexpiredinvoiceRequest),
DelInvoice(cln::DelinvoiceRequest),
Invoice(cln::InvoiceRequest),
ListDatastore(cln::ListdatastoreRequest),
Expand Down
2 changes: 1 addition & 1 deletion libs/gl-client/src/signer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
26 changes: 15 additions & 11 deletions libs/gl-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,9 @@ async fn on_peer_connected(plugin: Plugin, v: serde_json::Value) -> Result<serde
async fn on_openchannel(plugin: Plugin, v: serde_json::Value) -> Result<serde_json::Value> {
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;
Expand All @@ -174,13 +171,17 @@ async fn on_openchannel(plugin: Plugin, v: serde_json::Value) -> Result<serde_js
if !res.datastore.is_empty() {
match &res.datastore[0].string {
Some(serialized_request) => {
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 => {
Expand All @@ -189,10 +190,13 @@ async fn on_openchannel(plugin: Plugin, v: serde_json::Value) -> Result<serde_js
}
}

return Ok(json!({"result": "continue"}))
return Ok(json!({"result": "continue"}));
}
Err(e) => {
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"}))
}
}
Expand Down
4 changes: 4 additions & 0 deletions libs/gl-plugin/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct PluginNodeServer {
pub rpc: Arc<Mutex<LightningClient>>,
rpc_path: PathBuf,
events: tokio::sync::broadcast::Sender<super::Event>,
notifications: tokio::sync::broadcast::Sender<cln_rpc::Notification>,
signer_state: Arc<Mutex<State>>,
grpc_binding: String,
signer_state_store: Arc<Mutex<Box<dyn StateStore>>>,
Expand Down Expand Up @@ -98,6 +99,8 @@ impl PluginNodeServer {

let rrpc = rpc.clone();

let (notifications, _) = tokio::sync::broadcast::channel(1);

let s = PluginNodeServer {
ctx,
tls,
Expand All @@ -108,6 +111,7 @@ 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 {
Expand Down
Loading

0 comments on commit d2f8ac2

Please sign in to comment.