fix: change rpc call after get balance deprecation

This commit is contained in:
Taranto 2020-01-28 13:23:38 +00:00 committed by Josh Harvey
parent cf616c1f16
commit 086c5ec188
5 changed files with 65 additions and 35 deletions

View file

@ -25,16 +25,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function accountBalance (account, cryptoCode, confirmations) {
function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['*', confirmations]))
.then(r => BN(r).shift(unitScale).round())
.then(() => fetch('getwalletinfo'))
.then(({ balance }) => BN(balance).shift(unitScale).round())
}
function accountUnconfirmedBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round())
}
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1)
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -95,9 +101,9 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
accountBalance(account, cryptoCode, 0),
accountBalance(account, cryptoCode, 1),
newAddress(account, {cryptoCode})
accountUnconfirmedBalance(cryptoCode),
accountBalance(cryptoCode),
newAddress(account, { cryptoCode })
]
return Promise.all(promises)

View file

@ -25,16 +25,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function accountBalance (account, cryptoCode, confirmations) {
function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['*', confirmations]))
.then(r => BN(r).shift(unitScale).round())
.then(() => fetch('getwalletinfo'))
.then(({ balance }) => BN(balance).shift(unitScale).round())
}
function accountUnconfirmedBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round())
}
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1)
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -95,9 +101,9 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
accountBalance(account, cryptoCode, 0),
accountBalance(account, cryptoCode, 1),
newAddress(account, {cryptoCode})
accountUnconfirmedBalance(cryptoCode),
accountBalance(cryptoCode),
newAddress(account, { cryptoCode })
]
return Promise.all(promises)

View file

@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function accountBalance (acount, cryptoCode, confirmations) {
function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['', confirmations]))
.then(r => BN(r).shift(unitScale).round())
.then(() => fetch('getwalletinfo'))
.then(({ balance }) => BN(balance).shift(unitScale).round())
}
function accountUnconfirmedBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round())
}
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1)
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -96,9 +102,9 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
accountBalance(account, cryptoCode, 0),
accountBalance(account, cryptoCode, 1),
newAddress(account, {cryptoCode})
accountUnconfirmedBalance(cryptoCode),
accountBalance(cryptoCode),
newAddress(account, { cryptoCode })
]
return Promise.all(promises)

View file

@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function accountBalance (acount, cryptoCode, confirmations) {
function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['*', confirmations]))
.then(r => BN(r).shift(unitScale).round())
.then(() => fetch('getwalletinfo'))
.then(({ balance }) => BN(balance).shift(unitScale).round())
}
function accountUnconfirmedBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round())
}
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1)
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -96,9 +102,9 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
accountBalance(account, cryptoCode, 0),
accountBalance(account, cryptoCode, 1),
newAddress(account, {cryptoCode})
accountUnconfirmedBalance(cryptoCode),
accountBalance(cryptoCode),
newAddress(account, { cryptoCode })
]
return Promise.all(promises)

View file

@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve()
}
function accountBalance (acount, cryptoCode, confirmations) {
function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['', confirmations]))
.then(r => BN(r).shift(unitScale).round())
.then(() => fetch('getwalletinfo'))
.then(({ balance }) => BN(balance).shift(unitScale).round())
}
function accountUnconfirmedBalance (cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => fetch('getwalletinfo'))
.then(({ unconfirmed_balance: balance }) => BN(balance).shift(unitScale).round())
}
// We want a balance that includes all spends (0 conf) but only deposits that
// have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1)
return accountBalance(cryptoCode)
}
function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -96,9 +102,9 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode)
.then(() => {
const promises = [
accountBalance(account, cryptoCode, 0),
accountBalance(account, cryptoCode, 1),
newAddress(account, {cryptoCode})
accountUnconfirmedBalance(cryptoCode),
accountBalance(cryptoCode),
newAddress(account, { cryptoCode })
]
return Promise.all(promises)