Page MenuHomePhabricator

[Cashtab] [Chronik] [Tx Gen] Token transaction refactor - part 1 createToken
ClosedPublic

Authored by emack on Oct 19 2022, 07:43.

Details

Summary

T2503

Refactor the createToken function to utilize the newly landed generateTxInput & generateTxOutput utility functions, as well as the new approach of signing input UTXOs, building tx and broadcasting via the chronik client.

At this point in the diff avoid burning tokens because that's still being broadcasted via bch-api, which will confuse chronik and result in 'Invalid SLP burns' errors when trying to create another token.

Test Plan

npm test and ensure the chronikfied unit tests all pass
npm start
create a new token with no image and ensure successful creation (check decimals, supply...) and able to be sent
verify via explorer that the XEC change (if exists) is returned to the creator
create a new token with an image and ensure successful creation (check decimals, supply...) and able to be sent

Diff Detail

Repository
rABC Bitcoin ABC
Branch
createTokenRefactor
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 20597
Build 40859: Build Diffcashtab-tests
Build 40858: arc lint + arc unit

Event Timeline

emack requested review of this revision.Oct 19 2022, 07:43
bytesofman added inline comments.
web/cashtab/src/utils/cashMethods.js
202

This is needed though for SEND and BURN txs. Need to make this validation more specific.

This revision now requires changes to proceed.Oct 19 2022, 16:41

Added tokenId check and skipSlpCheck param.
The skipSlpCheck param in particular is needed here because if the wallet has existing burn txs through bch-api then chronik's safety mechanism to avoid accidental token burns will trigger and throw 'invalid-slp-burns' errors. This includes creating and sending tokens even though they have nothing to do with token burning.
Cashtab shouldn't be relying on other endpoints for validation anyway, so I don't see an issue in bypassing this.

This revision is now accepted and ready to land.Oct 24 2022, 17:08