diff --git a/docker/Dockerfile b/docker/Dockerfile index abe4b05..00c4027 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,35 +1,41 @@ -FROM rust:1.38 +FROM ubuntu:16.04 LABEL Description="Rust compile env for Linux + Windows (cross)" RUN apt update -RUN apt install -y build-essential mingw-w64 gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf +RUN apt install -y build-essential mingw-w64 gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf curl vim wget + +# Get Rust +RUN curl https://sh.rustup.rs -sSf | bash -s -- -y +ENV PATH="/root/.cargo/bin:${PATH}" RUN rustup target add x86_64-pc-windows-gnu RUN rustup target add aarch64-unknown-linux-gnu RUN rustup target add armv7-unknown-linux-gnueabihf # Append the linker to the cargo config for Windows cross compile -RUN echo "[target.x86_64-pc-windows-gnu]" >> /usr/local/cargo/config && \ - echo "linker = '/usr/bin/x86_64-w64-mingw32-gcc'" >> /usr/local/cargo/config +RUN echo "[target.x86_64-pc-windows-gnu]" >> /root/.cargo/config && \ + echo "linker = '/usr/bin/x86_64-w64-mingw32-gcc'" >> /root/.cargo/config -RUN echo "[target.aarch64-unknown-linux-gnu]" >> /usr/local/cargo/config && \ - echo "linker = '/usr/bin/aarch64-linux-gnu-gcc'" >> /usr/local/cargo/config +RUN echo "[target.aarch64-unknown-linux-gnu]" >> /root/.cargo/config && \ + echo "linker = '/usr/bin/aarch64-linux-gnu-gcc'" >> /root/.cargo/config -RUN echo "[target.armv7-unknown-linux-gnueabihf]" >> /usr/local/cargo/config && \ - echo "linker = '/usr/bin/arm-linux-gnueabihf-gcc'" >> /usr/local/cargo/config +RUN echo "[target.armv7-unknown-linux-gnueabihf]" >> /root/.cargo/config && \ + echo "linker = '/usr/bin/arm-linux-gnueabihf-gcc'" >> /root/.cargo/config ENV CC_x86_64_unknown_linux_musl="gcc" ENV CC_aarch64_unknown_linux_gnu="aarch64-linux-gnu-gcc" ENV CC_armv7_unknown_linux_gnueabhihf="arm-linux-gnueabihf-gcc" # This is a bug fix for the windows cross compiler for Rust. -RUN cp /usr/x86_64-w64-mingw32/lib/crt2.o /usr/local/rustup/toolchains/1.38.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o +RUN cp /usr/x86_64-w64-mingw32/lib/crt2.o /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/crt2.o # For windows cross compilation, use a pre-build binary. Remember to set the # SODIUM_LIB_DIR for windows cross compilation RUN cd /opt && wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.17-mingw.tar.gz && \ tar xvf libsodium-1.0.17-mingw.tar.gz +RUN apt install -y git + # Cargo fetch the dependencies so we don't download them over and over again RUN cd /tmp && git clone https://github.com/adityapk00/zecwallet-light-cli.git && \ cd zecwallet-light-cli && \ diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index a9db4c0..71d1005 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -767,7 +767,7 @@ impl LightWallet { None => true } }) - .map(|nd| if nd.spent.is_none() { nd.note.value } else { 0 }) + .map(|nd| if nd.spent.is_none() && nd.unconfirmed_spent.is_none() { nd.note.value } else { 0 }) .sum::() }) .sum::() diff --git a/lib/src/lightwallet/tests.rs b/lib/src/lightwallet/tests.rs index 2997694..69fdbae 100644 --- a/lib/src/lightwallet/tests.rs +++ b/lib/src/lightwallet/tests.rs @@ -706,6 +706,12 @@ fn test_z_spend_to_z() { let branch_id = u32::from_str_radix("2bb40e60", 16).unwrap(); let (ss, so) = get_sapling_params().unwrap(); + // Make sure that the balance exists + { + assert_eq!(wallet.zbalance(None), AMOUNT1); + assert_eq!(wallet.verified_zbalance(None), AMOUNT1); + } + // Create a tx and send to address let raw_tx = wallet.send_to_address(branch_id, &ss, &so, vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); @@ -736,6 +742,12 @@ fn test_z_spend_to_z() { assert_eq!(mem[&sent_txid].outgoing_metadata[0].memo.to_utf8().unwrap().unwrap(), outgoing_memo); } + { + // The wallet should deduct this from the balance and verified balance + assert_eq!(wallet.zbalance(None), 0); + assert_eq!(wallet.verified_zbalance(None), 0); + } + let mut cb3 = FakeCompactBlock::new(2, block_hash); cb3.add_tx(&sent_tx); wallet.scan_block(&cb3.as_bytes()).unwrap();