diff --git a/basicswap/js_server.py b/basicswap/js_server.py index af60043..2f6c858 100644 --- a/basicswap/js_server.py +++ b/basicswap/js_server.py @@ -192,6 +192,28 @@ def js_walletbalances(self, url_split, post_string, is_json) -> bytes: coin_entry["electrum_synced"] = sync_status.get("synced", False) coin_entry["electrum_height"] = sync_status.get("height", 0) + if k in wallets: + w = wallets[k] + if "error" not in w and "no_data" not in w: + if k == Coins.PART: + for field in ("blind_balance", "anon_balance"): + if field in w: + raw = w[field] + if isinstance(raw, float): + coin_entry[field] = ( + f"{raw:.8f}".rstrip("0").rstrip(".") + ) + elif isinstance(raw, int): + coin_entry[field] = str(raw) + else: + coin_entry[field] = raw + elif k == Coins.LTC: + if "mweb_balance" in w: + coin_entry["mweb_balance"] = w["mweb_balance"] + elif k == Coins.FIRO: + if "spark_balance" in w: + coin_entry["spark_balance"] = w["spark_balance"] + coins_with_balances.append(coin_entry) if k == Coins.PART: diff --git a/basicswap/static/js/pages/wallet-page.js b/basicswap/static/js/pages/wallet-page.js index ce510f4..84cb324 100644 --- a/basicswap/static/js/pages/wallet-page.js +++ b/basicswap/static/js/pages/wallet-page.js @@ -351,16 +351,19 @@ ); matchingCoins.forEach(coinData => { - const balanceElements = document.querySelectorAll('.coinname-value[data-coinname]'); + const balanceElements = document.querySelectorAll('.coinname-value[data-coinname][data-balance-type]'); balanceElements.forEach(element => { const elementCoinName = element.getAttribute('data-coinname'); if (elementCoinName === coinData.name) { - const currentText = element.textContent; - const ticker = coinData.ticker || coinId.toUpperCase(); - const newBalance = `${coinData.balance} ${ticker}`; - if (currentText !== newBalance) { - element.textContent = newBalance; - console.log(`Updated balance: ${coinData.name} -> ${newBalance}`); + const balanceType = element.getAttribute('data-balance-type'); + const value = coinData[balanceType]; + if (value !== undefined) { + const ticker = coinData.ticker || coinId.toUpperCase(); + const newBalance = balanceType === 'est_fee' ? value : `${value} ${ticker}`; + if (element.textContent !== newBalance) { + element.textContent = newBalance; + console.log(`Updated ${balanceType}: ${coinData.name} -> ${newBalance}`); + } } } }); diff --git a/basicswap/static/js/pages/wallets-page.js b/basicswap/static/js/pages/wallets-page.js index acb76a0..924a766 100644 --- a/basicswap/static/js/pages/wallets-page.js +++ b/basicswap/static/js/pages/wallets-page.js @@ -75,9 +75,28 @@ if (coinData.pending && parseFloat(coinData.pending) > 0) { this.updatePendingBalance('Particl', 'Blind Balance:', coinData.pending, coinData.ticker || 'PART', 'Blind Unconfirmed:', coinData); } + } else if (coinData.name === 'Litecoin MWEB') { + this.updateSpecificBalance('Litecoin', 'MWEB Balance:', coinData.balance, coinData.ticker || 'LTC'); + this.removePendingBalance('Litecoin', 'MWEB Balance:'); + if (coinData.pending && parseFloat(coinData.pending) > 0) { + this.updatePendingBalance('Litecoin', 'MWEB Balance:', coinData.pending, coinData.ticker || 'LTC', 'MWEB Pending:', coinData); + } } else { this.updateSpecificBalance(coinData.name, 'Balance:', coinData.balance, coinData.ticker || coinData.name); + if (coinData.mweb_balance !== undefined) { + this.updateSpecificBalance(coinData.name, 'MWEB Balance:', coinData.mweb_balance, coinData.ticker || coinData.name); + } + if (coinData.spark_balance !== undefined) { + this.updateSpecificBalance(coinData.name, 'Spark Balance:', coinData.spark_balance, coinData.ticker || coinData.name); + } + if (coinData.blind_balance !== undefined) { + this.updateSpecificBalance(coinData.name, 'Blind Balance:', coinData.blind_balance, coinData.ticker || coinData.name); + } + if (coinData.anon_balance !== undefined) { + this.updateSpecificBalance(coinData.name, 'Anon Balance:', coinData.anon_balance, coinData.ticker || coinData.name); + } + if (coinData.name !== 'Particl Anon' && coinData.name !== 'Particl Blind' && coinData.name !== 'Litecoin MWEB') { if (coinData.pending && parseFloat(coinData.pending) > 0) { this.updatePendingDisplay(coinData); diff --git a/basicswap/templates/wallet.html b/basicswap/templates/wallet.html index 5df2a53..7519e85 100644 --- a/basicswap/templates/wallet.html +++ b/basicswap/templates/wallet.html @@ -138,7 +138,7 @@ {{ w.name }} Balance: - {{ w.balance }} {{ w.ticker }} + {{ w.balance }} {{ w.ticker }} () {% if w.pending %} Pending: +{{ w.pending }} {{ w.ticker }} @@ -152,7 +152,7 @@ {{ w.name }} Blind Blind Balance: - {{ w.blind_balance }} {{ w.ticker }} + {{ w.blind_balance }} {{ w.ticker }} () {% if w.blind_unconfirmed %} Unconfirmed: +{{ w.blind_unconfirmed }} {{ w.ticker }} @@ -162,7 +162,7 @@ {{ w.name }} Anon Anon Balance: - {{ w.anon_balance }} {{ w.ticker }} + {{ w.anon_balance }} {{ w.ticker }} () {% if w.anon_pending %} Pending: +{{ w.anon_pending }} {{ w.ticker }} @@ -177,7 +177,7 @@ {% if is_electrum_mode %} Not available in light mode {% else %} - {{ w.mweb_balance }} {{ w.ticker }} + {{ w.mweb_balance }} {{ w.ticker }} () {% if w.mweb_pending %} Pending: +{{ w.mweb_pending }} {{ w.ticker }} @@ -200,7 +200,7 @@ {{ w.name }} Spark Spark Balance: - {{ w.spark_balance }} {{ w.ticker }} + {{ w.spark_balance }} {{ w.ticker }} () {% if w.spark_pending %} Pending: +{{ w.spark_pending }} {{ w.ticker }} @@ -211,7 +211,7 @@ {{ w.name }} Spark Spark Balance: - {{ w.spark_balance }} {{ w.ticker }} + {{ w.spark_balance }} {{ w.ticker }} () {% if w.spark_pending %} Pending: +{{ w.spark_pending }} {{ w.ticker }} @@ -348,16 +348,7 @@ {{ w.expected_seed }} {% endif %} - {% if w.account_key %} - - Extended Private Key: - - •••••••••••••••• - - - - - {% endif %} + @@ -556,7 +547,7 @@ {{ w.name }} Balance: - {{ w.balance }} {{ w.ticker }} + {{ w.balance }} {{ w.ticker }} () @@ -568,7 +559,7 @@ {% if is_electrum_mode %} Not available in light mode {% else %} - {{ w.mweb_balance }} {{ w.ticker }} + {{ w.mweb_balance }} {{ w.ticker }} () {% endif %} @@ -578,7 +569,7 @@ {{ w.name }} Spark Balance: - {{ w.spark_balance }} {{ w.ticker }} + {{ w.spark_balance }} {{ w.ticker }} () @@ -587,7 +578,7 @@ {{ w.name }} Spark Balance: - {{ w.spark_balance }} {{ w.ticker }} + {{ w.spark_balance }} {{ w.ticker }} () @@ -596,14 +587,14 @@ {{ w.name }} Blind Balance: - {{ w.blind_balance }} {{ w.ticker }} + {{ w.blind_balance }} {{ w.ticker }} () {{ w.name }} Anon Balance: - {{ w.anon_balance }} {{ w.ticker }} + {{ w.anon_balance }} {{ w.ticker }} () @@ -778,7 +769,7 @@ Fee Estimate: - {{ w.est_fee }} + {{ w.est_fee }} () diff --git a/basicswap/templates/wallets.html b/basicswap/templates/wallets.html index 37536dc..2ee3651 100644 --- a/basicswap/templates/wallets.html +++ b/basicswap/templates/wallets.html @@ -65,7 +65,7 @@

Balance:

-
{{ w.balance }} {{ w.ticker }}
+
{{ w.balance }} {{ w.ticker }}

{{ w.ticker }} USD value:

@@ -90,7 +90,7 @@ {% if w.cid == '1' %} {# PART #}

Blind Balance:

- {{ w.blind_balance }} {{ w.ticker }} + {{ w.blind_balance }} {{ w.ticker }}

Blind USD value:

@@ -108,7 +108,7 @@ {% endif %}

Anon Balance:

- {{ w.anon_balance }} {{ w.ticker }} + {{ w.anon_balance }} {{ w.ticker }}

Anon USD value:

@@ -129,7 +129,7 @@ {% if w.cid == '3' and w.connection_type != 'electrum' %} {# LTC - MWEB not available in electrum mode #}

MWEB Balance:

- {{ w.mweb_balance }} {{ w.ticker }} + {{ w.mweb_balance }} {{ w.ticker }}

MWEB USD value:

@@ -151,7 +151,7 @@ {% if w.cid == '13' %} {# FIRO #}

Spark Balance:

- {{ w.spark_balance }} {{ w.ticker }} + {{ w.spark_balance }} {{ w.ticker }}

Spark USD value: