Skip to content

Commit 69afaab

Browse files
committed
Add ldk-server backend support
Add `LdkServerNode` as a new `LightningNode` implementation ldk-server-client over gRPC-over-HTTPS. Supports keysend via `spontaneous_send`, payment tracking via polling `get_payment_details`, graph queries, and channel capacity reporting. Wire up `NodeConnection::LdkServer` in sim-cli parsing so ldk-server nodes can be specified in sim.json alongside LND, CLN, and Eclair nodes.
1 parent 66daf69 commit 69afaab

6 files changed

Lines changed: 484 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 146 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ lightning network development. It may be useful to you if you are:
1616
* LND ✅
1717
* CLN ✅
1818
* Eclair ✅️
19-
* LDK-node 🏗️
19+
* LDK-Server ✅
2020

2121
See our [tracking issue](https://github.com/bitcoin-dev-project/sim-ln/issues/26)
2222
for updates on implementation support (contributions welcome!).
@@ -36,6 +36,7 @@ of the simulator uses keysend to execute payments, which must be enabled as foll
3636
* LND: `--accept-keysend`
3737
* CLN: enabled by default
3838
* Eclair: `-Declair.features.keysend=optional` (or `--features.keysend=optional` if you're using Polar)
39+
* LDK-Server: enabled by default via `spontaneous_send`
3940

4041
NOTE: for CLN `keysend` to work with eclair, you need to add additional config to eclair:
4142
```
@@ -98,6 +99,23 @@ The required access details will depend on the node implementation.
9899
"api_password": <password_to_authorize>
99100
}
100101
```
102+
* LDK-Server:
103+
```
104+
{
105+
"address": <ip:port or domain:port>,
106+
"api_key": <hex_encoded_api_key>,
107+
"cert": <path_to_tls_cert>
108+
}
109+
```
110+
The `api_key` is the raw bytes of `~/.ldk-server/<network>/api_key` hex-encoded.
111+
Unlike other backends, ldk-server does not require an `id` field — the node's
112+
public key and network are fetched automatically on startup.
113+
114+
Note: ldk-server channels are **unannounced by default**. Pass `--announce-channel`
115+
to `open-channel` (and set `announcement_addresses` in the ldk-server config) to
116+
make channels public and visible to other nodes for routing. Also ldk-server enforces a minimum final CLTV expiry delta
117+
of **144 blocks** on inbound keysend payments. Ensure that sending nodes are configured with a sufficiently high final
118+
CLTV delta.
101119

102120
Payment activity can be simulated in two different ways:
103121
* [Random activity](#setup---random-activity): generate random activity on the `nodes` provided,
@@ -135,6 +153,11 @@ to send and receive payments when running with random activity.
135153
"base_url": "127.0.0.1:8286",
136154
"api_username": "",
137155
"api_password": "eclairpw"
156+
},
157+
{
158+
"address": "localhost:3536",
159+
"api_key": "ldk_server_hex_encoded_api_key",
160+
"cert": "/path/tls.crt"
138161
}
139162
]
140163
}

sim-cli/src/parsing.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use simln_lib::sim_node::{
99
SimGraph, SimNode, SimulatedChannel,
1010
};
1111
use simln_lib::{
12-
cln, cln::ClnNode, eclair, eclair::EclairNode, lnd, lnd::LndNode, serializers,
13-
ActivityDefinition, Amount, Interval, LightningError, LightningNode, NodeId, NodeInfo,
14-
Simulation, SimulationCfg, WriteResults,
12+
cln, cln::ClnNode, eclair, eclair::EclairNode, ldk_server, ldk_server::LdkServerNode, lnd,
13+
lnd::LndNode, serializers, ActivityDefinition, Amount, Interval, LightningError, LightningNode,
14+
NodeId, NodeInfo, Simulation, SimulationCfg, WriteResults,
1515
};
1616
use simln_lib::{ShortChannelID, SimulationError};
1717
use std::collections::HashMap;
@@ -160,6 +160,7 @@ pub enum NodeConnection {
160160
Lnd(lnd::LndConnection),
161161
Cln(cln::ClnConnection),
162162
Eclair(eclair::EclairConnection),
163+
LdkServer(ldk_server::LdkServerConnection),
163164
}
164165

165166
/// Data structure that is used to parse information from the simulation file. It is used to
@@ -396,6 +397,7 @@ async fn get_clients(
396397
NodeConnection::Lnd(c) => Arc::new(Mutex::new(LndNode::new(c).await?)),
397398
NodeConnection::Cln(c) => Arc::new(Mutex::new(ClnNode::new(c).await?)),
398399
NodeConnection::Eclair(c) => Arc::new(Mutex::new(EclairNode::new(c).await?)),
400+
NodeConnection::LdkServer(c) => Arc::new(Mutex::new(LdkServerNode::new(c).await?)),
399401
};
400402

401403
let node_info = node.lock().await.get_info().clone();

simln-lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ rand_distr = "0.4.3"
3333
rand_chacha = "0.3.1"
3434
reqwest = { version = "0.12", features = ["json", "multipart"] }
3535
tokio-util = { version = "0.7.13", features = ["rt"] }
36+
ldk-server-client = { git = "https://github.com/lightningdevkit/ldk-server", rev = "8163f4fe139368613959bf4f10b19ee6a5b9b4ab" }
3637

3738
[dev-dependencies]
3839
ntest = "0.9.0"

0 commit comments

Comments
 (0)