-
@ nym
2023-07-21 17:11:23The Bitcoin Improvement Proposal (BIP) 17 is a proposal to add a new opcode to Bitcoin's scripting system, and it also proposes a new 'standard' transaction type that uses this opcode. Here, I will explain each part of this proposal in simple terms.
BIP17 proposes the opcode
OP_CHECKHASHVERIFY
for the Bitcoin scripting system. An opcode is a type of operation that can be performed by a machine (in this case, the Bitcoin network). The opcode that BIP17 is proposing,OP_CHECKHASHVERIFY
, is a function that checks if the hash of the previous script matches the item at the top of the stack.The reason for introducing this opcode is to enable what is known as "pay-to-script-hash" transactions. These types of transactions allow the receiver of bitcoins to specify the transaction type needed to re-spend them, essentially shifting the responsibility of defining the conditions to redeem a transaction from the sender to the receiver.
The benefit of this is that it allows a sender to fund any arbitrary transaction, no matter how complicated, by using a fixed-length 20-byte hash. This makes it easier to handle in various interfaces, such as QR codes or copy-pasting.
The proposed opcode
OP_CHECKHASHVERIFY
works as follows:- It hashes the end of the previous script, starting from the last evaluated
OP_CODESEPARATOR
. - It then compares this hash with the item on top of the stack.
- If the hashes match, it proceeds with the script; if they don't match, the script fails immediately.
The new standard transaction type is defined as follows:
[20-byte-hash-value] OP_CHECKHASHVERIFY OP_DROP
This transaction type is redeemed by a standard scriptSig:
...signatures... OP_CODESEPARATOR {script}
The proposal also gives an example of how this might look for a one-signature-required transaction and a 2-of-3 multi-signature transaction.
The author of BIP17 believes this proposal would minimize changes needed to the existing infrastructure that sends funds to Bitcoin addresses, which would in turn allow for quicker adoption of multi-signature transactions.
Regarding backward compatibility, this BIP is not compatible with older implementations, and it might lead to a blockchain split if not handled carefully. The proposal includes a method for determining miner support for this BIP and a plan for a graceful upgrade if there is sufficient support.
- It hashes the end of the previous script, starting from the last evaluated