|
9 | 9 |
|
10 | 10 | #![crate_name = "ldk_node"]
|
11 | 11 |
|
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 |
| 14 | +//! [BDK](https://bitcoindevkit.org/). |
| 15 | +//! |
| 16 | +//! LDK Node is a non-custodial Lightning node in library form. Its central goal is to provide a |
| 17 | +//! small, simple, and straightforward interface that enables users to easily set up and run a |
| 18 | +//! Lightning node with an integrated on-chain wallet. While minimalism is at its core, LDK Node |
| 19 | +//! aims to be sufficiently modular and configurable to be useful for a variety of use cases. |
| 20 | +//! |
| 21 | +//! ## Getting Started |
| 22 | +//! |
| 23 | +//! The primary abstraction of the library is the [`Node`], which can be retrieved by setting up |
| 24 | +//! and configuring a [`Builder`] to your liking and calling [`build`]. `Node` can then be |
| 25 | +//! controlled via commands such as [`start`], [`stop`], [`connect_open_channel`], |
| 26 | +//! [`send_payment`], etc.: |
| 27 | +//! |
| 28 | +//! ```no_run |
| 29 | +//! use ldk_node::Builder; |
| 30 | +//! use ldk_node::lightning_invoice::Invoice; |
| 31 | +//! use std::str::FromStr; |
| 32 | +//! |
| 33 | +//! fn main() { |
| 34 | +//! let node = Builder::new() |
| 35 | +//! .set_network("testnet") |
| 36 | +//! .set_esplora_server_url("https://blockstream.info/testnet/api".to_string()) |
| 37 | +//! .build(); |
| 38 | +//! |
| 39 | +//! node.start().unwrap(); |
| 40 | +//! |
| 41 | +//! let _funding_address = node.new_funding_address(); |
| 42 | +//! |
| 43 | +//! // .. fund address .. |
| 44 | +//! |
| 45 | +//! node.sync_wallets().unwrap(); |
| 46 | +//! |
| 47 | +//! node.connect_open_channel("NODE_ID@PEER_ADDR:PORT", 10000, false).unwrap(); |
| 48 | +//! |
| 49 | +//! let invoice = Invoice::from_str("INVOICE_STR").unwrap(); |
| 50 | +//! node.send_payment(invoice).unwrap(); |
| 51 | +//! |
| 52 | +//! node.stop().unwrap(); |
| 53 | +//! } |
| 54 | +//! ``` |
| 55 | +//! |
| 56 | +//! [`build`]: Builder::build |
| 57 | +//! [`start`]: Node::start |
| 58 | +//! [`stop`]: Node::stop |
| 59 | +//! [`connect_open_channel`]: Node::connect_open_channel |
| 60 | +//! [`send_payment`]: Node::send_payment |
| 61 | +//! |
20 | 62 | #![deny(missing_docs)]
|
21 | 63 | #![deny(broken_intra_doc_links)]
|
22 | 64 | #![deny(private_intra_doc_links)]
|
@@ -273,7 +315,7 @@ impl Builder {
|
273 | 315 | config.network,
|
274 | 316 | database,
|
275 | 317 | )
|
276 |
| - .expect("Failed to setup on-chain wallet"); |
| 318 | + .expect("Failed to set up on-chain wallet"); |
277 | 319 |
|
278 | 320 | let tx_sync = Arc::new(EsploraSyncClient::new(
|
279 | 321 | config.esplora_server_url.clone(),
|
@@ -482,7 +524,7 @@ struct Runtime {
|
482 | 524 | stop_wallet_sync: Arc<AtomicBool>,
|
483 | 525 | }
|
484 | 526 |
|
485 |
| -/// The main interface object of the simplified API, wrapping the necessary LDK and BDK functionalities. |
| 527 | +/// The main interface object of LDK Node, wrapping the necessary LDK and BDK functionalities. |
486 | 528 | ///
|
487 | 529 | /// Needs to be initialized and instantiated through [`Builder::build`].
|
488 | 530 | pub struct Node {
|
@@ -716,12 +758,14 @@ impl Node {
|
716 | 758 |
|
717 | 759 | /// Blocks until the next event is available.
|
718 | 760 | ///
|
719 |
| - /// Note: this will always return the same event until handling is confirmed via [`Node::event_handled`]. |
| 761 | + /// **Note:** this will always return the same event until handling is confirmed via [`Node::event_handled`]. |
720 | 762 | pub fn next_event(&self) -> Event {
|
721 | 763 | self.event_queue.next_event()
|
722 | 764 | }
|
723 | 765 |
|
724 | 766 | /// Confirm the last retrieved event handled.
|
| 767 | + /// |
| 768 | + /// **Note:** This **MUST** be called after each event has been handled. |
725 | 769 | pub fn event_handled(&self) {
|
726 | 770 | self.event_queue.event_handled().unwrap();
|
727 | 771 | }
|
|
0 commit comments