From 5cf2c955e3436d9ddda1c0125746f95e8f3ac523 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 21 Oct 2019 13:09:47 -0700 Subject: [PATCH] Don't fix bug when no money is involved. --- lib/src/commands.rs | 2 +- lib/src/lightwallet/bugs.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/src/commands.rs b/lib/src/commands.rs index f8d282c..075dbe8 100644 --- a/lib/src/commands.rs +++ b/lib/src/commands.rs @@ -235,7 +235,7 @@ impl Command for EncryptCommand { use crate::lightwallet::bugs::BugBip39Derivation; if BugBip39Derivation::has_bug(lightclient) { let mut h = vec![]; - h.push("It looks like your wallet has the bop39bug. Please run 'fixbip39bug' to fix it"); + h.push("It looks like your wallet has the bip39bug. Please run 'fixbip39bug' to fix it"); h.push("before encrypting your wallet."); h.push("ERROR: Cannot encrypt while wallet has the bip39bug."); return h.join("\n"); diff --git a/lib/src/lightwallet/bugs.rs b/lib/src/lightwallet/bugs.rs index 48eeba7..ed4295b 100644 --- a/lib/src/lightwallet/bugs.rs +++ b/lib/src/lightwallet/bugs.rs @@ -73,13 +73,12 @@ impl BugBip39Derivation { 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(); let amount: u64 = balance_json["zbalance"].as_u64().unwrap() - + balance_json["tbalance"].as_u64().unwrap() - - fee; + + balance_json["tbalance"].as_u64().unwrap(); let txid = if amount > 0 { - match client.do_send(vec![(&zaddr, amount, None)]) { + let fee: u64 = DEFAULT_FEE.try_into().unwrap(); + match client.do_send(vec![(&zaddr, amount-fee, None)]) { Ok(txid) => txid, Err(e) => { let r = object!{