Page MenuHomePhabricator

[Cashtab] Deprecate ecashjs-lib
ClosedPublic

Authored by bytesofman on Apr 11 2023, 23:45.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCece69a1c4ccf: [Cashtab] Deprecate ecashjs-lib
Summary

T2893

This diff deprecates ecashjs-lib from Cashtab and replaces it with BitGo's utxo-lib. Unfortunately, we are still waiting for Bitgo to publish a version of utxo-lib that includes ecash transaction support. However, it is probably worth doing this drop-in now with the shims (i.e. the 0x01 | 0x40 in cashMethods.js) and then upgrading it later.

Test Plan

npm test

npm start
send an XEC tx
send an XEC tx with a cashtab msg
send an XEC tx with an encrypted cashtab msg
send an etoken tx
sign a msg
verify the msg

Diff Detail

Repository
rABC Bitcoin ABC
Branch
deprecating-ecashjs-lib
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 23222
Build 46063: Build Diffcashtab-tests
Build 46062: arc lint + arc unit

Event Timeline

This should still be stacked for ease of review. Lots going on here.

cashtab/package.json
112

Note: This change is required to ensure support of utxo-lib crypto libraries

150

Required for utxo-lib to work with jest

Uninstalling ecashjs-lib, removing custom uint8 test env from useWallet.test.js

Hm. Actually it is probably better not to stack this. Would basically be manufacturing partial implementations. Then would have to change the package.json again at the end by removing ecashjs-lib.

One go is the best way to have all the unit tests still work after the drop-in replacement.

