[RDY] Update Bcash to support native tokens and P2SH32 address type
This pull request upgrades the Bcash to support new BCH network upgrades to include P2SH32 address type support and BCH native tokens (CashTokens) support.
bchutil package was updated but referenced as a replacement package. A separate PR for it is out of scope for this review, but can be filed immediately .
Blockbook's bcashparser.go was updated to support new P2SH32 addresses from bchutil and to support token info parsing from output locking bytecode. Extensive tests were added to bcashparser_tests.go
New token type structs were put into types_bcash_type.go
rocksdb.go function packAddressKey was updated to strip token info from AddressDescriptor for BCH case and store all CashToken utxos under the same key.
worker.go functions getTransactionFromBchainTx and GetTransactionFromMempoolTx were updated to return BCH specific token data.
txdetail.html template and public.go were updated to render CashTokens specific data with different token categories being color-coded accordingly as there are more than one different tokens allowed to be interacted with within a single transaction.
go.sum updates are unintentional and made by my IDE to compile the project, let me know if we can sort this out with minimal interventions.
This PR looks for repository's maintainer feedback regarding data structures and other general remarks which will update its quality.
This PR is marked as WIP, as currently the token metadata (ticker, name, decimals, etc.) lookup and rendering are not implemented, and will be worked on after the submission.
Deployment preview:
Current:
https://bch1.trezor.io/tx/d7ad5f6336cd2c80c86e241ab2deb7b981b7dd9234b68a5b42e304829e482fb2 https://bch1.trezor.io/api/v2/tx/d7ad5f6336cd2c80c86e241ab2deb7b981b7dd9234b68a5b42e304829e482fb2
This PR: https://blockbook.pat.mn/tx/d7ad5f6336cd2c80c86e241ab2deb7b981b7dd9234b68a5b42e304829e482fb2 https://blockbook.pat.mn/api/v2/tx/d7ad5f6336cd2c80c86e241ab2deb7b981b7dd9234b68a5b42e304829e482fb2
MfG, pat.
Thank you for the contribution, we will take a look and review it!
Thank you for the contribution, we will take a look and review it!
Thanks.
While working further on BCH native token support in blockbook I realized that I'd need to reapproach the way I handle them (will commit soon). CashTokens live in output's PubkeyScript prepending the classical addrDesc script like 76a914..88ac with ef..tokenData. So storing the full PubkeyScript with token data in addrDesc and parsing token info on the fly leads to overly complex situations. Instead, I decided to put token info in TxInput, TxOutput and Utxo to clearly separate the addrDesc from token data and index token outputs by the same holder address.
Might sound a bit too technical, if you need any extra info, DM me on TG or discord @mainnet_pat
I am glad to announce that I have finished the work on CashTokens support in blockbook. Token information is nicely parsed from outputs and stored in TxAddresses and AddressBalance tables and available in API calls. Furthermore, the BCMR standard for token metadata publishing is supported and token category and NFT metadata is stored in RocksDB for fast access from consumers. API and UI were updated to render both CashTokens core info as well as optional metadata (see attached images).
Final sync is being completed and is available at https://blockbook.pat.mn
Please let me know if you have any questions so we can finalize this PR towards the inclusion in the mainline.
Images
Address page:
Transaction info:
Token category page:
Token nft details page:
Thank you for the contribution, we will take a look and review it!
Look forward to get your feedback on the latest work