diff --git a/libs/gl-client-py/glclient/__init__.py b/libs/gl-client-py/glclient/__init__.py index 6270edc4e..f714de6f8 100644 --- a/libs/gl-client-py/glclient/__init__.py +++ b/libs/gl-client-py/glclient/__init__.py @@ -113,9 +113,7 @@ def __init__(self, node_id: bytes, network: str, grpc_uri: str, creds: Credentia node_id=node_id, network=network, grpc_uri=grpc_uri, - tls=None, - rune=None, - creds=creds.to_bytes() + creds=creds._inner ) self.logger = logging.getLogger("glclient.Node") diff --git a/libs/gl-client-py/glclient/glclient.pyi b/libs/gl-client-py/glclient/glclient.pyi index 88c70b98f..8dbc1ad45 100644 --- a/libs/gl-client-py/glclient/glclient.pyi +++ b/libs/gl-client-py/glclient/glclient.pyi @@ -67,9 +67,7 @@ class Node: node_id: bytes, network: str, grpc_uri: str, - tls: Optional[TlsConfig] = None, - rune: Optional[str] = None, - creds: Optional[bytes] = None + creds: Credentials, ) -> None: ... def stop(self) -> None: ... def call(self, method: str, request: bytes) -> bytes: ... diff --git a/libs/gl-client-py/glclient/rpc.py b/libs/gl-client-py/glclient/rpc.py index 35bb9ca30..f4b9ca36a 100644 --- a/libs/gl-client-py/glclient/rpc.py +++ b/libs/gl-client-py/glclient/rpc.py @@ -1,6 +1,7 @@ # This file was generated by `genrpcstubs` from the CLN JSON-Schema. # Do not edit this file. from .tls import TlsConfig +from .credentials import Credentials from . import glclient as native import logging from pyln import grpc as clnpb @@ -11,16 +12,15 @@ def __init__( self, node_id: bytes, network: str, - tls: TlsConfig, - grpc_uri: str + grpc_uri: str, + creds: Credentials, ): - self.tls = tls self.grpc_uri = grpc_uri self.inner = native.Node( node_id=node_id, network=network, - tls=tls.inner, - grpc_uri=grpc_uri + grpc_uri=grpc_uri, + creds=creds._inner, ) self.logger = logging.getLogger("glclient.rpc.Node") diff --git a/libs/gl-client-py/src/node.rs b/libs/gl-client-py/src/node.rs index 506a4111b..4318bf929 100644 --- a/libs/gl-client-py/src/node.rs +++ b/libs/gl-client-py/src/node.rs @@ -1,6 +1,6 @@ use crate::lsps::LspClient; use crate::runtime::exec; -use crate::tls::TlsConfig; +use crate::Credentials; use gl_client as gl; use gl_client::bitcoin::Network; use gl_client::pb; @@ -23,40 +23,16 @@ impl Node { node_id: Vec, network: String, grpc_uri: String, - tls: Option, - rune: Option, - creds: Option>, + creds: &Credentials, ) -> PyResult { let network: Network = match network.parse() { Ok(v) => v, Err(_) => return Err(PyValueError::new_err("unknown network")), }; - - match creds { - Some(creds) => { - let creds = gl::credentials::Builder::from_bytes(&creds[..]) - .map_err(|e| PyValueError::new_err(e.to_string()))? - .build() - .map_err(|e| PyValueError::new_err(e.to_string()))?; - let mut node_builder = gl::node::Node::builder_from_creds(node_id, network, creds) - .map_err(|e| PyValueError::new_err(e.to_string()))?; - if let Some(tls) = tls { - node_builder = node_builder.with_tls(tls.inner); - } - if let Some(rune) = rune { - node_builder = node_builder.with_rune(&rune); - } - let inner = node_builder.build(); - return node_from_inner(inner, grpc_uri); - } - None => { - let tls = tls.ok_or(PyValueError::new_err("TLS configuration is missing"))?; - let rune = rune.ok_or(PyValueError::new_err("Rune is missing"))?; - let inner = - gl::node::Node::builder_from_parts(node_id, network, tls.inner, &rune).build(); - return node_from_inner(inner, grpc_uri); - } - }; + let tls = creds.tls_config()?; + let rune = creds.rune()?; + let inner = gl::node::Node::builder_from_parts(node_id, network, tls.inner, &rune).build(); + return node_from_inner(inner, grpc_uri); } fn call(&self, method: &str, payload: Vec) -> PyResult> {