Questions tagged [script]

A simple, stack-based, Forth-like programming language using "opcodes" to express spending conditions.

Filter by
Sorted by
Tagged with
1 vote
1 answer
63 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 ...
3 votes
2 answers
265 views

How is the clock reset in the Complex Script Example?

At the end of Mastering Bitcoin Chapter 7, in the "Complex Script Example", they ask this question in regards to the script: How do the partners "reset" the clock every 29 or 89 ...
1 vote
1 answer
890 views

How to regularly restart bitcoind after some period of time on Linux

If, like me you wish to automatically restart bitcoind after some period of time, or if it crashes at least it will restart sometime on it's own you know that it can take a long time on Linux before ...
3 votes
2 answers
572 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 ...
2 votes
1 answer
136 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. ...
-1 votes
1 answer
82 views

Callback from computation threads to root UTXO without trusted third party signature

No expert on Bitcoin. How I understand it, loops can be done by UTXO storing a hash of the code it requires to run the next iteration in, and then the next iteration creates a new UTXO and runs it ...
2 votes
1 answer
69 views

Is the Taproot script tree commitment quantum safe?

If an attacker in posession of a quantum computer can break the ECDLP, they can of course spend every Taproot output using the key path. However, do they also have the ability to construct a valid ...
6 votes
2 answers
931 views

Does createrawtransaction have the ability to create a transaction with custom scripts?

Does createrawtransaction always use the following script? scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG scriptSig: <sig> <pubKey> If so, how do you ...
4 votes
1 answer
2k views

Redeem script. script hash, witness script and witness program

I have a little confusion about naming in Bitcoin. Redeem script is the conditions that will be satisfy. For example P2PKH inside P2SH OP_DUP OP_HASH160 <PubKHash> OP_EQUALVERIFY OP_CHECKSIG ...
2 votes
1 answer
90 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
85 views

What is the point of having a script language now?

When I first started learning how transaction are validated, it made sense why a script language was needed: the scriptPubKey was executed along the scriptSig, the software just executes this "...
1 vote
3 answers
198 views

Where can I see Taproot scripts?

I am trying to look more into Taproot scripts and was wondering if someone could help me on how to access them? I was thinking of using a blockchain explorer that decodes Taproot scripts but I can't ...
1 vote
0 answers
23 views

Ways of emulating OP_CAT

I understand that it's possible to emulate concatenation for up to 32 bits by calculating: x || y = x + (y << len(x)), where the left shift (L_SHIFT) can be performed through multiple ...
1 vote
1 answer
112 views

Are there plans to make a script invalid if there is more than one element left in the stack?

In BIP62, it was proposed to make a script invalid if there was more than one element left in the stack after execution. This proposal was eventually withdrawn. From what I read, some people have ...
2 votes
1 answer
113 views

What’s going on with this "NULL address input" transaction?

I was reading this from the Bitcoin wiki (https://en.bitcoin.it/wiki/From_address). I understand the concept of UTXOs and that any input to a transaction is an output from a previous transaction. I ...
3 votes
1 answer
63 views

Do any browser wallets support custom bitcoin scripts?

I am creating an atomic swap interface between Bitcoin and EVM using hashed timelock contracts as the underlying swapping mechanism. The idea is to support atomic swaps via the browser, using browser-...
2 votes
2 answers
340 views

Simple math in Script

I want to create a script that takes 3 numbers and verifies that: Each of the numbers is less than 8. The sum of the numbers is 15. How can I do that?
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 vote
2 answers
220 views

Bitcoin library vs script to develop application

I'm curious about the development of application of Identity management in Blockchain platform, but I'm a bit confused about the technologies to use. In short words, when is more convenient to develop ...
2 votes
1 answer
266 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
638 views

Script to import multiple priv keys in Electrum

DuckDuckGo turns up nothing of interest. How to import multiple priv keys in Electrum from a file using Electrum console or shell script, for all derivable valid BTC addresses? (1,3,bc1) Eventually I ...
4 votes
1 answer
141 views

Is there a way to push the output value of a UTXO to the stack in Bitcoin script?

When defining the spending conditions for a UTXO can one use the output value in a script by pushing it to the stack?
1 vote
1 answer
981 views

How to restore redeem script from a spent transaction?

What is the procedure to restore redeem script of P2SH address from a transaction sent from that address? The script is stored on the blockchain in the tx data, the question is how to extract it?
0 votes
1 answer
45 views

How to set the output script of coinbase transaction

I found that the "getaddressinfo" command in RPC can get pubkey and scriptpubkey. My address pubkey scriptpubkey are: address='bcrt1q95h0le6kknpnjp4c29cau03gvdyxd35zug30yr' pubKey='...
2 votes
1 answer
2k views

what is the use of OP_PUSHBYTES

what is the meaning of this SCRIPTPUBKEY: OP_DUP OP_HASH160 OP_PUSHBYTES_20 xxxxx....xxxxxxxx OP_EQUALVERIFY OP_CHECKSIG in particular I searched for some documentation on OP_PUSHBYTES_X which only ...
2 votes
2 answers
102 views

What is a sane Miniscript? How does it differ to a valid Miniscript?

What is a sane Miniscript? How does it differ to a valid Miniscript? This was asked during a Bitcoin Core PR review club on Miniscript hosted by stickies-v on May 18th 2022.
1 vote
1 answer
50 views

Is it possible to use Bitcoin Script to implement a quantum-resistant locking script that would be safe to spend from?

Stewart, I., et. al. (2018). "Committing to quantum resistance: A slow defence for Bitcoin against a fast quantum computing attack" described a method by which funds could be safely moved ...
0 votes
2 answers
868 views

SegWit witness commitment merkle root location

BIP 141 defines the commitment structure here What i am unsure about is the location of this data. I know it will be in scriptPubKey. Does this mean Coinbase tx will have more than one output? Also is ...
3 votes
1 answer
54 views

How to use bitcoin multisig to prioritize one of the parties?

Normally when you use OP_CHECKMULTISIG you're basically setting up something like x-of-y, where any x of the y key holders can carry out a transaction. I want to know, if you can repurpose this ...
0 votes
1 answer
157 views

How to spend an anyone-can-spend input

I'm trying to teach myself bitcoin script, and so far I'm failing with a seemingly trivial example. I'm using the Bitcoin Test Framework, and this is what I'm doing (simplified): # p2sh address for ...
1 vote
1 answer
109 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 ...
0 votes
1 answer
102 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 ...
2 votes
1 answer
111 views

What would happen if we provide to OP_CHECKMULTISIG more than threshold number (m) of signatures?

Asked here but still no answer. What would happen if we provide to OP_CHECKMULTISIG opcode more than threshold number (m) of signatures? For example, if the m = 3 and n = 6 and the output script is: 3 ...
1 vote
1 answer
91 views

What are the all benefits/advantages of OP_CHECKSIGADD over OP_CHECKMULTISIG?

What are all the benefits of introducing OP_CHECKSIGADD in Taproot instead of OP_CHECKMULTISIG? I assume the first benefit is the following. For example, in pre-taproot approach, if we have 3-of-10 ...
1 vote
1 answer
136 views

Verifying a zkSNARK on Bitcoin/Hope for a future with OP_MUL

I am trying to write a script that can verify a SNARK, but from what I understand OP_MUL is still disabled in TapScript. Is anyone working on a BIP to provide OP_MUL or OP_MUL64? It seems ...
2 votes
1 answer
89 views

non-mandatory-script-verify-flag (Invalid Schnorr signature) when trying to reveal a TR output

I'm building a Bitcoin wallet, and I'm trying to spend a Taproot output via a script spend path, but I keep running into this "Invalid Schnorr signature" error from my RPC node: { "...
-2 votes
1 answer
49 views

Question on the integer size [closed]

Is there any kind of boolean division with bitcoin? There has to be something before the decimal number. Kind of say it seems like end to end and it always should be the number that is largest.
4 votes
1 answer
239 views

How is this transaction valid?

Transaction in question: 16ac7736552c5791cff5643e6104c76c24018236b2193e014b308efea4f32f81 The P2SH input has a strange redeem script: OP_DUP OP_HASH160 OP_PUSHBYTES_20 ...
0 votes
1 answer
132 views

processing input tx in bitcoin's block response and obtain transaction value of each input

so i was parsing the block #496 of bitcoin which contains two transactions, first tx in the list is the reward tx and the second tx contains three inputs and one output. i tried to parse each ...
2 votes
1 answer
138 views

Why is the data format for block height in coinbase scriptSigs inconsistent for heights 1-16?

BIP-34 claims that in coinbase transactions, the scriptSig should contain the block height. It says the format of this is "serialized CScript", i.e. a byte indicating the length of the ...
5 votes
2 answers
2k views

What are the scriptPubKey, scriptSig, redeem script and witness for the various output types?

scriptPubKey, redeem script, witness script, witness program are defined in this StackExchange post. What are the scriptPubKey, scriptSig, redeem script and witness for the various output types (P2PKH,...
5 votes
1 answer
213 views

Why does Miniscript add an extra size check for hash preimage comparisons?

When I input the following miniscript into https://bitcoin.sipa.be/miniscript/: and(pk(claimant_pk),sha256(H)) I get the following Script: <claimant_pk> OP_CHECKSIGVERIFY OP_SIZE <20> ...
3 votes
2 answers
581 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
112 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 ...
2 votes
2 answers
202 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
1 answer
146 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
288 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 ...
19 votes
4 answers
5k views

The Bitcoin scripting system is purposefully not Turing-complete - why?

Can somebody explain to me why the Bitcoin scripting system is purposefully not Turing-complete? To make malicious programs difficult to develop (I guess)? Or because it was difficult to make it ...
10 votes
1 answer
698 views

Full list of "special cases" during Bitcoin Script execution (p2sh, p2wsh, etc.)?

When executing a Bitcoin Script, there are some "special cases" where the interpreter performs extra verification beyond just executing scriptSig and then scriptPubKey. For example, if the ...
0 votes
1 answer
46 views

P2SH-P2WSH-P2PKH and P2SH-P2WPKH

What are the advantages and disadvantages of using P2WSH-wrapped P2PKH instead of P2WPKH? What are the advantages and disadvantages of using P2SH-wrapped P2WSH-wrapped P2PKH instead of P2SH-wrapped ...

1
2 3 4 5
13