From 8809293020944ce91f364cf034ad2b7a6bd5ec5d Mon Sep 17 00:00:00 2001 From: Elias Rohrer Date: Fri, 2 Feb 2024 14:08:45 +0100 Subject: [PATCH] f Update usage examples and doctests --- README.md | 7 ++++--- src/lib.rs | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 270bf25a7..198620b08 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,16 @@ LDK Node is a self-custodial Lightning node in library form. Its central goal is The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_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. ```rust -use ldk_node::Builder; +use ldk_node::{Builder, generate_entropy_mnemonic}; use ldk_node::lightning_invoice::Bolt11Invoice; use ldk_node::lightning::ln::msgs::SocketAddress; -use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::bitcoin::Network; +use ldk_node::bitcoin::secp256k1::PublicKey; use std::str::FromStr; fn main() { - let mut builder = Builder::new(); + let mnemonic = generate_entropy_mnemonic(); + let mut builder = Builder::from_entropy_bip39_mnemonic(mnemonic, None, None); 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()); diff --git a/src/lib.rs b/src/lib.rs index 8a11833cb..bfe6317a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ //! [`send_payment`], etc.: //! //! ```no_run -//! use ldk_node::Builder; +//! use ldk_node::{Builder, generate_entropy_mnemonic}; //! use ldk_node::lightning_invoice::Bolt11Invoice; //! use ldk_node::lightning::ln::msgs::SocketAddress; //! use ldk_node::bitcoin::Network; @@ -34,7 +34,8 @@ //! use std::str::FromStr; //! //! fn main() { -//! let mut builder = Builder::new(); +//! let mnemonic = generate_entropy_mnemonic(); +//! let mut builder = Builder::from_entropy_bip39_mnemonic(mnemonic, None, None); //! 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()); @@ -1548,12 +1549,13 @@ impl Node { /// /// For example, you could retrieve all stored outbound payments as follows: /// ``` - /// # use ldk_node::{Builder, Config, PaymentDirection}; + /// # use ldk_node::{Builder, Config, PaymentDirection, generate_entropy_mnemonic}; /// # use ldk_node::bitcoin::Network; + /// # let mnemonic = generate_entropy_mnemonic(); /// # let mut config = Config::default(); /// # config.network = Network::Regtest; /// # config.storage_dir_path = "/tmp/ldk_node_test/".to_string(); - /// # let builder = Builder::from_config(config); + /// # let builder = Builder::from_entropy_bip39_mnemonic(mnemonic, None, Some(config)); /// # let node = builder.build().unwrap(); /// node.list_payments_with_filter(|p| p.direction == PaymentDirection::Outbound); /// ```