Skip to content

Commit

Permalink
f Update usage examples and doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
tnull committed Feb 2, 2024
1 parent ed10c82 commit 20f4106
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@
//! [`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;
//! 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());
Expand Down Expand Up @@ -1548,12 +1549,13 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
///
/// 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);
/// ```
Expand Down

0 comments on commit 20f4106

Please sign in to comment.