Fabien added inline comments.
cashtab/package.json
149 ↗(On Diff #39581)

Can you explain how this relates to this diff ?

cashtab/src/utils/cashMethods.js
219 ↗(On Diff #39581)

You should make it a constant rather than using the magic numbers

cashtab/src/utils/cashMethods.js
219 ↗(On Diff #39649)

SIGHASH_FORKID

cashtab/package.json
149 ↗(On Diff #39581)

This is required to handle utxo-lib crypto library. I worked through this issue in the first proof of concept, D12939

https://github.com/BitGo/BitGoJS/issues/3148

Better labeling of SIGHASH_FORKID

change variable name everywhere used

Failed tests logs:

====== CashTab Unit Tests:  signAndBuildTx() successfully returns a raw tx hex for a tx with a single input and a single output ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: "0200000001582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006b483045022100b4ee5268cb64c4f097e739df7c6934d1df7e75a4f217d5824db18ae2e12554b102204faf039738181aae80c064b928b3d8079a82cdb080ce9a2d5453939a588f4372412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0158020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
Received: "0200000001582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006b483045022100fc0b496fc4d554d77ba610afa3e85c81eb0feeb4e188c7eb2414bb6bba14d61b022027d2e95b091951a15389af7423e5c19577f1bf0d07f4ee13f1fd0a9733250570012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0158020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
    at Object.<anonymous> (/work/cashtab/src/utils/__tests__/cashMethods.test.js:1116:22)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:391:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:316:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:218:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:155:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:66:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:389:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:475:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:133:12)
====== CashTab Unit Tests:  signAndBuildTx() successfully returns a raw tx hex for a tx with a single input and multiple outputs ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: "0200000001582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006b483045022100df29734c4fb348b0e8b613ce522c10c5ac14cb3ecd32843dc7fcf004d60f1b8a022023c4ae02b38c7272e29f344902ae2afa4db1ec37d582a31c16650a0abc4f480c412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0326020000000000001976a914f627e51001a51a1a92d8927808701373cf29267f88ac26020000000000001976a9140b7d35fda03544a08e65464d54cfae4257eb6db788ac26020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
Received: "0200000001582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006a4730440220784f205410e9bd22d72286332c8a26d0efc393ca01704057294eb6f674f3170d022071c4c023b576a3e985b78770c0b2acbbaeead459a9f743b5668461d0a5e9f942012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0326020000000000001976a914f627e51001a51a1a92d8927808701373cf29267f88ac26020000000000001976a9140b7d35fda03544a08e65464d54cfae4257eb6db788ac26020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
    at Object.<anonymous> (/work/cashtab/src/utils/__tests__/cashMethods.test.js:1147:22)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:391:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:316:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:218:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:155:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:66:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:389:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:475:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:133:12)
====== CashTab Unit Tests:  signAndBuildTx() successfully returns a raw tx hex for a tx with multiple inputs and a single output ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: "0200000003582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006a4730440220541366dd5ea25d65d3044dbde16fc6118ab1aee07c7d0d4c25c9e8aa299f040402203ed2f540948197d4c6a4ae963ad187d145a9fb339e311317b03c6172732e267b412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff7313e804af08113dfa290515390a8ec3ac01448118f2eb556ee168a96ee6acdd000000006b483045022100c1d02c5023f83b87a4f2dd26a7306ed9be9d53ab972bd935b440e45eb54a304302200b99aa2f1a728b3bb1dcbff80742c5fcab991bb74e80fa231255a31d58a6ff7d412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff960dd2f0c47e8a3cf1486b046d879f45a047da3b51aedfb5594138ac857214f1000000006b483045022100bd24d11d7070988848cb4aa2b10748aa0aeb79dc8af39c1f22dc1034b3121e5f02201491026e5f8f6eb566eb17cb195e3da3ff0d9cf01bdd34c944964d33a8d3b1ad412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0158020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
Received: "0200000003582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006a473044022059daa9254b880f836eee6a563fa35449b42a60bdd55d76f8b6c574c73d1cdc2a0220176ea66eaa523edcac41aa776b9f3ed944ce878c8efe5e74d507634fa41810da012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff7313e804af08113dfa290515390a8ec3ac01448118f2eb556ee168a96ee6acdd000000006a473044022021ebc6813176eb0a47ab2b8ea2956d8adca851f51e69526f259620eae31979510220110e9285a47d8143f2513db626d9efcdf75cad69ecc7de14cea9daef50163ec9012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff960dd2f0c47e8a3cf1486b046d879f45a047da3b51aedfb5594138ac857214f1000000006b483045022100b4fa09a4f25b3130a626065f46edfdc259e78b40eff77c6d5cfa68b63d940dad022032706a4c7dfdb2c9c0a24f028a8fb3140c25aef701c8a47497a7bae64eae3325012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0158020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
    at Object.<anonymous> (/work/cashtab/src/utils/__tests__/cashMethods.test.js:1175:22)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:391:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:316:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:218:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:155:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:66:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:389:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:475:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:133:12)
====== CashTab Unit Tests:  signAndBuildTx() successfully returns a raw tx hex for a tx with multiple inputs and multiple outputs ======
Error: expect(received).toStrictEqual(expected) // deep equality

Expected: "0200000003582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006a47304402203de4e6a512a6bec1d378b6444008484e1be5a0c621dc4b201d67addefffe864602202daf82e76b7594fe1ab54a49380c6b1226ab65551ae6ab9164216b66266f34a1412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff7313e804af08113dfa290515390a8ec3ac01448118f2eb556ee168a96ee6acdd000000006a473044022029f5fcbc9356beb9eae6b9ff9a479e8c8331b95406b6be456fccf9d90f148ea1022028f4e7fa7234f9429535360c8f5dad303e2c5044431615997861b10f26fa8a88412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff960dd2f0c47e8a3cf1486b046d879f45a047da3b51aedfb5594138ac857214f1000000006a473044022049a67738d99006b3523cff818f3626104cf5106bd463be70d22ad179a8cb403b022025829baf67f964202ea77ea7462a5447e32415e7293cdee382ea7ae9374364e8412102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0326020000000000001976a914f627e51001a51a1a92d8927808701373cf29267f88ac26020000000000001976a9140b7d35fda03544a08e65464d54cfae4257eb6db788ac26020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
Received: "0200000003582dfa42e2778a2e6b7d32fb1bf4cefc0be9d10a36538e9503465df99cd4a60d000000006a473044022079f10d08c27c11c1e1097ba69c84342770f4cb8d70364e408d68d4669a5d705602207f030f8cc8ece712c19ff19d9251c65e5b35f3582630859eeddc9d8b8e898865012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff7313e804af08113dfa290515390a8ec3ac01448118f2eb556ee168a96ee6acdd000000006a473044022048bab186b2c029d90bcb0fa723756a0f40b4f505f5d5a453f0574f2f9b3d5896022045a79306b12abbd9e5b7a3b04327db1da16d2306be15b3f7dfaf955530efc3b7012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff960dd2f0c47e8a3cf1486b046d879f45a047da3b51aedfb5594138ac857214f1000000006b483045022100864e172a2b9252733a034a6d171416b8993c3e0eabf1194d59c6b94d215c6539022014158b8ae4db9ad0dfb4892445e97e8f8965ce9269e99a93c63093d4679131ae012102322fe90c5255fe37ab321c386f9446a86e80c3940701d430f22325094fdcec60ffffffff0326020000000000001976a914f627e51001a51a1a92d8927808701373cf29267f88ac26020000000000001976a9140b7d35fda03544a08e65464d54cfae4257eb6db788ac26020000000000001976a9149846b6b38ff713334ac19fe3cf851a1f98c07b0088ac00000000"
    at Object.<anonymous> (/work/cashtab/src/utils/__tests__/cashMethods.test.js:1207:22)
    at Promise.then.completed (/work/cashtab/node_modules/jest-circus/build/utils.js:391:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/cashtab/node_modules/jest-circus/build/utils.js:316:10)
    at _callCircusTest (/work/cashtab/node_modules/jest-circus/build/run.js:218:40)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at _runTest (/work/cashtab/node_modules/jest-circus/build/run.js:155:3)
    at _runTestsForDescribeBlock (/work/cashtab/node_modules/jest-circus/build/run.js:66:9)
    at run (/work/cashtab/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
    at jestAdapter (/work/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
    at runTestInternal (/work/cashtab/node_modules/jest-runner/build/runTest.js:389:16)
    at runTest (/work/cashtab/node_modules/jest-runner/build/runTest.js:475:34)
    at Object.worker (/work/cashtab/node_modules/jest-runner/build/testWorker.js:133:12)

Each failure log is accessible here:
CashTab Unit Tests: signAndBuildTx() successfully returns a raw tx hex for a tx with a single input and a single output
CashTab Unit Tests: signAndBuildTx() successfully returns a raw tx hex for a tx with a single input and multiple outputs
CashTab Unit Tests: signAndBuildTx() successfully returns a raw tx hex for a tx with multiple inputs and a single output
CashTab Unit Tests: signAndBuildTx() successfully returns a raw tx hex for a tx with multiple inputs and multiple outputs

This revision is now accepted and ready to land.Apr 13 2023, 12:18
This revision was automatically updated to reflect the committed changes.