I assume it is simply the result of lazyness.
In the original client source code (and still today), the sighash type is represented as an int. The serialization framework by default serializes ints as 4 little-endian bytes.
I assume Bitcoin's creator did not bother converting it to a single byte before serializing.
If there is any other reason, I'm afraid ...
AFAIK this was a design choice by Satoshi originally that is unnecessary for the reasons stated in the OP. There is a comment about this in bitcoinj
// Set the input to the script of its output. Bitcoin Core does this but the step has no obvious purpose as
// the signature covers the hash of the prevout transaction which obviously includes the output ...
What is signed is a simplified version of the transaction (replacing the scriptSig, since that is what we are creating). There is a lot here so hopefully I covered it all:
* `version` (4 Bytes) - Transaction format version
* `flag` (2 Byte Array) - Optional flag, if present, must be 0001, which indicates there is witness data in this transaction
* `input ...
SIGHASH_NONE implies that Input 2 will only spend if Input 1 is included in the transaction.
This is false.
Input 2 is essentially a blank check. SIGHASH_NONE signs none of the outputs (I don't care where the BTC goes), and SIGHASH_ANYONECANPAY signs only input 2 (I don't care who else is participating in the tx. This essentially creates an input, which if ...
The signature is mathematically generated using the private key and the message, but is not the message itself (it uses the hash of the message during the signing process, the message is not recoverable from just the signature). It's just a value (specifically, it is 2 numbers, called r and s) which can be verified against the public key and the message to ...
Note: As of 2020 this answer is obsolete, as BIP143 / SegWit has been in use for years which fixes this concern.
You can fix it this way, and someone is in the process of doing so.
The problem with hashing the entire transaction is that in order to create a transaction hash, you must know the signature. However, in order to create the signature, you need to ...
The script for an output describes the condition that must be satisfied for the money to move.
It means that the public key is contained in the scriptPubKey. Usually, the scriptPubKey only contains a hash of the public key, and relies on the scriptSig to supply the public key.
Explanation of the asm field in decodescript:
OP_CHECKSIG needs to have the whole transaction to hash and to verify the tx. Btcdeb has the feature of allowing the tx as an argument however the website you linked doesn't hence this opcode is doomed to fail every time on this website.
It is reasonable to expect supplying the signature to verify the script/tx because otherwise to steal his coins, I would ...
The main confusion here comes from this :
First, generate the script by concatenating [sigScript][OP_CODESEPARATOR][pubkeyScript]
Then you add :
I understand that script execution has evolved from this
I'm not sure whether you mean "Builds upon this method" or "Has since changed this method", but if it is the former then this might explain the ...
After some additional research and helpful information found here, I was able to conclude the following:
Transactions encoded on 0.12.X bitcoin and then broadcast on 0.15 bitcoin may encounter "mandatory-script-verify-flag-failed (signature must be zero for failed check(multi)sig operation)"
This problem can be solved by doing the following:
Signing your 0....
Bitcoin Script is a programming language. As such, it is similar to other languages - You need to know what you are trying to achieve to be able to write in it.
The script you've presented is a P2PKH (pay-to-pubkey-hash) script. The goal here is to allow someone to spend Bitcoin with the corresponding private key by applying a signature. In this kind of ...
Now I understand, why there was no answer - it gets really long :-)
So I answer it by myself. I am with bitcoin core (getinfo) version 150100, on OpenBSD (ksh) and OSX (bash v3):
I solved it on testnet, and got the tx to go through. Some information from @nick here:
Does OP_HASH160 consume the top stack element?
I was wondering, if this holds true:
The way that VerifyingKey works is that it will actually hash the message before it verifies. The default hashing algorithm is sha1, so you will need to specify it to be sha256 as that is what Bitcoin uses. Furthermore, you are passing it the fully hashed message. What you need to do is pass it the step before hashing the message. Since Bitcoin uses SHA256 ...
Partial answer (not a new solution - I merely adapted the micropayment channel protocol):
if you allow for public key exchange, one solution seems to me to be:
t1: source funds an address A controlled by source and escrow
source partially signs transaction T spending A to destination. Then
she sends this partially signed transaction to escrow.
it is ...
i had the locktime field of the spending transaction accidentally set to 0 when in fact it is 272295 for this transaction.