From 037851a002fc6bfc09230290e39f8c084f0c27e7 Mon Sep 17 00:00:00 2001 From: tecnovert Date: Fri, 29 Nov 2024 12:30:36 +0200 Subject: [PATCH] ui: Add wallet_blocks to XMR wallet page. --- .github/workflows/ci.yml | 10 +++++----- basicswap/basicswap.py | 3 +++ basicswap/interface/xmr.py | 1 + basicswap/templates/wallet.html | 10 ++++++++-- basicswap/ui/page_wallet.py | 3 +++ 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0061673..6be7e1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ concurrency: env: BIN_DIR: /tmp/cached_bin - TEST_RELOAD_PATH: /tmp/test_basicswap1 + TEST_RELOAD_PATH: /tmp/test_basicswap jobs: ci: @@ -46,8 +46,8 @@ jobs: cache-name: cache-cores CACHE_KEY: $(printf $(python bin/basicswap-prepare.py --version --withcoins=bitcoin) | sha256sum | head -c 64) with: - path: "$BIN_DIR" - key: "$CACHE_KEY" + path: $BIN_DIR + key: $CACHE_KEY - if: ${{ steps.cache-yarn.outputs.cache-hit != 'true' }} name: Running basicswap-prepare @@ -57,6 +57,6 @@ jobs: run: | export PYTHONPATH=$(pwd) export TEST_PATH=${TEST_RELOAD_PATH} - mkdir -p ${TEST_RELOAD_PATH}/bin - cp -r $BIN_DIR/* ${TEST_RELOAD_PATH}/bin/ + mkdir -p ${TEST_PATH}/bin + cp -r $BIN_DIR/* ${TEST_PATH}/bin/ pytest tests/basicswap/extended/test_encrypted_xmr_reload.py diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index d327513..bbfb414 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -10285,6 +10285,9 @@ class BasicSwap(BaseApp): "locked": walletinfo["locked"], } + if "wallet_blocks" in walletinfo: + rv["wallet_blocks"] = walletinfo["wallet_blocks"] + if "immature_balance" in walletinfo: rv["immature"] = ci.format_amount( walletinfo["immature_balance"], conv_int=True diff --git a/basicswap/interface/xmr.py b/basicswap/interface/xmr.py index 1b0dfc5..bf5c21f 100644 --- a/basicswap/interface/xmr.py +++ b/basicswap/interface/xmr.py @@ -292,6 +292,7 @@ class XMRInterface(CoinInterface): rv = {} balance_info = self.rpc_wallet("get_balance") + rv["wallet_blocks"] = self.rpc_wallet("get_height")["height"] rv["balance"] = self.format_amount(balance_info["unlocked_balance"]) rv["unconfirmed_balance"] = self.format_amount( balance_info["balance"] - balance_info["unlocked_balance"] diff --git a/basicswap/templates/wallet.html b/basicswap/templates/wallet.html index aca5281..05943fc 100644 --- a/basicswap/templates/wallet.html +++ b/basicswap/templates/wallet.html @@ -163,6 +163,12 @@ {% endif %} + {% if w.wallet_blocks %} + + Wallet Blocks: + {{ w.wallet_blocks }}{% if w.known_block_count %} / {{ w.known_block_count }}{% endif %} + + {% endif %} Synced: {{ w.synced }} @@ -471,9 +477,9 @@ function copyAndShowMessage(elementId) { const addressElement = document.getElementById(elementId); if (!addressElement) return; const addressText = addressElement.innerText.trim(); - + if (addressText === 'Copied to clipboard') return; - + copyToClipboard(addressText); addressElement.innerText = 'Copied to clipboard'; const originalWidth = addressElement.offsetWidth; diff --git a/basicswap/ui/page_wallet.py b/basicswap/ui/page_wallet.py index e7e1c02..8efca8c 100644 --- a/basicswap/ui/page_wallet.py +++ b/basicswap/ui/page_wallet.py @@ -38,6 +38,9 @@ def format_wallet_data(swap_client, ci, w): "havedata": True, } + if "wallet_blocks" in w: + wf["wallet_blocks"] = w["wallet_blocks"] + if w.get("bootstrapping", False) is True: wf["bootstrapping"] = True if "known_block_count" in w: