ui: Add indication when XMR node is bootstrapping

This commit is contained in:
tecnovert 2022-07-06 14:35:35 +02:00
parent 1b7550ff76
commit 868dc27d64
No known key found for this signature in database
GPG Key ID: 8ED6D8750C4E3F93
6 changed files with 69 additions and 71 deletions

View File

@ -5271,6 +5271,11 @@ class BasicSwap(BaseApp):
'synced': '{0:.2f}'.format(round(blockchaininfo['verificationprogress'], 2)),
}
if 'known_block_count' in blockchaininfo:
rv['known_block_count'] = blockchaininfo['known_block_count']
if 'bootstrapping' in blockchaininfo:
rv['bootstrapping'] = blockchaininfo['bootstrapping']
return rv
except Exception as e:
self.log.warning('getWalletInfo failed with: %s', str(e))

View File

@ -127,17 +127,17 @@ class XMRInterface(CoinInterface):
# get_block_count.block_count is how many blocks are in the longest chain known to the node.
# get_block_count returns "Internal error" if bootstrap-daemon is active
if get_height['untrusted'] is True:
rv['untrusted'] = True
rv['bootstrapping'] = True
get_info = self.rpc_cb2('get_info', timeout=30)
if 'height_without_bootstrap' in get_info:
rv['blocks'] = get_info['height_without_bootstrap']
rv['block_count'] = get_info['height']
if rv['block_count'] > rv['blocks']:
rv['verificationprogress'] = rv['blocks'] / rv['block_count']
rv['known_block_count'] = get_info['height']
if rv['known_block_count'] > rv['blocks']:
rv['verificationprogress'] = rv['blocks'] / rv['known_block_count']
else:
rv['block_count'] = self.rpc_cb('get_block_count', timeout=30)['count']
rv['verificationprogress'] = rv['blocks'] / rv['block_count']
rv['known_block_count'] = self.rpc_cb('get_block_count', timeout=30)['count']
rv['verificationprogress'] = rv['blocks'] / rv['known_block_count']
except Exception as e:
self._log.warning('XMR get_block_count failed with: %s', str(e))
rv['verificationprogress'] = 0.0

View File

@ -73,7 +73,8 @@ def js_wallets(self, url_split, post_string, is_json):
return bytes(json.dumps(withdraw_coin(swap_client, coin_type, post_string, is_json)), 'UTF-8')
raise ValueError('Unknown command')
rv = swap_client.getWalletInfo(coin_type).update(swap_client.getBlockchainInfo(coin_type))
rv = swap_client.getWalletInfo(coin_type)
rv.update(swap_client.getBlockchainInfo(coin_type))
return bytes(json.dumps(rv), 'UTF-8')
return bytes(json.dumps(self.server.swap_client.getWalletsInfo()), 'UTF-8')

View File

@ -34,8 +34,11 @@
{% endif %}
<tr><td>Blocks:</td><td>{{ w.blocks }}</td></tr>
<tr><td>Blocks:</td><td>{{ w.blocks }} {% if w.known_block_count %} / {{ w.known_block_count }} {% endif %}</td></tr>
<tr><td>Synced:</td><td>{{ w.synced }}</td></tr>
{% if w.bootstrapping %}
<tr><td>Bootstrapping:</td><td>{{ w.bootstrapping }}</td></tr>
{% endif %}
<tr><td>Expected Seed:</td><td>{{ w.expected_seed }}</td>{% if w.expected_seed != true %}<td><input type="submit" name="reseed_{{ w.cid }}" value="Reseed wallet" onclick="return confirmReseed();"></td>{% endif %}</tr>
{% if w.cid == '1' %}
<tr><td>Stealth Address</td><td colspan=2>{{ w.stealth_address }}</td></tr>

View File

@ -33,8 +33,11 @@
{% endif %}
<tr><td>Blocks:</td><td>{{ w.blocks }}</td></tr>
<tr><td>Blocks:</td><td>{{ w.blocks }} {% if w.known_block_count %} / {{ w.known_block_count }} {% endif %}</td></tr>
<tr><td>Synced:</td><td>{{ w.synced }}</td></tr>
{% if w.bootstrapping %}
<tr><td>Bootstrapping:</td><td>{{ w.bootstrapping }}</td></tr>
{% endif %}
<tr><td>Expected Seed:</td><td>{{ w.expected_seed }}</td></tr>
<tr><td><a href="/wallet/{{ w.ticker }}">Manage</a></td></tr>
</table>

View File

