From c8d1f96770ec7333098d7d8c70075fe2867edcb3 Mon Sep 17 00:00:00 2001 From: user Date: Sat, 28 Feb 2026 13:44:14 -0800 Subject: [PATCH] feat: show red warning when sending to address with zero tx history On the confirm-tx view, asynchronously check the recipient address transaction count via getTransactionCount(). If zero, display a prominent red warning advising the user to double-check the address. Closes #82 --- src/popup/views/confirmTx.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/popup/views/confirmTx.js b/src/popup/views/confirmTx.js index 522e9e5..82c14dd 100644 --- a/src/popup/views/confirmTx.js +++ b/src/popup/views/confirmTx.js @@ -244,6 +244,7 @@ function show(txInfo) { showView("confirm-tx"); estimateGas(txInfo); + checkRecipientHistory(txInfo); } async function estimateGas(txInfo) { @@ -286,6 +287,28 @@ async function estimateGas(txInfo) { } } +async function checkRecipientHistory(txInfo) { + try { + const provider = getProvider(state.rpcUrl); + const txCount = await provider.getTransactionCount(txInfo.to); + if (txCount === 0) { + const warningsEl = $("confirm-warnings"); + const warning = + `
` + + `WARNING: The recipient address has ZERO transaction history. ` + + `This may indicate a fresh or unused address. Double-check the address before sending.
`; + if (warningsEl.classList.contains("hidden")) { + warningsEl.innerHTML = warning; + warningsEl.classList.remove("hidden"); + } else { + warningsEl.innerHTML += warning; + } + } + } catch (e) { + log.errorf("recipient history check failed:", e.message); + } +} + function init(ctx) { $("btn-confirm-send").addEventListener("click", async () => { const password = $("confirm-tx-password").value;