-
Notifications
You must be signed in to change notification settings - Fork 18
Add CLI and env var config support, split bitcoind_rpc_addr
into host/port
#69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added `clap` dependency to `ldk-server` to support passing essential node config via CLI arguments and environment variables. - Implemented layered config loading: config file (full set of options) + environment variables + CLI arguments. Env vars and CLI args override values from the config file when present. - Split `bitcoind_rpc_addr` into `bitcoind_rpc_host` and `bitcoind_rpc_port` for clearer configuration. - Added tests for the new config loading logic. - Updated README with usage instructions and explanation of config precedence.
I've assigned @jkczyz as a reviewer! |
Thank you for your work on this! I'm still going through the changes, but I have an early high-level question. Is there a reason or trade-off why the My initial thought was that a crate like Just want to make sure I understand the design decision. |
I chose to use I hadn’t considered using a separate configuration crate like |
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
🔔 2nd Reminder Hey @jkczyz! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling these issues! Looks like CI is failing, though.
None | ||
}; | ||
|
||
macro_rules! pick { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, the call sites may be more readable if everything was explicitly written out. There isn't much happening here, so I don't think it would be too verbose.
rpc_address: String, | ||
rpc_user: String, | ||
rpc_password: String, | ||
rpc_host: Option<String>, | ||
rpc_port: Option<u16>, | ||
rpc_user: Option<String>, | ||
rpc_password: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make a separate commit for splitting the RPC address?
|
||
macro_rules! pick { | ||
($cli:expr, $toml:expr, $err_msg:expr) => { | ||
$cli.or($toml).ok_or_else(|| io::Error::new(io::ErrorKind::InvalidInput, $err_msg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or_else
?
}; | ||
} | ||
|
||
fn missing_field_msg(field: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this return the io::Error
instead? Then the unrolled macro would be less verbose.
Added support for configuring the node via CLI arguments and environment variables, using
clap
(as already done inldk-server-cli
).Configuration is now loaded from three sources:
Environment variables and CLI arguments override values defined in the config file when provided.
In addition, the
bitcoind_rpc_addr
field was split into two variables for better clarity:bitcoind_rpc_host
bitcoind_rpc_port
Tests were added for the new configuration loading logic, and the README was updated with usage instructions.
close #42 and #66