Page MenuHomePhabricator

[Cashtab] [Chronik] [Tx Gen] Get change address from input UTXOs
ClosedPublic

Authored by emack on Jul 5 2022, 07:23.

Details

Summary

As per T2503, this is part of a series of diffs to refactor the transaction generation process within useBCH.

This diff is a standalone utility function which parses the input UTXOs for the address at element 0. If that particular address is invalid, then the function falls back onto the wallet's Path1899 cash address.

Test Plan

npm test
observe successful execution of buildTx() unit tests

Diff Detail

Repository
rABC Bitcoin ABC
Branch
changeAddress
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 19555
Build 38829: Build Diffcashtab-tests
Build 38828: arc lint + arc unit

Event Timeline

emack requested review of this revision.Jul 5 2022, 07:23
bytesofman requested changes to this revision.Jul 5 2022, 18:05
bytesofman added inline comments.
web/cashtab/src/utils/cashMethods.js
18

These BLOCKCAPS_UNDERSCORED variables are artifacts from I can't even remember. Do not preserve them in this standalone function.

Call it changeAddress everywhere for clarity + consistency.

29

Don't include this fallback. If the input utxo has an invalid address, we got problems --- the tx should fail.

This revision now requires changes to proceed.Jul 5 2022, 18:05
emack marked 2 inline comments as done.
  • Removed fallback to Path1899 address
  • Added unit test coverage for malformed input utxo and valid input utxo with invalid address params
  • Updated variable names
bytesofman requested changes to this revision.Jul 6 2022, 23:16
bytesofman added inline comments.
web/cashtab/src/utils/cashMethods.js
16 ↗(On Diff #34270)

This comment should read "Assume change address is input address of utxo at index 0"

17 ↗(On Diff #34270)

Remove this comment

This revision now requires changes to proceed.Jul 6 2022, 23:16
emack marked 2 inline comments as done.

Updated comments

This revision is now accepted and ready to land.Jul 7 2022, 21:02