Page MenuHomePhabricator

[Apps][Examples] Get Utxos from address
ClosedPublic

Authored by emack on Jun 30 2023, 15:31.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABC5e76d4421a08: [Apps][Examples] Get Utxos from address
Summary

Example using chronik to retrieve the XEC and eToken UTXOs of a given address

Test Plan

npm test
npm run getUtxosFromAddress <address>

Diff Detail

Repository
rABC Bitcoin ABC
Branch
getUtxo
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24283
Build 48176: Build Diffapp-dev-examples
Build 48175: arc lint + arc unit

Event Timeline

emack requested review of this revision.Jun 30 2023, 15:31
bytesofman added inline comments.
apps/examples/package.json
17 ↗(On Diff #41127)
apps/examples/scripts/getUtxosFromAddress.js
24–25 ↗(On Diff #41127)
28 ↗(On Diff #41127)
apps/examples/test/getUtxosFromAddress.test.js
13 ↗(On Diff #41127)

Add a unit test for an address with no utxos

chronik's response shape needs special handling by app devs, since chronik.script(type,hash).utxos() returns

  1. An empty array if there are no utxos at the address
  2. An array of one object with key utxos if there are are utxos at the address

So, typically, the dev is interested in response.utxos -- but this is undefined if there are no utxos (not an empty array).

Also include a comment about this in the function. Only way for new devs to learn this at the moment is run into the case and work through the errors.

This revision now requires changes to proceed.Jun 30 2023, 17:15
emack marked 4 inline comments as done.

updated address decoding call, new unit test for an address with no utxos and added contextual comments

bytesofman requested changes to this revision.Jul 1 2023, 05:35
bytesofman added inline comments.
apps/examples/scripts/getUtxosFromAddress.js
12
35

let's pull <chronik url> out of the required command line params. not intuitive to always be customizing this.

default to an ABC server that can be adjusted by editing a constant in some file.

This revision now requires changes to proceed.Jul 1 2023, 05:35
emack marked an inline comment as done.

removed chronik url from input args

bytesofman requested changes to this revision.Jul 1 2023, 21:11
bytesofman added inline comments.
apps/examples/scripts/getUtxosFromAddress.js
43 ↗(On Diff #41154)

We'll be using this in many scripts, so it should be kept in its own file.

e.g. create a config.js and export this here

This revision now requires changes to proceed.Jul 1 2023, 21:11
emack requested review of this revision.Jul 1 2023, 22:54

We'll be using this in many scripts, so it should be kept in its own file. e.g. create a config.js and export this here

Keeping it in the same fike as discussed

This revision is now accepted and ready to land.Jul 2 2023, 03:15
This revision was automatically updated to reflect the committed changes.
emack marked an inline comment as done.