Page MenuHomePhabricator

[Cashtab] [chronik] Add hash160 to wallet state
AbandonedPublic

Authored by bytesofman on May 16 2022, 22:34.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Chronik requires a hash160 to get info about an address. Add this info in wallet state to save needing to convert it every time you call chronik.

Test Plan

Changes planned. Need to update mocks and think about unit tests here. In general this diff should look exactly like D10550

Diff Detail

Repository
rABC Bitcoin ABC
Branch
add-hash160
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 19059
Build 37870: Build Diffcashtab-tests
Build 37869: arc lint + arc unit

Event Timeline

Failed tests logs:

====== CashTab Unit Tests: Correctly executes cash utility functions Recognizes a latest, current wallet that does not require migration ======
Error: expect(received).toBe(expected) // Object.is equality

Expected: false
Received: true
    at Object.<anonymous> (/work/web/cashtab/src/utils/__tests__/cashMethods.test.js:267:60)
    at Promise.then.completed (/work/web/cashtab/node_modules/jest-circus/build/utils.js:391:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/work/web/cashtab/node_modules/jest-circus/build/utils.js:316:10)
    at _callCircusTest (/work/web/cashtab/node_modules/jest-circus/build/run.js:218:40)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at _runTest (/work/web/cashtab/node_modules/jest-circus/build/run.js:155:3)
    at _runTestsForDescribeBlock (/work/web/cashtab/node_modules/jest-circus/build/run.js:66:9)
    at _runTestsForDescribeBlock (/work/web/cashtab/node_modules/jest-circus/build/run.js:60:9)
    at run (/work/web/cashtab/node_modules/jest-circus/build/run.js:25:3)
    at runAndTransformResultsToJestFormat (/work/web/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:170:21)
    at jestAdapter (/work/web/cashtab/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:82:19)
    at runTestInternal (/work/web/cashtab/node_modules/jest-runner/build/runTest.js:389:16)
    at runTest (/work/web/cashtab/node_modules/jest-runner/build/runTest.js:475:34)
    at Object.worker (/work/web/cashtab/node_modules/jest-runner/build/testWorker.js:133:12)
====== CashTab Unit Tests:  Migrating legacy wallet on testnet ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,26 +1,29 @@
  Object {
    "Path145": Object {
      "cashAddress": "bchtest:qq47pcxfn8n7w7jy86njd7pvgsv39l9f9vtdvpkdz7",
      "fundingAddress": "slptest:qq47pcxfn8n7w7jy86njd7pvgsv39l9f9vset6v6sr",
      "fundingWif": "cTKuvZ644Sf7xra5z3dPshEECJNaDyBCq7HyBsysQPh1ySSpxtQ1",
+     "hash160": "2be0e0c999e7e77a443ea726f82c441912fca92b",
      "legacyAddress": "mjWxk74mLM7TieAsSJArLF7nXqC6oc2mof",
      "publicKey": "02fe5308d77bcce825068a9e46adc6f032dbbe39167a7b6d05ac563ac71d8b186e",
      "slpAddress": "slptest:qq47pcxfn8n7w7jy86njd7pvgsv39l9f9vset6v6sr",
    },
    "Path1899": Object {
      "cashAddress": "bchtest:qzagy47mvh6qxkvcn3acjnz73rkhkc6y7c9ex06hrx",
      "fundingAddress": "slptest:qzagy47mvh6qxkvcn3acjnz73rkhkc6y7c7dp5qq3m",
      "fundingWif": "cNRFB6MmkNhyhAj1TpGhXdbHgzWg4BsdHbAkKjiz4vt4vwgpC44F",
+     "hash160": "ba8257db65f40359989c7b894c5e88ed7b6344f6",
      "legacyAddress": "mxX888y8yaPpTYh3WhrB9GEkT3cgumYwPw",
      "publicKey": "02a06bb380cf180d703f6f80796a13555aefff817d1f6f842f1e5c555b15f0fa70",
      "slpAddress": "slptest:qzagy47mvh6qxkvcn3acjnz73rkhkc6y7c7dp5qq3m",
    },
    "Path245": Object {
      "cashAddress": "bchtest:qztqe8k4v8ckn8cvfxt5659nhd7dcyvxy539jyxazm",
      "fundingAddress": "slptest:qztqe8k4v8ckn8cvfxt5659nhd7dcyvxy5234lu2sx",
      "fundingWif": "cN3NDtiabeeX1Wzg2CPgLgrb7fsDG8PgWqTnmwAhYWmY6osSta7Q",
+     "hash160": "960c9ed561f1699f0c49974d50b3bb7cdc118625",
      "legacyAddress": "muCLmiGfH961UuWrTTFNU3KxH9pVQJJx6Z",
      "publicKey": "03c4a69fd90c8b196683216cffd2943a7b13b0db0812e44a4ff156ac7e03fc4ed7",
      "slpAddress": "slptest:qztqe8k4v8ckn8cvfxt5659nhd7dcyvxy5234lu2sx",
    },
    "mnemonic": "apart vacuum color cream drama kind foil history hurt alone ask census",
    at Object.<anonymous> (/work/web/cashtab/src/hooks/__tests__/useWallet.test.js:37:20)
====== CashTab Unit Tests:  Migrating legacy wallet on mainnet ======
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 0
+ Received  + 3

@@ -1,26 +1,29 @@
  Object {
    "Path145": Object {
      "cashAddress": "bitcoincash:qq47pcxfn8n7w7jy86njd7pvgsv39l9f9v0lgx569z",
      "fundingAddress": "simpleledger:qq47pcxfn8n7w7jy86njd7pvgsv39l9f9vryrap6mu",
      "fundingWif": "L2xvTe6CdNxroR6pbdpGWNjAa55AZX5Wm59W5TXMuH31ihNJdDjt",
+     "hash160": "2be0e0c999e7e77a443ea726f82c441912fca92b",
      "legacyAddress": "1511T3ynXKgCwXhFijCUWKuTfqbPxFV1AF",
      "publicKey": "02fe5308d77bcce825068a9e46adc6f032dbbe39167a7b6d05ac563ac71d8b186e",
      "slpAddress": "simpleledger:qq47pcxfn8n7w7jy86njd7pvgsv39l9f9vryrap6mu",
    },
    "Path1899": Object {
      "cashAddress": "bitcoincash:qzagy47mvh6qxkvcn3acjnz73rkhkc6y7cptzgcqy6",
      "fundingAddress": "simpleledger:qzagy47mvh6qxkvcn3acjnz73rkhkc6y7cdsfndq6y",
      "fundingWif": "Kx4FiBMvKK1iXjFk5QTaAK6E4mDGPjmwDZ2HDKGUZpE4gCXMaPe9",
+     "hash160": "ba8257db65f40359989c7b894c5e88ed7b6344f6",
      "legacyAddress": "1J1Aq5tAAYxZgSDRo8soKM2Rb41z3xrYpm",
      "publicKey": "02a06bb380cf180d703f6f80796a13555aefff817d1f6f842f1e5c555b15f0fa70",
      "slpAddress": "simpleledger:qzagy47mvh6qxkvcn3acjnz73rkhkc6y7cdsfndq6y",
    },
    "Path245": Object {
      "cashAddress": "bitcoincash:qztqe8k4v8ckn8cvfxt5659nhd7dcyvxy54hkry298",
      "fundingAddress": "simpleledger:qztqe8k4v8ckn8cvfxt5659nhd7dcyvxy5evac32me",
      "fundingWif": "KwgNkyijAaxFr5XQdnaYyNMXVSZobgHzSoKKfWiC3Q7Xr4n7iYMG",
+     "hash160": "960c9ed561f1699f0c49974d50b3bb7cdc118625",
      "legacyAddress": "1EgPUfBgU7ekho3EjtGze87dRADnUE8ojP",
      "publicKey": "03c4a69fd90c8b196683216cffd2943a7b13b0db0812e44a4ff156ac7e03fc4ed7",
      "slpAddress": "simpleledger:qztqe8k4v8ckn8cvfxt5659nhd7dcyvxy5evac32me",
    },
    "mnemonic": "apart vacuum color cream drama kind foil history hurt alone ask census",
    at Object.<anonymous> (/work/web/cashtab/src/hooks/__tests__/useWallet.test.js:62:20)

Each failure log is accessible here:
CashTab Unit Tests: Correctly executes cash utility functions Recognizes a latest, current wallet that does not require migration
CashTab Unit Tests: Migrating legacy wallet on testnet
CashTab Unit Tests: Migrating legacy wallet on mainnet

For whatever reason, phab is not including the new line const hash160 = BCH.Address.toHash160(cashAddress); as a change to useWallet.js in this diff. I've probably made a git error in which branch this is based on. Abandoning and throwing up the change in a new diff.