mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-08 12:21:09 +03:00
Trivial wallet file operations logging improvement (#1888)
This commit is contained in:
parent
641e7f51f0
commit
a028748f11
2 changed files with 20 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
||||||
use serde_json as json;
|
use serde_json as json;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
/// Wallet commands processing
|
/// Wallet commands processing
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -325,15 +325,24 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||||
}
|
}
|
||||||
("receive", Some(send_args)) => {
|
("receive", Some(send_args)) => {
|
||||||
let mut receive_result: Result<(), grin_wallet::libwallet::Error> = Ok(());
|
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 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);
|
receive_result = api.file_receive_tx(tx_file);
|
||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
} else {
|
||||||
|
info!(
|
||||||
|
"Response file {}.response generated, sending it back to the transaction originator.",
|
||||||
|
tx_file,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
receive_result
|
receive_result
|
||||||
}
|
}
|
||||||
|
@ -342,6 +351,10 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||||
let tx_file = send_args
|
let tx_file = send_args
|
||||||
.value_of("input")
|
.value_of("input")
|
||||||
.expect("Receiver's transaction file required");
|
.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 pub_tx_f = File::open(tx_file)?;
|
||||||
let mut content = String::new();
|
let mut content = String::new();
|
||||||
pub_tx_f.read_to_string(&mut content)?;
|
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);
|
let result = api.post_tx(&slate, fluff);
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
info!("Tx sent");
|
info!("Transaction sent successfully, check the wallet again for confirmation.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -516,6 +529,7 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||||
thread::sleep(Duration::from_millis(100));
|
thread::sleep(Duration::from_millis(100));
|
||||||
|
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
|
error!("Wallet command failed: {:?}", res);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,7 @@ fn main() {
|
||||||
let mut l = w.members.as_mut().unwrap().logging.clone().unwrap();
|
let mut l = w.members.as_mut().unwrap().logging.clone().unwrap();
|
||||||
l.tui_running = Some(false);
|
l.tui_running = Some(false);
|
||||||
init_logger(Some(l));
|
init_logger(Some(l));
|
||||||
warn!(
|
info!(
|
||||||
"Using wallet configuration file at {}",
|
"Using wallet configuration file at {}",
|
||||||
w.config_file_path.as_ref().unwrap().to_str().unwrap()
|
w.config_file_path.as_ref().unwrap().to_str().unwrap()
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue