Skip to content
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

keys manager implementation for using custom channel secrets and private key #122

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Binary file added .DS_Store
Binary file not shown.
27 changes: 0 additions & 27 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ base64 = "0.13.0"
bitcoin = "0.29.0"
bitcoin-bech32 = "0.12"
bech32 = "0.8"
hex = "0.3"
libc = "0.2"

chrono = { version = "0.4", default-features = false, features = ["clock"] }
Expand Down
27 changes: 26 additions & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::str::FromStr;

pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
if env::args().len() < 3 {
println!("ldk-tutorial-node requires at least 2 arguments: `cargo run [<bitcoind-rpc-username>:<bitcoind-rpc-password>@]<bitcoind-rpc-host>:<bitcoind-rpc-port> ldk_storage_directory_path [<ldk-incoming-peer-listening-port>] [bitcoin-network] [announced-node-name announced-listen-addr*]`");
println!("ldk-tutorial-node requires at least 2 arguments: `cargo run [<bitcoind-rpc-username>:<bitcoind-rpc-password>@]<bitcoind-rpc-host>:<bitcoind-rpc-port> ldk_storage_directory_path [<ldk-incoming-peer-listening-port>] [bitcoin-network] [custom-private-key] [custom-channel-secrets] [announced-node-name announced-listen-addr*]`");
return Err(());
}
let bitcoind_rpc_info = env::args().skip(1).next().unwrap();
Expand Down Expand Up @@ -69,6 +69,28 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
println!("ERROR: bad bitcoind RPC URL provided");
return Err(());
};

let priv_key = match env::args().skip(arg_idx + 1).next() {
Some(s) => {
if s.len() != 64 {
panic!("Private key should be equal to 64 bytes");
}
arg_idx += 1;
s
}
None => "".to_owned(),
};

let channel_secrets = match env::args().skip(arg_idx + 1).next() {
Some(s) => {
if s.len() != 389 {
panic!("Channel secrets should be seperated by '/' and total string length should be 389");
}
arg_idx += 1;
s
}
None => "".to_owned(),
};

let ldk_announced_node_name = match env::args().skip(arg_idx + 1).next().as_ref() {
Some(s) => {
Expand Down Expand Up @@ -113,6 +135,9 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
ldk_announced_listen_addr,
ldk_announced_node_name,
network,
priv_key,
channel_secrets,

})
}

Expand Down
Loading
Loading