Questions tagged [script]

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

Filter by
Sorted by
Tagged with
64 votes
4 answers
40k views

Explanation of what an OP_RETURN transaction looks like

How is OP_RETURN used and why was it introduced in the first place?
almel's user avatar
  • 2,376
16 votes
3 answers
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 is encoded (correction) to Bitcoin Script. This is also a great resource on Miniscript: http://bitcoin.sipa.be/miniscript/ But I ...
Michael Folkson's user avatar
4 votes
3 answers
1k views

Why does Bitcoin uses a Script language?

From what I heard is that Bitcoin use Script to verify transactions (I'm probably wrong). Wouldn't be sufficient just signing the transaction with the private key and append the signature to the ...
Vladislav Zhdanov's user avatar
16 votes
3 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 ...
Giulio Prisco's user avatar
9 votes
1 answer
4k 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; ...
morsecoder's user avatar
  • 13.9k
8 votes
2 answers
853 views

Bitcoin and Smart Contracts

I have recently come across the features of ethereum and the idea of smart contracts. I like the concept of smart contracts however as a currency, I much prefer the bitcoin to the ether. Is there ...
Kenshin's user avatar
  • 496
61 votes
6 answers
26k 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 ...
Neon Flash's user avatar
  • 1,033
24 votes
1 answer
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?
ripper234's user avatar
  • 26.5k
10 votes
3 answers
8k 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: ...
mulllhausen's user avatar
  • 1,713
25 votes
2 answers
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 ...
Ash Moran's user avatar
  • 849
16 votes
2 answers
19k 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 ...
Karel Bílek's user avatar
  • 2,655
11 votes
1 answer
2k 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 ...
Michael Folkson's user avatar
16 votes
2 answers
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, ...
Karel Bílek's user avatar
  • 2,655
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 ...
mulllhausen's user avatar
  • 1,713
8 votes
1 answer
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? ...
makerofthings7's user avatar
7 votes
3 answers
7k 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 ...
ThePiachu's user avatar
  • 42.9k
5 votes
2 answers
1k views

What does this transaction script mean?

I was looking for scripts on the blockchain to test my program, and I encountered a weird scriptPubKey in this tx that I couldn't understand. The opcodes are pk1 = ...
Rod Lin's user avatar
  • 130
4 votes
3 answers
4k views

What are the parts of a Bitcoin Transaction "Input" script?

All the terminologies I find seem rather confusing about what explains what and they usually miss a few steps. Example: Transaction 82d62d5f4e69ae8338c39b7ae2e1d33db59bdf62c869ded7344adc936bab8653 ...
Mine's user avatar
  • 1,416
3 votes
1 answer
390 views

scriptcode, scriptsig, pubkeyscript confusion

I've been banging my head on a desk for a few days trying to understand the segwit protocol properly. Another roadblock has thrown me off-guard and I am struggling to grasp the concept of "scriptCode:...
cryptodescriptor's user avatar
3 votes
2 answers
1k views

Non-standard transaction scripts broadcasting

I'm developing an application on Bitcoin blockchain, and I use output transaction scripts that are not standard according to the classic payment methods. However, even so, on Tesnet everything works ...
Daniel's user avatar
  • 31
2 votes
1 answer
260 views

Extract lightning network funding transactions with python bitcoin blockchain parser lib

My ultimate goal is to parse funding transactions (as well as channel closes in a later step) from the blockchain. In order to do so I wanted to start with a funding transaction and disect it. ...
Rene Pickhardt's user avatar
2 votes
2 answers
2k views

How do I extract the address from a scriptPubKey?

I am creating a block parser and just learned about Scripts in Bitcoin yesterday which is kind of confusing so far. I want to extract the addresses involved in each transaction. Right now, I am able ...
fon's user avatar
  • 77
23 votes
10 answers
8k 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?
Geremia's user avatar
  • 4,469
19 votes
3 answers
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. ...
aland's user avatar
  • 1,388
17 votes
2 answers
3k 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 ...
bvpx's user avatar
  • 1,132
12 votes
1 answer
743 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. ...
hrobeers's user avatar
  • 133
12 votes
2 answers
4k 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 ...
morsecoder's user avatar
  • 13.9k
11 votes
2 answers
3k 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 ...
inersha's user avatar
  • 2,878
10 votes
2 answers
5k views

CHECKMULTISIG a worked out example

I was wondering if somebody could point me to or give me a worked out example of how OP_CHECKMULTISIG works behind the curtains? I expect that CHECKMULTISIG will call the CHECKSIG function and ...
Bjarne Magnussen's user avatar
9 votes
4 answers
1k 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 ...
makerofthings7's user avatar
8 votes
2 answers
3k 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 ...
Jan's user avatar
  • 451
6 votes
2 answers
906 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 ...
Zouppen's user avatar
  • 217
5 votes
1 answer
1k views

How is the hash that is signed calculated?

I'm a bit confused about the signature contained in the scriptSig of a transaction. My question is: what do we really sign? Is it the hash of the previous transaction?
anapaso's user avatar
  • 783
5 votes
3 answers
561 views

Are loans with enforced repayment possible on the blockchain?

Are loans with interest possible in Bitcoin, such that repayment is enforceably encoded with Bitcoin Script on the blockchain from the establishment of the lending contract?
Geremia's user avatar
  • 4,469
5 votes
1 answer
349 views

ScriptSig content during signature (quadratic hashing)

As far as I know, the quadratic hashing problem came from the fact that every time a transaction is verified (or signed), the "unsigned transaction" that is hashed and verified changes depending on ...
sr_gi's user avatar
  • 3,077
5 votes
3 answers
347 views

Can Scripts be used to implement Chargebacks?

I went ahead and wrote this semi-detailed post about how to implement Chargebacks, when I hit my head and said "Doh, maybe this can just be implemented more cleanly with Scripts". So ... is there a ...
ripper234's user avatar
  • 26.5k
4 votes
2 answers
372 views

Which scripts are currently considered standard and therefore actually propagated?

All I've learned about script so far is that while theoretically quite versatile (e.g. allowing multisignature transactions) most scripts are simply not propagated by the default client nodes, i.e. ...
Tobias Kienzler's user avatar
3 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 ...
monkeyUser's user avatar
3 votes
1 answer
273 views

Create Custom script from bitcoind

I'm able to create multisig with bitcoin-cli with addmultisigaddress bitcoin-cli addmultisigaddress 2 '["'$ADDR_MITT_1'","'$ADDR_MITT_2'","'$ADDR_MITT_3'"]' But How can I add extra OP like CLTV or ...
monkeyUser's user avatar
3 votes
1 answer
194 views

For a redeem script to satisfy the conditions of a script what must it leave on the stack post execution?

I was watching this Andreas Antonopoulos presentation on Advanced Bitcoin Scripting. It appears from Andreas' examples that for a redeem script to satisfy the conditions of the script it needs to ...
Michael Folkson's user avatar
2 votes
1 answer
805 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,...
Michael Folkson's user avatar
2 votes
1 answer
938 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 ...
Errol's user avatar
  • 117
2 votes
1 answer
96 views

What is the relationship between the Minsc language and Policy language?

Quoting from the Minsc website "Minsc is a high-level scripting language...based on the Miniscript Policy language with additional features and syntactic sugar sprinkled on top including ...
Michael Folkson's user avatar
2 votes
2 answers
611 views

What node implementations and mining pools relay and process 'non-standard' scripts?

Which Bitcoin node implementations, if any, currently relay valid transactions that use so-called 'non-standard' scripts? What proportion of the network is made up of these implementations? What ...
bames53's user avatar
  • 139
2 votes
1 answer
1k 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 ...
T. Rossi's user avatar
  • 133
2 votes
3 answers
3k views

Will BTC script be Turing complete in future?

I want to know if BTC script will have loops in it in the future?
D Star Let's Explore's user avatar
1 vote
1 answer
2k views

Walking through a transaction script

As an example, I would like to consider this transaction: https://blockchain.info/tx/6f7cf9580f1c2dfb3c4d5d043cdbb128c640e3f20161245aa7372e9666168516 I have three questions: 1) The first two entries ...
user1936752's user avatar
1 vote
1 answer
358 views

Taproot - Eliminating Key Path

I want to struct a transaction output the key-path of which I want to be eliminated, so enforcing only the script path. In order to eliminate key-path, in my opinion, I should set "Internal ...
Brqoo's user avatar
  • 372
0 votes
1 answer
280 views

Transaction still unspendable with CLTV

Previously I generated tx with CHECKLOCKTIMEVERIFY Here is the transaction https://tchain.btc.com/bb1415c166fd9f767c06d34d539f4b110ef4445f74a76c5ffad1ded33032e872 It lock funds before block 1442909. ...
Andrew's user avatar
  • 173
13 votes
0 answers
206 views

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? ...
Jason Dreyzehner's user avatar