From 1e64ab9a89a122ff218d7cb510092f0422433a6e Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Tue, 9 Aug 2022 10:19:20 -0500 Subject: [PATCH] v1.8.0-beta3 --- .github/workflows/electron.yml | 2 +- .vscode/settings.json | 2 +- bin/printversion.ps1 | 2 +- bin/printversion.sh | 2 +- native/Cargo.lock | 98 ++++++++++++++++++++++------------ native/Cargo.toml | 12 ++++- native/rust-toolchain | 2 +- package.json | 2 +- public/electron.js | 36 ------------- rust-toolchain | 2 +- src/Routes.tsx | 8 +-- src/components/AppState.ts | 42 +++++++++++---- src/components/Dashboard.tsx | 12 +++-- src/components/Receive.tsx | 65 ++++++++++++++++++---- src/components/Send.tsx | 30 +++++++---- src/components/Sidebar.tsx | 12 ++--- src/rpc.ts | 46 +++++++++++----- src/utils/utils.ts | 7 ++- 18 files changed, 249 insertions(+), 133 deletions(-) diff --git a/.github/workflows/electron.yml b/.github/workflows/electron.yml index cd04e045..9cedf8e6 100644 --- a/.github/workflows/electron.yml +++ b/.github/workflows/electron.yml @@ -23,7 +23,7 @@ jobs: fetch-depth: 1 - uses: actions-rs/toolchain@v1 with: - toolchain: 1.56.1 + toolchain: 1.62 override: true components: rustfmt - name: Use Node.js 14.x diff --git a/.vscode/settings.json b/.vscode/settings.json index dc9231f5..e7097f69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,7 +13,7 @@ "javascript.validate.enable": false, "javascript.format.enable": false, - "typescript.validate.enable": false, + "typescript.validate.enable": true, "typescript.format.enable": false, "flow.useNPMPackagedFlow": true, diff --git a/bin/printversion.ps1 b/bin/printversion.ps1 index bd52b5e3..12538485 100644 --- a/bin/printversion.ps1 +++ b/bin/printversion.ps1 @@ -1 +1 @@ -echo "VERSION=1.7.20" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append +echo "VERSION=1.8.0-beta3" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append diff --git a/bin/printversion.sh b/bin/printversion.sh index 6af41468..8037e966 100755 --- a/bin/printversion.sh +++ b/bin/printversion.sh @@ -1,3 +1,3 @@ #!/bin/bash -VERSION="1.7.20" +VERSION="1.8.0-beta3" echo "VERSION=$VERSION" >> $GITHUB_ENV diff --git a/native/Cargo.lock b/native/Cargo.lock index 0f2aa9db..ff61c053 100644 --- a/native/Cargo.lock +++ b/native/Cargo.lock @@ -612,13 +612,21 @@ checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be" [[package]] name = "equihash" -version = "0.1.0" -source = "git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481#7183acd2fe12ebf201cae5b871166e356273c481" +version = "0.2.0" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" dependencies = [ "blake2b_simd", "byteorder", ] +[[package]] +name = "f4jumble" +version = "0.1.0" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" +dependencies = [ + "blake2b_simd", +] + [[package]] name = "fastrand" version = "1.7.0" @@ -827,9 +835,9 @@ dependencies = [ [[package]] name = "halo2_gadgets" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13f3914f58cc4af5e4fe83d48b02d582be18976bc7e96c3151aa2bf1c98e9f60" +checksum = "85e10bf9924da1754e443641c9e7f9f00483749f8fb837fde696ef6ed6e2f079" dependencies = [ "arrayvec", "bitvec", @@ -845,9 +853,9 @@ dependencies = [ [[package]] name = "halo2_proofs" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e925780549adee8364c7f2b685c753f6f3df23bde520c67416e93bf615933760" +checksum = "cff771b9a2445cd2545c9ef26d863c290fbb44ae440c825a20eb7156f67a949a" dependencies = [ "blake2b_simd", "ff", @@ -855,6 +863,7 @@ dependencies = [ "pasta_curves", "rand_core 0.6.3", "rayon", + "tracing", ] [[package]] @@ -1360,9 +1369,8 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "orchard" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f918076e191a68d55c5517a16e075ecfe58fc63ed112408263f3d6194597bfcf" +version = "0.2.0" +source = "git+https://github.com/adityapk00/orchard?rev=0a960a380f4e9c3472c9260f3df61cd5e50d51b0#0a960a380f4e9c3472c9260f3df61cd5e50d51b0" dependencies = [ "aes", "bitvec", @@ -1382,7 +1390,8 @@ dependencies = [ "reddsa", "serde", "subtle", - "zcash_note_encryption 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing", + "zcash_note_encryption", ] [[package]] @@ -1774,6 +1783,22 @@ dependencies = [ "zeroize", ] +[[package]] +name = "redjubjub" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6039ff156887caf92df308cbaccdc058c9d3155a913da046add6e48c4cdbd91d" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.9.0", + "jubjub", + "rand_core 0.6.3", + "serde", + "thiserror", + "zeroize", +] + [[package]] name = "redox_syscall" version = "0.2.13" @@ -2947,10 +2972,21 @@ dependencies = [ "linked-hash-map", ] +[[package]] +name = "zcash_address" +version = "0.1.0" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" +dependencies = [ + "bech32", + "bs58", + "f4jumble", + "zcash_encoding", +] + [[package]] name = "zcash_client_backend" version = "0.5.0" -source = "git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481#7183acd2fe12ebf201cae5b871166e356273c481" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" dependencies = [ "base64", "bech32", @@ -2962,20 +2998,22 @@ dependencies = [ "jubjub", "log", "nom", + "orchard", "percent-encoding", "protobuf", "protobuf-codegen-pure", "rand_core 0.6.3", "subtle", "time 0.2.27", - "zcash_note_encryption 0.1.0 (git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481)", + "zcash_address", + "zcash_note_encryption", "zcash_primitives", ] [[package]] name = "zcash_encoding" version = "0.1.0" -source = "git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481#7183acd2fe12ebf201cae5b871166e356273c481" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" dependencies = [ "byteorder", "nonempty", @@ -2984,19 +3022,7 @@ dependencies = [ [[package]] name = "zcash_note_encryption" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33f84ae538f05a8ac74c82527f06b77045ed9553a0871d9db036166a4c344e3a" -dependencies = [ - "chacha20", - "chacha20poly1305", - "rand_core 0.6.3", - "subtle", -] - -[[package]] -name = "zcash_note_encryption" -version = "0.1.0" -source = "git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481#7183acd2fe12ebf201cae5b871166e356273c481" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" dependencies = [ "chacha20", "chacha20poly1305", @@ -3006,8 +3032,8 @@ dependencies = [ [[package]] name = "zcash_primitives" -version = "0.6.0" -source = "git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481#7183acd2fe12ebf201cae5b871166e356273c481" +version = "0.7.0" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" dependencies = [ "aes", "bip0039", @@ -3036,14 +3062,15 @@ dependencies = [ "secp256k1", "sha2", "subtle", + "zcash_address", "zcash_encoding", - "zcash_note_encryption 0.1.0 (git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481)", + "zcash_note_encryption", ] [[package]] name = "zcash_proofs" -version = "0.6.0" -source = "git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481#7183acd2fe12ebf201cae5b871166e356273c481" +version = "0.7.1" +source = "git+https://github.com/adityapk00/librustzcash?rev=adf49f8b848a5ac85e1476354614eeae9880206a#adf49f8b848a5ac85e1476354614eeae9880206a" dependencies = [ "bellman", "blake2b_simd", @@ -3055,6 +3082,8 @@ dependencies = [ "jubjub", "lazy_static", "rand_core 0.6.3", + "redjubjub", + "tracing", "zcash_primitives", ] @@ -3070,7 +3099,7 @@ dependencies = [ [[package]] name = "zecwalletlitelib" version = "0.1.0" -source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=4276057e9fcdc15f3dd5b4aacd12951d3fec3c48#4276057e9fcdc15f3dd5b4aacd12951d3fec3c48" +source = "git+https://github.com/adityapk00/zecwallet-light-cli?rev=8d9faccafe0056ad9b5f4e2a64dbba10ba6aeb17#8d9faccafe0056ad9b5f4e2a64dbba10ba6aeb17" dependencies = [ "arr_macro", "base58", @@ -3084,11 +3113,13 @@ dependencies = [ "group", "hex 0.3.2", "http", + "incrementalmerkletree", "json", "jubjub", "lazy_static", "log", "log4rs", + "orchard", "pairing", "prost", "rand 0.8.5", @@ -3105,9 +3136,10 @@ dependencies = [ "tonic", "tonic-build", "webpki-roots", + "zcash_address", "zcash_client_backend", "zcash_encoding", - "zcash_note_encryption 0.1.0 (git+https://github.com/adityapk00/librustzcash?rev=7183acd2fe12ebf201cae5b871166e356273c481)", + "zcash_note_encryption", "zcash_primitives", "zcash_proofs", ] diff --git a/native/Cargo.toml b/native/Cargo.toml index 2e896e2b..c4fe6a64 100644 --- a/native/Cargo.toml +++ b/native/Cargo.toml @@ -15,6 +15,16 @@ default-features = false features = ["napi-6"] [dependencies] -zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "4276057e9fcdc15f3dd5b4aacd12951d3fec3c48" } +zecwalletlitelib = { git = "https://github.com/adityapk00/zecwallet-light-cli", rev = "8d9faccafe0056ad9b5f4e2a64dbba10ba6aeb17" } #zecwalletlitelib = { path = "../../zecwallet-light-cli/lib" } lazy_static = "1.4.0" + + +[patch.crates-io] +zcash_address = { git = "https://github.com/adityapk00/librustzcash", rev = "adf49f8b848a5ac85e1476354614eeae9880206a"} +zcash_primitives = { git = "https://github.com/adityapk00/librustzcash", rev = "adf49f8b848a5ac85e1476354614eeae9880206a"} +zcash_client_backend = { git = "https://github.com/adityapk00/librustzcash", rev = "adf49f8b848a5ac85e1476354614eeae9880206a"} +zcash_note_encryption = { git = "https://github.com/adityapk00/librustzcash", rev = "adf49f8b848a5ac85e1476354614eeae9880206a"} +zcash_encoding = { git = "https://github.com/adityapk00/librustzcash", rev = "adf49f8b848a5ac85e1476354614eeae9880206a"} +zcash_proofs = { git = "https://github.com/adityapk00/librustzcash", rev = "adf49f8b848a5ac85e1476354614eeae9880206a"} +orchard = { git = "https://github.com/adityapk00/orchard", rev = "0a960a380f4e9c3472c9260f3df61cd5e50d51b0" } diff --git a/native/rust-toolchain b/native/rust-toolchain index 43c989b5..0a03ace4 100644 --- a/native/rust-toolchain +++ b/native/rust-toolchain @@ -1 +1 @@ -1.56.1 +1.62 diff --git a/package.json b/package.json index 9442c9ac..4d576f60 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zecwallet-lite", "productName": "Zecwallet Lite", - "version": "1.7.20", + "version": "1.8.0-beta3", "private": true, "description": "Zecwallet Lite", "license": "MIT", diff --git a/public/electron.js b/public/electron.js index f387a478..b07932ec 100644 --- a/public/electron.js +++ b/public/electron.js @@ -151,19 +151,7 @@ class MenuBuilder { this.mainWindow.webContents.send("zcashd"); }, }, - { - label: "Connect Mobile App", - click: () => { - this.mainWindow.webContents.send("connectmobile"); - }, - }, { type: "separator" }, - { - label: "Encrypt Wallet", - click: () => { - this.mainWindow.webContents.send("encrypt"); - }, - }, { label: "Remove Wallet Encryption", click: () => { @@ -233,19 +221,7 @@ class MenuBuilder { this.mainWindow.webContents.send("zcashd"); }, }, - { - label: "Connect Mobile App", - click: () => { - this.mainWindow.webContents.send("connectmobile"); - }, - }, { type: "separator" }, - { - label: "Encrypt Wallet", - click: () => { - this.mainWindow.webContents.send("encrypt"); - }, - }, { label: "Remove Wallet Encryption", click: () => { @@ -365,12 +341,6 @@ class MenuBuilder { this.mainWindow.webContents.send("zcashd"); }, }, - { - label: "Connect Mobile App", - click: () => { - this.mainWindow.webContents.send("connectmobile"); - }, - }, // { // label: 'Devtools', // click: () => { @@ -378,12 +348,6 @@ class MenuBuilder { // } // }, { type: "separator" }, - { - label: "Encrypt Wallet", - click: () => { - this.mainWindow.webContents.send("encrypt"); - }, - }, { label: "Remove Wallet Encryption", click: () => { diff --git a/rust-toolchain b/rust-toolchain index 43c989b5..0a03ace4 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.56.1 +1.62 diff --git a/src/Routes.tsx b/src/Routes.tsx index abd00766..c69cec88 100644 --- a/src/Routes.tsx +++ b/src/Routes.tsx @@ -25,6 +25,8 @@ import AppState, { PasswordState, ServerSelectState, SendProgress, + AddressType, + AddressDetail, } from "./components/AppState"; import RPC from "./rpc"; import Utils from "./utils/utils"; @@ -234,7 +236,7 @@ export default class RouteApp extends React.Component { this.setState({ transactions }); }; - setAllAddresses = (addresses: string[]) => { + setAllAddresses = (addresses: AddressDetail[]) => { this.setState({ addresses }); }; @@ -408,10 +410,10 @@ export default class RouteApp extends React.Component { this.setState({ addressBook: newAddressBook }); }; - createNewAddress = async (zaddress: boolean) => { + createNewAddress = async (type: AddressType) => { this.openPasswordAndUnlockIfNeeded(async () => { // Create a new address - const newaddress = RPC.createNewAddress(zaddress); + const newaddress = RPC.createNewAddress(type); console.log(`Created new Address ${newaddress}`); // And then fetch the list of addresses again to refresh (totalBalance gets all addresses) diff --git a/src/components/AppState.ts b/src/components/AppState.ts index 87f2e0d8..3856f57a 100644 --- a/src/components/AppState.ts +++ b/src/components/AppState.ts @@ -2,31 +2,41 @@ import { ErrorModalData } from "./ErrorModal"; +export enum AddressType { + transparent, + sapling, + unified, +} + export class TotalBalance { // Total t address, confirmed and spendable transparent: number; + // Total orchard balance + uabalance: number; + // Total private, confirmed + unconfirmed - private: number; + zbalance: number; // Total private, confirmed funds that have been verified - verifiedPrivate: number; + verifiedZ: number; // Total private that are waiting for confirmation - unverifiedPrivate: number; + unverifiedZ: number; // Total private funds that are spendable - spendablePrivate: number; + spendableZ: number; // Total unconfirmed + spendable total: number; constructor() { - this.private = 0; + this.uabalance = 0; + this.zbalance = 0; this.transparent = 0; - this.verifiedPrivate = 0; - this.unverifiedPrivate = 0; - this.spendablePrivate = 0; + this.verifiedZ = 0; + this.unverifiedZ = 0; + this.spendableZ = 0; this.total = 0; } } @@ -216,6 +226,20 @@ export class SendProgress { } } +export class AddressDetail { + address: string; + type: AddressType; + account?: number; + diversifier?: number; + + constructor(address: string, type: AddressType, account?: number, diversifier?: number) { + this.address = address; + this.type = type; + this.account = account; + this.diversifier = diversifier; + } +} + // eslint-disable-next-line max-classes-per-file export default class AppState { // The total confirmed and unconfirmed balance in this wallet @@ -233,7 +257,7 @@ export default class AppState { // List of all addresses in the wallet, including change addresses and addresses // that don't have any balance or are unused - addresses: string[]; + addresses: AddressDetail[]; // List of Address / Label pairs addressBook: AddressBookEntry[]; diff --git a/src/components/Dashboard.tsx b/src/components/Dashboard.tsx index 37340b63..efdb9f54 100644 --- a/src/components/Dashboard.tsx +++ b/src/components/Dashboard.tsx @@ -81,9 +81,15 @@ export default class Home extends Component { currencyName={info.currencyName} /> + {copied ? Copied! : Copy Address} - {!privateKey && ( + {Utils.isZaddr(address) && !privateKey && ( + + + {/* Change the hardcoded height */} @@ -270,10 +313,10 @@ export default class Receive extends Component { @@ -299,7 +342,7 @@ export default class Receive extends Component { diff --git a/src/components/Send.tsx b/src/components/Send.tsx index 00f21fdd..a4861de7 100644 --- a/src/components/Send.tsx +++ b/src/components/Send.tsx @@ -13,7 +13,16 @@ import TextareaAutosize from "react-textarea-autosize"; import { RouteComponentProps, withRouter } from "react-router-dom"; import styles from "./Send.module.css"; import cstyles from "./Common.module.css"; -import { ToAddr, AddressBalance, SendPageState, Info, AddressBookEntry, TotalBalance, SendProgress } from "./AppState"; +import { + ToAddr, + AddressBalance, + SendPageState, + Info, + AddressBookEntry, + TotalBalance, + SendProgress, + AddressDetail, +} from "./AppState"; import Utils from "../utils/utils"; import ScrollPane from "./ScrollPane"; import ArrowUpLight from "../assets/img/arrow_up_dark.png"; @@ -56,9 +65,10 @@ const ToAddrBox = ({ setSendButtonEnable, totalAmountAvailable, }: ToAddrBoxProps) => { - const isMemoDisabled = !Utils.isZaddr(toaddr.to); + const isMemoDisabled = !(Utils.isZaddr(toaddr.to) || Utils.isUnified(toaddr.to)); - const addressIsValid = toaddr.to === "" || Utils.isZaddr(toaddr.to) || Utils.isTransparent(toaddr.to); + const addressIsValid = + toaddr.to === "" || Utils.isUnified(toaddr.to) || Utils.isZaddr(toaddr.to) || Utils.isTransparent(toaddr.to); let amountError = null; if (toaddr.amount) { @@ -118,7 +128,7 @@ const ToAddrBox = ({ updateToField(toaddr.id as number, e, null, null)} @@ -148,7 +158,7 @@ const ToAddrBox = ({ - {isMemoDisabled &&
Memos only for z-addresses
} + {isMemoDisabled &&
Memos only for sapling or UA addresses
} {!isMemoDisabled && (
@@ -375,7 +385,7 @@ const ConfirmModalInternal: React.FC = const ConfirmModal = withRouter(ConfirmModalInternal); type Props = { - addresses: string[]; + addresses: AddressDetail[]; totalBalance: TotalBalance; addressBook: AddressBookEntry[]; sendPageState: SendPageState; @@ -561,13 +571,13 @@ export default class Send extends PureComponent { openPasswordAndUnlockIfNeeded, } = this.props; - const totalAmountAvailable = totalBalance.transparent + totalBalance.spendablePrivate; - const fromaddr = addresses.find((a) => Utils.isSapling(a)) as string; + const totalAmountAvailable = totalBalance.transparent + totalBalance.spendableZ + totalBalance.uabalance; + const fromaddr = addresses.find((a) => Utils.isSapling(a.address))?.address || ""; // If there are unverified funds, then show a tooltip let tooltip: string = ""; - if (totalBalance.unverifiedPrivate) { - tooltip = `Waiting for confirmation of ZEC ${totalBalance.unverifiedPrivate} with 5 blocks (approx 6 minutes)`; + if (totalBalance.unverifiedZ) { + tooltip = `Waiting for confirmation of ZEC ${totalBalance.unverifiedZ} with 5 blocks (approx 6 minutes)`; } return ( diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 7d5d4816..0b7ef3c4 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -12,7 +12,7 @@ import styles from "./Sidebar.module.css"; import cstyles from "./Common.module.css"; import routes from "../constants/routes.json"; import Logo from "../assets/img/logobig.png"; -import { Info, Transaction } from "./AppState"; +import { AddressDetail, Info, Transaction } from "./AppState"; import Utils from "../utils/utils"; import RPC from "../rpc"; import { parseZcashURI, ZcashURITarget } from "../utils/uris"; @@ -222,7 +222,7 @@ const SidebarMenuItem = ({ name, routeName, currentRoute, iconname }: SidebarMen type Props = { info: Info; setRescanning: (rescan: boolean, prevSyncId: number) => void; - addresses: string[]; + addresses: AddressDetail[]; transactions: Transaction[]; setInfo: (info: Info) => void; clearTimers: () => void; @@ -276,10 +276,10 @@ class Sidebar extends PureComponent { openErrorModal( "Zecwallet Lite",
-
Zecwallet Lite v1.7.20
-
Built with Electron. Copyright (c) 2018-2021, Aditya Kulkarni.
+
Zecwallet Lite v1.8.0-beta3
+
Built with Electron. Copyright (c) 2018-2022, Aditya Kulkarni.
- The MIT License (MIT) Copyright (c) 2018-2021 Zecwallet + The MIT License (MIT) Copyright (c) 2018-2022 Zecwallet

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated @@ -490,7 +490,7 @@ class Sidebar extends PureComponent { const { addresses, getPrivKeyAsString } = this.props; openPasswordAndUnlockIfNeeded(async () => { const privKeysPromise = addresses.map(async (a) => { - const privKey = await getPrivKeyAsString(a); + const privKey = getPrivKeyAsString(a.address); return `${privKey} #${a}`; }); const exportedPrivKeys = await Promise.all(privKeysPromise); diff --git a/src/rpc.ts b/src/rpc.ts index 4b640ba9..0f55f0e2 100644 --- a/src/rpc.ts +++ b/src/rpc.ts @@ -8,6 +8,8 @@ import { TxDetail, Info, SendProgress, + AddressType, + AddressDetail, } from "./components/AppState"; import { SendManyJson } from "./components/Send"; @@ -20,7 +22,7 @@ export default class RPC { fnSetTotalBalance: (tb: TotalBalance) => void; fnSetAddressesWithBalance: (abs: AddressBalance[]) => void; fnSetTransactionsList: (t: Transaction[]) => void; - fnSetAllAddresses: (a: string[]) => void; + fnSetAllAddresses: (a: AddressDetail[]) => void; fnSetZecPrice: (p?: number) => void; refreshTimerID?: NodeJS.Timeout; updateTimerId?: NodeJS.Timeout; @@ -34,7 +36,7 @@ export default class RPC { fnSetTotalBalance: (tb: TotalBalance) => void, fnSetAddressesWithBalance: (abs: AddressBalance[]) => void, fnSetTransactionsList: (t: Transaction[]) => void, - fnSetAllAddresses: (a: string[]) => void, + fnSetAllAddresses: (a: AddressDetail[]) => void, fnSetInfo: (info: Info) => void, fnSetZecPrice: (p?: number) => void ) { @@ -241,12 +243,13 @@ export default class RPC { // Total Balance const balance = new TotalBalance(); - balance.private = balanceJSON.zbalance / 10 ** 8; + balance.uabalance = balanceJSON.uabalance / 10 ** 8; + balance.zbalance = balanceJSON.zbalance / 10 ** 8; balance.transparent = balanceJSON.tbalance / 10 ** 8; - balance.verifiedPrivate = balanceJSON.verified_zbalance / 10 ** 8; - balance.unverifiedPrivate = balanceJSON.unverified_zbalance / 10 ** 8; - balance.spendablePrivate = balanceJSON.spendable_zbalance / 10 ** 8; - balance.total = balance.private + balance.transparent; + balance.verifiedZ = balanceJSON.verified_zbalance / 10 ** 8; + balance.unverifiedZ = balanceJSON.unverified_zbalance / 10 ** 8; + balance.spendableZ = balanceJSON.spendable_zbalance / 10 ** 8; + balance.total = balance.uabalance + balance.zbalance + balance.transparent; this.fnSetTotalBalance(balance); // Fetch pending notes and UTXOs @@ -266,6 +269,17 @@ export default class RPC { }); // Addresses with Balance. The lite client reports balances in zatoshi, so divide by 10^8; + const oaddresses = balanceJSON.ua_addresses + .map((o: any) => { + // If this has any unconfirmed txns, show that in the UI + const ab = new AddressBalance(o.address, o.balance / 10 ** 8); + if (pendingAddressBalances.has(ab.address)) { + ab.containsPending = true; + } + return ab; + }) + .filter((ab: AddressBalance) => ab.balance > 0); + const zaddresses = balanceJSON.z_addresses .map((o: any) => { // If this has any unconfirmed txns, show that in the UI @@ -288,14 +302,17 @@ export default class RPC { }) .filter((ab: AddressBalance) => ab.balance > 0); - const addresses = zaddresses.concat(taddresses); + const addresses = oaddresses.concat(zaddresses.concat(taddresses)); this.fnSetAddressesWithBalance(addresses); // Also set all addresses - const allZAddresses = balanceJSON.z_addresses.map((o: any) => o.address); - const allTAddresses = balanceJSON.t_addresses.map((o: any) => o.address); - const allAddresses = allZAddresses.concat(allTAddresses); + const allOAddresses = balanceJSON.ua_addresses.map((o: any) => new AddressDetail(o.address, AddressType.unified)); + const allZAddresses = balanceJSON.z_addresses.map((o: any) => new AddressDetail(o.address, AddressType.sapling)); + const allTAddresses = balanceJSON.t_addresses.map( + (o: any) => new AddressDetail(o.address, AddressType.transparent) + ); + const allAddresses = allOAddresses.concat(allZAddresses.concat(allTAddresses)); this.fnSetAllAddresses(allAddresses); } @@ -321,8 +338,11 @@ export default class RPC { return privKeyJSON[0].viewing_key; } - static createNewAddress(zaddress: boolean) { - const addrStr = native.litelib_execute("new", zaddress ? "z" : "t"); + static createNewAddress(type: AddressType) { + const addrStr = native.litelib_execute( + "new", + type === AddressType.unified ? "u" : type === AddressType.sapling ? "z" : "t" + ); const addrJSON = JSON.parse(addrStr); return addrJSON[0]; diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 626420c3..38e36c60 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -11,7 +11,12 @@ export default class Utils { static V2_LIGHTWALLETD: string = "https://lwdv2.zecwallet.co:1443"; // v3 LightwalletD - static V3_LIGHTWALLETD: string = "https://lwdv3.zecwallet.co"; + static V3_LIGHTWALLETD: string = "https://mainnet.lightwalletd.com:9067"; + + static isUnified(addr: string): boolean { + if (!addr) return false; + return addr.startsWith("u"); + } static isSapling(addr: string): boolean { if (!addr) return false;