diff --git a/basicswap/js_server.py b/basicswap/js_server.py index af60043..495dc16 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 @@
Balance:
Blind Balance:
Anon Balance:
Spark Balance:
Spark Balance:
Balance:
Spark Balance:
Spark Balance:
Blind Balance:
Anon Balance: