diff options
| author | Adam Soltys <[email protected]> | 2026-06-26 13:57:27 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-26 13:57:27 -0700 |
| commit | bb939f73e4e02b528e346b9f9d909c3a25cfedbb (patch) | |
| tree | 8fe13e6b2dc644bbf13ee3fba0d47877b0450f96 /src/app.js | |
| parent | 9f4bc29025287e8e12a7ef31c9918c1adfdfff5d (diff) | |
| download | coinosv3-bb939f73e4e02b528e346b9f9d909c3a25cfedbb.tar.gz coinosv3-bb939f73e4e02b528e346b9f9d909c3a25cfedbb.zip | |
Update balance/history optimistically right after a send
On the Electrum backend the post-send rescan is many round-trips, so the balance
lagged a few seconds. Now a successful broadcast immediately applies the tx
locally (applySentTx): drop the spent coins, credit change as pending, add a
pending history row, recompute the balance, and emit — so the UI reflects the
send instantly. The realtime watcher / backstop poll reconciles and fills in the
confirmation once the explorer has indexed it (no immediate rescan, so a
not-yet-indexed tx can't briefly revert the optimistic state). Verified the
balance/utxo/history math.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'src/app.js')
| -rw-r--r-- | src/app.js | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -2768,12 +2768,12 @@ async function broadcast() { wallet.broadcast(hexTx), new Promise((_, rej) => setTimeout(() => rej(new Error(t('broadcastTimeout'))), 30000)), ]); + wallet.applySentTx(ui.draft.tx); // update balance/history locally, right now ui.sendResult = { txid }; ui.draft = null; ui.send = blankSend(); ui.busy = false; - render(); // show success immediately — don't hold the - wallet.scan().catch(() => {}); // spinner up for the post-send rescan + render(); // the realtime watcher / backstop poll reconciles + confirms later return; } catch (e) { ui.sendError = t('broadcastFailed', { msg: e.message }); |
