Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [script]

This tag should be used for questions regarding Bitcoin transaction scripts or scripting languages used in transactions of altcoins such as Solidity. Scripts are a set of instructions on how to complete a transaction.

Filter by
Sorted by
Tagged with
48
votes
2answers
24k views

Explanation of what an OP_RETURN transaction looks like

How is OP_RETURN used and why was it introduced in the first place?
47
votes
5answers
16k views

What is relation between scriptSig and scriptPubKey?

Scenario: A is sending 1 BTC to B. scriptSig appears in the Input Script. scriptSig = <sig> <pubKey> Here, public key is the Public Key of the sender, A. (this is the public key ...
24
votes
2answers
4k views

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 ...
22
votes
1answer
5k views

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 ...
21
votes
2answers
2k views

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 ...
20
votes
1answer
4k views

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?
17
votes
3answers
2k views

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. ...
16
votes
2answers
1k views

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, ...
15
votes
7answers
5k views

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?
15
votes
2answers
2k views

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 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG? It seems very odd ...
14
votes
3answers
4k 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 ...
13
votes
2answers
12k views

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 ...
12
votes
2answers
2k views

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 ...
12
votes
3answers
587 views

Tx Malleability: Why is the Script not included in the Signed Hash?

Sipa lists sources of tx malleability here: https://gist.github.com/sipa/8907691 It is clear to me how a change in the signature itself or the signature formating leads to a different tx hash (1. &...
10
votes
3answers
6k views

parsing bitcoin input and output addresses from scripts

can someone walk me through the process of combining script inputs and outputs to reveal the base58 encoded input and output addresses. take for example, block 728. this has two raw script inputs: ...
10
votes
1answer
1k views

Turing completeness of Bitcoin Script

For me, scripts are one of the most interesting features of Bitcoin. They provide possibilities which have no equivalent in classical currencies. However, the wiki states It is purposefully not ...
10
votes
3answers
781 views

Why is Script needed?

As I see it, the script feature is one of the most complicated features in the entire protocol. It features $ cat src/script.h|grep '^ *OP_'|wc -l 118 instructions, and requires a stack to ...
10
votes
2answers
3k views

How vulnerable is bitcoin to quantum algorithms? [duplicate]

Assuming that quantum computers are implemented some time in the near-ish future, how vulnerable is Bitcoin to decryption via quantum algorithms? For example, Shor's algorithm enables a quantum ...
10
votes
2answers
2k views

How to get addresses from scriptPubKey in segwit transactions?

I'm running through raw transaction data, and I'd like to be able to gather addresses (where possible). So far, I've made this diagram to help me understand when it's possible to figure out addresses ...
9
votes
1answer
3k views

Why does the default miner implementation use pay-to-pubkey?

Looking at the v0.9.3 source in miner.cpp: CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) { CPubKey pubkey; if (!reservekey.GetReservedKey(pubkey)) return NULL; ...
9
votes
2answers
278 views

Why does script need to be purged from transactions for mimblewimble to work?

What is the compatibility problem between script and mimblewimble usage on the main chain? Is there a way that Bitcoin can adapt to allow both mimblewimble and features like multi sig, atomic swaps ...
9
votes
2answers
2k views

How does ScriptPubKey know the public key of an Bitcoin address?

I am currently having a blonde moment. The ScriptPubKey provides a hashed version of the receivers public key. scriptPubKey OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG However, if I give ...
9
votes
1answer
1k views

How is a “standard” Bitcoin transaction defined?

This is useful in Andreas Antonopoulos' book, Mastering Bitcoin: https://github.com/bitcoinbook/bitcoinbook/blob/7c552ea5cfbc19448635b36407761b377ff5cbe9/ch05.asciidoc#standard-transactions "In the ...
9
votes
1answer
3k views

How is the Output script formed?

I read about Input and output scripts on the wiki here: https://en.bitcoin.it/wiki/Transactions Let's say, I use my Bitcoin - QT Program, I go to "Send Coins" tab, enter a Bitcoin Address, BTC ...
9
votes
1answer
3k views

How would I hand code a Bitcoin transaction

Form the Bitcoin Wiki - Transactions I see a transaction has the following format. Input: Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6 Index: 0 scriptSig: ...
9
votes
1answer
116 views

Can we construct a UTXO which is spendable only via proof of work?

Do the current Bitcoin opcodes and transaction size limit allow constructing a UTXO which is only spendable if a specified amount of work has been performed? So the spender, would provide a nonce as ...
8
votes
3answers
1k views

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 compiles to Bitcoin Script. This is also a great resource on Miniscript: http://bitcoin.sipa.be/miniscript/ But I know very ...
8
votes
2answers
2k views

Is there a maximum size of a scriptSig/scriptPubKey?

Previous research: Transaction's maximum size What is the maximum size of a transaction? The maximum size of a standard transaction is 100k bytes. Are there any consensus rules that prohibit ...
8
votes
1answer
1k views

What is the alt stack?

I noticed in the bitcoin wiki script page (https://en.bitcoin.it/wiki/Script) that there were two opcodes named: OP_TOALTSTACK OP_FROMALTSTACK It looks like there is another stack that can be used ...
8
votes
1answer
6k views

How is a Transaction ID generated & when does it change? (with a new sequence ID?)

I'm creating a non-mainstream client that processes and validates Bitcoin transactions and need to track transactions in my database. How is the TxID generated and when does it change? ...
8
votes
2answers
1k views

What is OP_CODESEPARATOR used for?

Looking at the bitcoin source (https://github.com/bitcoin/bitcoin/blob/v0.9.3/src/script.cpp#L843-L847, specifically), I ran into the the use of the OP_CODESEPARATOR. Am I right in interpreting this ...
8
votes
3answers
967 views

Is there a listing of strange or unusual scripts found in transactions?

I'm studying scripts and am looking for strange or unusual scripts that have appeared in any of the *coin networks..(outside the standard ones listed on this page) Is any one person, or website ...
7
votes
3answers
3k views

Can I send message inside the transactions script?

I would like to send transactions with messages as described in the wiki. In Transaction with slightly changed script is never relayed, someone answered that non-standard transactions are not relaid ...
7
votes
3answers
2k 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 ...
7
votes
1answer
1k views

Script - OP_IF etc. clarifications

Description of the OP IF is a bit vague on the wiki. Where does one get statements for the op for? Are they coming from the stack, or from somewhere else? Are there any available examples of how a ...
7
votes
4answers
6k views

How do you get the OP_HASH160 value from a bitcoin address?

I'm trying to sign a coinbase transaction. I know I need to use 76 A9 14 (HASH160) 88 AC but I don't understand how to create the HASH160 (20 byte) from a bitcoin address.
7
votes
2answers
2k views

Different error messages under “Mandatory script verify flag failed.”

I've been playing with raw transactions and signed transaction and I've noticed that the error "Mandatory script verify flag failed" comes in two variations. script failed on OP_EQUALVERIFY OP Script ...
7
votes
1answer
208 views

What's the use of not relaying non-standard transactions if anyone can still use them using P2SH?

It seems that non-standard transactions are not normally relayed because there is a concern this might break the network or it might make future upgrades harder. But anyone can use these non-standard ...
7
votes
1answer
322 views

How does a recipient know they can satisfy the transaction script to spend their bitcoins?

The wiki page on the transaction script says: The party who originally sent the Bitcoins now being spent, dictates the script operations that will occur last in order to release them for use in ...
7
votes
2answers
401 views

PUSHDATA4 unnecessary?

Any data push greater than 520 bytes in a Bitcoin transaction is not allowed (https://github.com/bitcoin/bitcoin/blob/v0.10.0rc3/src/script/script.h#L18). The opcode OP_PUSHDATA4 specifies, that the ...
7
votes
1answer
514 views

Does OP_HASH160 consume the top stack element?

In a standard P2PKH configuration, the scripts look like: Pubkey script: OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG Signature script: <sig> <pubkey> When redeeming ...
7
votes
2answers
2k views

What is the format of coinbase input scripts?

The input script of the coinbase transaction of block number 1 (right after the genesis block) looks like this: 04ffff001d010b How do I recognize this as a coinbase transaction? Do I simply know ...
7
votes
1answer
3k views

Bitcoin script example

Is there some good example on how to process a basic tx's scriptsig and get the recipient's address from the raw transaction?
7
votes
1answer
390 views

Which release fixed CVE-2010-5141 (attacker can spend any coin)

This post by Mike Hearn relates an interesting bit of history: When Bitcoin was first released, it contained two completely fatal bugs that made the entire system worthless. Fortunately, they were ...
7
votes
3answers
5k views

How to know if a transaction is valid?

I understand there are a couple things that need to be checked for a transaction to be valid - the previous transaction had to be correct, no OP can invalidate the transaction, etc, but is there a ...
6
votes
2answers
558 views

Which bitcoin script forms should be detected when tracking wallet balance?

I am implementing a library for tracking wallet balance of given bitcoin addresses. How should the transaction output script be parsed to find if the output belongs to the given address? Is it dirty ...
6
votes
2answers
2k views

How OP_EQUALVERIFY works in a standard transaction?

3 weeks ago I began learning about Bitcoins, and now I'm analyzing how it works internally. My problem is that I can't understand what two public key hashes are compare to use de OP_EQUALVERIFY, ...
6
votes
1answer
327 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. ...
6
votes
3answers
1k views

Can I use single address for all my transactions?

Can I always use single public key (addr1) for all my transactions and when I spend every time protect it with different scripts / keys (key2, key3, etc.), so that spending requires at least two keys (...
6
votes
2answers
1k views

Bitcoin Script tutorial

Are there any tutorials with examples on Bitcoin Script: from basics to complex scripts?