From 873980869b8d3fa8153404d68aaf8c39fe079689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 14 Feb 2022 19:16:19 +0000 Subject: [PATCH] fix: pending and confirmed address balance --- lib/plugins/wallet/monerod/monerod.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/plugins/wallet/monerod/monerod.js b/lib/plugins/wallet/monerod/monerod.js index 4dccc759..04bf288e 100644 --- a/lib/plugins/wallet/monerod/monerod.js +++ b/lib/plugins/wallet/monerod/monerod.js @@ -131,7 +131,10 @@ function newAddress (account, info, tx, settings, operatorId) { function addressBalance (address, confirmations) { return fetch('get_address_index', { address: address }) .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)) }