fix: pending and confirmed address balance

This commit is contained in:
Sérgio Salgado 2022-02-14 19:16:19 +00:00
parent 63b0f01409
commit 873980869b

View file

@ -131,7 +131,10 @@ function newAddress (account, info, tx, settings, operatorId) {
function addressBalance (address, confirmations) { function addressBalance (address, confirmations) {
return fetch('get_address_index', { address: address }) return fetch('get_address_index', { address: address })
.then(addressRes => fetch('get_balance', { account_index: addressRes.index.major, address_indices: [addressRes.index.minor] })) .then(addressRes => fetch('get_balance', { account_index: addressRes.index.major, address_indices: [addressRes.index.minor] }))
.then(res => BN(_.find(it => it.address === address, res.per_subaddress).unlocked_balance)) .then(res => {
const addressInfo = _.find(it => it.address === address, res.per_subaddress)
return confirmations > 0 ? BN(addressInfo.unlocked_balance) : BN(addressInfo.balance)
})
.catch(err => handleError(err)) .catch(err => handleError(err))
} }