fix: initial zcash 5.0 fixes
This commit is contained in:
parent
157137afc0
commit
f56035aa43
2 changed files with 27 additions and 8 deletions
|
|
@ -20,6 +20,13 @@ function updateCore (coinRec, isCurrentlyRunning) {
|
||||||
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
|
common.es(`rm -r /tmp/${coinRec.dir.replace('/bin', '')}`)
|
||||||
common.es(`rm /tmp/zcash.tar.gz`)
|
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) {
|
if (isCurrentlyRunning) {
|
||||||
common.logger.info('Starting wallet...')
|
common.logger.info('Starting wallet...')
|
||||||
common.es(`sudo supervisorctl start zcash`)
|
common.es(`sudo supervisorctl start zcash`)
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,18 @@ function checkCryptoCode (cryptoCode) {
|
||||||
|
|
||||||
function accountBalance (cryptoCode) {
|
function accountBalance (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getwalletinfo'))
|
.then(() => fetch('z_listaccounts'))
|
||||||
.then(({ balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0))
|
.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) {
|
function accountUnconfirmedBalance (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('getwalletinfo'))
|
.then(() => fetch('z_listaccounts'))
|
||||||
.then(({ unconfirmed_balance: balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0))
|
.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
|
// 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 })
|
const checker = opid => pRetry(() => checkSendStatus(opid), { retries: 20, minTimeout: 300, factor: 1.05 })
|
||||||
|
|
||||||
return checkCryptoCode(cryptoCode)
|
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(checker)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -91,6 +95,14 @@ function sendCoins (account, tx, settings, operatorId) {
|
||||||
.catch(errorHandle)
|
.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) {
|
function newAddress (account, info, tx, settings, operatorId) {
|
||||||
return checkCryptoCode(info.cryptoCode)
|
return checkCryptoCode(info.cryptoCode)
|
||||||
.then(() => fetch('z_listaccounts'))
|
.then(() => fetch('z_listaccounts'))
|
||||||
|
|
@ -136,13 +148,13 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
||||||
const promises = [
|
const promises = [
|
||||||
accountUnconfirmedBalance(cryptoCode),
|
accountUnconfirmedBalance(cryptoCode),
|
||||||
accountBalance(cryptoCode),
|
accountBalance(cryptoCode),
|
||||||
newAddress(account, { cryptoCode })
|
defaultAddress(account, { cryptoCode })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
})
|
})
|
||||||
.then(([fundingPendingBalance, fundingConfirmedBalance, fundingAddress]) => ({
|
.then(([fundingUnconfirmedBalance, fundingConfirmedBalance, fundingAddress]) => ({
|
||||||
fundingPendingBalance,
|
fundingPendingBalance: new BN(fundingUnconfirmedBalance).minus(fundingConfirmedBalance),
|
||||||
fundingConfirmedBalance,
|
fundingConfirmedBalance,
|
||||||
fundingAddress
|
fundingAddress
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue