Page MenuHomePhabricator

[Cashtab] Remove parsedTxHistory from wallet state
ClosedPublic

Authored by bytesofman on Sep 23 2025, 18:48.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC8de6a10f47b7: [Cashtab] Remove parsedTxHistory from wallet state
Summary

Tx history is helpful information for the user. However, it is not necessary for any wallet actions. It should not be associated with the wallet state, especially now that we have paginated tx history which can only use the wallet state for page 1.

Remove the parsedTxHistory key from wallet state. Note we are no longer storing this key, so this change does not require a migration.

This allows us to implement more fine-grained handling of tx history and avalanche finality and achieve current performance without the hacky batchUpdates process. We could probably also lose our async queueing of websocket msgs, now that we are appropriately using Reacts setState with prev, but at the moment it works and is basically instant so will do that in another diff if it should be done.

This diff is additional prep for dropping in ecash-wallet. With wallet state parsedTxHistory no longer used by the app, we can use ecash-wallet instead of cashtab wallet state, once it has feature parity with Cashtab's custom methods.

Test Plan

npm test, npm start, send a bunch of txs, note they are instantly added to history, note if the page is full the last tx is removed from the page, note they all finalize at the same time with no issues. This diff is live at cashtab.io

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested changes to this revision.Sep 23 2025, 21:17
Fabien added a subscriber: Fabien.
Fabien added inline comments.
cashtab/src/components/Header/index.tsx
100 ↗(On Diff #55814)

this is an unrelated change

cashtab/src/wallet/useWallet.ts
298 ↗(On Diff #55814)

Due to the way chronik manages the pagination this might give a different result from what will appear after a refresh. Is that a problem ?

This revision now requires changes to proceed.Sep 23 2025, 21:17
cashtab/src/components/Header/index.tsx
100 ↗(On Diff #55814)

Actually this needs to be rebased, I see the fix has been split into its own diff in D18670.

bytesofman added inline comments.
cashtab/src/wallet/useWallet.ts
298 ↗(On Diff #55814)

Yes, I think it's acceptable and somewhat inevitable.

We could implement a standard Cashtab sorting for the first page, say by timeFirstSeen only even the block time sort is different, but that could cause its own challenges (varies from different chronik servers, not always available, etc).

But I think it's okay for tx history to not always be the same as long as they resolve to a canonical order, which the history endpoint should handle.

Indeed, it may not always be the same from refresh to refresh even now, given how the history endpoint returns confirmed vs unconfirmed txs.

Going forward and esp after precon, maintaining tx order by when first finalized is an interesting and relevant app dev problem. There is no canonical time_finalized available afaik, at least not an exact one that can later be referenced in the future.

bytesofman marked an inline comment as done.

rebase

Fabien added inline comments.
cashtab/src/wallet/useWallet.ts
298 ↗(On Diff #55814)

it's more that this whole logic only saves a single chronik call (for fetching the first page history). It might be worth just pulling it from chronik directly. Updating the finalization status in the page is fine.

This revision is now accepted and ready to land.Sep 24 2025, 07:50
bytesofman added inline comments.
cashtab/src/wallet/useWallet.ts
298 ↗(On Diff #55814)

hm good point. will keep this as an option. the reason tho I think the whole logic is worthwhile:

  1. it moves the appearance and ordering of new incoming (or outgoing) txs to the user's websocket msg ordering, which is likely to be consistent with the user's "timeFirstSeen" experience (vs chronik call may not be this way, esp txs are in various blocks)
  1. The ultimate goal is to move cashtab away from updating the whole utxo set every time we see a tx (current behavior). We used to update the whole first page of tx history and the whole utxo set every time we saw a new tx. Now we are still updating the utxo set. Admittedly this is only 2 calls, now 1 call, and is quite quick. But both calls are superfluous and could be handled by the already-made chronik.tx call on websocket msgs. The utxo call in particular can be heavy if the wallet has many utxos, so overkill when we know any given tx is only changing a handful of utxos.

With ecash-wallet, the utxo set will now auto-update on sent txs. Just need to add updating on received txs (which may also simply be managed within ecash-wallet, have not decided yet).

The expected benefit is ludicrously fast repeated txs without any utxo set / already-spent errors, as well as Cashtab loading instantly with a correct cached utxo set (unless the wallet was used in another app while the user was offline).

This revision was automatically updated to reflect the committed changes.
bytesofman marked an inline comment as done.