From 3d57ac2a6f70a7b881d9f1fd2d9d304c2f0ba2a3 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 25 Jun 2026 17:05:02 -0700 Subject: Lazily fetch a receive's fee when opening its detail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A watcher-credited receive arrives with no fee (the push can't compute it from the raw tx, and the reduced reconcile doesn't revisit the now-used address). On opening the tx detail, fetch the full tx from the explorer to fill in the fee (and confirmations) — works for pending mempool txs too. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/app.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/app.js b/src/app.js index f016cac..88a77a1 100644 --- a/src/app.js +++ b/src/app.js @@ -2458,7 +2458,7 @@ function txHistoryItem(tx) { const stuck = !tx.confirmed && wallet.isStuck(tx); return h( 'div', - { class: 'item', style: 'cursor:pointer', onClick: () => { ui.txDetail = tx.txid; render(); } }, + { class: 'item', style: 'cursor:pointer', onClick: () => openTx(tx.txid) }, h('div', { class: `ico ${incoming ? 'in' : 'out'}` }, incoming ? '↓' : '↑'), h('div', { class: 'grow' }, h('div', { class: 'row gap6' }, @@ -2557,6 +2557,30 @@ function historyTab() { ); } +// Open a tx's detail view, lazily fetching its fee/details if we don't have them +// yet. A watcher-credited receive arrives with no fee (the push can't compute it +// from the raw tx), so fill it in from the explorer on demand — works for pending +// mempool txs too. +async function openTx(txid) { + ui.txDetail = txid; + render(); + const tx = wallet.txs.find((t) => t.txid === txid); + if (!tx || tx.fee || wallet.offline) return; + try { + const full = await wallet.api.getTx(txid); + if (!full || ui.txDetail !== txid) return; + if (full.fee != null) tx.fee = full.fee; + if (full.weight) tx.vsize = Math.ceil(full.weight / 4); + if (full.status && full.status.confirmed) { + tx.confirmed = true; + tx.blockHeight = full.status.block_height || tx.blockHeight; + tx.blockTime = full.status.block_time || tx.blockTime; + } + wallet.saveCache(); + render(); + } catch {} +} + function txDetailView(tx) { const incoming = tx.net >= 0; const line = (k, v) => h('div', { class: 'line' }, h('span', { class: 'k' }, k), h('span', { class: 'v' }, v)); -- cgit v1.2.3