Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode sstxcommitment script #2523

Merged
merged 4 commits into from
Jul 7, 2020

Conversation

vctt94
Copy link
Member

@vctt94 vctt94 commented Jun 10, 2020

After merging #2468, we removed our grpc call to decodeRawTransactions.

When working at #2516, I noticed we are not properly decoding sstxcommitment scripts, which are needed for signing the tx message for the vsp.

This PR adds it.

Diff description:

  • I added the opcode constants file, which have all opcodes described on the btc wiki, in bitcoin core and in most if not all other references and software related to handling DCR scripts.
  • at our helpers/script.js I am adding the parseScript method, which was removed from dcrd due to optmizations at the txscript on txscript: Zero alloc optimization refactor. dcrd#1656.
    • The reason I am doing that is for convinience. This way we need to import less code from dcrd into decrediton, and as we do not decode big scripts in decrediton, it is fine for us, for now.
  • added addrFromSStxPkScrCommitment so we can get addressses from sstxcommitment scripts
  • fixed some of our tests after the new additions, move some test data to different folders, for better naming and increased out test coveraged.
    • I added a new wallet/service.spec.js which is a integration test of our decodeRawTransaction methods from wallet service. It is in unit tests because right now our package.json consider our unit/test folder as test's rootDir. We need to add integration tests to it.

Copy link
Member

@matheusd matheusd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the decred-specific opcodes.

"numInputs": 1,
"inputs": [
{
"opRawHash": Buffer.from([132, 107, 192, 162, 131, 217, 8, 228, 140, 36, 137, 147, 128, 220, 21, 80, 233, 149, 72, 230, 4, 157, 215, 148, 83, 194, 10, 148, 245, 249, 167, 105]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend creating a helper to convert from an hex string to a Buffer for these functions, since it makes it easier to review.

Or maybe dropping opRawHash altogether and working off of prevTxId (since having two fields for the same info could lead to using inconsistent data)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. I removed the opRawHash from decodedTransaction object.

@vctt94 vctt94 force-pushed the decode-sstxcommitment-script branch from 34c348b to c6ce2ac Compare July 6, 2020 21:36
@alexlyp alexlyp merged commit 8eeee11 into decred:master Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants