aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-27 13:49:48 -0700
committerAdam Soltys <[email protected]>2026-06-27 13:49:48 -0700
commit1dc0c188d38c9d291375601c25a0533924402359 (patch)
tree955b66a1277e4e82eb2b6822652013f7abd788e7 /src
parent5de1b09a26745f3ba1ba54e3e666266c2620352c (diff)
downloadcoinosv3-1dc0c188d38c9d291375601c25a0533924402359.tar.gz
coinosv3-1dc0c188d38c9d291375601c25a0533924402359.zip
Sort pending txs newest-first in History (by firstSeen, not blockTime)
All pending txs share blockTime 0, so _sortTxs's blockTime comparator returned 0 for every pending pair and they kept array (scan/arrival-append) order — so the most recently received tx sat at the bottom of the pending group instead of the top. Order pending txs by firstSeen descending (the timestamp we already record when a tx is first seen unconfirmed); confirmed txs still sort by block time. Also sort on cache restore so the order is right immediately, not only after the first refresh. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/wallet.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/wallet.js b/src/wallet.js
index 7236a9f..46b9f5c 100644
--- a/src/wallet.js
+++ b/src/wallet.js
@@ -706,6 +706,9 @@ export class Wallet {
_sortTxs() {
this.txs.sort((a, b) => {
if (a.confirmed !== b.confirmed) return a.confirmed ? 1 : -1; // pending first
+ // Pending txs share blockTime 0, so order them by when we first saw them
+ // (newest on top); confirmed txs go by block time (newest on top).
+ if (!a.confirmed) return (b.firstSeen || 0) - (a.firstSeen || 0);
return (b.blockTime || 0) - (a.blockTime || 0);
});
}
@@ -1801,6 +1804,7 @@ export class Wallet {
this.change = d.change || [];
this.utxos = d.utxos || [];
this.txs = d.txs || [];
+ this._sortTxs(); // a cache saved before the firstSeen-ordering fix may be stale
this.nextReceiveIndex = d.nextReceiveIndex || 0;
this.nextChangeIndex = d.nextChangeIndex || 0;
this.feeRates = d.feeRates || this.feeRates;