Questions tagged [opcodes]
The opcodes tag has no usage guidance.
66
questions
1
vote
1
answer
118
views
What is the OP_CAT proposal?
What does the proposed OP_CAT opcode do? What is the history of the OP_CAT opcode?
1
vote
1
answer
70
views
Does a OP_CHECKSIGADD and OP_EQUAL script for a threshold signature fail if you provide too many valid signatures in the unlocking script?
For this CHECKSIGADD script for a 2-of-3 multisig:
<pk1> OP_CHECKSIG <pk2> OP_CHECKSIGADD <pk3> OP_CHECKSIGADD OP_2 OP_EQUAL
What happens if you provide more than the 2 required ...
0
votes
1
answer
50
views
Make signed transaction invalid after specified time
Is it possible to construct a valid signed transaction that will become invalid if it hasn't been included in a block before a specified height? Is there any opcode or other way to accomplish this?
...
1
vote
1
answer
37
views
What did the opcode 0xba do prior to creation of OP_CHECKSIGADD?
From BIP0342:
The opcode 186 (0xba) is named as OP_CHECKSIGADD.
What did 0xba do prior to this?
1
vote
1
answer
189
views
How is tapscript different than P2PKH using opcodes from a developer perspective?
I'm going to use ordinals as an example because they illustrate my question the most effectively. My understanding is that ordinals are created by writing opcodes into the transaction just like you ...
1
vote
1
answer
79
views
Is there any way for a script to depend on blockchain info?
The locktime opcodes OP_CHECKLOCKTIMEVERIFYand OP_CHECKSEQUENCEVERIFY indirectly allow for an approximate block number check, is there any way to obtain other information such as the previously mined ...
2
votes
1
answer
154
views
If no push opcode, how does item still end up on stack (tx verification)
I was reading the following link and there it says: "Alice’s pubkey script then pushes the pubkey hash that Bob gave her for the first transaction". I mean how ? there's no opcode for that. ...
2
votes
1
answer
196
views
Can OP_DROP be used to include arbitrary data?
I have recently been looking into OP_RETURN and its uses in so far as including data in a transaction. Given the fact that OP_RETURN is limited to 80 bytes I thought what if OP_DROP was used? That way ...
2
votes
1
answer
286
views
What was the OP_IF opcode used for (except Lightning) before 2023?
There is the OP_IF opcode in Script. What did users use the OP_IF opcode for (use cases except for Lightning) before 2023? What tools to use to extract the transactions (with OP_IF) from historical ...
0
votes
1
answer
124
views
What is an "empty vector" in Bitcoin?
EDIT: Pieter Wuille gave an answer (look at the comments) to the last situation (with OP_CHECKSIG). OP_CHECKSIG is pushing 0x00.
E.g. OP_0 pushes the empty vector, which represents the number 0 (to
...
1
vote
1
answer
146
views
Is the signature check performed when the signature is the empty vector?
In this answer Vojtěch Strnad wrote the following:
OP_CHECKSIGADD always performs one check per signature, since unused
public keys are required to be paired with an empty witness item and
are ...
3
votes
2
answers
614
views
Undefined opcodes in bitcoin core defined as "Synonyms for OP_RETURN" in rust-bitcoin
In rust-bitcoin, opcodes past the 0xba opcode are named as such: OP_RETURN_187, OP_RETURN_188, ..., OP_RETURN_254. Their description is all the same: Synonym for OP_RETURN. The definition for ...
2
votes
1
answer
171
views
Is OP_CODESEPARATOR disabled in Bitcoin and if so why?
OP_CODESEPARATOR is used in the Bitcoin script language to mark the beginning of signature-checked data. However, the given operator never found its real practical use case. So, is the given operator ...
8
votes
1
answer
436
views
Why are OP_MUL and OP_DIV disabled in Bitcoin?
What is the reason why OP_MUL and OP_DIV operators were removed from Bitcoin? Is this because someone could maliciously create a script that multiplies large numbers and thus blows the stack, or is ...
2
votes
0
answers
37
views
Scripting an escrow transaction where the arbitrator ALWAYS gets paid
I am trying to make an Escrow and Arbitration where the arbitrator always gets paid say 5% of the transaction.
As in the famous escrow example here:
Charlie-the-customer wants to buy a product from ...
2
votes
1
answer
72
views
Is it possible to create an output locked to a specific mining difficulty target?
When the network sees a block appear with enough difficulty nodes can detect this as potentially the longest valid chain allowing the blocks miner to officially claim the block reward via coinbase ...
2
votes
1
answer
147
views
Bitcoin Script Puzzle
I found this script puzzle post by ValentinoZ:
https://twitter.com/vazertuche/status/1691814230129848473
I've tried solving it and can't seem to get it. I get stuck at the op_equalverify for the hash ...
4
votes
3
answers
776
views
What are MATT opcodes?
There is plenty of discussion in the Bitcoin-dev mailing list about MATT opcodes, and I would like to know what these are.
2
votes
1
answer
248
views
How do I use python-bitcoin-utils to add an OP_RETURN message into a bitcoin transaction?
I have the following code that successfully created a bitcoin transaction with python-bitcoin-utils:
from bitcoinutils.utils import to_satoshis
from bitcoinutils.setup import setup
from bitcoinutils....
1
vote
2
answers
335
views
What are the OP codes associated with bc1?
As the title says I'm trying to extract bc1 addresses by using opcodes I've found from reading about bitcoin online. However, I cannot actually find the opcodes associated with bc1. The segwit outputs ...
2
votes
1
answer
158
views
How come an `OP_3` P2SH redeem script is spendable?
I completed a round trip transaction with the redeem script hash: 31vFvEkyAb2iusbPip36H9rVt6pxExuaVR, whose redeem script is OP_3 (0x53) (yes I know not secure).
I can understand OP_1 redeem script ...
2
votes
1
answer
277
views
Can any Script opcode be used in the witness program, or only specific ones?
I was wondering, can one use an OP_RETURN in the witness script? If not, why not? Also, how could I figure this out from reading Bitcoin Core source? I looked at this file, and it wasn't quite clear ...
2
votes
2
answers
214
views
What are the risks of OP_VAULT?
In the past it has been argued that some covenant schemes could be risky. However AFAIK OP_VAULT is a very specific and limited construction.
What are the risks associated with it, if any?
2
votes
3
answers
330
views
A question about the role of OP_DUP in the P2PK(H) transaction specification, and possibility of slightly smaller single address transactions
Original Thread: Why OP_DUP instead of providing the PubKey twice in P2PKH?
I am struggling to understand the logic in the most popular answer and my "reputation" is < 50 so I cannot ...
2
votes
1
answer
131
views
What is OP_RETURN_252?
The first scriptsig opcode in this coinbase transaction is OP_RETURN_252, followed a bit later by a OP_RETURN_188.
These don't show in this list of opcodes.
Digging the internet, I found this rust lib ...
1
vote
1
answer
137
views
Why is there a OP_NUMEQUAL opcode? Does OP_NUMEQUAL offer a subset of the functionality of OP_EQUAL?
There is a OP_EQUAL opcode that returns (from the Bitcoin wiki):
1 if the inputs are exactly equal, 0 otherwise
And a OP_NUMEQUAL opcode that returns:
1 if the numbers are equal, 0 otherwise
In ...
0
votes
1
answer
320
views
How does the CHECKSIGADD opcode work? How does it compare to its predecessor CHECKMULTISIG?
How does the CHECKSIGADD opcode (defined in the Tapscript BIP) BIP342 work? How does it compare to its predecessor CHECKMULTISIG?
The design of CHECKSIGADD was discussed in this StackExchange question....
4
votes
2
answers
435
views
Why do invalid signatures in OP_CHECKSIGADD not push to the stack?
I've been working through the static test vectors provided by bitcoin core to implement an interpreter.
Some surprising behavior I found was that in the case of OP_CHECKSIGADD, if an invalid signature ...
2
votes
1
answer
254
views
Why does `OP_CHECKSIGADD` allow TAPROOT keyspends?
My understanding is this sig version is only for taproot keyspends, why is it allowed to be used in OP_CHECKSIGADD?
https://github.com/bitcoin/bitcoin/blob/e826b22da252e0599c61d21c98ff89f366b3120f/src/...
8
votes
2
answers
603
views
Was the addition of OP_NOP codes in Bitcoin 0.3.6 a hard or soft fork?
I'm doing some deeper research into historical consensus changes and it seems like most folks consider the addition of the OP_NOP codes to be a hard fork. Here's the diff for their addition: https://...
4
votes
1
answer
275
views
Why isn't `OP_CHECKMULTISIG` compatible with batch verification of schnorr signatures?
BIP342 defines OP_CHECKSIGADD as a replacement for OP_CHECKMULTISIG. In the footnote it's mentioned that OP_CHECKMULTISIG is not compatible with batch verification, but I can't understand why and I ...
1
vote
2
answers
176
views
Why does this not return TRUE?
scriptSig: <pubKey>
scriptPubKey: <pubKey> OP_EQUALVERIFY
The stack has <pubKey>, <pubKey> and then OP_EQUALVERIFY. So why, does it not return TRUE, even when the recent two ...
1
vote
1
answer
169
views
Is it possible to design a recursive covenant opcode that results in a full node stuck in an infinite verification loop?
Is it possible to design a new opcode enabling recursive covenants that could result in a full node stuck in an infinite loop of verifying transactions? (Obviously this would never be considered for a ...
0
votes
1
answer
157
views
Why is OP_XOR disabled? Are there any forks on which it has been enabled? [duplicate]
Why is OP_XOR disabled?
Are there any forks on which it has been enabled?
Are there any plans to enable it?
Perhaps this is the answer, still perhaps there is another reason for the bitwise logic ...
2
votes
1
answer
1k
views
How to check OP_CHECKLOCKTIMEVERIFY?
I try to simply get into the OP_CHECKLOCKTIMEVERIFY opcode and test it. However I get the error
error: Locktime requirement not satisfied
no matter what unix- or blocktime I enter in my btcdeb. I ...
2
votes
1
answer
196
views
Meaning of "Drop the signature" comments in OP_CHECKSIG code (Bitcoin v0.1.0)
I'm doing my homework by reading the C++ code of the 0.1.0 release of Bitcoin available here. I'm interested in better understanding how to validate transaction 1 of block 170. This transaction has ...
2
votes
2
answers
243
views
Elements (/Liquid) Tapscript opcodes
Related question: What opcodes are supported on Liquid but not yet on Bitcoin?
I had seen few opcodes in the slides shared by notgrubles on Twitter. They are:
OP_INSPECTCURRENTINPUT
OP_INSPECTINPUT
...
2
votes
1
answer
269
views
What opcodes are supported on Liquid but not yet on Bitcoin?
What opcodes are supported in Liquid as of today (September 2021) but not (yet) on Bitcoin? What is the rationale for including these particular opcodes but not others?
2
votes
1
answer
388
views
What prevents OP_SUCCESS from being used nefariously?
If a script is automatically valid when an OP_SUCCESS opcode is called, what mechanism prevents a malicious actor from taking a random UTXO and creating a fake scriptsig with an OP_SUCCESS included?
8
votes
2
answers
1k
views
What are the downsides to enabling potentially suboptimal or unused opcodes in a future soft fork?
It appears to me that there are various ways to build covenants and vaults with opcodes and sighash flags that are not yet enabled in Bitcoin (e.g. OP_CHECKTEMPLATEVERIFY, SIGHASH_ANYPREVOUT, OP_CAT).
...
7
votes
1
answer
886
views
Inner working of OP_IF and OP_ELSE
How does OP_ELSE work exactly? Is there an else if in Script?
According to https://en.bitcoin.it/wiki/Script#Flow_control, the statements after an OP_ELSE are executed in three cases. It says:
If ...
1
vote
1
answer
73
views
Script: How to check if the top item on the main stack is numeric or not?
I'm looking for the clearest way to check whether the top element of the stack is numeric or not.
Thank you in advance
2
votes
1
answer
707
views
Is there a difference between OP_PUSHBYTES and OP_PUSHDATA
In some documentation about Script we sometimes have to use OP_PUSHBYTESx or OP_PUSHDATAx to indicate that some number of bytes will be an element to read.
They seem to do the same thing so is there a ...
2
votes
1
answer
132
views
In what year and in which Bitcoin improvement proposal Opcodes such as OP_MODE have been disabled?
On Bitcoin wiki several opcodes are listed as "disabled".
My question is simple: which Bitcoin improvement proposal proposed to disable them, and when they have effectively been disabled in ...
0
votes
1
answer
98
views
The bitcoin opcode seems to have a flat rate
The bitcoin opcode seems to have a flat rate, is that correct?
Or, if bitcoin has a price per opcode, please give me the link.
If it is a flat rate, please tell me why bitcoin does not have a ...
2
votes
1
answer
169
views
Are P2SH transactions with disabled opcodes relayed/mined?
Many OPCODES like OP_AND, OP_CAT, OP_SUBSTR are disabled as described in https://en.bitcoin.it/wiki/Script. Although, with Bitcoin Core 0.10.0 Gavin Andresen proposed "any Script" in P2SH ...
2
votes
1
answer
78
views
How is a locking script reliably detected as a P2PKH script?
I've taken this example from a p2pkh guide:
1976a9145fb0e9755a3424efd2ba0587d20b1e98ee29814a88ac
This is broken down into:
19 - byte length of the following unlocking script
76 - OP_DUP: Duplicates ...
1
vote
0
answers
50
views
Why does printing a scriptPubKey have an extra OP_PUSHBYTES_20? [duplicate]
I am building a P2PKH script pubkey in code, and the standard format is:
OP_DUP OP_HASH160 <PUBKEYHASH> OP_EQUALVERIFY OP_CHECKSIG
However, when I print it (I'm using the bitcoin Rust crate) it ...
4
votes
1
answer
248
views
Which opcodes where disabled by Satoshi Nakamoto for cve 2010 5137
Lot of opcodes where disabled over the years.
But which opcodes where disabled Satoshi himself and specifically for the any one can spend any coin bug?
1
vote
1
answer
163
views
Could CHECKSIGADD be used on new ECDSA multisignatures instead of CHECKMULTISIG?
The proposed Taproot soft fork (BIP 342) defines the new opcode OP_CHECKSIGADD to verify Schnorr multisignatures whilst OP_CHECKMULTISIG (and OP_CHECKMULTISIGVERIFY) are disabled for Taproot spends (...