Show active address ETH balance and USD value in headline
Some checks failed
check / check (push) Has been cancelled

The headline now shows the active address's balance as
"x.yyyy ETH ($z.aa USD)" instead of the sum across all wallets.
This commit is contained in:
2026-02-26 15:56:09 +07:00
parent e8e5edf5f2
commit ba54f412d2

View File

@@ -12,14 +12,32 @@ const QRCode = require("qrcode");
const { deriveAddressFromXpub } = require("../../shared/wallet");
const {
formatUsd,
getPrice,
getAddressValueUsd,
getTotalValueUsd,
} = require("../../shared/prices");
function findActiveAddr() {
for (const w of state.wallets) {
for (const a of w.addresses) {
if (a.address === state.activeAddress) return a;
}
}
return null;
}
function renderTotalValue() {
const el = $("total-value");
if (!el) return;
el.textContent = formatUsd(getTotalValueUsd(state.wallets));
const addr = findActiveAddr();
if (!addr) {
el.textContent = "";
return;
}
const ethBal = parseFloat(addr.balance || "0");
const ethStr = ethBal.toFixed(4) + " ETH";
const usd = getAddressValueUsd(addr);
const usdStr = usd !== null ? " (" + formatUsd(usd) + " USD)" : "";
el.textContent = ethStr + usdStr;
}
const EXT_ICON =