From a028748f113ec18c029b81f05919d7ae30f54897 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Tue, 30 Oct 2018 16:12:30 -0700 Subject: [PATCH] Trivial wallet file operations logging improvement (#1888) --- src/bin/cmd/wallet.rs | 24 +++++++++++++++++++----- src/bin/grin.rs | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/bin/cmd/wallet.rs b/src/bin/cmd/wallet.rs index 76936c46b..c4be7f3e5 100644 --- a/src/bin/cmd/wallet.rs +++ b/src/bin/cmd/wallet.rs @@ -15,7 +15,7 @@ use serde_json as json; use std::fs::File; use std::io::Read; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; /// Wallet commands processing use std::process::exit; use std::sync::Arc; @@ -325,15 +325,24 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { } ("receive", Some(send_args)) => { let mut receive_result: Result<(), grin_wallet::libwallet::Error> = Ok(()); + let tx_file = send_args + .value_of("input") + .expect("Transaction file required"); + if !Path::new(tx_file).is_file() { + error!("File {} not found.", { tx_file }); + exit(1); + } let res = controller::foreign_single_use(wallet, |api| { - let tx_file = send_args - .value_of("input") - .expect("Transaction file required"); receive_result = api.file_receive_tx(tx_file); Ok(()) }); if res.is_err() { exit(1); + } else { + info!( + "Response file {}.response generated, sending it back to the transaction originator.", + tx_file, + ); } receive_result } @@ -342,6 +351,10 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { let tx_file = send_args .value_of("input") .expect("Receiver's transaction file required"); + if !Path::new(tx_file).is_file() { + error!("File {} not found.", { tx_file }); + exit(1); + } let mut pub_tx_f = File::open(tx_file)?; let mut content = String::new(); pub_tx_f.read_to_string(&mut content)?; @@ -352,7 +365,7 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { let result = api.post_tx(&slate, fluff); match result { Ok(_) => { - info!("Tx sent"); + info!("Transaction sent successfully, check the wallet again for confirmation."); Ok(()) } Err(e) => { @@ -516,6 +529,7 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) { thread::sleep(Duration::from_millis(100)); if res.is_err() { + error!("Wallet command failed: {:?}", res); exit(1); } } diff --git a/src/bin/grin.rs b/src/bin/grin.rs index 1dd476c47..5cb007b2e 100644 --- a/src/bin/grin.rs +++ b/src/bin/grin.rs @@ -374,7 +374,7 @@ fn main() { let mut l = w.members.as_mut().unwrap().logging.clone().unwrap(); l.tui_running = Some(false); init_logger(Some(l)); - warn!( + info!( "Using wallet configuration file at {}", w.config_file_path.as_ref().unwrap().to_str().unwrap() );