Crates.io | fedimint-ldk-node |
lib.rs | fedimint-ldk-node |
version | 0.1.0 |
source | src |
created_at | 2023-11-25 10:16:05.884778 |
updated_at | 2023-11-25 10:16:05.884778 |
description | A ready-to-go node implementation built using LDK. |
homepage | https://lightningdevkit.org/ |
repository | https://github.com/lightningdevkit/ldk-node/ |
max_upload_size | |
id | 1048182 |
size | 605,944 |
A ready-to-go Lightning node library built using LDK and BDK.
LDK Node is a self-custodial Lightning node in library form. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily set up and run a Lightning node with an integrated on-chain wallet. While minimalism is at its core, LDK Node aims to be sufficiently modular and configurable to be useful for a variety of use cases.
The primary abstraction of the library is the Node
, which can be retrieved by setting up and configuring a Builder
to your liking and calling one of the build
methods. Node
can then be controlled via commands such as start
, stop
, connect_open_channel
, send_payment
, etc.
use ldk_node::{Builder, NetAddress};
use ldk_node::lightning_invoice::Invoice;
use ldk_node::bitcoin::secp256k1::PublicKey;
use ldk_node::bitcoin::Network;
use std::str::FromStr;
fn main() {
let mut builder = Builder::new();
builder.set_network(Network::Testnet);
builder.set_esplora_server("https://blockstream.info/testnet/api".to_string());
builder.set_gossip_source_rgs("https://rapidsync.lightningdevkit.org/testnet/snapshot".to_string());
let node = builder.build().unwrap();
node.start().unwrap();
let funding_address = node.new_onchain_address();
// .. fund address ..
let node_id = PublicKey::from_str("NODE_ID").unwrap();
let node_addr = NetAddress::from_str("IP_ADDR:PORT").unwrap();
node.connect_open_channel(node_id, node_addr, 10000, None, None, false).unwrap();
let event = node.wait_next_event();
println!("EVENT: {:?}", event);
node.event_handled();
let invoice = Invoice::from_str("INVOICE_STR").unwrap();
node.send_payment(&invoice).unwrap();
node.stop().unwrap();
}
LDK Node currently comes with a decidedly opinionated set of design choices:
bitcoind
RPC will follow soon.LDK Node itself is written in Rust and may therefore be natively added as a library dependency to any std
Rust program. However, beyond its Rust API it also offers language bindings for Swift, Kotlin, and Python based on the UniFFI. Moreover, Flutter bindings are also available.
The Minimum Supported Rust Version (MSRV) is currently 1.60.0.