mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-20 19:11:08 +03:00
a bit refactoring on wallet controller for issue_send_tx (#2280)
* a bit refactoring on wallet controller for issue_send_tx
This commit is contained in:
parent
3092221997
commit
939f42ea56
3 changed files with 15 additions and 17 deletions
|
@ -14,7 +14,6 @@
|
|||
|
||||
use crate::cmd::wallet_args;
|
||||
use crate::config::GlobalWalletConfig;
|
||||
use crate::servers::start_webwallet_server;
|
||||
use clap::ArgMatches;
|
||||
use grin_wallet::{self, HTTPNodeClient, WalletConfig, WalletSeed};
|
||||
use std::path::PathBuf;
|
||||
|
|
|
@ -67,6 +67,7 @@ impl Default for LoggingConfig {
|
|||
|
||||
use std::ops::Deref;
|
||||
use zeroize::Zeroize;
|
||||
/// Zeroing string, mainly useful for password
|
||||
pub struct ZeroingString(String);
|
||||
|
||||
impl Drop for ZeroingString {
|
||||
|
|
|
@ -343,23 +343,21 @@ where
|
|||
return Err(e);
|
||||
}
|
||||
};
|
||||
if args.method == "http" {
|
||||
let adapter = HTTPWalletCommAdapter::new();
|
||||
slate = adapter.send_tx_sync(&args.dest, &slate)?;
|
||||
api.tx_lock_outputs(&slate, lock_fn)?;
|
||||
let adapter = match args.method.as_ref() {
|
||||
"http" => HTTPWalletCommAdapter::new(),
|
||||
"file" => FileWalletCommAdapter::new(),
|
||||
"keybase" => KeybaseWalletCommAdapter::new(),
|
||||
_ => {
|
||||
error!("unsupported payment method: {}", args.method);
|
||||
return Err(ErrorKind::ClientCallback("unsupported payment method"))?;
|
||||
}
|
||||
};
|
||||
// TODO: improve it:
|
||||
// in case of keybase, the response might take 60s and leave the service hanging
|
||||
slate = adapter.send_tx_sync(&args.dest, &slate)?;
|
||||
api.tx_lock_outputs(&slate, lock_fn)?;
|
||||
if args.method != "file" {
|
||||
api.finalize_tx(&mut slate)?;
|
||||
} else if args.method == "file" {
|
||||
let adapter = FileWalletCommAdapter::new();
|
||||
adapter.send_tx_async(&args.dest, &slate)?;
|
||||
api.tx_lock_outputs(&slate, lock_fn)?;
|
||||
} else if args.method == "keybase" {
|
||||
let adapter = KeybaseWalletCommAdapter::new();
|
||||
slate = adapter.send_tx_sync(&args.dest, &slate)?;
|
||||
api.tx_lock_outputs(&slate, lock_fn)?;
|
||||
api.finalize_tx(&mut slate)?;
|
||||
} else {
|
||||
error!("unsupported payment method: {}", args.method);
|
||||
return Err(ErrorKind::ClientCallback("unsupported payment method"))?;
|
||||
}
|
||||
Ok(slate)
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue