Questions tagged [script]

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

Script is used to define how funds may be spent. A script consists of two parts. In a transaction output funds are assigned to a locking script, the scriptPubKey. The corresponding transaction input provides a method for initializing a stack as input to the scriptPubKey, the scriptSig. In segwit output types, the witness encodes the stack directly. The set of commands in Script are referred to as "opcodes".

There are a number of standard scripts and scripts which are defined by an address. These include Pay-to-Public-Key-Hash, Pay-to-Script-Hash, Pay-to-Witness-Public-key-hash, and Pay-to-Witness-Script-Hash.

This tag should be used for questions regarding scripts and opcodes used in transactions.

603 questions
64
votes
4 answers

Explanation of what an OP_RETURN transaction looks like

How is OP_RETURN used and why was it introduced in the first place?
almel
  • 2,376
  • 1
  • 17
  • 17
61
votes
6 answers

What is relation between scriptSig and scriptPubKey?

Scenario: A is sending 1 BTC to B. scriptSig appears in the Input Script. scriptSig = Here, public key is the Public Key of the sender, A. (this is the public key corresponding to his Bitcoin Address which has some unspent…
Neon Flash
  • 1,033
  • 2
  • 10
  • 10
25
votes
2 answers

Useful alternative Bitcoin transaction scripts

The Bitcoin wiki describes a transaction's script as something that describes "how the next person wanting to spend the Bitcoins being transferred can gain access to them". The script for "a typical Bitcoin transfer to destination Bitcoin address D"…
Ash Moran
  • 849
  • 8
  • 10
25
votes
2 answers

History behind the scripting language in Bitcoin?

What is the history of the current existing scripting language in Bitcoin? Satoshi's original whitepaper on Bitcoin makes no mention of a stack based scripting language. So who was the first person to propose this idea and implement it? And why did…
k kurokawa
  • 2,072
  • 14
  • 28
24
votes
1 answer

How do Scripts work?

Bitcoin protocol supports scripts. How do they work? How are those implemented? What are their intended usages? When are they planned to be used?
ripper234
  • 26,452
  • 30
  • 111
  • 246
23
votes
10 answers

Online Bitcoin Script simulator or debugger?

Is there an online simulator that would allow me to step through, debug, or simulate the execution of a Bitcoin script?
Geremia
  • 4,469
  • 4
  • 37
  • 75
23
votes
1 answer

How do "Pay to Script Hash" transactions work?

BIP16 gives the following example to explain "Pay to Script Hash": scriptSig: [signature] {[pubkey] OP_CHECKSIG} scriptPubKey: OP_HASH160 [20-byte-hash of {[pubkey] OP_CHECKSIG} ] OP_EQUAL But I don't get what's happening here. I've tried…
jnnk
  • 1,906
  • 15
  • 23
19
votes
3 answers

Will general non-standard transactions ever be allowed?

To the best of my knowledge, currently "Satoshi" client relays and most pools accept only standard (transfer or generation) transactions. Besides, community is working on M-of-N transaction type. Adding non-standard transaction to the blockchain is…
aland
  • 1,388
  • 8
  • 18
17
votes
2 answers

How to create a transaction with a custom script?

Is there a step-by-step tutorial or any documentation covering how to create a transaction that is not a standard OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG? It seems very odd that there is absolutely no documentation or information…
bvpx
  • 1,132
  • 7
  • 28
16
votes
2 answers

What is "Script Hash" address exactly and how does it work?

I found out this address playing with blockchain https://blockchain.info/address/3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8 I found out it's something called "scripthash". How does it work exactly? How does it differ from a normal address? I found out this…
Karel Bílek
  • 2,655
  • 3
  • 24
  • 45
16
votes
3 answers

What does Bitcoin policy language offer the developer that Miniscript doesn't? What is the difference between Bitcoin policy language and Miniscript?

I understand that policy language compiles to Miniscript and Miniscript is encoded (correction) to Bitcoin Script. This is also a great resource on Miniscript: http://bitcoin.sipa.be/miniscript/ But I know very little about policy language and there…
Michael Folkson
  • 14,337
  • 3
  • 11
  • 45
16
votes
2 answers

Transaction with slightly changed script is never relayed

I am playing with bitcoin transaction a bit now. I have a question. Normally, the output script looks like OP_DUP OP_HASH160 (hash) OP_EQUALVERIFY OP_CHECKSIG Now that is understandable. However, when I slightly change the script with an outgoing…
Karel Bílek
  • 2,655
  • 3
  • 24
  • 45
16
votes
3 answers

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 Turing-complete? Bitcoin uses a scripting system for…
Giulio Prisco
  • 377
  • 2
  • 12
16
votes
1 answer

What prior work influenced the design of the Bitcoin instruction set?

The "Script" system used by Bitcoin transactions is commonly described as a Forth-like, stack-based language. What prior work influenced the design and layout of the Script instruction set? There may have been a research paper or essay about a…
14
votes
2 answers

Is sha-1 used in Bitcoin?

The Bitcoin scripting language has OP_SHA1 as one of its opcodes. However, I'm not able to find any usage of this opcode (it is not used in any standard scripts nor in any other procedures such as block hashing). So my question is: is sha-1 used…
cpsola
  • 1,588
  • 10
  • 25
1
2 3
40 41