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

add OP_CHECKCOLDSTAKEVERIFY_LOF #14

Merged
merged 2 commits into from
Nov 27, 2022

Conversation

PeterL73
Copy link
Contributor

@PeterL73 PeterL73 commented Oct 29, 2022

Issue being fixed or feature implemented

Could this be related to or even fix #8 ?

Only opcode OP_CHECKCOLDSTAKEVERIFY is used to identify Cold Staking Contracts.
And opcode OP_CHECKCOLDSTAKEVERIFY [0xd1] differs from PIVX [0xd2]

PIVX changed the name of opcode OP_CHECKCOLDSTAKEVERIFY to OP_CHECKCOLDSTAKEVERIFY_LOF
And added a new opcode OP_CHECKCOLDSTAKEVERIFY [0xd2]
PIVX-Project/PIVX#2275

What was done?

Change opcode OP_CHECKCOLDSTAKEVERIFY to OP_CHECKCOLDSTAKEVERIFY_LOF
Add opcode OP_CHECKCOLDSTAKEVERIFY [0xd2]
Use both opcodes to check if it is a Pay to ColdStake Script

How Has This Been Tested?

It has not been tested. I could not get the go compiler working on my machine (yet), but could not wait to share.

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@PeterL73
Copy link
Contributor Author

Finally got the go compiler working (and saw a typo and force pushed the correction)

Tested with /api/v2/address/utxo/<addr>

Before

[
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":6,"value":"926600000000","height":952322,"confirmations":3639,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":5,"value":"15000000000","height":952322,"confirmations":3639,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":4,"value":"15000000000","height":952322,"confirmations":3639,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":3,"value":"15000000000","height":952322,"confirmations":3639,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":2,"value":"15000000000","height":952322,"confirmations":3639,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":1,"value":"15000000000","height":952322,"confirmations":3639,"stake_contract":false},
{"txid":"c3db984966d0e06c718a41b61e3b7cc073272149f492dab6c3d7f68bbaa35531","vout":0,"value":"24799918400","height":951969,"confirmations":3992,"stake_contract":false}
]

After

[
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":6,"value":"926600000000","height":952322,"confirmations":3653,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":5,"value":"15000000000","height":952322,"confirmations":3653,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":4,"value":"15000000000","height":952322,"confirmations":3653,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":3,"value":"15000000000","height":952322,"confirmations":3653,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":2,"value":"15000000000","height":952322,"confirmations":3653,"stake_contract":false},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":1,"value":"15000000000","height":952322,"confirmations":3653,"stake_contract":false},
{"txid":"c3db984966d0e06c718a41b61e3b7cc073272149f492dab6c3d7f68bbaa35531","vout":0,"value":"24799918400","height":951969,"confirmations":4006,"stake_contract":false},
{"txid":"44ce8d86a154078ae0f628ee14fef2e0bc1cd5aa497bfd0278a7890ac27fe2bd","vout":1,"value":"15000000000","height":951171,"confirmations":4804,"stake_contract":false},
{"txid":"2e4f7a1fa1389462b328582291f4e25db03a4720ebfacf03e87dc0be670762cf","vout":1,"value":"15000000000","height":951166,"confirmations":4809,"stake_contract":false},
{"txid":"9ce3fc3949e094b7c1c11e0ab2c4ef11869e21ccf2e97d27d61211e0407da7c0","vout":1,"value":"15000000000","height":951164,"confirmations":4811,"stake_contract":false},
{"txid":"34cfd413db8074f9d9c56905d3db33b81ab172be33f0654597b8e21d437dbdcb","vout":1,"value":"15000000000","height":951159,"confirmations":4816,"stake_contract":false},
{"txid":"a2c5b17919f84b5b3c07280098bfe33cdf2ac3aeb00f5614c6473d81c68c6ed2","vout":1,"value":"15000000000","height":951157,"confirmations":4818,"stake_contract":false},
{"txid":"23a7fedcada54cda32e9937cc001dc7e9167abac78ca7534e348bfbf4f465739","vout":1,"value":"1000000000000","height":951011,"confirmations":4964,"stake_contract":false}
]

Observation

stake_contract is always false. Added a commit to check if the scriptPubKey is a cold staking contract.

After

[
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":6,"value":"926600000000","height":952322,"confirmations":3671,"stake_contract":true},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":5,"value":"15000000000","height":952322,"confirmations":3671,"stake_contract":true},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":4,"value":"15000000000","height":952322,"confirmations":3671,"stake_contract":true},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":3,"value":"15000000000","height":952322,"confirmations":3671,"stake_contract":true},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":2,"value":"15000000000","height":952322,"confirmations":3671,"stake_contract":true},
{"txid":"f007c820fa57c651988a3efeee7c827d4d89d6dedf4805360a0af97dbdc75100","vout":1,"value":"15000000000","height":952322,"confirmations":3671,"stake_contract":true},
{"txid":"c3db984966d0e06c718a41b61e3b7cc073272149f492dab6c3d7f68bbaa35531","vout":0,"value":"24799918400","height":951969,"confirmations":4024,"stake_contract":false},
{"txid":"44ce8d86a154078ae0f628ee14fef2e0bc1cd5aa497bfd0278a7890ac27fe2bd","vout":1,"value":"15000000000","height":951171,"confirmations":4822,"stake_contract":true},
{"txid":"2e4f7a1fa1389462b328582291f4e25db03a4720ebfacf03e87dc0be670762cf","vout":1,"value":"15000000000","height":951166,"confirmations":4827,"stake_contract":true},
{"txid":"9ce3fc3949e094b7c1c11e0ab2c4ef11869e21ccf2e97d27d61211e0407da7c0","vout":1,"value":"15000000000","height":951164,"confirmations":4829,"stake_contract":true},
{"txid":"34cfd413db8074f9d9c56905d3db33b81ab172be33f0654597b8e21d437dbdcb","vout":1,"value":"15000000000","height":951159,"confirmations":4834,"stake_contract":true},
{"txid":"a2c5b17919f84b5b3c07280098bfe33cdf2ac3aeb00f5614c6473d81c68c6ed2","vout":1,"value":"15000000000","height":951157,"confirmations":4836,"stake_contract":true},
{"txid":"23a7fedcada54cda32e9937cc001dc7e9167abac78ca7534e348bfbf4f465739","vout":1,"value":"1000000000000","height":951011,"confirmations":4982,"stake_contract":true}
]

Tested the frontend /tx/<txid>

Before

The stake contract is displayed as Unparsed address
Before

After

The stake contract is displayed as Cold Staking Contract
After

@DeanSparrow DeanSparrow merged commit 90af96e into DeanSparrow:main Nov 27, 2022
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.

bug: Cold Staking outputs invisible to /v2/utxo/ API
2 participants