From 94e70cc3f776ce2b3d15cf03e5cded649e46a9d8 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Mon, 21 Oct 2019 13:00:31 -0700 Subject: [PATCH] Fix bip39 bug before encryption --- lib/src/commands.rs | 10 ++++++++++ mkrelease.sh | 12 +++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/src/commands.rs b/lib/src/commands.rs index fd6b2ca..f8d282c 100644 --- a/lib/src/commands.rs +++ b/lib/src/commands.rs @@ -231,6 +231,16 @@ impl Command for EncryptCommand { return self.help(); } + // Refuse to encrypt if the bip39 bug has not been fixed + 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("before encrypting your wallet."); + h.push("ERROR: Cannot encrypt while wallet has the bip39bug."); + return h.join("\n"); + } + let passwd = args[0].to_string(); match lightclient.wallet.write().unwrap().encrypt(passwd) { diff --git a/mkrelease.sh b/mkrelease.sh index c328780..134569f 100755 --- a/mkrelease.sh +++ b/mkrelease.sh @@ -25,8 +25,14 @@ set -- "${POSITIONAL[@]}" # restore positional parameters if [ -z $APP_VERSION ]; then echo "APP_VERSION is not set"; exit 1; fi -# Clean everything first -cargo clean +# First, do the tests +cd lib && cargo test --release +retVal=$? +if [ $retVal -ne 0 ]; then + echo "Error" + exit $retVal +fi +cd .. # Compile for mac directly cargo build --release @@ -40,7 +46,7 @@ cp target/release/zecwallet-cli target/macOS-zecwallet-cli-v$APP_VERSION/ docker run --rm -v $(pwd)/:/opt/zecwallet-light-cli rustbuild:latest bash -c "cd /opt/zecwallet-light-cli && cargo build --release && SODIUM_LIB_DIR='/opt/libsodium-win64/lib/' cargo build --release --target x86_64-pc-windows-gnu" # Now sign and zip the binaries -#macOS +# macOS gpg --batch --output target/macOS-zecwallet-cli-v$APP_VERSION/zecwallet-cli.sig --detach-sig target/macOS-zecwallet-cli-v$APP_VERSION/zecwallet-cli cd target cd macOS-zecwallet-cli-v$APP_VERSION