mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 15:21:39 +02:00
* version bump for next potential release * Merge master into milestone/2.1.0 (#182) * Derive --version output dynamically from cargo package version (#174) * add --txid to the `wallet txs` command (#176) * add --txid to the `wallet txs` command * add test for `wallet txs` command with `--txid` parameter * Refactor - Split WalletCommAdapter into multiple traits (#180) * Derive --version output dynamically from cargo package version (#174) * add server auth argument to http client * Revert "add server auth argument to http client" This reverts commit f52a8d2c7cdfb8583af5716ad621eb560811d6ee. * modify WalletCommAdapter, moving dest argument into fields on implementors, visiting havok on automated tests, at least one of which is now out of date and failing * Split WalletCommAdapter into four traits, one for each of its intended behaviors. * Remove two vestigals 1. args, a stringly typed argument to put_tx 2. NullAdapter, which is no longer used * Remove unused "params" argument from listen method. * Re-add previously existing TODO comment * Fix non-test build * completely Fix non-test build * Full Lifecycle API Support (#184) * refactoring wallet lib traits * rustfmt * rustfmt * add new files * explicit lifetime specifiers on all wallet traits * rustfmt * modify apis to use new walletinst * rustfmt * converting controller crate * rustfmt * controller crate compiling * rustfmt * compilation * rustfmt * Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl * rustfmt * full compilation, changing recovery + init to new model * rustfmt * wallet initialisation working, init command output and flow identical to v2.0.0 wallet * rustfmt * fix listener and owner api startup * rustfmt * rustfmt * move encryption test * rustfmt * fix api doctests * rustfmt * fix for most tests in controller crate * rustfmt * fix for check tests in controller crate * fix main wallet tests * rustfmt * add explicit functions to handle mnemonic recovery, fix CLI recovery workflow * rustfmt * update keybase adapter to use new wallet format * rustfmt * test fix * remove debug output
70 lines
2.6 KiB
Rust
70 lines
2.6 KiB
Rust
// Copyright 2018 The Grin Developers
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use crate::cmd::wallet_args;
|
|
use crate::config::GlobalWalletConfig;
|
|
use clap::ArgMatches;
|
|
use grin_wallet_impls::HTTPNodeClient;
|
|
use grin_wallet_libwallet::NodeClient;
|
|
use semver::Version;
|
|
use std::thread;
|
|
use std::time::Duration;
|
|
|
|
const MIN_COMPAT_NODE_VERSION: &str = "2.0.0-beta.1";
|
|
|
|
pub fn wallet_command(wallet_args: &ArgMatches<'_>, config: GlobalWalletConfig) -> i32 {
|
|
// just get defaults from the global config
|
|
let wallet_config = config.members.unwrap().wallet;
|
|
|
|
// Check the node version info, and exit with report if we're not compatible
|
|
let mut node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None);
|
|
let global_wallet_args = wallet_args::parse_global_args(&wallet_config, &wallet_args)
|
|
.expect("Can't read configuration file");
|
|
node_client.set_node_api_secret(global_wallet_args.node_api_secret.clone());
|
|
|
|
// This will also cache the node version info for calls to foreign API check middleware
|
|
if let Some(v) = node_client.clone().get_version_info() {
|
|
// Isn't going to happen just yet (as of 2.0.0) but keep this here for
|
|
// the future. the nodeclient's get_version_info will return 1.0 if
|
|
// it gets a 404 for the version function
|
|
if Version::parse(&v.node_version) < Version::parse(MIN_COMPAT_NODE_VERSION) {
|
|
let version = if v.node_version == "1.0.0" {
|
|
"1.x.x series"
|
|
} else {
|
|
&v.node_version
|
|
};
|
|
println!("The Grin Node in use (version {}) is outdated and incompatible with this wallet version.", version);
|
|
println!("Please update the node to version 2.0.0 or later and try again.");
|
|
return 1;
|
|
}
|
|
}
|
|
// ... if node isn't available, allow offline functions
|
|
|
|
let res = wallet_args::wallet_command(wallet_args, wallet_config, node_client);
|
|
|
|
// we need to give log output a chance to catch up before exiting
|
|
thread::sleep(Duration::from_millis(100));
|
|
|
|
if let Err(e) = res {
|
|
println!("Wallet command failed: {}", e);
|
|
1
|
|
} else {
|
|
println!(
|
|
"Command '{}' completed successfully",
|
|
wallet_args.subcommand().0
|
|
);
|
|
0
|
|
}
|
|
}
|