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
12 changes: 12 additions & 0 deletions contrib/ldk-server-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ alias = "ldk_server" # Lightning node alias
#rgs_server_url = "https://rapidsync.lightningdevkit.org/snapshot/v2/" # Optional: RGS URL for rapid gossip sync
#async_payments_role = "client" # Optional async payments role: "client" or "server"

# Node entropy settings
[node.entropy]
# Path to a BIP39 mnemonic file. If unset, a fresh 24-word mnemonic is generated on
# first start. Defaults to "<storage_dir>/keys_mnemonic".
# CLI/env: --node-entropy-mnemonic-file / LDK_SERVER_NODE_ENTROPY_MNEMONIC_FILE
#mnemonic_file = "/tmp/ldk-server/keys_mnemonic"
# Legacy: path to a raw 64-byte seed file used by ldk-server installs initialized before
# BIP39 mnemonic support. Configure this explicitly to keep using an existing keys_seed file.
# CLI/env: --node-entropy-seed-file / LDK_SERVER_NODE_ENTROPY_SEED_FILE
# Mutually exclusive with `mnemonic_file`.
#seed_file = "/tmp/ldk-server/keys_seed"

# Storage settings
[storage.disk]
dir_path = "/tmp/ldk-server/" # Path for LDK and BDK data persistence, optional, defaults to ~/Library/Application Support/ldk-server/ on macOS, ~/.ldk-server/ on Linux
Expand Down
26 changes: 22 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ Two resolution methods are supported via the `mode` field:

```
<storage_dir>/
keys_seed # Node entropy/seed
keys_mnemonic # BIP39 mnemonic (default for new installs)
keys_seed # Legacy raw seed (only used when explicitly configured)
tls.crt # TLS certificate (PEM)
tls.key # TLS private key (PEM)
<network>/ # e.g., bitcoin/, regtest/, signet/
Expand All @@ -161,6 +162,23 @@ Two resolution methods are supported via the `mode` field:
ldk_server_data.sqlite # Payment and forwarding history
```

The `keys_seed` file is the node's master secret, required to recover on-chain funds.
`ldk_node_data.sqlite` holds channel state, both are required to recover channel funds. See
[Operations - Backups](operations.md#backups) for backup guidance.
The mnemonic (or, for legacy installs, the raw seed) is the node's master secret, required to
recover on-chain funds. `ldk_node_data.sqlite` holds channel state, both are required to recover
channel funds. See [Operations - Backups](operations.md#backups) for backup guidance.

### Node entropy (`[node.entropy]`)

By default, ldk-server reads or generates a 24-word BIP39 mnemonic at `<storage_dir>/keys_mnemonic`,
which can be imported into any standard BIP39-compatible wallet to recover on-chain funds. The
defaults can be overridden under `[node.entropy]`:

- `mnemonic_file`: path to the BIP39 mnemonic file. Defaults to `<storage_dir>/keys_mnemonic`. If
the file does not exist on first start, a fresh 24-word mnemonic is generated and written.
CLI/env: `--node-entropy-mnemonic-file` / `LDK_SERVER_NODE_ENTROPY_MNEMONIC_FILE`.
- `seed_file`: path to a raw 64-byte seed file. Provided for backwards compatibility with installs
initialized before BIP39 mnemonic support. Mutually exclusive with `mnemonic_file`.
CLI/env: `--node-entropy-seed-file` / `LDK_SERVER_NODE_ENTROPY_SEED_FILE`.

Legacy raw-seed installs are not auto-detected. To keep using an existing
`<storage_dir>/keys_seed`, set `seed_file` explicitly or use the corresponding CLI argument or
environment variable.
9 changes: 5 additions & 4 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ setup):

| File | Priority | Description |
| -------------------------------------- | ------------ | -------------------------------------------------------------------------- |
| `<storage_dir>/keys_seed` | **Critical** | Node identity and master secret. Required to recover on-chain funds. |
| `<storage_dir>/keys_mnemonic` | **Critical** | BIP39 mnemonic. Required to recover on-chain funds. Default for new installs. |
| `<storage_dir>/keys_seed` | **Critical** | Legacy raw seed file. Only used when explicitly configured. |
| `<network_dir>/ldk_node_data.sqlite` | **Critical** | Channel state and on-chain wallet data. Required to recover channel funds. |
| `<network_dir>/ldk_server_data.sqlite` | Nice-to-have | Payment and forwarding history |

Expand Down Expand Up @@ -195,6 +196,6 @@ Data is stored in per-network subdirectories (`bitcoin/`, `testnet/`, `signet/`,
etc.) under the storage root. This means you can run multiple networks from one storage
directory without conflicts.

The `keys_seed` file is shared across networks (stored at the storage root, not per-network).
Keys are split by network at the derivation path level, so the same seed will produce
different keys.
The `keys_mnemonic` file, or an explicitly configured legacy `keys_seed`, is shared across
networks (stored at the storage root, not per-network). Keys are split by network at the
derivation path level, so the same mnemonic/seed will produce different keys.
9 changes: 5 additions & 4 deletions ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use hyper::server::conn::http2;
use hyper_util::rt::{TokioExecutor, TokioIo};
use ldk_node::bitcoin::Network;
use ldk_node::config::Config;
use ldk_node::entropy::NodeEntropy;
use ldk_node::lightning::events::ClosureReason;
use ldk_node::lightning::ln::channelmanager::PaymentId;
use ldk_node::lightning::ln::types::ChannelId;
Expand Down Expand Up @@ -213,11 +212,13 @@ fn main() {

builder.set_runtime(runtime.handle().clone());

let seed_path = storage_dir.join("keys_seed").to_str().unwrap().to_string();
let node_entropy = match NodeEntropy::from_seed_path(seed_path) {
let node_entropy = match crate::util::entropy::load_or_generate_node_entropy(
&storage_dir,
&config_file.entropy,
) {
Ok(entropy) => entropy,
Err(e) => {
error!("Failed to load or generate seed: {e}");
error!("Failed to load or generate node entropy: {e}");
std::process::exit(-1);
},
};
Expand Down
Loading