3 ms·
Here's my attempt at explanatory comments - the ScriptPubkey is a program (written in Bitcoin Script) which is attached to an output of a Bitcoin transaction -
by ryan-c 11y ago
Here's my attempt at explanatory comments - the ScriptPubkey is a program (written in Bitcoin Script) which is attached to an output of a Bitcoin transaction - parameters must be provided that make it return "true".
# Compute the SHA256 of the value on the top of the stack (spender input),
# then add the result to the top of the stack
OP_SHA256
# Check whether this value is equal to Y, the hash of the key under which
# the solution was encrypted.
<Y> OP_EQUAL
# If the correct key was provided, add the seller's public key to the stack
OP_IF
<Seller Pubkey>
# Otherwise, if it has been 100 blocks or more, add the buyer's public key
# to the stack so they may refund themselves if the seller does not complete
# the protocol
OP_ELSE
<block_height+100> OP_CHECKLOCKTIMEVERIFY OP_DROP
<Buyer Pubkey>
OP_ENDIF
# Verify the signature against the public key on the top of the stack
OP_CHECKSIG
- bramblerose 11y agoThank you, that clarifies a lot.
- jnbiche 11y agoGood explanation. By way of background, I'll add that Bitcoin Script runs on a stack machine, similar to Forth (except Script is non-Turing complete).