Fix for API secret on node API startup (#131)

* fix for api_secret when reading node height

* rustfmt

* remove macro export

* trigger ci again
This commit is contained in:
Yeastplume 2019-06-01 10:37:33 +01:00 committed by GitHub
parent cc940fb978
commit 03ab8ad8bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -17,6 +17,7 @@ use crate::config::GlobalWalletConfig;
use clap::ArgMatches;
use grin_wallet_config::WalletConfig;
use grin_wallet_impls::{HTTPNodeClient, WalletSeed, SEED_FILE};
use grin_wallet_libwallet::NodeClient;
use std::path::PathBuf;
use std::thread;
use std::time::Duration;
@ -43,20 +44,23 @@ pub fn wallet_command(wallet_args: &ArgMatches<'_>, config: GlobalWalletConfig)
// just get defaults from the global config
let wallet_config = config.members.unwrap().wallet;
let node_client = HTTPNodeClient::new(&wallet_config.check_node_api_http_addr, None);
// TODO: Very temporary code to obsolete grin wallet for the first hard fork
// All tx operations call get_chain_height as a first order of business,
// so this is the most non-intrusive place to put this
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());
match node_client.clone().chain_height() {
Ok(h) => {
if h >= 262080 {
let err_str = "This version of grin-wallet is obsolete as of block 252080. Please download v2.0.0 from https://github.com/mimblewimble/grin-wallet/releases";
error!("{}", err_str);
println!();
println!("**************");
println!("***************");
println!("{}", err_str);
println!("**************");
println!("***************");
println!("(You can still view your balances by disconnecting from the grin node, however you will not be able to transact until you upgrade)");
println!();
return 1;