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
64 changes: 62 additions & 2 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 @@ -28,6 +28,7 @@ chrono = { version = "0.4", default-features = false, features = ["clock"] }
rand = "0.4"
serde_json = { version = "1.0" }
serde = { version = "1.0", features = ["derive"] }
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"
Expand Down
59 changes: 30 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ cd ldk-sample
cargo run <ldk_storage_directory_path>
```
The only CLI argument is the storage directory path. All configuration is read from
`<ldk_storage_directory_path>/.ldk/config.json`.
`<ldk_storage_directory_path>/.ldk/config.toml`.

Use `config.example.json` in the repo root as a template for your config file.
Use `config.example.toml` in the repo root as a template for your config file.

## Configuration

Config is loaded from `<storage_dir>/.ldk/config.json` and strictly validated. Unknown
Config is loaded from `<storage_dir>/.ldk/config.toml` and strictly validated. Unknown
fields cause an error (`deny_unknown_fields`).

Required sections: `bitcoind`.
Expand All @@ -29,32 +29,33 @@ Network options: `mainnet`, `testnet`, `regtest`, `signet` (default is `testnet`

### Example config

```json
{
"bitcoind": {
"rpc_host": "127.0.0.1",
"rpc_port": 8332,
"rpc_username": "your_rpc_user",
"rpc_password": "your_rpc_password"
},
"network": "testnet",
"ldk": {
"peer_listening_port": 9735,
"announced_node_name": "MyLDKNode",
"announced_listen_addr": []
},
"rapid_gossip_sync": {
"enabled": true,
"url": "https://rapidsync.lightningdevkit.org/snapshot/",
"interval_hours": 6
},
"probing": {
"interval_sec": 300,
"peers": ["02abc123...@1.2.3.4:9735"],
"amount_msats": [1000, 10000, 100000, 1000000],
"timeout_sec": 60
}
}
```toml
network = "testnet"

[bitcoind]
rpc_host = "127.0.0.1"
rpc_port = 8332
rpc_username = "your_rpc_user"
rpc_password = "your_rpc_password"

# [ldk]
# peer_listening_port = 9735
# announced_node_name = "MyLDKNode"
# announced_listen_addr = []

[rapid_gossip_sync]
enabled = true
url = "https://rapidsync.lightningdevkit.org/snapshot/"
interval_hours = 6

[probing]
interval_sec = 300
peers = ["02abc123...@1.2.3.4:9735"]
amount_msats = [1000, 10000, 100000, 1000000]
timeout_sec = 60

probe_delay_sec = 1
peer_delay_sec = 2
```
Comment on lines 51 to 59
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The probing configuration example is missing the new probe_delay_sec and peer_delay_sec fields that were added in this PR. These fields should be included in the example for completeness and consistency with the other example configurations (config.example.toml and the help text in src/config.rs).

Copilot uses AI. Check for mistakes.

### Key options
Expand Down
27 changes: 0 additions & 27 deletions config.example.json

This file was deleted.

27 changes: 27 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[bitcoind]
rpc_host = "127.0.0.1"
rpc_port = 8332
rpc_username = "your_rpc_user"
rpc_password = "your_rpc_password"

network = "testnet"

[ldk]
peer_listening_port = 9735
announced_node_name = "MyLDKNode"
announced_listen_addr = []

[rapid_gossip_sync]
enabled = true
url = "https://rapidsync.lightningdevkit.org/snapshot/"
interval_hours = 6

[probing]
interval_sec = 300
peers = [
"02abc123...@1.2.3.4:9735"
]
amount_msats = [1000, 10000, 100000, 1000000]
timeout_sec = 60
probe_delay_sec = 1
peer_delay_sec = 2
4 changes: 3 additions & 1 deletion prober_config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
"037d8e050899fa0732fdd6fc1e0d5d8d685c2093932a7e10dc5e6fab8a34ed1c43"
],
"probe_amount_msats": [1000, 10000000, 100000000, 500000000],
"probe_timeout_sec": 3
"probe_timeout_sec": 3,
"probe_delay_sec": 1,
"peer_delay_sec": 2
}
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
println!("Usage: {} <ldk_storage_directory_path>", args[0]);
println!();
println!(
"The config.json file should be located at <ldk_storage_directory_path>/.ldk/config.json",
"The config.toml file should be located at <ldk_storage_directory_path>/.ldk/config.toml",
);
crate::config::print_config_help();
return Err(());
Expand Down
4 changes: 3 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ use std::time::Duration;

