[WIP] Factoring out wallet traits and continued wallet library work (#1096)
* rename wallet libs * rename transaction.rs to slate.rs * rename transaction.rs to slate.rs * move some types into libwallet/types * rustfmt * rename libtransaction libtx * rename libtransaction libtx * change types.rs to file_wallet * rustfmt * rename WalletData to FileWallet * refactoring WalletBackend types out * rustfmt * All compiling, at least * rustfmt * fix FileWallet paths to persist * rustfmt * re-ignore wallet integration test
This commit is contained in:
+19
-20
@@ -37,20 +37,21 @@ extern crate grin_wallet as wallet;
|
||||
mod client;
|
||||
pub mod tui;
|
||||
|
||||
use std::thread;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use std::env::current_dir;
|
||||
use std::process::exit;
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use clap::{App, Arg, ArgMatches, SubCommand};
|
||||
use daemonize::Daemonize;
|
||||
|
||||
use config::GlobalConfig;
|
||||
use core::global;
|
||||
use core::core::amount_to_hr_string;
|
||||
use util::{init_logger, LoggingConfig, LOGGER};
|
||||
use core::global;
|
||||
use tui::ui;
|
||||
use util::{init_logger, LoggingConfig, LOGGER};
|
||||
use wallet::FileWallet;
|
||||
|
||||
// include build information
|
||||
pub mod built_info {
|
||||
@@ -422,7 +423,10 @@ fn server_command(server_args: Option<&ArgMatches>, mut global_config: GlobalCon
|
||||
let _ = thread::Builder::new()
|
||||
.name("wallet_listener".to_string())
|
||||
.spawn(move || {
|
||||
wallet::server::start_rest_apis(wallet_config, keychain);
|
||||
let wallet = FileWallet::new(wallet_config.clone(), keychain).unwrap_or_else(|e| {
|
||||
panic!("Error creating wallet: {:?} Config: {:?}", e, wallet_config)
|
||||
});
|
||||
wallet::server::start_rest_apis(wallet, &wallet_config.api_listen_addr());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -530,16 +534,18 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
|
||||
let passphrase = wallet_args
|
||||
.value_of("pass")
|
||||
.expect("Failed to read passphrase.");
|
||||
let mut keychain = wallet_seed
|
||||
let keychain = wallet_seed
|
||||
.derive_keychain(&passphrase)
|
||||
.expect("Failed to derive keychain from seed file and passphrase.");
|
||||
let mut wallet = FileWallet::new(wallet_config.clone(), keychain)
|
||||
.unwrap_or_else(|e| panic!("Error creating wallet: {:?} Config: {:?}", e, wallet_config));
|
||||
|
||||
match wallet_args.subcommand() {
|
||||
("listen", Some(listen_args)) => {
|
||||
if let Some(port) = listen_args.value_of("port") {
|
||||
wallet_config.api_listen_port = port.parse().unwrap();
|
||||
}
|
||||
wallet::server::start_rest_apis(wallet_config, keychain);
|
||||
wallet::server::start_rest_apis(wallet, &wallet_config.api_listen_addr());
|
||||
}
|
||||
("send", Some(send_args)) => {
|
||||
let amount = send_args
|
||||
@@ -564,8 +570,7 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
|
||||
}
|
||||
let max_outputs = 500;
|
||||
let result = wallet::issue_send_tx(
|
||||
&wallet_config,
|
||||
&mut keychain,
|
||||
&mut wallet,
|
||||
amount,
|
||||
minimum_confirmations,
|
||||
dest.to_string(),
|
||||
@@ -618,22 +623,16 @@ fn wallet_command(wallet_args: &ArgMatches, global_config: GlobalConfig) {
|
||||
.parse()
|
||||
.expect("Could not parse minimum_confirmations as a whole number.");
|
||||
let max_outputs = 500;
|
||||
wallet::issue_burn_tx(
|
||||
&wallet_config,
|
||||
&keychain,
|
||||
amount,
|
||||
minimum_confirmations,
|
||||
max_outputs,
|
||||
).unwrap();
|
||||
wallet::issue_burn_tx(&mut wallet, amount, minimum_confirmations, max_outputs).unwrap();
|
||||
}
|
||||
("info", Some(_)) => {
|
||||
wallet::show_info(&wallet_config, &keychain);
|
||||
wallet::show_info(&mut wallet);
|
||||
}
|
||||
("outputs", Some(_)) => {
|
||||
wallet::show_outputs(&wallet_config, &keychain, show_spent);
|
||||
wallet::show_outputs(&mut wallet, show_spent);
|
||||
}
|
||||
("restore", Some(_)) => {
|
||||
let _ = wallet::restore(&wallet_config, &keychain);
|
||||
let _ = wallet::restore(&mut wallet);
|
||||
}
|
||||
_ => panic!("Unknown wallet command, use 'grin help wallet' for details"),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user