Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

4
votes
3answers
645 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 ...
45
votes
2answers
22k views

Explanation of what an OP_RETURN transaction looks like

How is OP_RETURN used and why was it introduced in the first place?
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; ...
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 ...
47
votes
5answers
15k 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 ...
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?
9
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: ...
13
votes
2answers
11k 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 ...
9
votes
1answer
946 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 ...
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 ...
15
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, ...
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 ...
2
votes
3answers
2k 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 ...
8
votes
1answer
5k 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? ...
4
votes
2answers
420 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 = ...
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 ...
9
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 ...
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. ...
6
votes
2answers
520 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 ...
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 ...
4
votes
1answer
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?
5
votes
3answers
328 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 ...
5
votes
1answer
188 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 ...
2
votes
1answer
75 views

Cant spend input with non-standart redeemscript (OP_CSV)

I'm playing with OP_CHECKSEQUENCEVERIFY. Here is my transaction that I'm trying to spend: https://tchain.btc.com/e79d469698915aa6724288ae3a4141a31706d081f39fb7fd0b956a73a9044b22 which has the ...
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 ...
5
votes
3answers
499 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?
2
votes
2answers
457 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 ...
14
votes
7answers
4k 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?
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: ...
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 ...
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
490 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
1answer
900 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 ...
5
votes
1answer
1k views

Is Ethereum essentially Bitcoin with Turing-complete Script?

Is Ethereum essentially Bitcoin with a Turing-complete scripting language and, if I understand correctly, where the script to be executed (not its hash) is placed in the Ethereum blockchain? If so, ...
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.
3
votes
1answer
822 views

Missing public key in transaction input

I'm in the process of understanding scriptSigs of transaction inputs and encountered some transactions with inputs that seem to be missing a public key. This is what I expect to see as a scriptSig. A ...
3
votes
2answers
360 views

OP_HASH256 of a negative number

transaction 9 in block 251684 spends transaction 25 of block 249957. the script to be evaluated here is: OP_PUSHDATA0(20) 16cfb9bc7654ef1d7723e5c2722fc0c3d505045e OP_SIZE OP_DUP OP_TRUE ...
3
votes
2answers
318 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. ...
3
votes
1answer
381 views

How should a Bitcoin Oracle verify a transaction prior to signing?

What are the specific parts of a transaction(s) that need to be signed in the "inheritance scripting sample". Specifically, can someone provide more detail on what exactly is signed of the ...
2
votes
1answer
506 views

How to tell which part of the previous tx I need to make the hash to sign for an old given tx?

I have recently been taught (here) how to create the hash to sign for a given "input script" for an existing transaction. I then sought to test my abilities and sought out a difficult transaction to ...
2
votes
2answers
113 views

How is subscript computed for OP_CHECKMULTISIG?

I'm trying to learn the Bitcoin protocol by implementing it, and I've got OP_CHECKSIG working (following instructions in https://en.bitcoin.it/wiki/OP_CHECKSIG), but I can't get an transaction input ...
1
vote
1answer
105 views

Create an arbitrary script with two locktimes and p2sh

Alice, Bob and Carol create a p2sh address that initially requires 3/3 signatures. After some time (lock1 using OP_CHECKLOCKTIMEVERIFY) only Alice and Carol can spend and Bob is permanently forgot. ...
1
vote
1answer
668 views

Single signature P2SH redeem script

How would one go about creating a single signature P2SH transaction? (Analogous to a "2 of 3 multisig P2SH" but instead I'm asking about a "1 of 1".) Would one wrap a standard P2PKH scriptPubKey ...
1
vote
1answer
86 views

I cannot see the expected OP_CODE in transactions

According to different answers on this site the format of the standard TX claim script should be [OP_PUSH DER(R+S)+HashType OP_PUSH PubKey] The OP_PUSH code is 4C, 4D or 4E depending on push length. ...
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 ...
5
votes
1answer
362 views

Where the P2SH script gets written?

I understand that when I'm doing a transaction, I'm locking those bitcoins to whoever provide the solution to a script that has the hash I posted. But, where does the hash get written? I would ...
3
votes
1answer
249 views

Are all the *coin networks consistent in which script actions are permitted and disabled?

The reference Bitcoin client disables several script commands (the programming within a transaction) due to possible implementation issues in the network. I think it's possible that a forked client ...
3
votes
2answers
81 views

Is it possible to make an output only spendable to a specific address?

Basically, the entire question fits into the title. Does the Bitcoin scripting language allow for a transaction output to only be spendable to a specific address? Is it possible to forbid all other ...
3
votes
1answer
381 views

OP_RETURN marks transaction or output as invalid

I am currently looking into the Bitcoin script. I want to create a transaction with one output with OP_RETURN and some data, and one output which pays coins to some address. I am confused, does ...
3
votes
4answers
246 views

Why doesn't address contain a full scriptPubKey?

This is a general question, but let's suppose a P2PKH transaction. P2PKH address starts with "1" and the sender incorporates it into the scriptPubKey as: OP_DUP OP_HASH160 <PublicKeyHash> ...