diff --git a/src/bin/cmd/wallet.rs b/src/bin/cmd/wallet.rs index 086e47cf..0f87b8d6 100644 --- a/src/bin/cmd/wallet.rs +++ b/src/bin/cmd/wallet.rs @@ -99,8 +99,8 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) -> i ("listen", Some(args)) => { let mut c = wallet_config.clone(); let mut g = global_wallet_args.clone(); - arg_parse!(command_args::parse_listen_args(&mut c, &mut g, &args)); - command::listen(&wallet_config, &g) + let a = arg_parse!(command_args::parse_listen_args(&mut c, &mut g, &args)); + command::listen(&wallet_config, &a, &g) } ("owner_api", Some(_)) => { let mut g = global_wallet_args.clone(); diff --git a/wallet/src/command.rs b/wallet/src/command.rs index 2d8ce7b9..b315aaab 100644 --- a/wallet/src/command.rs +++ b/wallet/src/command.rs @@ -30,7 +30,10 @@ use keychain; use error::{Error, ErrorKind}; use {controller, display, HTTPNodeClient, WalletConfig, WalletInst, WalletSeed}; -use {FileWalletCommAdapter, HTTPWalletCommAdapter, LMDBBackend, NullWalletCommAdapter}; +use { + FileWalletCommAdapter, HTTPWalletCommAdapter, KeybaseWalletCommAdapter, LMDBBackend, + NullWalletCommAdapter, +}; pub type WalletRef = Arc>>; @@ -99,17 +102,22 @@ pub fn recover(config: &WalletConfig, args: RecoverArgs) -> Result<(), Error> { /// Arguments for listen command pub struct ListenArgs { - pub port: String, + pub method: String, } -pub fn listen(config: &WalletConfig, g_args: &GlobalArgs) -> Result<(), Error> { +pub fn listen(config: &WalletConfig, args: &ListenArgs, g_args: &GlobalArgs) -> Result<(), Error> { let mut params = HashMap::new(); params.insert("api_listen_addr".to_owned(), config.api_listen_addr()); if let Some(t) = g_args.tls_conf.as_ref() { params.insert("certificate".to_owned(), t.certificate.clone()); params.insert("private_key".to_owned(), t.private_key.clone()); } - let adapter = HTTPWalletCommAdapter::new(); + let adapter = match args.method.as_str() { + "http" => HTTPWalletCommAdapter::new(), + "keybase" => KeybaseWalletCommAdapter::new(), + _ => NullWalletCommAdapter::new(), + }; + let res = adapter.listen( params, config.clone(), @@ -213,6 +221,7 @@ pub fn send(wallet: WalletRef, args: SendArgs) -> Result<(), Error> { let adapter = match args.method.as_str() { "http" => HTTPWalletCommAdapter::new(), "file" => FileWalletCommAdapter::new(), + "keybase" => KeybaseWalletCommAdapter::new(), "self" => NullWalletCommAdapter::new(), _ => NullWalletCommAdapter::new(), }; diff --git a/wallet/src/command_args.rs b/wallet/src/command_args.rs index 74482c75..adb0cc95 100644 --- a/wallet/src/command_args.rs +++ b/wallet/src/command_args.rs @@ -197,7 +197,7 @@ pub fn parse_listen_args( config: &mut WalletConfig, g_args: &mut command::GlobalArgs, args: &ArgMatches, -) -> Result<(), Error> { +) -> Result { // listen args let pass = match g_args.password.clone() { Some(p) => Some(p.to_owned()), @@ -207,7 +207,10 @@ pub fn parse_listen_args( if let Some(port) = args.value_of("port") { config.api_listen_port = port.parse().unwrap(); } - Ok(()) + let method = parse_required(args, "method")?; + Ok(command::ListenArgs { + method: method.to_owned(), + }) } pub fn parse_account_args(account_args: &ArgMatches) -> Result {