Questions tagged [opcodes]
The opcodes tag has no usage guidance.
57
questions
0
votes
1
answer
84
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
85
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
565
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
137
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
222
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 ...
1
vote
0
answers
22
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
64
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 ...
1
vote
1
answer
83
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 ...
3
votes
3
answers
514
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.
1
vote
1
answer
91
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
267
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
113
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 ...
1
vote
1
answer
159
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
189
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
275
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
110
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 ...
0
votes
1
answer
100
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
210
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
405
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
210
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/...
7
votes
2
answers
540
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
254
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
145
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 ...
0
votes
1
answer
128
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
141
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
836
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
165
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
203
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
...
1
vote
1
answer
205
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
346
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).
...
6
votes
1
answer
624
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
63
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
406
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
96
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
85
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
146
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
75
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
46
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 ...
3
votes
0
answers
173
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
157
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 (...
2
votes
2
answers
286
views
Given OP_VER was never used, is disabled and not considered useful can its meaning be stripped and it be made OP_SUCCESS?
Given OP_VER (0x62) was never used onchain, is disabled and is not considered useful can its meaning be stripped and it be made OP_SUCCESS for the purposes of introducing a new different opcode in ...
2
votes
2
answers
135
views
OP_LSHIFT & OP_RSHIFT purpose & functionality
What is the purpose & functionalities of the LSHIFT & RSHIFT Script OP codes ?
1
vote
1
answer
137
views
Bitcoin script verification fails after certain time period
So I want to write a bitcoin script so that after a certain time period (say for example after 30 mins), the verification fails and transaction is marked invalid even if it gets broadcasted. Time ...
0
votes
2
answers
318
views
Creating a custom transactions
I am currently learning how to create raw transactions. I can already create standard using bitcoin core (0.19.1), but when I wanted to create with custom opcode like this:
asm: OP_HASH160 ...
4
votes
2
answers
955
views
What is the purpose of OP_DROP
From what I can tell OP_DROP is a method of storing non validation data in a tx (separate from using data after OP_RETURN).
However in this unlocking script described by bip199, the timeout block and ...
7
votes
2
answers
1k
views
OP_HASH160 vs OP_SHA256
Why would I use OP_HASH160 over OP_SHA256 and vice versa? Why are there two options? In what situations should I use one over the other?
Example unlocking scripts:
From BIP199: ( where HASHOP could ...
4
votes
1
answer
3k
views
How does OP_CHECKSIG work
Hi I am learning bitcoin and learning how scripting works and how to use P2PKH. I was wondering how does OP_CHECKSIG work. I want to understand what is the data that the private key signs to create ...
3
votes
2
answers
553
views
How to calculate P2WSH signatures with OP_CODESEPARATOR?
I read the bip143, but didn't understand how to calculate the scriptCode of p2wsh.
bip143 told us:
A new transaction digest algorithm is defined, but only applicable to sigops in version 0 witness ...
11
votes
1
answer
570
views
Did the introduction of VerifyScript cause a backwards incompatible change to consensus?
My question is about the changes to bitcoin done by commit range [a75560d8, 6ff5f718], and their effect on consensus.
Out of this range of four commits (all attributed to satoshi) during the dates ...