fix: change rpc call after get balance deprecation
This commit is contained in:
parent
cf616c1f16
commit
086c5ec188
5 changed files with 65 additions and 35 deletions
|
|
@ -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,9 +101,9 @@ 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 })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
|
|
||||||
|
|
@ -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,9 +101,9 @@ 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 })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
|
|
||||||
|
|
@ -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,9 +102,9 @@ 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 })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
|
|
||||||
|
|
@ -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,9 +102,9 @@ 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 })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
|
|
||||||
|
|
@ -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,9 +102,9 @@ 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 })
|
||||||
]
|
]
|
||||||
|
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue