]> git.bitcoin.ninja Git - ldk-sample/commitdiff
use rsplitn for rpc info extraction in case passwords have @
authorcadwgan0 <cadwgan@protonmail.com>
Fri, 15 Oct 2021 04:14:03 +0000 (00:14 -0400)
committercadwgan0 <cadwgan@protonmail.com>
Sun, 17 Oct 2021 01:01:07 +0000 (21:01 -0400)
remove swap, fix rustfmt issue

remove return

src/cli.rs

index 50d02df46577ee2dc92d00fcb118ac3ff83c1aac..66fc3164ecbbc180733417bd08c87e2b2b559567 100644 (file)
@@ -45,19 +45,19 @@ pub(crate) fn parse_startup_args() -> Result<LdkUserInfo, ()> {
                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(());