@ -22,6 +22,43 @@ from basicswap.chainparams import (
)
def format_wallet_data(ci, w):
wf = {
'name': ci.coin_name(),
'version': w.get('version', '?'),
'ticker': ci.ticker_mainnet(),
'cid': str(int(ci.coin_type())),
'balance': w.get('balance', '?'),
'blocks': w.get('blocks', '?'),
'synced': w.get('synced', '?'),
'expected_seed': w.get('expected_seed', '?'),
'updating': w.get('updating', '?'),
'havedata': True,
}
if w.get('bootstrapping', False) is True:
wf['bootstrapping'] = True
if 'known_block_count' in w:
wf['known_block_count'] = w['known_block_count']
if 'balance' in w and 'unconfirmed' in w:
wf['balance_all'] = float(w['balance']) + float(w['unconfirmed'])
if 'lastupdated' in w:
wf['lastupdated'] = format_timestamp(w['lastupdated'])
if 'unconfirmed' in w and float(w['unconfirmed']) > 0.0:
wf['unconfirmed'] = w['unconfirmed']
if ci.coin_type() == Coins.PART:
wf['stealth_address'] = w.get('stealth_address', '?')
wf['blind_balance'] = w.get('blind_balance', '?')
if 'blind_unconfirmed' in w and float(w['blind_unconfirmed']) > 0.0:
wf['blind_unconfirmed'] = w['blind_unconfirmed']
wf['anon_balance'] = w.get('anon_balance', '?')
if 'anon_pending' in w and float(w['anon_pending']) > 0.0:
wf['anon_pending'] = w['anon_pending']
return wf
def page_wallets(self, url_split, post_string):
server = self.server
swap_client = server.swap_client
@ -109,36 +146,7 @@ def page_wallets(self, url_split, post_string):
continue
ci = swap_client.ci(k)
cid = str(int(k))
wf = {
'name': ci.coin_name(),
'version': w.get('version', '?'),
'ticker': ci.ticker_mainnet(),
'cid': cid,
'balance': w.get('balance', '?'),
'blocks': w.get('blocks', '?'),
'synced': w.get('synced', '?'),
'deposit_address': w.get('deposit_address', '?'),
'expected_seed': w.get('expected_seed', '?'),
'updating': w.get('updating', '?'),
'havedata': True,
}
if 'balance' in w and 'unconfirmed' in w:
wf['balance_all'] = float(w['balance']) + float(w['unconfirmed'])
if 'lastupdated' in w:
wf['lastupdated'] = format_timestamp(w['lastupdated'])
if 'unconfirmed' in w and float(w['unconfirmed']) > 0.0:
wf['unconfirmed'] = w['unconfirmed']
if k == Coins.PART:
wf['stealth_address'] = w.get('stealth_address', '?')
wf['blind_balance'] = w.get('blind_balance', '?')
if 'blind_unconfirmed' in w and float(w['blind_unconfirmed']) > 0.0:
wf['blind_unconfirmed'] = w['blind_unconfirmed']
wf['anon_balance'] = w.get('anon_balance', '?')
if 'anon_pending' in w and float(w['anon_pending']) > 0.0:
wf['anon_pending'] = w['anon_pending']
wf = format_wallet_data(ci, w)
wallets_formatted.append(wf)
@ -246,7 +254,7 @@ def page_wallet(self, url_split, post_string):
}
continue
if 'balance' not in w:
if 'no_data' in w:
wallet_data = {
'name': w['name'],
'havedata': False,
@ -255,40 +263,18 @@ def page_wallet(self, url_split, post_string):
continue
ci = swap_client.ci(k)
cid = str(int(coin_id))
wallet_data = format_wallet_data(ci, w)
fee_rate, fee_src = swap_client.getFeeRateForCoin(k)
est_fee = swap_client.estimateWithdrawFee(k, fee_rate)
cid = str(int(k))
wallet_data = {
'name': w['name'],
'version': w['version'],
'ticker': ci.ticker_mainnet(),
'cid': cid,
'fee_rate': ci.format_amount(int(fee_rate * ci.COIN())),
'fee_rate_src': fee_src,
'est_fee': 'Unknown' if est_fee is None else ci.format_amount(int(est_fee * ci.COIN())),
'balance': w['balance'],
'blocks': w['blocks'],
'synced': w['synced'],
'deposit_address': w['deposit_address'],
'expected_seed': w['expected_seed'],
'balance_all': float(w['balance']) + float(w['unconfirmed']),
'updating': w['updating'],
'lastupdated': format_timestamp(w['lastupdated']),
'havedata': True,
}
if float(w['unconfirmed']) > 0.0:
wallet_data['unconfirmed'] = w['unconfirmed']
wallet_data['fee_rate'] = ci.format_amount(int(fee_rate * ci.COIN()))
wallet_data['fee_rate_src'] = fee_src
wallet_data['est_fee'] = 'Unknown' if est_fee is None else ci.format_amount(int(est_fee * ci.COIN()))
wallet_data['deposit_address'] = w.get('deposit_address', 'Refresh necessary')
if k == Coins.PART:
wallet_data['stealth_address'] = w['stealth_address']
wallet_data['blind_balance'] = w['blind_balance']
if float(w['blind_unconfirmed']) > 0.0:
wallet_data['blind_unconfirmed'] = w['blind_unconfirmed']
wallet_data['anon_balance'] = w['anon_balance']
if float(w['anon_pending']) > 0.0:
wallet_data['anon_pending'] = w['anon_pending']
elif k == Coins.XMR:
if k == Coins.XMR:
wallet_data['main_address'] = w.get('main_address', 'Refresh necessary')
if 'wd_type_from_' + cid in page_data: