feat: show red warning when sending to address with zero tx history
All checks were successful
check / check (push) Successful in 9s

On the confirm-tx screen, asynchronously check the recipient address
via Blockscout API. If the address has never sent or received any
transactions (normal or ERC-20), display a prominent red warning.

Fails open: network errors silently skip the warning to avoid
blocking legitimate sends.

Closes #82
This commit is contained in:
user
2026-02-28 15:00:48 -08:00
parent dc8ec7d28f
commit 7bd6b5bbdc
2 changed files with 56 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ const { decryptWithPassword } = require("../../shared/vault");
const { formatUsd, getPrice } = require("../../shared/prices");
const { getProvider } = require("../../shared/balances");
const { isScamAddress } = require("../../shared/scamlist");
const { hasZeroTransactionHistory } = require("../../shared/transactions");
const { ERC20_ABI } = require("../../shared/constants");
const { log } = require("../../shared/log");
const makeBlockie = require("ethereum-blockies-base64");
@@ -244,6 +245,7 @@ function show(txInfo) {
showView("confirm-tx");
estimateGas(txInfo);
checkRecipientHistory(txInfo);
}
async function estimateGas(txInfo) {
@@ -286,6 +288,23 @@ async function estimateGas(txInfo) {
}
}
async function checkRecipientHistory(txInfo) {
const isNew = await hasZeroTransactionHistory(
txInfo.to,
state.blockscoutUrl,
);
if (!isNew) return;
const warningsEl = $("confirm-warnings");
const warningHtml =
`<div class="border border-red-500 border-dashed p-2 mb-1 text-xs font-bold text-red-500">` +
`WARNING: This address has ZERO transaction history. ` +
`It has never sent or received any funds. ` +
`Double-check the address before sending.</div>`;
warningsEl.innerHTML = warningHtml + warningsEl.innerHTML;
warningsEl.classList.remove("hidden");
}
function init(ctx) {
$("btn-confirm-send").addEventListener("click", async () => {
const password = $("confirm-tx-password").value;