Skip to content

Commit 0df678a

Browse files
committed
Add initial README and crate-level docs
1 parent 8bc5c40 commit 0df678a

File tree

2 files changed

+100
-11
lines changed

2 files changed

+100
-11
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
11
# LDK Node
2-
A ready-to-go node implementation built using LDK.
2+
A ready-to-go Lightning node library built using [LDK](https://lightningdevkit.org/) and [BDK](https://bitcoindevkit.org/).
3+
4+
LDK Node is a non-custodial Lightning node in library form. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily setup 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.
5+
6+
## Getting Started
7+
8+
The main interface of the library is the `Node`, which can be retrieved by setting up and configuring a `Builder` to the user's liking and calling `built()`. `Node` can then be controlled via commands such as `start`,`stop`,`connect_open_channel`, `send_payment`, etc.:
9+
10+
```rust
11+
use ldk_node::Builder;
12+
use ldk_node::lightning_invoice::Invoice;
13+
use std::str::FromStr;
14+
15+
fn main() {
16+
let node = Builder::new()
17+
.set_network("testnet")
18+
.set_esplora_server_url("https://blockstream.info/testnet/api".to_string())
19+
.build();
20+
21+
node.start().unwrap();
22+
23+
let _funding_address = node.new_funding_address();
24+
25+
// .. fund address ..
26+
27+
node.sync_wallets().unwrap();
28+
29+
node.connect_open_channel("NODE_ID@PEER_ADDR:PORT", 10000, false).unwrap();
30+
31+
let invoice = Invoice::from_str("INVOICE_STR").unwrap();
32+
node.send_payment(invoice).unwrap();
33+
34+
node.stop().unwrap();
35+
}
36+
```
37+
38+
## Modularity
39+
40+
LDK Node currently comes with a decidedly opionated set of design choices:
41+
42+
- On-chain data is handled by the integrated BDK wallet.
43+
- Chain data is accessed via Esplora (support for Electrum and `bitcoind` RPC will follow)
44+
- Wallet and channel state is persisted to file system (support for SQLite will follow)
45+
- Gossip data is sourced via Lightnings peer-to-peer network (support for [Rapid Gossip Sync](https://docs.rs/lightning-rapid-gossip-sync/*/lightning_rapid_gossip_sync/) will follow)
46+
- Entropy for the Lightning and on-chain wallets may be generated and persisted for or provided by the user (support for [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) mnemonics will follow)
47+
48+
49+
## Language Support
50+
51+
LDK Node is written in [Rust](https://www.rust-lang.org/) and may therefore be natively included in any `std` Rust program. Beyond it's Rust API it also offers language bindings for Swift, Kotlin, and Python based on [UniFFI](https://github.com/mozilla/uniffi-rs/).

src/lib.rs

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,52 @@
99

1010
#![crate_name = "ldk_node"]
1111

12-
//! A library providing a simplified API for the Lightning Dev Kit. While LDK itself provides a
13-
//! highly configurable and adaptable interface, this API champions simplicity and ease of use over
14-
//! configurability. To this end, it provides an opionated set of design choices and ready-to-go
15-
//! default modules, while still enabling some configurability when dearly needed by the user:
16-
//! - Chain data is accessed through an Esplora client.
17-
//! - Wallet and channel states are persisted to disk.
18-
//! - Gossip is retrieved over the P2P network.
19-
12+
//! # LDK Node
13+
//! A ready-to-go Lightning node library built using [LDK](https://lightningdevkit.org/) and [BDK](https://bitcoindevkit.org/).
14+
//!
15+
//! LDK Node is a non-custodial Lightning node in library form. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily setup 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.
16+
//!
17+
//! ## Getting Started
18+
//!
19+
//! The main interface of the library is the [`Node`], which can be retrieved by setting up and
20+
//! configuring a [`Builder`] to the user's liking and calling [`build`]. `Node` can then be
21+
//! controlled via commands such as [`start`],[`stop`],[`connect_open_channel`], [`send_payment`],
22+
//! etc.:
23+
//!
24+
//! ```no_run
25+
//! use ldk_node::Builder;
26+
//! use ldk_node::lightning_invoice::Invoice;
27+
//! use std::str::FromStr;
28+
//!
29+
//! fn main() {
30+
//! let node = Builder::new()
31+
//! .set_network("testnet")
32+
//! .set_esplora_server_url("https://blockstream.info/testnet/api".to_string())
33+
//! .build();
34+
//!
35+
//! node.start().unwrap();
36+
//!
37+
//! let _funding_address = node.new_funding_address();
38+
//!
39+
//! // .. fund address ..
40+
//!
41+
//! node.sync_wallets().unwrap();
42+
//!
43+
//! node.connect_open_channel("NODE_ID@PEER_ADDR:PORT", 10000, false).unwrap();
44+
//!
45+
//! let invoice = Invoice::from_str("INVOICE_STR").unwrap();
46+
//! node.send_payment(invoice).unwrap();
47+
//!
48+
//! node.stop().unwrap();
49+
//! }
50+
//! ```
51+
//!
52+
//! [`build`]: Builder::build
53+
//! [`start`]: Node::start
54+
//! [`stop`]: Node::stop
55+
//! [`connect_open_channel`]: Node::connect_open_channel
56+
//! [`send_payment`]: Node::send_payment
57+
//!
2058
#![deny(missing_docs)]
2159
#![deny(broken_intra_doc_links)]
2260
#![deny(private_intra_doc_links)]
@@ -482,7 +520,7 @@ struct Runtime {
482520
stop_wallet_sync: Arc<AtomicBool>,
483521
}
484522

485-
/// The main interface object of the simplified API, wrapping the necessary LDK and BDK functionalities.
523+
/// The main interface object of LDK Node, wrapping the necessary LDK and BDK functionalities.
486524
///
487525
/// Needs to be initialized and instantiated through [`Builder::build`].
488526
pub struct Node {
@@ -716,12 +754,14 @@ impl Node {
716754

717755
/// Blocks until the next event is available.
718756
///
719-
/// Note: this will always return the same event until handling is confirmed via [`Node::event_handled`].
757+
/// **Note:** this will always return the same event until handling is confirmed via [`Node::event_handled`].
720758
pub fn next_event(&self) -> Event {
721759
self.event_queue.next_event()
722760
}
723761

724762
/// Confirm the last retrieved event handled.
763+
///
764+
/// **Note:** This **MUST** be called after each event has been handled.
725765
pub fn event_handled(&self) {
726766
self.event_queue.event_handled().unwrap();
727767
}

0 commit comments

Comments
 (0)