Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ toml = { version = "0.8" }
tokio = { version = "1", features = [ "io-util", "macros", "rt", "rt-multi-thread", "sync", "net", "time", "io-std" ] }
reqwest = { version = "0.11", features = ["tokio-native-tls", "stream"] }
futures-util = "0.3"
thiserror = "1"

# DNS bootstrap (BOLT-0010)
hickory-resolver = { version = "0.24", features = ["tokio-runtime"] }
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Use `config.example.toml` in the repo root as a template for your config file.
Config is loaded from `<storage_dir>/.ldk/config.toml` and strictly validated. Unknown
fields cause an error (`deny_unknown_fields`).

`config.json` is deprecated and no longer supported.

Required sections: `bitcoind`.
Optional sections: `ldk`, `rapid_gossip_sync`, `probing` (probing is disabled if
missing), and `dns_bootstrap` (enabled by default with sensible defaults).
Expand Down Expand Up @@ -52,6 +54,8 @@ interval_hours = 6
interval_sec = 300
peers = ["02abc123...@1.2.3.4:9735"]
Comment thread
dzdidi marked this conversation as resolved.
Comment thread
dzdidi marked this conversation as resolved.
amount_msats = [1000, 10000, 100000, 1000000]
random_min_amount_msat = 1000
random_nodes_per_interval = 1
timeout_sec = 60

probe_delay_sec = 1
Expand Down Expand Up @@ -85,8 +89,12 @@ fails, the node falls back to P2P gossip sync. `url` defaults to
`https://rapidsync.lightningdevkit.org/snapshot/`, `interval_hours` defaults to 6.

`probing`:
Optional. If omitted, probing is disabled. Configure probe interval, peers, probe
amounts in millisatoshis, and timeout.
Optional. If omitted, probing is disabled. Peer-list probing uses `peers` +
`amount_msats` and probes each configured peer with incrementally increasing amounts.
Random-graph probing uses `random_min_amount_msat` and
`random_nodes_per_interval` to probe randomly selected graph nodes at a fixed
minimal amount each interval. Set `random_min_amount_msat = 0` to disable
random-graph probing.

`dns_bootstrap`:
Optional. Enabled by default. Discovers peers via DNS SRV lookups per BOLT-0010.
Expand Down
4 changes: 3 additions & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ interval_hours = 6
[probing]
interval_sec = 300
peers = [
"02abc123...@1.2.3.4:9735"
"02abc123...f1"
Comment thread
dzdidi marked this conversation as resolved.
]
amount_msats = [1000, 10000, 100000, 1000000]
random_min_amount_msat = 1000
random_nodes_per_interval = 1
timeout_sec = 60
probe_delay_sec = 1
peer_delay_sec = 2
11 changes: 0 additions & 11 deletions prober_config.json.example

This file was deleted.

53 changes: 21 additions & 32 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -1,46 +1,35 @@
use crate::cli::LdkUserInfo;
use crate::runtime_config::LdkUserInfo;
use std::env;
use std::fs;
use thiserror::Error;

pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
#[derive(Debug, Error)]
pub(crate) enum StartupArgsError {
#[error("missing storage directory argument")]
MissingStorageDirectory,
#[error("failed to create LDK data directory {path}: {source}")]
CreateDataDir {
path: String,
#[source]
source: std::io::Error,
},
#[error(transparent)]
Config(#[from] crate::config::ConfigError),
}

pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, StartupArgsError> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Usage: {} <ldk_storage_directory_path>", args[0]);
println!();
println!(
"The config.toml file should be located at <ldk_storage_directory_path>/.ldk/config.toml",
);
crate::config::print_config_help();
return Err(());
return Err(StartupArgsError::MissingStorageDirectory);
}

let ldk_storage_dir_path = args[1].clone();
let ldk_data_dir = format!("{}/.ldk", ldk_storage_dir_path);

if let Err(e) = fs::create_dir_all(&ldk_data_dir) {
println!("ERROR: Failed to create LDK data directory {}: {}", ldk_data_dir, e);
return Err(());
if let Err(source) = fs::create_dir_all(&ldk_data_dir) {
return Err(StartupArgsError::CreateDataDir { path: ldk_data_dir, source });
}

let config = match crate::config::NodeConfig::load(&ldk_data_dir) {
Ok(c) => c,
Err(crate::config::ConfigError::FileNotFound(path)) => {
println!("ERROR: Config file not found at {}", path);
println!();
crate::config::print_config_help();
return Err(());
},
Err(crate::config::ConfigError::ParseError(msg)) => {
println!("ERROR: {}", msg);
println!();
crate::config::print_config_help();
return Err(());
},
Err(crate::config::ConfigError::ValidationError(msg)) => {
println!("ERROR: Config validation failed: {}", msg);
return Err(());
},
};

let config = crate::config::NodeConfig::load(&ldk_data_dir)?;
Ok(config.into_ldk_user_info(ldk_storage_dir_path))
}
Loading