-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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_TXHASH and OP_CHECKTXHASHVERIFY opcodes #2078
Open
sputn1ck
wants to merge
7
commits into
btcsuite:master
Choose a base branch
from
sputn1ck:op_txhash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit adds the TxFieldSelector type which is used to generate TxHash values for the OP_TXHASH and OP_CHECKTXHASHVERIFY opcodes.
sputn1ck
force-pushed
the
op_txhash
branch
2 times, most recently
from
December 24, 2023 12:41
55242a4
to
1b6ba7e
Compare
This commit adds two new opcodes, OP_TXHASH and OP_CHECKTXHASHVERIFY. These opcodes replace the OP_NOP4 and OP_UNKNOWN189 opcodes that were previously reserved for future use.
This commit adds a simple example of how to use the new OP_CHECKTXHASHVERIFY opcode added in the previous commit. The example shows how to create a transaction that is restricted to spend to two specific outputs.
This commit removes the NOP4 stuff from the script_tests.json file in order for the test to succeed. This commit will be changed to reflect expected OP_TXHASH changes.
Pull Request Test Coverage Report for Build 7314655737
💛 - Coveralls |
halseth
reviewed
Jan 4, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the implementation :)
// should be hashed into the TxHash. | ||
TXFSControl uint8 = 1 << 7 | ||
|
||
// TXFSAll is the bit that indicates that all fields should be hashed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/bit/byte
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementation of OP_TXHASH and OP_CHECKTXHASHVERIFY, as per bitcoin/bips#1500.
I mainly did this to learn about the BIP, maybe others might find this interesting and useful.
The code passes all testvectors specified in the BIP, I also added an example of restricting a transaction to be only spent to specified outputs.
I also added a rudimentary cache with a benchmark.