Page MenuHomePhabricator

[Apps][Examples] Refactor sendXec demo to use updated API in ecash-coinselect v2.0.1
ClosedPublic

Authored by emack on Oct 2 2023, 12:59.

Details

Summary

Update sendXec example to use the new API in ecash-coinselect v2.0.1.

Test Plan

npm test
Fill in sender mnemonic and address and execute npm run sendXec <address> <amountInXec> and ensure it is broadcasted successfully via explorer.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested review of this revision.Oct 2 2023, 12:59
bytesofman requested changes to this revision.Oct 2 2023, 13:54
bytesofman added inline comments.
apps/examples/scripts/sendXec.js
91 ↗(On Diff #42478)

add a comment about why we need this legacy address

This revision now requires changes to proceed.Oct 2 2023, 13:54
emack marked an inline comment as done.

Updated comments

bytesofman requested changes to this revision.Oct 3 2023, 18:08
bytesofman added inline comments.
apps/examples/scripts/sendXec.js
70 ↗(On Diff #42499)

since the point of the example is readability / followability, go ahead and pull the utxos out on their own line with their own comment

71 ↗(On Diff #42499)

same here. define a targetOutputs variable.

the targetOutput should also have a address: destinationAddress key/value

135 ↗(On Diff #42499)

like the refactored cashtab tx function -- return {txid, hex} -- then your unit test can test if you are actually getting the tx that you want.

In this case, the unit test is "passing" because it gets the same mock txid you ask it for. But we miss that the tx is sending xec to its own change address.

To check the rawtx response, you can load it into electrum and confirm you have the expected inputs, outputs, and fee.

This revision now requires changes to proceed.Oct 3 2023, 18:08
emack marked 3 inline comments as done.

Responding to feedback

apps/examples/scripts/sendXec.js
70 ↗(On Diff #42499)

Updated

71 ↗(On Diff #42499)

Updated

135 ↗(On Diff #42499)

Updated the response from sendXec per feedback and adjusted unit test accordingly

bytesofman requested changes to this revision.Oct 4 2023, 18:59
bytesofman added inline comments.
apps/examples/scripts/sendXec.js
69 ↗(On Diff #42534)
73 ↗(On Diff #42534)
apps/examples/test/sendXec.test.js
63 ↗(On Diff #42534)

lol yes this still works but the point is we want to confirm the hex also matches.

This revision now requires changes to proceed.Oct 4 2023, 18:59
emack marked 3 inline comments as done.

Responding to feedback

bytesofman requested changes to this revision.Oct 5 2023, 16:36

image.png (590×803 px, 40 KB)

.... i dunno why this is the example tx (a self-send tx with no change output that some crazy how ends up with a fee well below 1 sat per byte) but

  1. it shouldn't be, we should use a 'normal' tx like sending ecash from one address to a different address
  2. We should have tests for doing this with and without a change output
  3. on the plus side, the presence of this tx seems to present a bug with coinselect ... should be throwing an error here, need to look into this
This revision now requires changes to proceed.Oct 5 2023, 16:36

Added two standard one to one send XEC tests, one with change and one without.

This revision is now accepted and ready to land.Oct 6 2023, 16:22