Bitcoin script


This mechanism may be used in the future for fidelity bonds to sacrifice funds in a provable way. Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.

Transaction a4bfa8abae5f25dae9d89e4eb67dfacafc1ddc5abbc31b is an interesting puzzle. To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash. This transaction was successfully spent by 09fbe71fd1db51ffda40cc0e4f8c8c2c4ab1.

The required data happened to be the Genesis block , and the given hash in the script was the genesis block header hashed twice with SHA Note that while transactions like this are fun, they are not secure, because they do not contain any signatures and thus any transaction attempting to spend them can be replaced with a different transaction sending the funds somewhere else. In Peter Todd created scripts that result in true if a hash collision is found.

Bitcoin addresses resulting from these scripts can have money sent to them. If someone finds a hash collision they can spend the bitcoins on that address, so this setup acts as an incentive for somebody to do so. See the bitcointalk thread [1] and reddit thread [2] for more details.

Retrieved from " https: Technical Vocabulary Bitcoin Core documentation. Navigation menu Personal tools Create account Log in. Views Read View source View history. Sister projects Essays Source. This page was last edited on 26 May , at Content is available under Creative Commons Attribution 3. Privacy policy About Bitcoin Wiki Disclaimers. An empty array of bytes is pushed onto the stack. This is not a no-op: The next two bytes contain the number of bytes to be pushed onto the stack in little endian order.

The next four bytes contain the number of bytes to be pushed onto the stack in little endian order. If the top stack value is not False, the statements are executed. The top stack value is removed. All blocks must end, or the transaction is invalid. Marks transaction as invalid if top stack value is not true. Marks transaction as invalid. Such outputs are provably unspendable, reducing their cost to the network. Keeps only characters left of the specified point in a string. Keeps only characters right of the specified point in a string.

Boolean exclusive or between each bit in the inputs. If it is, 1 is returned, 0 otherwise. Starting with the subsequent public key, it compares the second signature against each remaining public key until it finds an ECDSA match.

The process is repeated until all signatures have been checked or not enough public keys remain to produce a successful result. All signatures need to match a public key. Because public keys are not checked again if they fail any signature comparison, signatures must be placed in the scriptSig using the same order as their corresponding public keys were placed in the scriptPubKey or redeemScript. If all signatures are valid, 1 is returned, 0 otherwise.

Due to a bug, one extra unused value is removed from the stack. Transaction is also invalid if 1. If at the end of execution the stack contains a 'true' value, then the transaction is valid. You can do this in bitcore by using the Interpreter class.

The entry point and probably the only interface you'll need for most applications is the method Interpreter verify. Note that verify expects two scripts: This is because different conditions are checked for each. Bitcoin transactions contain scripts. Each input has a script called the scriptSig, and each output has a script called the scriptPubkey.

If at the end of execution the stack contains a "true" value, then the transaction is valid. Verifies a Script by executing it and returns true if it is valid.

This function needs to be provided with the scriptSig and the scriptPubkey separately. Based on bitcoind's EvalScript function, with the inner loop moved to Interpreter. Checks a locktime parameter with the transaction's locktime. There are two times of nLockTime: See the corresponding code on bitcoin core: Based on the inner loop of bitcoind's EvalScript function bitcoind commit: A bitcoin transaction script.

Each transaction's inputs and outputs has a script that is evaluated to validate it's spending. Retrieve the associated data for this script. In the case of a pay to public key hash or P2SH, return the hash. Script - this script instance. Script - a new pay to script hash script that pays to this script.

Address boolean - the associated address for this script if possible, or false. Analogous to bitcoind's FindAndDelete.

Find and delete equivalent chunks, typically used with push data chunks. Note that this will find and delete not just the same data, but the same data with the same push data op as produced by default. Script - a new Multisig output script for given public keys, requiring m of those public keys to spend. A new P2SH Multisig input script for the given public keys, requiring m of those public keys to spend.

Script - a new pay to public key hash output for the given address or public key. Script - a new pay to public key output for the given public key. Script - new pay to script hash script for given script. Script - an empty script.

Script - an output script built from the address.