Questions tagged [opcodes]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1 vote
2 answers
198 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
62 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 ...
  • 63
1 vote
1 answer
72 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 ...
  • 173
2 votes
3 answers
233 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 ...
  • 172
0 votes
1 answer
48 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 ...
  • 127
0 votes
1 answer
60 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
105 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
372 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
134 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
453 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://...
0 votes
0 answers
45 views

Is it possible to do OP_MOD with OP_GREATERTHAN and a few other opcodes?

Currently OP MOD is considered nonstandard in the Bitcoin protocol, but we can for example combine OP SHA1 and OP GREATERTHAN to gain a similar effect. https://www.cs.technion.ac.il/~idddo/...
4 votes
1 answer
235 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
112 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
91 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
119 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 ...
  • 356
2 votes
1 answer
582 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 ...
  • 323
2 votes
1 answer
130 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
166 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 ...
user avatar
1 vote
1 answer
158 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
314 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). ...
4 votes
1 answer
414 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 ...
  • 73
1 vote
1 answer
56 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
  • 41
2 votes
1 answer
258 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,550
2 votes
1 answer
91 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 ...
  • 41
0 votes
1 answer
72 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
128 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 ...
  • 362
2 votes
1 answer
69 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
41 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 ...
  • 167
2 votes
0 answers
125 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
145 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
234 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
115 views

OP_LSHIFT & OP_RSHIFT purpose & functionality

What is the purpose & functionalities of the LSHIFT & RSHIFT Script OP codes ?
1 vote
1 answer
123 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
282 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 ...
  • 69
4 votes
2 answers
794 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 ...
  • 1,588
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 ...
  • 1,588
3 votes
2 answers
492 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 ...
  • 31
11 votes
1 answer
543 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 ...
  • 1,824
2 votes
1 answer
923 views

How to create a p2sh transaction with a scriptsig of OP_true?

How can I create a p2sh transaction with a scriptsig containing OP_TRUE only, removing the need for a digital signature, which will be broadcasted and mined? Also could some one provide an example of ...
  • 117
2 votes
2 answers
3k views

List of current opcodes?

Anyone know how / where to run enum optypecode (or some other method) to get a list of current opcodes? Like this result... https://www.slideshare.net/gvrooyen/20140220-bitcoin/34-...
12 votes
1 answer
729 views

Why is OP_SUBSTR disabled? (and OP_LEFT, OP_RIGHT)

Why are the substring opcodes disabled? I understand that OP_CAT is disabled because it can blow up the stack easily (in combination with OP_DUP). But the substring opcodes reduce the stack size. ...
  • 133
12 votes
3 answers
3k views

Why is OP_CHECKLOCKTIMEVERIFY disabled by maximum sequence number?

In the code for OP_CHECKLOCKTIMEVERIFY i noticed that if the txin sequence number is maxxed out then the script will fail to validate. I'm wondering what the point of this is? Why would anybody ever ...
  • 1,703
2 votes
1 answer
554 views

Script. OP_PICK/OP_ROLL

OP_PICK should take the nth element from the back of the stack and take it on top: for input xn ... x2 x1 x0 gives xn ... x2 x1 x0 xn I have used it in some scripts, but I've noticed some strange ...
  • 1,408
2 votes
1 answer
192 views

Can someone explain this [outdated] BIP12 OP_EVAL exploit?

I understand that BIP12 was withdrawn, and probably because of this exploit below. Can someone explain how this attack would have worked and the effect it would have on the network? for (;;) { ...
8 votes
1 answer
791 views

What is op_eval?

I have been hearing a lot lately about "OP_EVAL", what is it? Gavin has mentioned it here: http://sourceforge.net/mailarchive/forum.php?thread_name=201110130938.35014.luke%40dashjr.org&...
  • 3,171