[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:
- In wallet/index.ts, update type so that sk and pk are required ("the one change" of this diff)
- Update isValidCashtabWallet so that only this newest type is valid
- Update cashtabWalletToJSON and cashtabWalletFromJSON to deal with storing / reviving Uint8Array
- Update wallet types (now we have a new legacy type, and a new stored type)
- Update all wallets used by tests to be the valid format (only the migration tests should use invalid wallets)
- 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