ui: Rename unconfirmed balance to pending, include immature balance.

This commit is contained in:
tecnovert
2024-02-09 22:53:37 +02:00
parent 1f810fab6b
commit 6e4feb33d7
9 changed files with 72 additions and 33 deletions

View File

@@ -42,7 +42,6 @@ from .util import (
LockedCoinError,
TemporaryError,
InactiveCoin,
format_amount,
format_timestamp,
DeserialiseNum,
zeroIfNone,
@@ -6584,16 +6583,18 @@ class BasicSwap(BaseApp):
try:
walletinfo = ci.getWalletInfo()
scale = chainparams[coin]['decimal_places']
rv = {
'deposit_address': self.getCachedAddressForCoin(coin),
'balance': format_amount(make_int(walletinfo['balance'], scale), scale),
'unconfirmed': format_amount(make_int(walletinfo.get('unconfirmed_balance'), scale), scale),
'balance': ci.format_amount(walletinfo['balance'], conv_int=True),
'unconfirmed': ci.format_amount(walletinfo['unconfirmed_balance'], conv_int=True),
'expected_seed': ci.knownWalletSeed(),
'encrypted': walletinfo['encrypted'],
'locked': walletinfo['locked'],
}
if 'immature_balance' in walletinfo:
rv['immature'] = ci.format_amount(walletinfo['immature_balance'], conv_int=True)
if 'locked_utxos' in walletinfo:
rv['locked_utxos'] = walletinfo['locked_utxos']
@@ -6611,7 +6612,6 @@ class BasicSwap(BaseApp):
rv['mweb_address'] = self.getCachedStealthAddressForCoin(Coins.LTC_MWEB)
rv['mweb_balance'] = walletinfo['mweb_balance']
rv['mweb_pending'] = walletinfo['mweb_unconfirmed'] + walletinfo['mweb_immature']
rv['mweb_pending'] = walletinfo['mweb_unconfirmed'] + walletinfo['mweb_immature']
return rv
except Exception as e:

View File

@@ -23,10 +23,7 @@ from .util import jsonDecimal
def waitForRPC(rpc_func, expect_wallet=True, max_tries=7):
for i in range(max_tries + 1):
try:
if expect_wallet:
rpc_func('getwalletinfo')
else:
rpc_func('getblockchaininfo')
rpc_func('getwalletinfo' if expect_wallet else 'getblockchaininfo')
return
except Exception as ex:
if i < max_tries:

View File

@@ -141,7 +141,7 @@
<img class="h-7" src="/static/images/coins/{{ w.name }}.png" alt="{{ w.name }}">
</span>Balance:
</td>
<td class="py-3 px-6 bold coinname-value" data-coinname="{{ w.name }}">{{ w.balance }} {{ w.ticker }} (<span class="usd-value"></span>){% if w.unconfirmed %} <span class="inline-block py-1 px-2 rounded-full bg-green-100 text-green-500 dark:bg-gray-500 dark:text-green-500">Unconfirmed: +{{ w.unconfirmed }} {{ w.ticker }}</span>{% endif %}</td>
<td class="py-3 px-6 bold coinname-value" data-coinname="{{ w.name }}">{{ w.balance }} {{ w.ticker }} (<span class="usd-value"></span>){% if w.pending %} <span class="inline-block py-1 px-2 rounded-full bg-green-100 text-green-500 dark:bg-gray-500 dark:text-green-500">Pending: +{{ w.pending }} {{ w.ticker }}</span>{% endif %}</td>
</tr>
{% if w.cid == '1' %} {# PART #}
<tr class="opacity-100 text-gray-500 dark:text-gray-100 hover:bg-coolGray-200 dark:hover:bg-gray-600">

View File

@@ -48,9 +48,9 @@
<section class="py-4">
<div class="container px-4 mx-auto">
<div class="flex flex-wrap -m-4">
{% for w in wallets %}
{% if w.havedata %}
{% if w.error %}<p>Error: {{ w.error }}</p>
{% for w in wallets %}
{% if w.havedata %}
{% if w.error %}<p>Error: {{ w.error }}</p>
{% else %}
<div class="w-full lg:w-1/3 p-4">
<div class="bg-gray-50 shadow rounded overflow-hidden dark:bg-gray-500">
@@ -76,13 +76,13 @@
<h4 class="text-xs font-medium dark:text-white">{{ w.ticker }} USD value:</h4>
<div class="bold inline-block py-1 px-2 rounded-full bg-blue-100 text-xs text-black-500 dark:bg-gray-500 dark:text-gray-200 usd-value"></div>
</div>
{% if w.unconfirmed %}
{% if w.pending %}
<div class="flex mb-2 justify-between items-center">
<h4 class="text-xs font-bold text-green-500 dark:text-green-500">Unconfirmed:</h4>
<span class="bold inline-block py-1 px-2 rounded-full bg-green-100 text-xs text-green-500 dark:bg-gray-500 dark:text-green-500 coinname-value" data-coinname="{{ w.name }}">+{{ w.unconfirmed }} {{ w.ticker }}</span>
<h4 class="text-xs font-bold text-green-500 dark:text-green-500">Pending:</h4>
<span class="bold inline-block py-1 px-2 rounded-full bg-green-100 text-xs text-green-500 dark:bg-gray-500 dark:text-green-500 coinname-value" data-coinname="{{ w.name }}">+{{ w.pending }} {{ w.ticker }}</span>
</div>
<div class="flex mb-2 justify-between items-center">
<h4 class="text-xs font-bold text-green-500 dark:text-green-500">Unconfirmed USD value:</h4>
<h4 class="text-xs font-bold text-green-500 dark:text-green-500">Pending USD value:</h4>
<div class="bold inline-block py-1 px-2 rounded-full bg-green-100 text-xs text-green-500 dark:bg-gray-500 dark:text-green-500 usd-value"></div>
</div>
{% endif %}
@@ -413,4 +413,4 @@ window.onload = async () => {
};
</script>
</body>
</html>
</html>

View File

@@ -48,8 +48,14 @@ def format_wallet_data(swap_client, ci, w):
wf['balance_all'] = float(w['balance']) + float(w['unconfirmed'])
if 'lastupdated' in w:
wf['lastupdated'] = format_timestamp(w['lastupdated'])
pending: int = 0
if 'unconfirmed' in w and float(w['unconfirmed']) > 0.0:
wf['unconfirmed'] = w['unconfirmed']
pending += ci.make_int(w['unconfirmed'])
if 'immature' in w and float(w['immature']) > 0.0:
pending += ci.make_int(w['immature'])
if pending > 0.0:
wf['pending'] = ci.format_amount(pending)
if ci.coin_type() == Coins.PART:
wf['stealth_address'] = w.get('stealth_address', '?')