Skip to content

Commit

Permalink
Add partial CLN support with potential for others in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpp committed Jul 16, 2024
1 parent f7c050a commit eb472a7
Show file tree
Hide file tree
Showing 8 changed files with 864 additions and 320 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ axum-extra = { version = "0.9.3", features = ["cookie"] }
axum_typed_multipart = "0.11.0"
tempfile = "3.10.1"
tower-http = { version = "0.5.2", features = ["fs", "cors"] }
async-trait = "0.1.81"

[build-dependencies]
configure_me_codegen = "0.4.1"
32 changes: 21 additions & 11 deletions config_spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ name = "sound_dir"
type = "String"
doc = "The location to store boost sounds."

[[param]]
name = "macaroon"
type = "String"
doc = "The location of the macaroon file."

[[param]]
name = "cert"
type = "String"
doc = "The location of the tls certificate file."

[[param]]
name = "listen_port"
type = "u16"
Expand All @@ -31,4 +21,24 @@ doc = "The password to use to access Helipad."
[[param]]
name = "lnd_url"
type = "String"
doc = "The url and port of the LND grpc api."
doc = "The url and port of the LND grpc api."

[[param]]
name = "macaroon"
type = "String"
doc = "The location of the LND macaroon file."

[[param]]
name = "cert"
type = "String"
doc = "The location of the LND tls certificate file."

[[param]]
name = "cln_rest_url"
type = "String"
doc = "The url and port of the CLN REST API (e.g. localhost:3001)."

[[param]]
name = "cln_rest_rune_path"
type = "String"
doc = "The location of the CLN REST Rune."
12 changes: 8 additions & 4 deletions src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use std::string::String;
use url::Url;
use tempfile::NamedTempFile;

use crate::lnclient;

//Structs and Enums ------------------------------------------------------------------------------------------
#[derive(Debug, Serialize, Deserialize)]
struct JwtClaims {
Expand Down Expand Up @@ -461,10 +463,12 @@ pub async fn api_v1_reply(
});

let helipad_config = state.helipad_config.clone();
let lightning = match lightning::connect_to_lnd(helipad_config.node_address, helipad_config.cert_path, helipad_config.macaroon_path).await {
Some(lndconn) => lndconn,
None => {
return (StatusCode::INTERNAL_SERVER_ERROR, "** Error connecting to LND.").into_response();

let lightning = match lnclient::connect(&helipad_config).await {
Ok(conn) => conn,
Err(e) => {
eprintln!("** Error connecting to node: {}", e);
return (StatusCode::INTERNAL_SERVER_ERROR, "** Error connecting to node.").into_response();
}
};

Expand Down
Loading

0 comments on commit eb472a7

Please sign in to comment.