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.

18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,34 @@ We welcome your feedback and contributions to help shape the future of LDK Serve
### Configuration
Refer `./ldk-server/ldk-server-config.toml` to see available configuration options.

You can configure the node via a TOML file, environment variables, or CLI arguments. All options are optional — values provided via CLI override environment variables, which override the values in the TOML file.

### Building
```
git clone https://github.com/lightningdevkit/ldk-server.git
cargo build
```

### Running
- Using a config file:
```
cargo run --bin ldk-server ./ldk-server/ldk-server-config.toml
```

Interact with the node using CLI:
- Using environment variables (all optional):
```
export LDK_SERVER_NODE_NETWORK=regtest
export LDK_SERVER_NODE_LISTENING_ADDRESS=localhost:3001
export LDK_SERVER_NODE_REST_SERVICE_ADDRESS=127.0.0.1:3002
export LDK_SERVER_NODE_ALIAS=LDK-Server
export LDK_SERVER_BITCOIND_RPC_ADDRESS=127.0.0.1:18443
export LDK_SERVER_BITCOIND_RPC_USER=your-rpc-user
export LDK_SERVER_BITCOIND_RPC_PASSWORD=your-rpc-password
export LDK_SERVER_STORAGE_DIR_PATH=/path/to/storage
cargo run --bin ldk-server
```

- Using CLI arguments (all optional):
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is calling the cli, not running the server with command line args

```
ldk-server-cli -b localhost:3002 --api-key your-secret-api-key --tls-cert /path/to/tls_cert.pem onchain-receive # To generate onchain-receive address.
ldk-server-cli -b localhost:3002 --api-key your-secret-api-key --tls-cert /path/to/tls_cert.pem help # To print help/available commands.
Expand Down
1 change: 1 addition & 0 deletions ldk-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ toml = { version = "0.8.9", default-features = false, features = ["parse"] }
chrono = { version = "0.4", default-features = false, features = ["clock"] }
log = "0.4.28"
base64 = { version = "0.21", default-features = false, features = ["std"] }
clap = { version = "4.0.5", default-features = false, features = ["derive", "std", "error-context", "suggestions", "help", "env"] }

# Required for RabittMQ based EventPublisher. Only enabled for `events-rabbitmq` feature.
lapin = { version = "2.4.0", features = ["rustls"], default-features = false, optional = true }
Expand Down
10 changes: 7 additions & 3 deletions ldk-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ use tokio::net::TcpListener;
use tokio::select;
use tokio::signal::unix::SignalKind;

use clap::Parser;

use crate::io::events::event_publisher::EventPublisher;
use crate::io::events::get_event_name;
#[cfg(feature = "events-rabbitmq")]
Expand All @@ -48,7 +50,7 @@ use crate::io::persist::{
PAYMENTS_PERSISTENCE_SECONDARY_NAMESPACE,
};
use crate::service::NodeService;
use crate::util::config::{load_config, ChainSource};
use crate::util::config::{load_config, ArgsConfig, ChainSource};
use crate::util::logger::ServerLogger;
use crate::util::proto_adapter::{forwarded_payment_to_proto, payment_to_proto};
use crate::util::tls::get_or_generate_tls_config;
Expand Down Expand Up @@ -110,11 +112,13 @@ fn main() {
std::process::exit(-1);
}

let args_config = ArgsConfig::parse();

let mut ldk_node_config = Config::default();
let config_file = match load_config(&config_path) {
let config_file = match load_config(&args_config) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Config path and the args above is never used now. We should be able to remove that logic as we use clap now, but we still should check for the default config file

Ok(config) => config,
Err(e) => {
eprintln!("Invalid configuration file: {}", e);
eprintln!("Invalid configuration: {}", e);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
eprintln!("Invalid configuration: {}", e);
eprintln!("Invalid configuration: {e}");

Copy link
Collaborator

Choose a reason for hiding this comment

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

small preference

std::process::exit(-1);
},
};
Expand Down
Loading