Skip to content

Commit 0ca463a

Browse files
committed
Add CLN support with potential for others in the future
1 parent f7c050a commit 0ca463a

File tree

8 files changed

+875
-320
lines changed

8 files changed

+875
-320
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ axum-extra = { version = "0.9.3", features = ["cookie"] }
3333
axum_typed_multipart = "0.11.0"
3434
tempfile = "3.10.1"
3535
tower-http = { version = "0.5.2", features = ["fs", "cors"] }
36+
async-trait = "0.1.81"
3637

3738
[build-dependencies]
3839
configure_me_codegen = "0.4.1"

config_spec.toml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ name = "sound_dir"
88
type = "String"
99
doc = "The location to store boost sounds."
1010

11-
[[param]]
12-
name = "macaroon"
13-
type = "String"
14-
doc = "The location of the macaroon file."
15-
16-
[[param]]
17-
name = "cert"
18-
type = "String"
19-
doc = "The location of the tls certificate file."
20-
2111
[[param]]
2212
name = "listen_port"
2313
type = "u16"
@@ -31,4 +21,24 @@ doc = "The password to use to access Helipad."
3121
[[param]]
3222
name = "lnd_url"
3323
type = "String"
34-
doc = "The url and port of the LND grpc api."
24+
doc = "The url and port of the LND grpc api."
25+
26+
[[param]]
27+
name = "macaroon"
28+
type = "String"
29+
doc = "The location of the LND macaroon file."
30+
31+
[[param]]
32+
name = "cert"
33+
type = "String"
34+
doc = "The location of the LND tls certificate file."
35+
36+
[[param]]
37+
name = "cln_rest_url"
38+
type = "String"
39+
doc = "The url and port of the CLN REST API (e.g. localhost:3001)."
40+
41+
[[param]]
42+
name = "cln_rest_rune_path"
43+
type = "String"
44+
doc = "The location of the CLN REST Rune."

src/handler.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ use std::string::String;
2525
use url::Url;
2626
use tempfile::NamedTempFile;
2727

28+
use crate::lnclient;
29+
2830
//Structs and Enums ------------------------------------------------------------------------------------------
2931
#[derive(Debug, Serialize, Deserialize)]
3032
struct JwtClaims {
@@ -461,10 +463,12 @@ pub async fn api_v1_reply(
461463
});
462464

463465
let helipad_config = state.helipad_config.clone();
464-
let lightning = match lightning::connect_to_lnd(helipad_config.node_address, helipad_config.cert_path, helipad_config.macaroon_path).await {
465-
Some(lndconn) => lndconn,
466-
None => {
467-
return (StatusCode::INTERNAL_SERVER_ERROR, "** Error connecting to LND.").into_response();
466+
467+
let lightning = match lnclient::connect(&helipad_config).await {
468+
Ok(conn) => conn,
469+
Err(e) => {
470+
eprintln!("** Error connecting to node: {}", e);
471+
return (StatusCode::INTERNAL_SERVER_ERROR, "** Error connecting to node.").into_response();
468472
}
469473
};
470474

0 commit comments

Comments
 (0)