From: cadwgan0 Date: Fri, 15 Oct 2021 04:14:03 +0000 (-0400) Subject: use rsplitn for rpc info extraction in case passwords have @ X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=6f53265d3ed57646a96ffa96b3acba6b4fbb55dd;p=ldk-sample use rsplitn for rpc info extraction in case passwords have @ remove swap, fix rustfmt issue remove return --- diff --git a/src/cli.rs b/src/cli.rs index 50d02df..66fc316 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -45,19 +45,19 @@ pub(crate) fn parse_startup_args() -> Result { return Err(()); } let bitcoind_rpc_info = env::args().skip(1).next().unwrap(); - let bitcoind_rpc_info_parts: Vec<&str> = bitcoind_rpc_info.split("@").collect(); + let bitcoind_rpc_info_parts: Vec<&str> = bitcoind_rpc_info.rsplitn(2, "@").collect(); if bitcoind_rpc_info_parts.len() != 2 { println!("ERROR: bad bitcoind RPC URL provided"); return Err(()); } - let rpc_user_and_password: Vec<&str> = bitcoind_rpc_info_parts[0].split(":").collect(); + let rpc_user_and_password: Vec<&str> = bitcoind_rpc_info_parts[1].split(":").collect(); if rpc_user_and_password.len() != 2 { println!("ERROR: bad bitcoind RPC username/password combo provided"); return Err(()); } let bitcoind_rpc_username = rpc_user_and_password[0].to_string(); let bitcoind_rpc_password = rpc_user_and_password[1].to_string(); - let bitcoind_rpc_path: Vec<&str> = bitcoind_rpc_info_parts[1].split(":").collect(); + let bitcoind_rpc_path: Vec<&str> = bitcoind_rpc_info_parts[0].split(":").collect(); if bitcoind_rpc_path.len() != 2 { println!("ERROR: bad bitcoind RPC path provided"); return Err(());