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()
|
||||
}
|
||||
|
||||
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,8 +101,8 @@ function newFunding (account, cryptoCode) {
|
|||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const promises = [
|
||||
accountBalance(account, cryptoCode, 0),
|
||||
accountBalance(account, cryptoCode, 1),
|
||||
accountUnconfirmedBalance(cryptoCode),
|
||||
accountBalance(cryptoCode),
|
||||
newAddress(account, { cryptoCode })
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -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,8 +101,8 @@ function newFunding (account, cryptoCode) {
|
|||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const promises = [
|
||||
accountBalance(account, cryptoCode, 0),
|
||||
accountBalance(account, cryptoCode, 1),
|
||||
accountUnconfirmedBalance(cryptoCode),
|
||||
accountBalance(cryptoCode),
|
||||
newAddress(account, { cryptoCode })
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -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,8 +102,8 @@ function newFunding (account, cryptoCode) {
|
|||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const promises = [
|
||||
accountBalance(account, cryptoCode, 0),
|
||||
accountBalance(account, cryptoCode, 1),
|
||||
accountUnconfirmedBalance(cryptoCode),
|
||||
accountBalance(cryptoCode),
|
||||
newAddress(account, { cryptoCode })
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -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,8 +102,8 @@ function newFunding (account, cryptoCode) {
|
|||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const promises = [
|
||||
accountBalance(account, cryptoCode, 0),
|
||||
accountBalance(account, cryptoCode, 1),
|
||||
accountUnconfirmedBalance(cryptoCode),
|
||||
accountBalance(cryptoCode),
|
||||
newAddress(account, { cryptoCode })
|
||||
]
|
||||
|
||||
|
|
|
|||
|
|
@ -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,8 +102,8 @@ function newFunding (account, cryptoCode) {
|
|||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
const promises = [
|
||||
accountBalance(account, cryptoCode, 0),
|
||||
accountBalance(account, cryptoCode, 1),
|
||||
accountUnconfirmedBalance(cryptoCode),
|
||||
accountBalance(cryptoCode),
|
||||
newAddress(account, { cryptoCode })
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue