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() return Promise.resolve()
} }
function accountBalance (account, cryptoCode, confirmations) { function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['*', confirmations])) .then(() => fetch('getwalletinfo'))
.then(r => BN(r).shift(unitScale).round()) .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 // 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. // have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) { function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1) return accountBalance(cryptoCode)
} }
function sendCoins (account, address, cryptoAtoms, cryptoCode) { function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -95,8 +101,8 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => { .then(() => {
const promises = [ const promises = [
accountBalance(account, cryptoCode, 0), accountUnconfirmedBalance(cryptoCode),
accountBalance(account, cryptoCode, 1), accountBalance(cryptoCode),
newAddress(account, { cryptoCode }) newAddress(account, { cryptoCode })
] ]

View file

@ -25,16 +25,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve() return Promise.resolve()
} }
function accountBalance (account, cryptoCode, confirmations) { function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['*', confirmations])) .then(() => fetch('getwalletinfo'))
.then(r => BN(r).shift(unitScale).round()) .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 // 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. // have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) { function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1) return accountBalance(cryptoCode)
} }
function sendCoins (account, address, cryptoAtoms, cryptoCode) { function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -95,8 +101,8 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => { .then(() => {
const promises = [ const promises = [
accountBalance(account, cryptoCode, 0), accountUnconfirmedBalance(cryptoCode),
accountBalance(account, cryptoCode, 1), accountBalance(cryptoCode),
newAddress(account, { cryptoCode }) newAddress(account, { cryptoCode })
] ]

View file

@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve() return Promise.resolve()
} }
function accountBalance (acount, cryptoCode, confirmations) { function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['', confirmations])) .then(() => fetch('getwalletinfo'))
.then(r => BN(r).shift(unitScale).round()) .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 // 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. // have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) { function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1) return accountBalance(cryptoCode)
} }
function sendCoins (account, address, cryptoAtoms, cryptoCode) { function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -96,8 +102,8 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => { .then(() => {
const promises = [ const promises = [
accountBalance(account, cryptoCode, 0), accountUnconfirmedBalance(cryptoCode),
accountBalance(account, cryptoCode, 1), accountBalance(cryptoCode),
newAddress(account, { cryptoCode }) newAddress(account, { cryptoCode })
] ]

View file

@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve() return Promise.resolve()
} }
function accountBalance (acount, cryptoCode, confirmations) { function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['*', confirmations])) .then(() => fetch('getwalletinfo'))
.then(r => BN(r).shift(unitScale).round()) .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 // 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. // have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) { function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1) return accountBalance(cryptoCode)
} }
function sendCoins (account, address, cryptoAtoms, cryptoCode) { function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -96,8 +102,8 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => { .then(() => {
const promises = [ const promises = [
accountBalance(account, cryptoCode, 0), accountUnconfirmedBalance(cryptoCode),
accountBalance(account, cryptoCode, 1), accountBalance(cryptoCode),
newAddress(account, { cryptoCode }) newAddress(account, { cryptoCode })
] ]

View file

@ -26,16 +26,22 @@ function checkCryptoCode (cryptoCode) {
return Promise.resolve() return Promise.resolve()
} }
function accountBalance (acount, cryptoCode, confirmations) { function accountBalance (cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => fetch('getbalance', ['', confirmations])) .then(() => fetch('getwalletinfo'))
.then(r => BN(r).shift(unitScale).round()) .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 // 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. // have at least 1 confirmation. getbalance does this for us automatically.
function balance (account, cryptoCode) { function balance (account, cryptoCode) {
return accountBalance(account, cryptoCode, 1) return accountBalance(cryptoCode)
} }
function sendCoins (account, address, cryptoAtoms, cryptoCode) { function sendCoins (account, address, cryptoAtoms, cryptoCode) {
@ -96,8 +102,8 @@ function newFunding (account, cryptoCode) {
return checkCryptoCode(cryptoCode) return checkCryptoCode(cryptoCode)
.then(() => { .then(() => {
const promises = [ const promises = [
accountBalance(account, cryptoCode, 0), accountUnconfirmedBalance(cryptoCode),
accountBalance(account, cryptoCode, 1), accountBalance(cryptoCode),
newAddress(account, { cryptoCode }) newAddress(account, { cryptoCode })
] ]