From 60d7f3d8ded12d7da9c0d47c4e5a1862b535b20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Fri, 15 Apr 2022 17:43:12 +0100 Subject: [PATCH 1/7] feat: change generated addresses to be UA --- lib/blockchain/common.js | 1 + lib/plugins/wallet/zcashd/zcashd.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js index ea28c639..65fa0aac 100644 --- a/lib/blockchain/common.js +++ b/lib/blockchain/common.js @@ -30,6 +30,7 @@ const BINARIES = { url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.17-25c9b49f.tar.gz', dir: 'geth-linux-amd64-1.10.17-25c9b49f' }, + // TODO: update ZEC URL for new 4.7.0 version once the tarball is available ZEC: { url: 'https://z.cash/downloads/zcash-4.6.0-2-linux64-debian-bullseye.tar.gz', dir: 'zcash-4.6.0-2/bin' diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index b55d1ec5..8a9afb17 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -93,7 +93,10 @@ function sendCoins (account, tx, settings, operatorId) { function newAddress (account, info, tx, settings, operatorId) { return checkCryptoCode(info.cryptoCode) - .then(() => fetch('getnewaddress')) + .then(() => fetch('z_listaccounts')) + .then(accountsRes => _.size(accountsRes) === 0 ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) + .then(account => fetch('z_getaddressforaccount', [account.account])) + .then(res => res.address) } function addressBalance (address, confs) { From ffdab69ce00217521d4c06cca49c16b28a2a9ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Sun, 17 Apr 2022 23:34:12 +0100 Subject: [PATCH 2/7] chore: update zcash download url --- lib/blockchain/common.js | 5 ++--- lib/blockchain/zcash.js | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js index 65fa0aac..8d8eba90 100644 --- a/lib/blockchain/common.js +++ b/lib/blockchain/common.js @@ -30,10 +30,9 @@ const BINARIES = { url: 'https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.17-25c9b49f.tar.gz', dir: 'geth-linux-amd64-1.10.17-25c9b49f' }, - // TODO: update ZEC URL for new 4.7.0 version once the tarball is available ZEC: { - url: 'https://z.cash/downloads/zcash-4.6.0-2-linux64-debian-bullseye.tar.gz', - dir: 'zcash-4.6.0-2/bin' + url: 'https://download.z.cash/downloads//zcash-4.7.0-linux64-debian-bullseye.tar.gz', + dir: 'zcash-4.7.0/bin' }, DASH: { url: 'https://github.com/dashpay/dash/releases/download/v0.17.0.3/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz', diff --git a/lib/blockchain/zcash.js b/lib/blockchain/zcash.js index 777a67b4..00dc239f 100644 --- a/lib/blockchain/zcash.js +++ b/lib/blockchain/zcash.js @@ -50,5 +50,6 @@ rpcuser=lamassuserver rpcpassword=${common.randomPass()} dbcache=500 keypool=10000 +walletrequirebackup=false ` } From 157137afc0dadd1323756e063af5bfadcd4a74ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 18 Apr 2022 15:23:59 +0100 Subject: [PATCH 3/7] fix: small fixes --- lib/blockchain/common.js | 2 +- lib/plugins/wallet/zcashd/zcashd.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js index 8d8eba90..96524f34 100644 --- a/lib/blockchain/common.js +++ b/lib/blockchain/common.js @@ -31,7 +31,7 @@ const BINARIES = { dir: 'geth-linux-amd64-1.10.17-25c9b49f' }, ZEC: { - url: 'https://download.z.cash/downloads//zcash-4.7.0-linux64-debian-bullseye.tar.gz', + url: 'https://download.z.cash/downloads/zcash-4.7.0-linux64-debian-bullseye.tar.gz', dir: 'zcash-4.7.0/bin' }, DASH: { diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index 8a9afb17..1be3a45f 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -94,7 +94,7 @@ function sendCoins (account, tx, settings, operatorId) { function newAddress (account, info, tx, settings, operatorId) { return checkCryptoCode(info.cryptoCode) .then(() => fetch('z_listaccounts')) - .then(accountsRes => _.size(accountsRes) === 0 ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) + .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) .then(account => fetch('z_getaddressforaccount', [account.account])) .then(res => res.address) } From f56035aa43c89cc0a0850b00ed387ec8b9bd0b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Fri, 10 Jun 2022 20:04:49 +0100 Subject: [PATCH 4/7] fix: initial zcash 5.0 fixes --- lib/blockchain/zcash.js | 7 +++++++ lib/plugins/wallet/zcashd/zcashd.js | 28 ++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/lib/blockchain/zcash.js b/lib/blockchain/zcash.js index 00dc239f..51430969 100644 --- a/lib/blockchain/zcash.js +++ b/lib/blockchain/zcash.js @@ -20,6 +20,13 @@ function updateCore (coinRec, isCurrentlyRunning) { common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`) common.es(`rm /tmp/zcash.tar.gz`) + if (common.es(`grep "walletrequirebackup=" /mnt/blockchains/zcash/zcash.conf || true`)) { + common.logger.info(`walletrequirebackup already defined, skipping...`) + } else { + common.logger.info(`Setting 'walletrequirebackup=false' in config file...`) + common.es(`echo "\nwalletrequirebackup=false" >> /mnt/blockchains/zcash/zcash.conf`) + } + if (isCurrentlyRunning) { common.logger.info('Starting wallet...') common.es(`sudo supervisorctl start zcash`) diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index 1be3a45f..199ccc6e 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -33,14 +33,18 @@ function checkCryptoCode (cryptoCode) { function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getwalletinfo')) - .then(({ balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0)) + .then(() => fetch('z_listaccounts')) + .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) + .then(account => fetch('z_getbalanceforaccount', [account.account, 1])) + .then(res => new BN(res.pools.transparent.valueZat).plus(res.pools.sapling.valueZat).plus(res.pools.orchard.valueZat)) } function accountUnconfirmedBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('getwalletinfo')) - .then(({ unconfirmed_balance: balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0)) + .then(() => fetch('z_listaccounts')) + .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) + .then(account => fetch('z_getbalanceforaccount', [account.account, 0])) + .then(res => new BN(res.pools.transparent.valueZat).plus(res.pools.sapling.valueZat).plus(res.pools.orchard.valueZat)) } // We want a balance that includes all spends (0 conf) but only deposits that @@ -74,7 +78,7 @@ function sendCoins (account, tx, settings, operatorId) { const checker = opid => pRetry(() => checkSendStatus(opid), { retries: 20, minTimeout: 300, factor: 1.05 }) return checkCryptoCode(cryptoCode) - .then(() => fetch('z_sendmany', ['ANY_TADDR', [{ address: toAddress, amount: coins }]])) + .then(() => fetch('z_sendmany', [defaultAddress(account, { cryptoCode }), [{ address: toAddress, amount: coins }]])) .then(checker) .then((res) => { return { @@ -91,6 +95,14 @@ function sendCoins (account, tx, settings, operatorId) { .catch(errorHandle) } +function defaultAddress (account, info, tx, settings, operatorId) { + return checkCryptoCode(info.cryptoCode) + .then(() => fetch('z_listaccounts')) + .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) + .then(account => fetch('z_getaddressforaccount', [account.account, [], 0])) + .then(res => res.address) +} + function newAddress (account, info, tx, settings, operatorId) { return checkCryptoCode(info.cryptoCode) .then(() => fetch('z_listaccounts')) @@ -136,13 +148,13 @@ function newFunding (account, cryptoCode, settings, operatorId) { const promises = [ accountUnconfirmedBalance(cryptoCode), accountBalance(cryptoCode), - newAddress(account, { cryptoCode }) + defaultAddress(account, { cryptoCode }) ] return Promise.all(promises) }) - .then(([fundingPendingBalance, fundingConfirmedBalance, fundingAddress]) => ({ - fundingPendingBalance, + .then(([fundingUnconfirmedBalance, fundingConfirmedBalance, fundingAddress]) => ({ + fundingPendingBalance: new BN(fundingUnconfirmedBalance).minus(fundingConfirmedBalance), fundingConfirmedBalance, fundingAddress })) From d78e7bb18c152c676a3e71246e84f92986956c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 13 Jun 2022 19:10:28 +0100 Subject: [PATCH 5/7] chore: revert sendCoins and cash-out to use transparent addresses --- lib/plugins/wallet/zcashd/zcashd.js | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index 199ccc6e..26c31b62 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -33,18 +33,14 @@ function checkCryptoCode (cryptoCode) { function accountBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('z_listaccounts')) - .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) - .then(account => fetch('z_getbalanceforaccount', [account.account, 1])) - .then(res => new BN(res.pools.transparent.valueZat).plus(res.pools.sapling.valueZat).plus(res.pools.orchard.valueZat)) + .then(() => fetch('getwalletinfo')) + .then(({ balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0)) } function accountUnconfirmedBalance (cryptoCode) { return checkCryptoCode(cryptoCode) - .then(() => fetch('z_listaccounts')) - .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) - .then(account => fetch('z_getbalanceforaccount', [account.account, 0])) - .then(res => new BN(res.pools.transparent.valueZat).plus(res.pools.sapling.valueZat).plus(res.pools.orchard.valueZat)) + .then(() => fetch('getwalletinfo')) + .then(({ unconfirmed_balance: balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0)) } // We want a balance that includes all spends (0 conf) but only deposits that @@ -78,7 +74,7 @@ function sendCoins (account, tx, settings, operatorId) { const checker = opid => pRetry(() => checkSendStatus(opid), { retries: 20, minTimeout: 300, factor: 1.05 }) return checkCryptoCode(cryptoCode) - .then(() => fetch('z_sendmany', [defaultAddress(account, { cryptoCode }), [{ address: toAddress, amount: coins }]])) + .then(() => fetch('z_sendmany', ['ANY_TADDR', [{ address: toAddress, amount: coins }], null, null, 'NoPrivacy'])) .then(checker) .then((res) => { return { @@ -105,10 +101,7 @@ function defaultAddress (account, info, tx, settings, operatorId) { function newAddress (account, info, tx, settings, operatorId) { return checkCryptoCode(info.cryptoCode) - .then(() => fetch('z_listaccounts')) - .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) - .then(account => fetch('z_getaddressforaccount', [account.account])) - .then(res => res.address) + .then(() => fetch('getnewaddress')) } function addressBalance (address, confs) { @@ -148,13 +141,13 @@ function newFunding (account, cryptoCode, settings, operatorId) { const promises = [ accountUnconfirmedBalance(cryptoCode), accountBalance(cryptoCode), - defaultAddress(account, { cryptoCode }) + newAddress(account, { cryptoCode }) ] return Promise.all(promises) }) - .then(([fundingUnconfirmedBalance, fundingConfirmedBalance, fundingAddress]) => ({ - fundingPendingBalance: new BN(fundingUnconfirmedBalance).minus(fundingConfirmedBalance), + .then(([fundingPendingBalance, fundingConfirmedBalance, fundingAddress]) => ({ + fundingPendingBalance, fundingConfirmedBalance, fundingAddress })) From 5c18dbca9a062d1306cfb29982a4b3fcfd96baa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 13 Jun 2022 22:38:46 +0100 Subject: [PATCH 6/7] fix: zcash version --- lib/blockchain/common.js | 2 +- lib/plugins/wallet/zcashd/zcashd.js | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js index 96524f34..9cbaa5bc 100644 --- a/lib/blockchain/common.js +++ b/lib/blockchain/common.js @@ -31,7 +31,7 @@ const BINARIES = { dir: 'geth-linux-amd64-1.10.17-25c9b49f' }, ZEC: { - url: 'https://download.z.cash/downloads/zcash-4.7.0-linux64-debian-bullseye.tar.gz', + url: 'https://z.cash/downloads/zcash-5.0.0-linux64-debian-bullseye.tar.gz', dir: 'zcash-4.7.0/bin' }, DASH: { diff --git a/lib/plugins/wallet/zcashd/zcashd.js b/lib/plugins/wallet/zcashd/zcashd.js index 26c31b62..f576cebe 100644 --- a/lib/plugins/wallet/zcashd/zcashd.js +++ b/lib/plugins/wallet/zcashd/zcashd.js @@ -91,14 +91,6 @@ function sendCoins (account, tx, settings, operatorId) { .catch(errorHandle) } -function defaultAddress (account, info, tx, settings, operatorId) { - return checkCryptoCode(info.cryptoCode) - .then(() => fetch('z_listaccounts')) - .then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes))) - .then(account => fetch('z_getaddressforaccount', [account.account, [], 0])) - .then(res => res.address) -} - function newAddress (account, info, tx, settings, operatorId) { return checkCryptoCode(info.cryptoCode) .then(() => fetch('getnewaddress')) From 28d40fb1ca36fda01f5956c7231c57a7f020cab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Tue, 14 Jun 2022 16:01:46 +0100 Subject: [PATCH 7/7] fix: zcash files version --- lib/blockchain/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blockchain/common.js b/lib/blockchain/common.js index 9cbaa5bc..2c07f68e 100644 --- a/lib/blockchain/common.js +++ b/lib/blockchain/common.js @@ -32,7 +32,7 @@ const BINARIES = { }, ZEC: { url: 'https://z.cash/downloads/zcash-5.0.0-linux64-debian-bullseye.tar.gz', - dir: 'zcash-4.7.0/bin' + dir: 'zcash-5.0.0/bin' }, DASH: { url: 'https://github.com/dashpay/dash/releases/download/v0.17.0.3/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz',