diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 0e04956..1bc03b6 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -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)) diff --git a/basicswap/interface_xmr.py b/basicswap/interface_xmr.py index 6952e02..402aae1 100644 --- a/basicswap/interface_xmr.py +++ b/basicswap/interface_xmr.py @@ -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 diff --git a/basicswap/js_server.py b/basicswap/js_server.py index 39d22d0..8a101c6 100644 --- a/basicswap/js_server.py +++ b/basicswap/js_server.py @@ -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') diff --git a/basicswap/templates/wallet.html b/basicswap/templates/wallet.html index 8e875b8..fd265bb 100644 --- a/basicswap/templates/wallet.html +++ b/basicswap/templates/wallet.html @@ -34,8 +34,11 @@ {% endif %} -Blocks:{{ w.blocks }} +Blocks:{{ w.blocks }} {% if w.known_block_count %} / {{ w.known_block_count }} {% endif %} Synced:{{ w.synced }} +{% if w.bootstrapping %} +Bootstrapping:{{ w.bootstrapping }} +{% endif %} Expected Seed:{{ w.expected_seed }}{% if w.expected_seed != true %}{% endif %} {% if w.cid == '1' %} Stealth Address{{ w.stealth_address }} diff --git a/basicswap/templates/wallets.html b/basicswap/templates/wallets.html index c2bbf5f..63a14a1 100644 --- a/basicswap/templates/wallets.html +++ b/basicswap/templates/wallets.html @@ -33,8 +33,11 @@ {% endif %} -Blocks:{{ w.blocks }} +Blocks:{{ w.blocks }} {% if w.known_block_count %} / {{ w.known_block_count }} {% endif %} Synced:{{ w.synced }} +{% if w.bootstrapping %} +Bootstrapping:{{ w.bootstrapping }} +{% endif %} Expected Seed:{{ w.expected_seed }} Manage diff --git a/basicswap/ui/page_wallet.py b/basicswap/ui/page_wallet.py index 5cd5f04..1481674 100644 --- a/basicswap/ui/page_wallet.py +++ b/basicswap/ui/page_wallet.py @@ -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: