mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21: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::cmd::wallet_args;
|
||||||
use crate::config::GlobalWalletConfig;
|
use crate::config::GlobalWalletConfig;
|
||||||
use crate::servers::start_webwallet_server;
|
|
||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use grin_wallet::{self, HTTPNodeClient, WalletConfig, WalletSeed};
|
use grin_wallet::{self, HTTPNodeClient, WalletConfig, WalletSeed};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
|
@ -67,6 +67,7 @@ impl Default for LoggingConfig {
|
||||||
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use zeroize::Zeroize;
|
use zeroize::Zeroize;
|
||||||
|
/// Zeroing string, mainly useful for password
|
||||||
pub struct ZeroingString(String);
|
pub struct ZeroingString(String);
|
||||||
|
|
||||||
impl Drop for ZeroingString {
|
impl Drop for ZeroingString {
|
||||||
|
|
|
@ -343,24 +343,22 @@ where
|
||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if args.method == "http" {
|
let adapter = match args.method.as_ref() {
|
||||||
let adapter = HTTPWalletCommAdapter::new();
|
"http" => HTTPWalletCommAdapter::new(),
|
||||||
slate = adapter.send_tx_sync(&args.dest, &slate)?;
|
"file" => FileWalletCommAdapter::new(),
|
||||||
api.tx_lock_outputs(&slate, lock_fn)?;
|
"keybase" => KeybaseWalletCommAdapter::new(),
|
||||||
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);
|
error!("unsupported payment method: {}", args.method);
|
||||||
return Err(ErrorKind::ClientCallback("unsupported payment 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)?;
|
||||||
|
}
|
||||||
Ok(slate)
|
Ok(slate)
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue