chore: revert sendCoins and cash-out to use transparent addresses
This commit is contained in:
parent
f56035aa43
commit
d78e7bb18c
1 changed files with 9 additions and 16 deletions
|
|
@ -33,18 +33,14 @@ function checkCryptoCode (cryptoCode) {
|
||||||
|
|
||||||
function accountBalance (cryptoCode) {
|
function accountBalance (cryptoCode) {
|
||||||
return checkCryptoCode(cryptoCode)
|
return checkCryptoCode(cryptoCode)
|
||||||
.then(() => fetch('z_listaccounts'))
|
.then(() => fetch('getwalletinfo'))
|
||||||
.then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes)))
|
.then(({ balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0))
|
||||||
.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('z_listaccounts'))
|
.then(() => fetch('getwalletinfo'))
|
||||||
.then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes)))
|
.then(({ unconfirmed_balance: balance }) => new BN(balance).shiftedBy(unitScale).decimalPlaces(0))
|
||||||
.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
|
||||||
|
|
@ -78,7 +74,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', [defaultAddress(account, { cryptoCode }), [{ address: toAddress, amount: coins }]]))
|
.then(() => fetch('z_sendmany', ['ANY_TADDR', [{ address: toAddress, amount: coins }], null, null, 'NoPrivacy']))
|
||||||
.then(checker)
|
.then(checker)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -105,10 +101,7 @@ function defaultAddress (account, info, tx, settings, operatorId) {
|
||||||
|
|
||||||
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('getnewaddress'))
|
||||||
.then(accountsRes => _.isEmpty(accountsRes) ? fetch('z_getnewaccount') : Promise.resolve(_.first(accountsRes)))
|
|
||||||
.then(account => fetch('z_getaddressforaccount', [account.account]))
|
|
||||||
.then(res => res.address)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addressBalance (address, confs) {
|
function addressBalance (address, confs) {
|
||||||
|
|
@ -148,13 +141,13 @@ function newFunding (account, cryptoCode, settings, operatorId) {
|
||||||
const promises = [
|
const promises = [
|
||||||
accountUnconfirmedBalance(cryptoCode),
|
accountUnconfirmedBalance(cryptoCode),
|
||||||
accountBalance(cryptoCode),
|
accountBalance(cryptoCode),
|
||||||
defaultAddress(account, { cryptoCode })
|
newAddress(account, { cryptoCode })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
})
|
})
|
||||||
.then(([fundingUnconfirmedBalance, fundingConfirmedBalance, fundingAddress]) => ({
|
.then(([fundingPendingBalance, fundingConfirmedBalance, fundingAddress]) => ({
|
||||||
fundingPendingBalance: new BN(fundingUnconfirmedBalance).minus(fundingConfirmedBalance),
|
fundingPendingBalance,
|
||||||
fundingConfirmedBalance,
|
fundingConfirmedBalance,
|
||||||
fundingAddress
|
fundingAddress
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue