Page MenuHomePhabricator

[Cashtab] [utxo handling p1] Add chronik utxo fetch functionality
AbandonedPublic

Authored by bytesofman on Aug 2 2022, 23:51.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Summary

T2447

Add a function to get utxo set using chronik instead of bch-api

This diff creates a new file, chronik.js, to contain functions that wrap chronik API calls. Due to the current limitation in chronik where hash160s are required instead of addresses, together with the need to preserve existing data structures and app functionality, these functions may be slightly more involved than a simple API call and hence warrant specific methods.

Test Plan

npm start
Compare the console.log statements for bchApiUtxos and chronikUtxos -- confirm the same number of total utxos

Diff Detail

Repository
rABC Bitcoin ABC
Branch
chronik-utxo-handling
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 19764
Build 39247: Build Diffcashtab-tests
Build 39246: arc lint + arc unit

Event Timeline

Unit tests and mocks to be added

emack added inline comments.
web/cashtab/src/utils/chronik.js
66 ↗(On Diff #34567)

Consider the scenario where a wallet has utxos on both Path1899 and Path145 - should there be any filtering here for Path1899 specific utxos prior to pushing them into the chronikUtxoPromises array?

Adding unit test and mocks

web/cashtab/src/utils/chronik.js
66 ↗(On Diff #34567)

The returnGetUtxosChronikPromise function ends up tagging every utxo with its individual address, matching the way Cashtab currently approaches this problem.

I think important to preserve to support future HD wallet implementation.

In pseudocode terms, this is what the diff is intended to implement:

  • Iterate through Cashtab's addresses (right now, hardcoded 3 addresses, Path145, Path245, and Path1899..though in practice all wallets created after early 2021 will only have utxos at Path1899)
  • For each one, ask chronik what utxos are at that address
  • Process chronik's response by adding an address: <address> key/value to each utxo object at that address

The unit test includes my own older wallet, which still has some of these archaic path utxos on it.

This revision is now accepted and ready to land.Aug 3 2022, 15:30