use tokio::io::{AsyncBufReadExt, BufReader};

/// Probing configuration passed from config.json
/// Probing configuration passed from config.toml
#[derive(Clone)]
pub(crate) struct ProbingConfig {
pub(crate) interval_sec: u64,
pub(crate) peers: Vec<String>,
pub(crate) amount_msats: Vec<u64>,
pub(crate) timeout_sec: u64,
pub(crate) probe_delay_sec: u64,
pub(crate) peer_delay_sec: u64,
}

pub(crate) struct LdkUserInfo {
Expand Down
70 changes: 42 additions & 28 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub struct ProbingConfig {
pub amount_msats: Vec<u64>,
#[serde(default = "default_probe_timeout")]
pub timeout_sec: u64,
#[serde(default = "default_probe_delay")]
pub probe_delay_sec: u64,
#[serde(default = "default_peer_delay")]
pub peer_delay_sec: u64,
}

// Default functions
Expand All @@ -86,6 +90,14 @@ fn default_probe_timeout() -> u64 {
60
}

fn default_probe_delay() -> u64 {
1
}

fn default_peer_delay() -> u64 {
2
}

impl Default for RapidGossipSyncConfig {
fn default() -> Self {
Self { enabled: true, url: None, interval_hours: 6 }
Expand All @@ -94,14 +106,14 @@ impl Default for RapidGossipSyncConfig {

impl NodeConfig {
pub fn load(ldk_data_dir: &str) -> Result<Self, ConfigError> {
let config_path = format!("{}/config.json", ldk_data_dir);
let config_path = format!("{}/config.toml", ldk_data_dir);
if !Path::new(&config_path).exists() {
return Err(ConfigError::FileNotFound(config_path));
}
let content = fs::read_to_string(&config_path)
.map_err(|e| ConfigError::ParseError(format!("Failed to read config: {}", e)))?;
let config: NodeConfig = serde_json::from_str(&content)
.map_err(|e| ConfigError::ParseError(format!("Invalid JSON: {}", e)))?;
let config: NodeConfig = toml::from_str(&content)
.map_err(|e| ConfigError::ParseError(format!("Invalid TOML: {}", e)))?;
config.validate()?;
Ok(config)
}
Expand Down Expand Up @@ -177,6 +189,8 @@ impl NodeConfig {
peers: p.peers,
amount_msats: p.amount_msats,
timeout_sec: p.timeout_sec,
probe_delay_sec: p.probe_delay_sec,
peer_delay_sec: p.peer_delay_sec,
});
LdkUserInfo {
bitcoind_rpc_username: self.bitcoind.rpc_username,
Expand All @@ -200,33 +214,33 @@ pub fn print_config_help() {
println!("ERROR: Config file not found or invalid.");
println!();
println!(
"Please create a config.json file in your LDK data directory with the following structure:"
"Please create a config.toml file in your LDK data directory with the following structure:"
);
println!();
println!(
r#"{{
"bitcoind": {{
"rpc_host": "127.0.0.1",
"rpc_port": 8332,
"rpc_username": "your_rpc_user",
"rpc_password": "your_rpc_password"
}},
"network": "testnet",
"ldk": {{
"peer_listening_port": 9735,
"announced_node_name": "MyNode",
"announced_listen_addr": []
}},
"rapid_gossip_sync": {{
"enabled": true,
"interval_hours": 6
}},
"probing": {{
"interval_sec": 300,
"peers": [],
"amount_msats": [1000, 10000, 100000],
"timeout_sec": 60
}}
}}"#
r#"[bitcoind]
rpc_host = "127.0.0.1"
rpc_port = 8332
rpc_username = "your_rpc_user"
rpc_password = "your_rpc_password"

network = "testnet"

[ldk]
peer_listening_port = 9735
announced_node_name = "MyNode"
announced_listen_addr = []

[rapid_gossip_sync]
enabled = true
interval_hours = 6

[probing]
interval_sec = 300
peers = []
amount_msats = [1000, 10000, 100000]
timeout_sec = 60
probe_delay_sec = 1
peer_delay_sec = 2"#
);
}
Loading