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
3
votes
2answers
232 views

Does the alternative stack make Script Turing complete?

The wiki documents the presence of an "alt stack" in Script: OP_TOALTSTACK Puts the input onto the top of the alt stack. Removes it from the main stack. OP_FROMALTSTACK Puts the input onto the top of ...
0
votes
2answers
145 views

How is a transaction formated/signed?

Every transaction takes unspent outputs as inputs and creates new outputs. The creator of the transaction uses his private key to sign the transaction and nodes validate that transaction by using the ...
0
votes
2answers
127 views

Why is this script invalid, and how can I generate valid public key/digital signature pairs?

Why does the default P2PKH transaction at http://bitcoin-script-debugger.visvirial.com/ return NULL rather than true? I haven't tried to swallow the gory details of OP_CHECKSIG yet, but everything ...
1
vote
0answers
105 views

What does this elaborate output script mean? [duplicate]

Bitcoin transaction a214a2daf91691afdd491fd00d894eb3301e35bc18b5554b14e12843037e954c has an interesting output script: PUSHDATA(33)[...
1
vote
1answer
44 views

Can I use opcodes traditionally used for verifying keys to verify payment sizes?

Can I use binary opcodes usually used for verifying keys to verify payment sizes? It looks like these opcodes like OP_EQUALVERIFY and OP_NUMEQUALVERIFY are used for checking signatures or keys, ...
4
votes
2answers
489 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 = ...
0
votes
1answer
102 views

During Bitcoin Script execution, what is the significance of the signature verification in the stack?

During execution of the script i.e. ScriptSig + ScriptPub , the last step is the verification of the Signature against the public key provided by the recipient. How does this work and what is the ...
1
vote
0answers
54 views

what are ScriptSig? [duplicate]

I was studying bitcoin script, and upon watching this transaction in blockexplorer i was confused , what exactly is ScriptSig and scriptPubKey is of reciever? According to what I know, the receiver ...
1
vote
2answers
129 views

Can bitcoin script look at the output?

I was wondering if it possible for a bitcoin script check part of the output of the transaction. Lets say, I want to check that the transaction is splited equaly between 3 outputs, I dont care which.
1
vote
1answer
58 views

anyonecanspend final condition of a script can be spotted just by looking at the script hash, without the redeem data?

Consider the following scenario. Alice, Carol and Bob create and fund a script with the following rules: if now, alice pubkey, bob pubkey else if now+500 blocks, bob pubkey, carol pubkey else if now+...
0
votes
1answer
57 views

hash locked multisig, can one cosigner sign without the pre-image?

Consider Alice and Bob created the following native segwit script: hash SHA256 defined as H | Alice PubKey | Bob Pubkey Only Bob has the pre-image (plain text that hashes [sha256] to H). Can Alice ...
4
votes
3answers
723 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 ...
0
votes
1answer
194 views

funding and spending a “no-multisig/no segwit” P2SH tx

I got inspired by this thread: Single signature P2SH redeem script Assume I want to "hide" my address as long as can be. So I want a P2SH tx, which only shows a redeemscript (hash of my pubkey) on ...
1
vote
1answer
717 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 ...
4
votes
1answer
511 views

How are sigops calculated?

How are sigops calculated on a transaction? For example in the (randomly selected) following transaction: https://btc.com/bc9384919ad5d08b2c66e31f29e7c63572c398a87631c03a4ce9e94ff1cbe62f It says ...
3
votes
2answers
85 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 ...
2
votes
2answers
103 views

Why we must reference the entire txid for each output we want to spend?

Suppose I want to spend from 3 unspent outputs. I must reference the txid of these unspent outputs. Suppose they are: eb36eca9a06fbe68278ad3e7d16d10ed02e22ad891ed59ef2b84ed4a49e8a6d2 ...
0
votes
0answers
417 views

Error: mandatory-script-verify-flag-failed

I have created a raw transaction from myElectrum wallet, but when I try to broadcast it I get this error: mandatory-script-verify-flag-failed Why is this happening? The transaction is below: ...
0
votes
1answer
316 views

How secure is bitcoin private key generated by this script? [closed]

I found this python script on github. It generates a pair of bitcoin private key and address. I know the private key may be vulnerable if it is created insecurely. I don't have much knowledge ...
4
votes
4answers
297 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> ...
1
vote
1answer
583 views

Bitcoin - Is the <pubKeyHash> in scriptPubKey already hashed?

In Bitcoin protocol, to set the output of a transaction you need a scriptPubKey which is in the following format. scriptPubKey = OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG Is &...
1
vote
1answer
126 views

Why does this script return an error ?

I'm trying to understand how Script validates transactions. I have taken this transaction as an example 55e5bbdba33050bbe6584e896b4a20575cf3fe3f29114467f17f67f6b172eb73 When showing the scripts, we ...
1
vote
2answers
165 views

Mastering Bitcoin: Advanced Scripting Question

At the end of Mastering Bitcoin Chapter 7. https://github.com/bitcoinbook/bitcoinbook/blob/second_edition/ch07.asciidoc#complex-script-example They ask this question in regards to the script: How do ...
1
vote
1answer
118 views

Where to find the sighash type?

Where can I find the sighash type specified in a script? Is it included in the scriptsig?
2
votes
1answer
590 views

Multiple input/output transactions using golang btcd

I am using golang's btcd as a basis for creating some server-side tools for handling transactions. I found a good example for creating a basic one-input-one-output transaction to get me started on the ...
0
votes
1answer
2k views

Signature verification in python

When trying to implement OP_CHECKSIG, I am unable to figure out how to do the actual signature verification in python (python3) I obtained the signature, public key, and hashed message digest of a ...
0
votes
2answers
370 views

Creating an OP_CSV transaction with bitcoinjs

I'm working on a tool for timelocked contract generation. My redeem script looks like so: OP_HASH160 <revocationHash> OP_EQUAL OP_IF <bobPubKey> OP_ELSE <timeDelay> ...
1
vote
1answer
413 views

Why does the Genesis block coinbase input script push bits and the value 0x04 before the famous “Chancellor” message?

According to the Wiki, the input script of the Genesis block consists of these bytes: ...
1
vote
1answer
591 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?
1
vote
1answer
203 views

OP_ADD operation in bitcoin script for integers greater than 128 in java

I want to execute a simple series of instructions to implement a bitcoin script in java using bitcoinj API. All I am looking for is performing arithmetic operations for negative integers or integers ...
3
votes
1answer
519 views

Why does pay to pubkey hash contain OP_CHECKSIG at the end instead of beginning?

According to the bitcoin wiki, the most common form of transaction (pay-to-pubkey-hash) looks like this: scriptPubKey: OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG scriptSig: <...
1
vote
2answers
887 views

Convert plaintext script into hex-encoded script in python

I'm creating a program (for an altcoin I'm developing) that should make it easy to create OP_RETURN transactions. Currently I'm having some trouble with actually creating the script pythonically (I ...
1
vote
1answer
470 views

Bitcoin core multisig signing order

I have a technical question regarding the signrawtransaction function in Bitcoin core when signing a partially-signed transaction. I have tested different scenarios and signrawtransaction will always ...
2
votes
1answer
125 views

How can blockchain.info show the output address of a transaction when the output address has never been used in any other transaction?

I've stumbled across a transition on blockchain.info where the output address was displayed even though the output address had never been used in any other transaction. How can blockchain.info know ...
1
vote
2answers
137 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 ...
0
votes
3answers
2k views

What is wrong with my ScriptSig? I get 64: scriptsig-not-pushonly

I currently try to create and sign transaction from scratch. I made it to construct and sign a transaction. If I verify it manually it looks good but using a "proper" wallet my transaction is refused: ...
0
votes
1answer
70 views

Why there are no OP_CODEs for querying the blockchain and retrieving data to the stack?

Blockchain data is immutable, so once valid a transaction will always be valid and full nodes can verify it.
0
votes
2answers
66 views

Upper bound on transaction confirmation time

Today I saw a case where a transaction had a very low fee, so it got stuck in the mempool for days. The original wallet refused to allow a new transaction to be created with the same input, and in a ...
1
vote
2answers
223 views

Why are there so many opcodes in Bitcoin Script, but they are not usable

In my understanding, miners wont accept non standard scripts. Then why are there several opcodes which cannot be used in custom scripts because they are nonstandard?
0
votes
1answer
349 views

Why is using a simple SHA1 in a scriptPubKey to emulate a “password” a security problem?

I'm independently working my way through an excellent online course on bitcoin, made available from Stanford. (https://crypto.stanford.edu/cs251). One of the problems in the homework challenges the ...
3
votes
1answer
935 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 ...
4
votes
1answer
399 views

What is 'ScriptCode'?

I don't understand what the 'ScriptCode' thing is. Is it a part of transaction format? The wiki https://en.bitcoin.it/wiki/Transaction describes scriptPubKey and scriptSig, mentioning nothing about '...
3
votes
2answers
1k views

How does P2SH unlocking work?

"Mastering Bitcoin" by Antonopoulos in its P2SH section describes how the unlocking and locking scripts are executed and evaluated by nodes. The author gives this as example of an unlocking script: &...
2
votes
1answer
576 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 ...
0
votes
1answer
120 views

How would one go about acquiring the HashofThingtoSign from this old transaction?

How would one go about acquiring the HashofThingToSign that is used in the "Signature Generation" equation for this example transaction such that it could easily also be applied to any other given pre-...
2
votes
3answers
3k 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 ...
3
votes
1answer
732 views

Verifying a P2SH transaction script by hand. How should I concatenate OP CODES in order to hash the script?

I'm reading this: Transaction 40eee3ae1760e3a8532263678cdf64569e6ad06abc133af64f735e52562bccc8 paid to P2SH address 3P14159f73E4gFr7JterCCQh9QjiTjiZrG. You can see the redeem script in ...
1
vote
1answer
827 views

Why are Virtual Machines used in Ethereum?

I'm wondering why the Ethereum Virtual Machine (EVM) is used? What if they didn't use it? Why don't we have them in Bitcoin?
2
votes
1answer
470 views

what is the difference between OP_CHECKMULTISIG and OP_CHECKMULTISIGVERIFY

I would like to learn the difference, explained as simple as possible, between OP_CHECKMULTISIG / OP_CHECKMULTISIGVERIFY and OP_CHECKSIG / OP_CHECKSIGVERIFY. The only explanation I found is: Same as ...
1
vote
3answers
504 views

OP_HASH160 and number of bytes of public key

When creating a raw transaction, why after the OP_HASH160 the number of bytes of the hashed public key should be included if it's always 20 bytes (that's what RIPEMD160 throws)? Does this happen with ...