HomePhabricator

[Cashtab] Migrate to new wallet shape that includes ecash-lib-ready sk and pk

Description

[Cashtab] Migrate to new wallet shape that includes ecash-lib-ready sk and pk

Summary:
We have been calculating sk and pk from wif every time we need them for ecash-lib txs. This was not particularly complicated when we were still using sendXec for all txs in Cashtab. However, with advanced tx construction methods provided by ecash-agora, we now to to calculate sk and pk in many places throughout Cashtab.

These values should be calculated when Cashtab first loads its wallets, not recalculated for every tx.

Migrate wallets to include these values.

This ends up being a large diff. Here is a summary of the changes:

  1. In wallet/index.ts, update type so that sk and pk are required ("the one change" of this diff)
  2. Update isValidCashtabWallet so that only this newest type is valid
  3. Update cashtabWalletToJSON and cashtabWalletFromJSON to deal with storing / reviving Uint8Array
  4. Update wallet types (now we have a new legacy type, and a new stored type)
  5. Update all wallets used by tests to be the valid format (only the migration tests should use invalid wallets)
  6. Add tests to confirm migration

Now that we have monorepo-confirmed type stability with chronik in the node, CashtabWallet should really be a class. Perhaps even in a separate library so other developers could more easily work with chronik utxo sets and avoid burns.

We're getting there. But Cashtab is the place to get it right first.

Test Plan: npm test

Reviewers: #bitcoin_abc, emack

Reviewed By: #bitcoin_abc, emack

Subscribers: emack

Differential Revision: https://reviews.bitcoinabc.org/D17168

Details

Provenance
bytesofmanAuthored on Nov 20 2024, 13:37
bytesofmanPushed on Nov 22 2024, 14:11
Reviewer
Restricted Project
Differential Revision
D17168: [Cashtab] Migrate to new wallet shape that includes ecash-lib-ready sk and pk
Parents
rABCf0d32cf005dc: [ecashaddrjs] Implement typescript linting and add to arclint
Branches
Unknown
Tags
Unknown