From c1dd259caf7cff8690d78d2fedc3f06c5c7630f7 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Sun, 20 Oct 2019 13:40:54 -0700 Subject: [PATCH] Add bug warning --- lib/src/lightclient.rs | 18 ++++++++++++++++++ lib/src/lightwallet/bugs.rs | 1 + 2 files changed, 19 insertions(+) diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index acc6cf3..fcaf7a5 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -42,6 +42,18 @@ pub struct LightClientConfig { impl LightClientConfig { + // Create an unconnected (to any server) config to test for local wallet etc... + pub fn create_unconnected(chain_name: String) -> LightClientConfig { + LightClientConfig { + server : http::Uri::default(), + chain_name : chain_name, + sapling_activation_height : 0, + consensus_branch_id : "".to_string(), + anchor_offset : ANCHOR_OFFSET, + no_cert_verification : false, + } + } + pub fn create(server: http::Uri, dangerous: bool) -> io::Result<(LightClientConfig, u64)> { // Do a getinfo first, before opening the wallet let info = grpcconnector::get_info(server.clone(), dangerous) @@ -255,6 +267,12 @@ impl LightClient { info!("Read wallet with birthday {}", lc.wallet.read().unwrap().get_first_tx_block()); info!("Created LightClient to {}", &config.server); + if crate::lightwallet::bugs::BugBip39Derivation::has_bug(&lc) { + let m = format!("WARNING!!!\nYour wallet has a bip39derivation bug that's showing incorrect addresses.\nPlease run 'fixbip39bug' to automatically fix the address derivation in your wallet!\nPlease see: https://github.com/adityapk00/zecwallet-light-cli/blob/master/bip39bug.md"); + info!("{}", m); + println!("{}", m); + } + Ok(lc) } diff --git a/lib/src/lightwallet/bugs.rs b/lib/src/lightwallet/bugs.rs index 60f237f..48eeba7 100644 --- a/lib/src/lightwallet/bugs.rs +++ b/lib/src/lightwallet/bugs.rs @@ -70,6 +70,7 @@ impl BugBip39Derivation { // Tranfer money // 1. The desination is z address #0 + println!("Sending funds to ourself."); let zaddr = client.do_address()["z_addresses"][0].as_str().unwrap().to_string(); let balance_json = client.do_balance(); let fee: u64 = DEFAULT_FEE.try_into().unwrap();