Page MenuHomePhabricator

[Cashtab] [BCH Deprecation] [Mnemonic] Pt 4/7 - Implement BCH.Mnemonic.validate locally
ClosedPublic

Authored by emack on Nov 10 2022, 12:57.

Details

Summary

T2730

Depends on D12452

Stacked diff to localize existing uses of BCH.Mnemonic throughout the app and deprecate the BCH.Mnemonic object.

Pt 1/7 - Implement BCH.Mnemonic.toSeed locally
Pt 2/7 - Implement BCH.Mnemonic.generate locally
Pt 3/7 - Implement BCH.Mnemonic.wordLists locally
Pt 4/7 - Implement BCH.Mnemonic.validate locally
Pt 5/7 - Deprecate BCH.Mnemonic throughout the app
Pt 6/7 - Optimize bip39 bundle via webpack IgnorePlugin
Pt 7/7 - Unwrap validateMnemonicWordList

Test Plan

npm test
npm start
import a wallet and observe the 'mnemonicTestOutput matches localMnemonicTestOutput' console log message

Diff Detail

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

Event Timeline

emack requested review of this revision.Nov 10 2022, 12:57

Do we need a wrapper function here? I am guessing bch-js had some reason to include this. But it seems kind of strange. Ideally the function would just return "true" or "false" --- instead of this wrapper version that returns strings, which then need to be parsed by the app.

It's okay for this diff since we are matching legacy functionality, but we should add another part to this stack to clean it up.

Rabbit hole to library function points here: https://github.com/bitcoinjs/bip39/blob/master/src/index.js#L66

Maybe a blank string does return a false positive. But in this case, we should just also control for blank strings, not persist an artifact wrapper function of questionable value in Cashtab.

This revision is now accepted and ready to land.Nov 14 2022, 09:12
emack retitled this revision from [Cashtab] [BCH Deprecation] [Mnemonic] Pt 4/6 - Implement BCH.Mnemonic.validate locally to [Cashtab] [BCH Deprecation] [Mnemonic] Pt 4/7 - Implement BCH.Mnemonic.validate locally.Nov 14 2022, 12:07
emack edited the summary of this revision. (Show Details)