<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Roconnor</id>
	<title>Bitcoin Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.bitcoin.it/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Roconnor"/>
	<link rel="alternate" type="text/html" href="https://en.bitcoin.it/wiki/Special:Contributions/Roconnor"/>
	<updated>2026-04-17T08:44:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=61707</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=61707"/>
		<updated>2016-10-14T22:23:36Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: Adding reference to the formal definition of script in interpreter.cpp&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
This document is for information purposes only. Officially Bitcoin script is defined by [https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp its reference implementation].&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.&lt;br /&gt;
When used as numbers, byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer.&lt;br /&gt;
Thus 0x81 represents -1.&lt;br /&gt;
0x80 is another representation of zero (so called negative 0).&lt;br /&gt;
Positive 0 is represented by a null-length vector.&lt;br /&gt;
Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words, also known as opcodes, commands, or functions.&lt;br /&gt;
&lt;br /&gt;
There are some words which existed in very early versions of Bitcoin but were removed out of a concern that the client might have a bug in their implementation. This fear was motivated by a bug found in OP_LSHIFT which could crash any Bitcoin node if exploited, and by other bugs in how Script worked which allowed anyone to spend anyone&#039;s bitcoins. The removed opcodes are sometimes said to be &amp;quot;disabled&amp;quot; opcodes, but this is something of a misnomer because there is &#039;&#039;absolutely no way&#039;&#039; for anyone using Bitcoin to use these opcodes (they simply &#039;&#039;do not exist anymore&#039;&#039; in the protocol), and there are also no solid plans to ever re-enable all of these opcodes. They are listed here only for historical interest.&lt;br /&gt;
&lt;br /&gt;
New opcodes can be added by means of a carefully designed and executed [[softfork]] using OP_NOP1-OP_NOP10.&lt;br /&gt;
&lt;br /&gt;
False is zero or negative zero (using any number of bytes) or an empty array, and True is anything else.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not False, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is False, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block. All blocks must end, or the transaction is &#039;&#039;&#039;invalid&#039;&#039;&#039;. An OP_ENDIF without OP_IF earlier is also &#039;&#039;&#039;invalid&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_RETURN]]&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;fail&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. A standard way of attaching extra data to transactions is to add a zero-value output with a scriptPubKey consisting of OP_RETURN followed by exactly one pushdata op. Such outputs are provably unspendable, reducing their cost to the network. Currently it is usually considered non-standard (though valid) for a transaction to have more than one OP_RETURN output or an OP_RETURN output with more than one pushdata op.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the top stack value is not 0, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as disabled is present in a script, it must abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Concatenates two strings. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns a section of a string. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters left of the specified point in a string. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Keeps only characters right of the specified point in a string. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Pushes the string length of the top element of the stack (without popping it).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
If any opcode marked as disabled is present in a script, it must abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Flips all of the bits in the input. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
Note: Arithmetic inputs are limited to signed 32-bit integers, but may overflow their output.&lt;br /&gt;
&lt;br /&gt;
If any input value for any of these commands is longer than 4 bytes, the script must abort and fail. &lt;br /&gt;
If any opcode marked as &#039;&#039;disabled&#039;&#039; is present in a script - it must also abort and fail.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is multiplied by 2. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|The input is divided by 2. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is multiplied by b. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|a is divided by b. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Returns the remainder after dividing a by b. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a left b bits, preserving sign. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|style=&amp;quot;background:#D97171;&amp;quot;|Shifts a right b bits, preserving sign. &#039;&#039;disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|Nothing / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|Nothing / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Compares the first signature against each public key until it finds an ECDSA match. 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.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|Nothing / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Locktime ===&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKLOCKTIMEVERIFY (previously OP_NOP2)&lt;br /&gt;
|177&lt;br /&gt;
|0xb1&lt;br /&gt;
|x&lt;br /&gt;
|x / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if the top stack item is greater than the transaction&#039;s nLockTime field, otherwise script evaluation continues as though an OP_NOP was executed. Transaction is also invalid if 1. the stack is empty; or 2. the top stack item is negative; or 3. the top stack item is greater than or equal to 500000000 while the transaction&#039;s nLockTime field is less than 500000000, or vice versa; or 4. the input&#039;s nSequence field is equal to 0xffffffff. The precise semantics are described in [[BIP 0065]]&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSEQUENCEVERIFY (previously OP_NOP3)&lt;br /&gt;
|178&lt;br /&gt;
|0xb2&lt;br /&gt;
|x&lt;br /&gt;
|x / &#039;&#039;fail&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if the relative lock time of the input (enforced by [[BIP 0068]] with nSequence) is not equal to or longer than the value of the top stack item. The precise semantics are described in [[BIP 0112]].&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction &#039;&#039;&#039;invalid&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|&#039;&#039;&#039;Transaction is invalid&#039;&#039;&#039; unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|&#039;&#039;&#039;Transaction is invalid&#039;&#039;&#039; unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|&#039;&#039;&#039;Transaction is invalid even when occuring in an unexecuted OP_IF branch&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|&#039;&#039;&#039;Transaction is invalid even when occuring in an unexecuted OP_IF branch&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|&#039;&#039;&#039;Transaction is invalid&#039;&#039;&#039; unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|&#039;&#039;&#039;Transaction is invalid&#039;&#039;&#039; unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1, OP_NOP4-OP_NOP10&lt;br /&gt;
|176, 179-185&lt;br /&gt;
|0xb0, 0xb2-0xb9&lt;br /&gt;
|The word is ignored. Does not mark transaction as invalid.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above. Note that there is a small number of standard script forms that are relayed from node to node; non-standard scripts are accepted if they are in a block, but nodes will not relay them.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address (pay-to-pubkey-hash) ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: scriptSig is in the input of the spending transaction and scriptPubKey is in the output of the previously unspent i.e. &amp;quot;available&amp;quot; transaction.&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Obsolete pay-to-pubkey transaction ===&lt;br /&gt;
&lt;br /&gt;
OP_CHECKSIG is used directly without first hashing the public key.&lt;br /&gt;
This was used by early versions of Bitcoin where people paid directly to IP addresses, before Bitcoin addresses were introduced.&lt;br /&gt;
scriptPubKeys of this transaction form are still recognized as payments to user by Bitcoin Core.&lt;br /&gt;
The disadvantage of this transaction form is that the whole public key needs to be known in advance, implying longer payment addresses, and that it provides less protection in the event of a break in the ECDSA signature algorithm.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Provably Unspendable/Prunable Outputs ===&lt;br /&gt;
&lt;br /&gt;
The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: OP_RETURN {zero or more ops}&lt;br /&gt;
&lt;br /&gt;
OP_RETURN immediately marks the script as invalid, guaranteeing that no scriptSig exists that could possibly spend that output. Thus the output can be immediately pruned from the UTXO set even if it has not been spent. [http://blockexplorer.com/tx/eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29 eb31ca1a4cbd97c2770983164d7560d2d03276ae1aee26f12d7c2c6424252f29] is an example: it has a single output of zero value, thus giving the full 0.125BTC fee to the miner who mined the transaction without adding an entry to the UTXO set. You can also use OP_RETURN to add data to a transaction without the data ever appearing in the UTXO set, as seen in 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc; [[P2Pool]] does this with the share chain hash txout in the coinbase of blocks it creates.&lt;br /&gt;
&lt;br /&gt;
=== Anyone-Can-Spend Outputs ===&lt;br /&gt;
&lt;br /&gt;
Conversely a transaction can be made spendable by anyone at all:&lt;br /&gt;
&lt;br /&gt;
  scriptPubKey: (empty)&lt;br /&gt;
  scriptSig: OP_TRUE&lt;br /&gt;
&lt;br /&gt;
With some software changes such transactions can be used as a way to donate funds to miners in addition to transaction fees: any miner who mines such a transaction can also include an additional one after it sending the funds to an address they control. This mechanism may be used in the future for [[fidelity bonds]] to sacrifice funds in a provable way.&lt;br /&gt;
&lt;br /&gt;
Anyone-Can-Spend outputs are currently considered non-standard, and are not relayed on the P2P network.&lt;br /&gt;
&lt;br /&gt;
=== Transaction puzzle ===&lt;br /&gt;
&lt;br /&gt;
Transaction a4bfa8ab6435ae5f25dae9d89e4eb67dfa94283ca751f393c1ddc5a837bbc31b is an interesting puzzle.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_HASH256 6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000 OP_EQUAL&lt;br /&gt;
 scriptSig: &amp;lt;data&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To spend the transaction you need to come up with some data such that hashing the data twice results in the given hash.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;data&amp;gt; OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data&amp;gt;&lt;br /&gt;
|OP_HASH256 &amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt;&lt;br /&gt;
|&amp;lt;given_hash&amp;gt; OP_EQUAL&lt;br /&gt;
|The data is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;data_hash&amp;gt; &amp;lt;given_hash&amp;gt;&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|The given hash is pushed to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|The hashes are compared, leaving true on the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This transaction was successfully spent by 09f691b2263260e71f363d1db51ff3100d285956a40cc0e4f8c8c2c4a80559b1. The required data happened to be the [[Genesis block]], and the given hash was the genesis block hash. 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.&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Transactions]]&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
*[https://www.cs.princeton.edu/~tongbinw/bitcoinIDE/build/editor.html Bitcoin IDE]: Bitcoin Script for dummies&lt;br /&gt;
*[https://webbtc.com/script Bitcoin Debug Script Execution]&lt;br /&gt;
*[http://www.crmarsh.com/script-playground/ Script Playground] — convert Script to JavaScript&lt;br /&gt;
&amp;lt;sup&amp;gt;(cf. &amp;quot;[http://bitcoin.stackexchange.com/q/42576/4334 Online Bitcoin Script simulator or debugger?]&amp;quot;)&amp;lt;/sup&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;br /&gt;
&lt;br /&gt;
{{Bitcoin Core documentation}}&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Protocol_documentation&amp;diff=22565</id>
		<title>Protocol documentation</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Protocol_documentation&amp;diff=22565"/>
		<updated>2012-01-22T05:01:29Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: Adding compressed public keys.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sources:&lt;br /&gt;
* [[Original Bitcoin client]] source&lt;br /&gt;
&lt;br /&gt;
Type names used in this documentation are from the C99 standard.&lt;br /&gt;
&lt;br /&gt;
==Common standards==&lt;br /&gt;
&lt;br /&gt;
=== Hashes ===&lt;br /&gt;
&lt;br /&gt;
Usually, when a hash is computed within bitcoin, it is computed twice. Most of the time [http://en.wikipedia.org/wiki/SHA-2 SHA-256] hashes are used, however [http://en.wikipedia.org/wiki/RIPEMD RIPEMD-160] is also used when a shorter hash is desirable (for example when creating a bitcoin address).&lt;br /&gt;
&lt;br /&gt;
Example of double-SHA-256 encoding of string &amp;quot;hello&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
 hello&lt;br /&gt;
 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round of sha-256)&lt;br /&gt;
 9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50 (second round of sha-256)&lt;br /&gt;
&lt;br /&gt;
For bitcoin addresses (RIPEMD-160) this would give:&lt;br /&gt;
&lt;br /&gt;
 hello&lt;br /&gt;
 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round is sha-256)&lt;br /&gt;
 b6a9c8c230722b7c748331a8b450f05566dc7d0f (with ripemd-160)&lt;br /&gt;
&lt;br /&gt;
=== Merkle Trees ===&lt;br /&gt;
&lt;br /&gt;
Merkle trees are binary trees of hashes. Merkle trees in bitcoin use &#039;&#039;&#039;Double&#039;&#039;&#039; SHA-256, and are built up as so:&lt;br /&gt;
 &lt;br /&gt;
 hash(a) = sha256(sha256(a))&lt;br /&gt;
 &lt;br /&gt;
 hash(a) hash(b) hash(c)&lt;br /&gt;
 hash(hash(a)+hash(b)) hash(hash(c)+hash(c))&lt;br /&gt;
 hash(hash(hash(a)+hash(b))+hash(hash(c)+hash(c)))&lt;br /&gt;
&lt;br /&gt;
They are paired up, with the last element being _duplicated_.&lt;br /&gt;
&lt;br /&gt;
Note: Hashes in Merkle Tree displayed in the [[Block Explorer]] are of little-endian notation. For some implementations and [http://www.fileformat.info/tool/hash.htm calculations], the bits need to be reversed before they are hashed, and again after the hashing operation.&lt;br /&gt;
&lt;br /&gt;
=== Signatures ===&lt;br /&gt;
&lt;br /&gt;
Bitcoin uses [http://en.wikipedia.org/wiki/Elliptic_curve_cryptography Elliptic Curve] [http://en.wikipedia.org/wiki/Digital_Signature_Algorithm Digital Signature Algorithm] ([http://en.wikipedia.org/wiki/Elliptic_Curve_DSA ECDSA]) to sign transactions. &lt;br /&gt;
&lt;br /&gt;
For ECDSA the secp256k1 curve from http://www.secg.org/collateral/sec2_final.pdf is used.&lt;br /&gt;
&lt;br /&gt;
Public keys (in scripts) are given as 04 &amp;lt;x&amp;gt; &amp;lt;y&amp;gt; where &#039;&#039;x&#039;&#039; and &#039;&#039;y&#039;&#039; are 32 byte big-endian integers representing the coordinates of a point on the curve or in compressed form given as &amp;lt;sign&amp;gt; &amp;lt;x&amp;gt; where &amp;lt;sign&amp;gt; is 0x02 if &#039;&#039;y&#039;&#039; is even and 0x03 if &#039;&#039;y&#039;&#039; is odd. Signatures use [http://en.wikipedia.org/wiki/Distinguished_Encoding_Rules DER encoding] to pack the &#039;&#039;r&#039;&#039; and &#039;&#039;s&#039;&#039; components into a single byte stream (this is also what OpenSSL produces by default).&lt;br /&gt;
&lt;br /&gt;
=== Transaction Verification ===&lt;br /&gt;
Transactions are cryptographically signed records that reassign ownership of Bitcoins to new addresses.  Transactions have &#039;&#039;inputs&#039;&#039; - records which reference the funds from other previous transactions - and &#039;&#039;outputs&#039;&#039; - records which determine the new owner of the transferred Bitcoins, and which will be referenced as inputs in future transactions as those funds are respent.&lt;br /&gt;
&lt;br /&gt;
Each &#039;&#039;input&#039;&#039; must have a cryptographic digital signature that unlocks the funds from the prior transaction.  Only the person possessing the appropriate [[private key]] is able to create a satisfactory signature; this in effect ensures that funds can only be spent by their owners.&lt;br /&gt;
&lt;br /&gt;
Each &#039;&#039;output&#039;&#039; determines which Bitcoin address (or other criteria, see [[Scripting]]) is the recipient of the funds.&lt;br /&gt;
&lt;br /&gt;
In a transaction, the sum of all inputs must be equal to or greater than the sum of all outputs.  If the inputs exceed the outputs, the difference is considered a [[transaction fee]], and is redeemable by whoever first includes the transaction into the block chain.&lt;br /&gt;
&lt;br /&gt;
A special kind of transaction, called a [[coinbase transaction]], has no inputs.  It is created by [[miners]], and there is one coinbase transaction per block.  Because each block comes with a reward of newly created Bitcoins (e.g. 50 BTC for the first 210,000 blocks), the first transaction of a block is, with few exceptions, the transaction that grants those coins to their recipient (the miner).  In addition to the newly created Bitcoins, the coinbase transaction is also used for assigning the recipient of any transaction fees that were paid within the other transactions being included in the same block.  The coinbase transaction can assign the entire reward to a single Bitcoin address, or split it in portions among multiple addresses, just like any other transaction.  Coinbase transactions always contain outputs totaling the sum of the block reward plus all transaction fees collected from the other transactions in the same block.&lt;br /&gt;
&lt;br /&gt;
Most Bitcoin outputs encumber the newly transferred coins with a single ECDSA private key.  The actual record saved with inputs and outputs isn&#039;t necessarily a key, but a &#039;&#039;script&#039;&#039;.  Bitcoin uses an interpreted scripting system to determine whether an output&#039;s criteria have been satisfied, with which more complex operations are possible, such as outputs that require two ECDSA signatures, or two-of-three-signature schemes.  An output that references a single Bitcoin address is a &#039;&#039;typical&#039;&#039; output; an output actually contains this information in the form of a script that requires a single ECDSA signature (see [[OP_CHECKSIG]]).  The output script specifies what must be provided to unlock the funds later, and when the time comes in the future to spend the transaction in another input, that input must provide all of the thing(s) that satisfy the requirements defined by the original output script.&lt;br /&gt;
&lt;br /&gt;
=== Addresses ===&lt;br /&gt;
&lt;br /&gt;
A bitcoin address is in fact the hash of a ECDSA public key, computed this way:&lt;br /&gt;
&lt;br /&gt;
 Version = 1 byte of 0 (zero); on the test network, this is 1 byte of 111&lt;br /&gt;
 Key hash = Version concatenated with RIPEMD-160(SHA-256(public key))&lt;br /&gt;
 Checksum = 1st 4 bytes of SHA-256(SHA-256(Key hash))&lt;br /&gt;
 Bitcoin Address = Base58Encode(Key hash concatenated with Checksum)&lt;br /&gt;
&lt;br /&gt;
The Base58 encoding used is home made, and has some differences. Especially, leading zeroes are kept as single zeroes when conversion happens.&lt;br /&gt;
&lt;br /&gt;
== Common structures ==&lt;br /&gt;
&lt;br /&gt;
Almost all integers are encoded in little endian. Only IP or port number are encoded big endian.&lt;br /&gt;
&lt;br /&gt;
=== Message structure ===&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || magic || uint32_t || Magic value indicating message origin network, and used to seek to next message when stream state is unknown&lt;br /&gt;
|-&lt;br /&gt;
| 12 || command || char[12] || ASCII string identifying the packet content, NULL padded (non-NULL padding results in packet rejected)&lt;br /&gt;
|-&lt;br /&gt;
| 4 || length || uint32_t || Length of payload in number of bytes&lt;br /&gt;
|-&lt;br /&gt;
| 4 || checksum || uint32_t || First 4 bytes of sha256(sha256(payload)) (not included in version or verack)&lt;br /&gt;
|-&lt;br /&gt;
| ? || payload || uchar[] || The actual data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Before 20 February 2012, the version and verack messages do not have a checksum; the payload starts 4 bytes earlier. On and after 20 February 2012, all messages have checksums.&lt;br /&gt;
&lt;br /&gt;
Known magic values:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Network !! Magic value !! Sent over wire as&lt;br /&gt;
|-&lt;br /&gt;
| main || 0xD9B4BEF9 || F9 BE B4 D9&lt;br /&gt;
|-&lt;br /&gt;
| testnet || 0xDAB5BFFA || FA BF B5 DA&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Variable length integer ===&lt;br /&gt;
&lt;br /&gt;
Integer can be encoded depending on the represented value to save space.  Variable length integers always precede an array/vector of a type of data that may vary in length.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Storage length !! Format&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 0xfd || 1 || uint8_t&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;= 0xffff || 3 || 0xfd followed by the length as uint16_t&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;= 0xffffffff || 5 || 0xfe followed by the length as uint32_t&lt;br /&gt;
|-&lt;br /&gt;
| - || 9 || 0xff followed by the length as uint64_t&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Variable length string ===&lt;br /&gt;
&lt;br /&gt;
Variable length string can be stored using a variable length integer followed by the string itself.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || length || [[Protocol_specification#Variable_length_integer|var_int]] || Length of the string&lt;br /&gt;
|-&lt;br /&gt;
| ? || string || char[] || The string itself (can be empty)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Network address ===&lt;br /&gt;
&lt;br /&gt;
When a network address is needed somewhere, this structure is used.  This protocol and structure supports IPv6, &#039;&#039;&#039;but note that the original client currently only supports IPv4 networking&#039;&#039;&#039;. Network addresses are not prefixed with a timestamp in the version message.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || time || uint32 || the Time (version &amp;gt;= 31402)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || services || uint64_t || same service(s) listed in [[#version|version]]&lt;br /&gt;
|-&lt;br /&gt;
| 16 || IPv6/4 || char[16] || IPv6 address. Network byte order. The original client only supports IPv4 and only reads the last 4 bytes to get the IPv4 address. However, the IPv4 address is written into the message as a 16 byte [http://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses IPv4-mapped IPv6 address]&lt;br /&gt;
(12 bytes &#039;&#039;00 00 00 00  00 00 00 00  00 00 FF FF&#039;&#039;, followed by the 4 bytes of the IPv4 address).&lt;br /&gt;
|-&lt;br /&gt;
| 2 || port || uint16_t || port number, network byte order&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Hexdump example of Network address structure&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  ................&lt;br /&gt;
0010   00 00 FF FF 0A 00 00 01  20 8D                    ........ .&lt;br /&gt;
&lt;br /&gt;
Network address:&lt;br /&gt;
 01 00 00 00 00 00 00 00                         - 1 (NODE_NETWORK: see services listed under version command)&lt;br /&gt;
 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 01 - IPv6: ::ffff:10.0.0.1 or IPv4: 10.0.0.1&lt;br /&gt;
 20 8D                                           - Port 8333&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Inventory Vectors ===&lt;br /&gt;
&lt;br /&gt;
Inventory vectors are used for notifying other nodes about objects they have or data which is being requested.&lt;br /&gt;
&lt;br /&gt;
Inventory vectors consist of the following data format:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || type || uint32_t || Identifies the object type linked to this inventory&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash || char[32] || Hash of the object&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The object type is currently defined as one of the following possibilities:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || ERROR || Any data of with this number may be ignored&lt;br /&gt;
|-&lt;br /&gt;
| 1 || MSG_TX || Hash is related to a transaction&lt;br /&gt;
|-&lt;br /&gt;
| 2 || MSG_BLOCK || Hash is related to a data block&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Other Data Type values are considered reserved for future implementations.&lt;br /&gt;
&lt;br /&gt;
=== Block Headers ===&lt;br /&gt;
&lt;br /&gt;
Block headers are sent in a headers packet in response to a getheaders message.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Block version information, based upon the software version creating this block&lt;br /&gt;
|-&lt;br /&gt;
| 32 || prev_block || char[32] || The hash value of the previous block this particular block references&lt;br /&gt;
|-&lt;br /&gt;
| 32 || merkle_root || char[32] || The reference to a Merkle tree collection which is a hash of all transactions related to this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || timestamp || uint32_t || A timestamp recording when this block was created (Limited to 2106!)&lt;br /&gt;
|-&lt;br /&gt;
| 4 || bits || uint32_t || The calculated difficulty target being used for this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || nonce || uint32_t || The nonce used to generate this block… to allow variations of the header and compute different hashes&lt;br /&gt;
|-&lt;br /&gt;
| 1 || txn_count || uint8_t || Number of transaction entries, this value is always 0&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Message types ==&lt;br /&gt;
&lt;br /&gt;
=== version ===&lt;br /&gt;
&lt;br /&gt;
When a node creates an outgoing connection, it will immediately advertise its version. The remote node will respond with its version. No futher communication is possible until both peers have exchanged their version.&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || int32_t || Identifies protocol version being used by the node&lt;br /&gt;
|-&lt;br /&gt;
| 8 || services || uint64_t || bitfield of features to be enabled for this connection&lt;br /&gt;
|-&lt;br /&gt;
| 8 || timestamp || int64_t || standard UNIX timestamp in seconds&lt;br /&gt;
|-&lt;br /&gt;
| 26 || addr_recv || net_addr || The network address of the node receiving this message&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| version &amp;gt;= 106&lt;br /&gt;
|-&lt;br /&gt;
| 26 || addr_from || net_addr || The network address of the node emitting this message&lt;br /&gt;
|-&lt;br /&gt;
| 8 || nonce || uint64_t || Node random nonce, randomly generated every time a version packet is sent. This nonce is used to detect connections to self.&lt;br /&gt;
|-&lt;br /&gt;
| ? || user_agent || [[#Variable length string|var_str]] || [[BIP_0014|User Agent]] (0x00 if string is 0 bytes long)&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| version &amp;gt;= 209&lt;br /&gt;
|-&lt;br /&gt;
| 4 || start_height || int32_t || The last block received by the emitting node&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the emitter of the packet has version &amp;gt;= 209, a &amp;quot;verack&amp;quot; packet shall be sent if the version packet was accepted.&lt;br /&gt;
&lt;br /&gt;
The following services are currently assigned:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 1 || NODE_NETWORK || This node can be asked for full blocks instead of just headers.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Hexdump example of version message (note the message header for this version message does not have a checksum):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   F9 BE B4 D9 76 65 72 73  69 6F 6E 00 00 00 00 00   ....version.....&lt;br /&gt;
0010   55 00 00 00 9C 7C 00 00  01 00 00 00 00 00 00 00   U....|..........&lt;br /&gt;
0020   E6 15 10 4D 00 00 00 00  01 00 00 00 00 00 00 00   ...M............&lt;br /&gt;
0030   00 00 00 00 00 00 00 00  00 00 FF FF 0A 00 00 01   ................&lt;br /&gt;
0040   20 8D 01 00 00 00 00 00  00 00 00 00 00 00 00 00   ................&lt;br /&gt;
0050   00 00 00 00 FF FF 0A 00  00 02 20 8D DD 9D 20 2C   .......... ... ,&lt;br /&gt;
0060   3A B4 57 13 00 55 81 01  00                        :.W..U...&lt;br /&gt;
&lt;br /&gt;
Message header:&lt;br /&gt;
 F9 BE B4 D9                                                                   - Main network magic bytes&lt;br /&gt;
 76 65 72 73 69 6F 6E 00 00 00 00 00                                           - &amp;quot;version&amp;quot; command&lt;br /&gt;
 55 00 00 00                                                                   - Payload is 85 bytes long&lt;br /&gt;
                                                                               - No checksum in version message until 20 February 2012. See https://bitcointalk.org/index.php?topic=55852.0&lt;br /&gt;
Version message:&lt;br /&gt;
 9C 7C 00 00                                                                   - 31900 (version 0.3.19)&lt;br /&gt;
 01 00 00 00 00 00 00 00                                                       - 1 (NODE_NETWORK services)&lt;br /&gt;
 E6 15 10 4D 00 00 00 00                                                       - Mon Dec 20 21:50:14 EST 2010&lt;br /&gt;
 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 01 20 8D - Recipient address info - see Network Address&lt;br /&gt;
 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 02 20 8D - Sender address info - see Network Address&lt;br /&gt;
 DD 9D 20 2C 3A B4 57 13                                                       - Node random unique ID&lt;br /&gt;
 00                                                                            - &amp;quot;&amp;quot; sub-version string (string is 0 bytes long)&lt;br /&gt;
 55 81 01 00                                                                   - Last block sending node has is block #98645&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== verack ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;verack&#039;&#039; message is sent in reply to &#039;&#039;version&#039;&#039; for clients &amp;gt;= 209.  This message consists of only a [[#Message structure|message header]] with the command string &amp;quot;verack&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Hexdump of the verack message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   F9 BE B4 D9 76 65 72 61  63 6B 00 00 00 00 00 00   ....verack......&lt;br /&gt;
0010   00 00 00 00                                        ....&lt;br /&gt;
&lt;br /&gt;
Message header:&lt;br /&gt;
 F9 BE B4 D9                          - Main network magic bytes&lt;br /&gt;
 76 65 72 61  63 6B 00 00 00 00 00 00 - &amp;quot;verack&amp;quot; command&lt;br /&gt;
 00 00 00 00                          - Payload is 0 bytes long&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== addr ===&lt;br /&gt;
&lt;br /&gt;
Provide information on known nodes of the network. Non-advertised nodes should be forgotten after typically 3 hours&lt;br /&gt;
&lt;br /&gt;
Payload (maximum payload length: 1000 bytes):&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of address entries&lt;br /&gt;
|-&lt;br /&gt;
| 30x? || addr_list || (uint32_t + net_addr)[] || Address of other nodes on the network. version &amp;lt; 209 will only read the first one. The uint32_t is a timestamp (see note below).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Starting version 31402, addresses are prefixed with a timestamp. If no timestamp is present, the addresses should not be relayed to other peers, unless it is indeed confirmed they are up.&lt;br /&gt;
&lt;br /&gt;
Hexdump example of &#039;&#039;addr&#039;&#039; message:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0000   F9 BE B4 D9 61 64 64 72  00 00 00 00 00 00 00 00   ....addr........&lt;br /&gt;
0010   1F 00 00 00 ED 52 39 9B  01 E2 15 10 4D 01 00 00   .....R9.....M...&lt;br /&gt;
0020   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 FF   ................&lt;br /&gt;
0030   FF 0A 00 00 01 20 8D                               ..... .&lt;br /&gt;
&lt;br /&gt;
Message Header:&lt;br /&gt;
 F9 BE B4 D9                                     - Main network magic bytes&lt;br /&gt;
 61 64 64 72  00 00 00 00 00 00 00 00            - &amp;quot;addr&amp;quot;&lt;br /&gt;
 1F 00 00 00                                     - payload is 31 bytes long&lt;br /&gt;
 ED 52 39 9B                                     - checksum of payload&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
 01                                              - 1 address in this message&lt;br /&gt;
&lt;br /&gt;
Address:&lt;br /&gt;
 E2 15 10 4D                                     - Mon Dec 20 21:50:10 EST 2010 (only when version is &amp;gt;= 31402)&lt;br /&gt;
 01 00 00 00 00 00 00 00                         - 1 (NODE_NETWORK service - see version message)&lt;br /&gt;
 00 00 00 00 00 00 00 00 00 00 FF FF 0A 00 00 01 - IPv4: 10.0.0.1, IPv6: ::ffff:10.0.0.1 (IPv4-mapped IPv6 address)&lt;br /&gt;
 20 8D                                           - port 8333&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== inv ===&lt;br /&gt;
&lt;br /&gt;
Allows a node to advertise its knowledge of one or more objects. It can be received unsolicited, or in reply to &#039;&#039;getblocks&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Payload (maximum payload length: 50000 bytes):&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of inventory entries&lt;br /&gt;
|-&lt;br /&gt;
| 36x? || inventory || [[Protocol specification#Inventory Vectors|inv_vect]][] || Inventory vectors&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== getdata ===&lt;br /&gt;
&lt;br /&gt;
getdata is used in response to inv, to retrieve the content of a specific object, and is usually sent after receiving an &#039;&#039;inv&#039;&#039; packet, after filtering known elements.&lt;br /&gt;
&lt;br /&gt;
Payload (maximum payload length: 50000 bytes):&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of inventory entries&lt;br /&gt;
|-&lt;br /&gt;
| 36x? || inventory || [[Protocol specification#Inventory Vectors|inv_vect]][] || Inventory vectors&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== getblocks ===&lt;br /&gt;
&lt;br /&gt;
Return an &#039;&#039;inv&#039;&#039; packet containing the list of blocks starting right after the last known (and correct) hash in the block locator object, up to hash_stop or 500 blocks, whichever comes first. To receive the next blocks hashes, one needs to issue getblocks again with a new block locator object.&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || the protocol version&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || hash count || [[Protocol_specification#Variable_length_integer|var_int]] || number of block locator hash entries&lt;br /&gt;
|-&lt;br /&gt;
| 32+ || block locator hashes || char[32] || block locator object; newest back to genesis block (dense to start, but then sparse)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash_stop || char[32] || hash of the last desired block; set to zero to get as many blocks as possible (500)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
To create the block locator hashes, keep pushing hashes until you go back to the genesis block. After pushing 10 hashes back, the step backwards doubles every loop:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// From libbitcoin which is under AGPL&lt;br /&gt;
std::vector&amp;lt;size_t&amp;gt; block_locator_indices(int top_depth)&lt;br /&gt;
{&lt;br /&gt;
    // Start at max_depth&lt;br /&gt;
    std::vector&amp;lt;size_t&amp;gt; indices;&lt;br /&gt;
    // Push last 10 indices first&lt;br /&gt;
    size_t step = 1, start = 0;&lt;br /&gt;
    for (int i = top_depth; i &amp;gt; 0; i -= step, ++start)&lt;br /&gt;
    {&lt;br /&gt;
        if (start &amp;gt;= 10)&lt;br /&gt;
            step *= 2;&lt;br /&gt;
        indices.push_back(i);&lt;br /&gt;
    }&lt;br /&gt;
    indices.push_back(0);&lt;br /&gt;
    return indices;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that it is allowed to send in fewer known hashes down to a minimum of just one hash. However, the purpose of the block locator object is to detect a wrong branch in the caller&#039;s main chain. If the peer detects that you are off the main chain, it will send in block hashes which are earlier than your last known block. So if you just send in your last known hash and it is off the main chain, the peer starts over at block #1.&lt;br /&gt;
&lt;br /&gt;
=== getheaders ===&lt;br /&gt;
&lt;br /&gt;
Return a &#039;&#039;headers&#039;&#039; packet containing the headers of blocks starting right after the last known (and correct) hash in the block locator object, up to hash_stop or 2000 blocks, whichever comes first. To receive the next block headers, one needs to issue getheaders again with a new block locator object. The &#039;&#039;getheaders&#039;&#039; command is used by thin clients to quickly download the blockchain where the contents of the transactions would be irrelevant (because they are not ours). &lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || the protocol version&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || hash count || [[Protocol_specification#Variable_length_integer|var_int]] || number of block locator hash entries&lt;br /&gt;
|-&lt;br /&gt;
| 32+ || block locator hashes || char[32] || block locator object; newest back to genesis block (dense to start, but then sparse)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash_stop || char[32] || hash of the last desired block header; set to zero to get as many blocks as possible (2000)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the block locator object in this packet, the same rules apply as for the [[Protocol_specification#Variable_length_integer|getblocks]] packet.&lt;br /&gt;
&lt;br /&gt;
=== tx ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;tx&#039;&#039; describes a bitcoin transaction, in reply to &#039;&#039;getdata&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Transaction data format version&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || tx_in count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of Transaction inputs&lt;br /&gt;
|-&lt;br /&gt;
| 41+ || tx_in || tx_in[] || A list of 1 or more transaction inputs or sources for coins&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || tx_out count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of Transaction outputs&lt;br /&gt;
|-&lt;br /&gt;
| 8+ || tx_out || tx_out[] || A list of 1 or more transaction outputs or destinations for coins&lt;br /&gt;
|-&lt;br /&gt;
| 4 || lock_time || uint32_t || The block number or timestamp at which this transaction is locked:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Always locked&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt; 500000000  || Block number at which this transaction is locked&lt;br /&gt;
|-&lt;br /&gt;
| &amp;gt;= 500000000 || UNIX timestamp at which this transaction is locked&lt;br /&gt;
|}&lt;br /&gt;
A non-locked transaction must not be included in blocks, and it can be modified by broadcasting a new version before the time has expired (replacement is currently disabled in Bitcoin, however, so this is useless).&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
TxIn consists of the following fields:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 36 || previous_output || outpoint || The previous output transaction reference, as an OutPoint structure&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || script length || [[Protocol_specification#Variable_length_integer|var_int]] || The length of the signature script&lt;br /&gt;
|-&lt;br /&gt;
| ? || signature script || uchar[] || Computational Script for confirming transaction authorization&lt;br /&gt;
|-&lt;br /&gt;
| 4 || [http://bitcoin.stackexchange.com/q/2025/323 sequence] || uint32_t || Transaction version as defined by the sender. Intended for &amp;quot;replacement&amp;quot; of transactions when information is updated before inclusion into a block.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The OutPoint structure consists of the following fields:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash || char[32] || The hash of the referenced transaction.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || index || uint32_t || The index of the specific output in the transaction. The first output is 0, etc.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The Script structure consists of a series of pieces of information and operations related to the value of the transaction.&lt;br /&gt;
&lt;br /&gt;
(Structure to be expanded in the future… see script.h and script.cpp and [[Script]] for more information)&lt;br /&gt;
&lt;br /&gt;
The TxOut structure consists of the following fields:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 8 || value || uint64_t || Transaction Value&lt;br /&gt;
|-&lt;br /&gt;
| 1+ || pk_script length || [[Protocol_specification#Variable_length_integer|var_int]] || Length of the pk_script&lt;br /&gt;
|-&lt;br /&gt;
| ? || pk_script || uchar[] || Usually contains the public key as a Bitcoin script setting up conditions to claim this output.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Example &#039;&#039;tx&#039;&#039; message:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
000000	F9 BE B4 D9 74 78 00 00  00 00 00 00 00 00 00 00   ....tx..........&lt;br /&gt;
000010	02 01 00 00 E2 93 CD BE  01 00 00 00 01 6D BD DB   .............m..&lt;br /&gt;
000020	08 5B 1D 8A F7 51 84 F0  BC 01 FA D5 8D 12 66 E9   .[...Q........f.&lt;br /&gt;
000030	B6 3B 50 88 19 90 E4 B4  0D 6A EE 36 29 00 00 00   .;P......j.6)...&lt;br /&gt;
000040	00 8B 48 30 45 02 21 00  F3 58 1E 19 72 AE 8A C7   ..H0E.!..X..r...&lt;br /&gt;
000050	C7 36 7A 7A 25 3B C1 13  52 23 AD B9 A4 68 BB 3A   .6zz%;..R#...h.:&lt;br /&gt;
000060	59 23 3F 45 BC 57 83 80  02 20 59 AF 01 CA 17 D0   Y#?E.W... Y.....&lt;br /&gt;
000070	0E 41 83 7A 1D 58 E9 7A  A3 1B AE 58 4E DE C2 8D   .A.z.X.z...XN...&lt;br /&gt;
000080	35 BD 96 92 36 90 91 3B  AE 9A 01 41 04 9C 02 BF   5...6..;...A....&lt;br /&gt;
000090	C9 7E F2 36 CE 6D 8F E5  D9 40 13 C7 21 E9 15 98   .~.6.m...@..!...&lt;br /&gt;
0000A0	2A CD 2B 12 B6 5D 9B 7D  59 E2 0A 84 20 05 F8 FC   *.+..].}Y... ...&lt;br /&gt;
0000B0	4E 02 53 2E 87 3D 37 B9  6F 09 D6 D4 51 1A DA 8F   N.S..=7.o...Q...&lt;br /&gt;
0000C0	14 04 2F 46 61 4A 4C 70  C0 F1 4B EF F5 FF FF FF   ../FaJLp..K.....&lt;br /&gt;
0000D0	FF 02 40 4B 4C 00 00 00  00 00 19 76 A9 14 1A A0   ..@KL......v....&lt;br /&gt;
0000E0	CD 1C BE A6 E7 45 8A 7A  BA D5 12 A9 D9 EA 1A FB   .....E.z........&lt;br /&gt;
0000F0	22 5E 88 AC 80 FA E9 C7  00 00 00 00 19 76 A9 14   &amp;quot;^...........v..&lt;br /&gt;
000100	0E AB 5B EA 43 6A 04 84  CF AB 12 48 5E FD A0 B7   ..[.Cj.....H^...&lt;br /&gt;
000110	8B 4E CC 52 88 AC 00 00  00 00                     .N.R......&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Message header:&lt;br /&gt;
 F9 BE B4 D9                                       - main network magic bytes&lt;br /&gt;
 74 78 00 00 00 00 00 00 00 00 00 00               - &amp;quot;tx&amp;quot; command&lt;br /&gt;
 02 01 00 00                                       - payload is 258 bytes long&lt;br /&gt;
 E2 93 CD BE                                       - checksum of payload&lt;br /&gt;
&lt;br /&gt;
Transaction:&lt;br /&gt;
 01 00 00 00                                       - version&lt;br /&gt;
&lt;br /&gt;
Inputs:&lt;br /&gt;
 01                                                - number of transaction inputs&lt;br /&gt;
&lt;br /&gt;
Input 1:&lt;br /&gt;
 6D BD DB 08 5B 1D 8A F7  51 84 F0 BC 01 FA D5 8D  - previous output (outpoint)&lt;br /&gt;
 12 66 E9 B6 3B 50 88 19  90 E4 B4 0D 6A EE 36 29&lt;br /&gt;
 00 00 00 00&lt;br /&gt;
&lt;br /&gt;
 8B                                                - script is 139 bytes long&lt;br /&gt;
&lt;br /&gt;
 48 30 45 02 21 00 F3 58  1E 19 72 AE 8A C7 C7 36  - signature script (scriptSig)&lt;br /&gt;
 7A 7A 25 3B C1 13 52 23  AD B9 A4 68 BB 3A 59 23&lt;br /&gt;
 3F 45 BC 57 83 80 02 20  59 AF 01 CA 17 D0 0E 41&lt;br /&gt;
 83 7A 1D 58 E9 7A A3 1B  AE 58 4E DE C2 8D 35 BD&lt;br /&gt;
 96 92 36 90 91 3B AE 9A  01 41 04 9C 02 BF C9 7E&lt;br /&gt;
 F2 36 CE 6D 8F E5 D9 40  13 C7 21 E9 15 98 2A CD&lt;br /&gt;
 2B 12 B6 5D 9B 7D 59 E2  0A 84 20 05 F8 FC 4E 02&lt;br /&gt;
 53 2E 87 3D 37 B9 6F 09  D6 D4 51 1A DA 8F 14 04&lt;br /&gt;
 2F 46 61 4A 4C 70 C0 F1  4B EF F5&lt;br /&gt;
&lt;br /&gt;
 FF FF FF FF                                       - sequence&lt;br /&gt;
&lt;br /&gt;
Outputs:&lt;br /&gt;
 02                                                - 2 Output Transactions&lt;br /&gt;
&lt;br /&gt;
Output 1:&lt;br /&gt;
 40 4B 4C 00 00 00 00 00                           - 0.05 BTC (5000000)&lt;br /&gt;
 19                                                - pk_script is 25 bytes long&lt;br /&gt;
&lt;br /&gt;
 76 A9 14 1A A0 CD 1C BE  A6 E7 45 8A 7A BA D5 12  - pk_script&lt;br /&gt;
 A9 D9 EA 1A FB 22 5E 88  AC&lt;br /&gt;
&lt;br /&gt;
Output 2:&lt;br /&gt;
 80 FA E9 C7 00 00 00 00                           - 33.54 BTC (3354000000)&lt;br /&gt;
 19                                                - pk_script is 25 bytes long&lt;br /&gt;
&lt;br /&gt;
 76 A9 14 0E AB 5B EA 43  6A 04 84 CF AB 12 48 5E  - pk_script&lt;br /&gt;
 FD A0 B7 8B 4E CC 52 88  AC&lt;br /&gt;
&lt;br /&gt;
Locktime:&lt;br /&gt;
 00 00 00 00                                       - lock time&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== block ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;block&#039;&#039;&#039; message is sent in response to a getdata message which requests transaction information from a block hash.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || version || uint32_t || Block version information, based upon the software version creating this block&lt;br /&gt;
|-&lt;br /&gt;
| 32 || prev_block || char[32] || The hash value of the previous block this particular block references&lt;br /&gt;
|-&lt;br /&gt;
| 32 || merkle_root || char[32] || The reference to a Merkle tree collection which is a hash of all transactions related to this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || timestamp || uint32_t || A unix timestamp recording when this block was created (Currently limited to dates before the year 2106!)&lt;br /&gt;
|-&lt;br /&gt;
| 4 || bits || uint32_t || The calculated [[Difficulty|difficulty target]] being used for this block&lt;br /&gt;
|-&lt;br /&gt;
| 4 || nonce || uint32_t || The nonce used to generate this block… to allow variations of the header and compute different hashes&lt;br /&gt;
|-&lt;br /&gt;
| ? || txn_count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of transaction entries&lt;br /&gt;
|-&lt;br /&gt;
| ? || txns || tx[] || Block transactions, in format of &amp;quot;tx&amp;quot; command&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The SHA256 hash that identifies each block (and which must have a run of 0 bits) is calculated from the first 6 fields of this structure (version, prev_block, merkle_root, timestamp, bits, nonce, and standard SHA256 padding, making two 64-byte chunks in all) and &#039;&#039;not&#039;&#039; from the complete block. To calculate the hash, only two chunks need to be processed by the SHA256 algorithm. Since the &#039;&#039;nonce&#039;&#039; field is in the second chunk, the first chunk stays constant during mining and therefore only the second chunk needs to be processed. However, a Bitcoin hash is the hash of the hash, so two SHA256 rounds are needed for each mining iteration.&lt;br /&gt;
See [[Block hashing algorithm]] for details and an example.&lt;br /&gt;
&lt;br /&gt;
=== headers ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;headers&#039;&#039; packet returns block headers in response to a &#039;&#039;getheaders&#039;&#039; packet. &lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || count || [[Protocol_specification#Variable_length_integer|var_int]] || Number of block headers&lt;br /&gt;
|-&lt;br /&gt;
| 81x? || headers || [[Protocol_specification#Block_Headers|block_header]][] || [[Protocol_specification#Block_Headers|Block headers]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the block headers in this packet include a transaction count (a var_int, so there can be more than 81 bytes per header) as opposed to the block headers which are sent to miners.&lt;br /&gt;
&lt;br /&gt;
=== getaddr ===&lt;br /&gt;
&lt;br /&gt;
The getaddr message sends a request to a node asking for information about known active peers to help with identifying potential nodes in the network. The response to receiving this message is to transmit an addr message with one or more peers from a database of known active peers. The typical presumption is that a node is likely to be active if it has been sending a message within the last three hours.&lt;br /&gt;
&lt;br /&gt;
No additional data is transmitted with this message.&lt;br /&gt;
&lt;br /&gt;
=== checkorder ===&lt;br /&gt;
&lt;br /&gt;
This message is used for [[IP Transactions]], to ask the peer if it accepts such transactions and allow it to look at the content of the order.&lt;br /&gt;
&lt;br /&gt;
It contains a CWalletTx object&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| Fields from CMerkleTx&lt;br /&gt;
|-&lt;br /&gt;
| ? || hashBlock&lt;br /&gt;
|-&lt;br /&gt;
| ? || vMerkleBranch&lt;br /&gt;
|-&lt;br /&gt;
| ? || nIndex&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;4&amp;quot;| Fields from CWalletTx&lt;br /&gt;
|-&lt;br /&gt;
| ? || vtxPrev&lt;br /&gt;
|-&lt;br /&gt;
| ? || mapValue&lt;br /&gt;
|-&lt;br /&gt;
| ? || vOrderForm&lt;br /&gt;
|-&lt;br /&gt;
| ? || fTimeReceivedIsTxTime&lt;br /&gt;
|-&lt;br /&gt;
| ? || nTimeReceived&lt;br /&gt;
|-&lt;br /&gt;
| ? || fFromMe&lt;br /&gt;
|-&lt;br /&gt;
| ? || fSpent&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== submitorder ===&lt;br /&gt;
&lt;br /&gt;
Confirms an order has been submitted. &lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 32 || hash || char[32] || Hash of the transaction&lt;br /&gt;
|-&lt;br /&gt;
| ? || wallet_entry || CWalletTx || Same payload as checkorder&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== reply ===&lt;br /&gt;
&lt;br /&gt;
Generic reply for [[IP Transactions]]&lt;br /&gt;
&lt;br /&gt;
Payload:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || reply || uint32_t || reply code&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Possible values:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Value !! Name !! Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || SUCCESS || The IP Transaction can proceed (&#039;&#039;checkorder&#039;&#039;), or has been accepted (&#039;&#039;submitorder&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || WALLET_ERROR || AcceptWalletTransaction() failed&lt;br /&gt;
|-&lt;br /&gt;
| 2 || DENIED || IP Transactions are not accepted by this node&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== ping ===&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;ping&#039;&#039; message is sent primarily to confirm that the TCP/IP connection is still valid. An error in transmission is presumed to be a closed connection and the address is removed as a current peer. No reply is expected as a result of this message being sent nor any sort of action expected on the part of a client when it is used.&lt;br /&gt;
&lt;br /&gt;
=== alert ===&lt;br /&gt;
&lt;br /&gt;
An &#039;&#039;&#039;alert&#039;&#039;&#039; is sent between nodes to send a general notification message throughout the network. If the alert can be confirmed with the signature as having come from the the core development group of the Bitcoin software, the message is suggested to be displayed for end-users. Attempts to perform transactions, particularly automated transactions through the client, are suggested to be halted. The text in the Message string should be relayed to log files and any user interfaces.&lt;br /&gt;
&lt;br /&gt;
Alert format:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| ? || payload || var_str || Serialized alert payload&lt;br /&gt;
|-&lt;br /&gt;
| ? || signature || var_str || An ECDSA signature of the message&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The developers of Satoshi&#039;s client use this public key for signing alerts:&lt;br /&gt;
 04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284&lt;br /&gt;
 (hash) 1AGRxqDa5WjUKBwHB9XYEjmkv1ucoUUy1s&lt;br /&gt;
&lt;br /&gt;
The payload is serialized into a var_str to ensure that versions using incompatible alert formats can still relay alerts among one another. The current alert payload format is:&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Field Size !! Description !! Data type !! Comments&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Version || int32_t || Alert format version&lt;br /&gt;
|-&lt;br /&gt;
| 8 || RelayUntil || int64_t || The timestamp beyond which nodes should stop relaying this alert&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Expiration || int64_t || The timestamp beyond which this alert is no longer in effect and should be ignored&lt;br /&gt;
|-&lt;br /&gt;
| 4 || ID || int32_t || A unique ID number for this alert&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Cancel || int32_t || All alerts with an ID number less than or equal to this number should be canceled: deleted and not accepted in the future&lt;br /&gt;
|-&lt;br /&gt;
| ? || setCancel || set&amp;lt;int&amp;gt; || All alert IDs contained in this set should be canceled as above&lt;br /&gt;
|-&lt;br /&gt;
| 4 || MinVer || int32_t || This alert only applies to versions greater than or equal to this version. Other versions should still relay it.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || MaxVer || int32_t || This alert only applies to versions less than or equal to this version. Other versions should still relay it.&lt;br /&gt;
|-&lt;br /&gt;
| ? || setSubVer || set&amp;lt;string&amp;gt; || If this set contains any elements, then only nodes that have their subVer contained in this set are affected by the alert. Other versions should still relay it.&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Priority || int32_t || Relative priority compared to other alerts&lt;br /&gt;
|-&lt;br /&gt;
| ? || Comment || string || A comment on the alert that is not displayed&lt;br /&gt;
|-&lt;br /&gt;
| ? || StatusBar || string || The alert message that is displayed to the user&lt;br /&gt;
|-&lt;br /&gt;
| ? || Reserved || string || Reserved&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripting ==&lt;br /&gt;
&lt;br /&gt;
See [[script]].&lt;br /&gt;
&lt;br /&gt;
== Wireshark dissector ==&lt;br /&gt;
A dissector for wireshark is being developed at https://github.com/blueCommand/bitcoin-dissector&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Network]]&lt;br /&gt;
* [[Protocol rules]]&lt;br /&gt;
[[zh-cn:协议说明]]&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=BIP_UNOFFICIAL_DRAFT_0&amp;diff=22211</id>
		<title>BIP UNOFFICIAL DRAFT 0</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=BIP_UNOFFICIAL_DRAFT_0&amp;diff=22211"/>
		<updated>2012-01-15T02:39:18Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: documented exploit and changed status to rejected.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
  BIP: 17&lt;br /&gt;
  Title: OP_NO_SKIP&lt;br /&gt;
  Author: Ben Reeves &amp;lt;support@pi.uk.com&amp;gt;&lt;br /&gt;
  Status: Rejected&lt;br /&gt;
  Type: Standards Track&lt;br /&gt;
  Created: 14-01-2012&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Abstract==&lt;br /&gt;
&lt;br /&gt;
This BIP describes a new op code (&amp;quot;OP_NO_SKIP&amp;quot;) and a new type of standard transaction.&lt;br /&gt;
&lt;br /&gt;
==Motivation==&lt;br /&gt;
&lt;br /&gt;
The purpose of this propose is to provide pay to script functionality without making a standard templates a mandatory part of the scripting language.&lt;br /&gt;
&lt;br /&gt;
Quote BIP_0016:&lt;br /&gt;
&lt;br /&gt;
The purpose of pay-to-script-hash is to move the responsibility for supplying the conditions to redeem a transaction from the sender of the funds to the redeemer.&lt;br /&gt;
&lt;br /&gt;
The benefit is allowing a sender to fund any arbitrary transaction, no matter how complicated, using a fixed-length 20-byte hash that is short enough to scan from a QR code or easily copied and pasted.&lt;br /&gt;
&lt;br /&gt;
==Specification==&lt;br /&gt;
&lt;br /&gt;
OP_NOP1 will be redefined as OP_NO_SKIP and will behave as follows:&lt;br /&gt;
&lt;br /&gt;
* OP_NO_SKIP remains a null op on its own. &lt;br /&gt;
* Any &amp;quot;push data&amp;quot; operation immediately following an OP_NO_SKIP will push the data onto the stack as normal but will not advance the instruction pointer i.e. the data will be pushed onto the stack and executed after.&lt;br /&gt;
&lt;br /&gt;
Additionally a new standard scriptPubKey will be defined:&lt;br /&gt;
&lt;br /&gt;
   OP_CHECKMULTISIGVERIFY OP_HASH160 [20-byte-hash-value] OP_EQUAL&lt;br /&gt;
&lt;br /&gt;
Redeemed by a new standard scriptSig (M-of-N)&lt;br /&gt;
&lt;br /&gt;
   OP_0  &amp;lt;sig&amp;gt; OP_NO_SKIP &amp;lt;OP_SWAP {1 [pubkey1] [pubkey2] 2} &amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Example Execution==&lt;br /&gt;
&lt;br /&gt;
Basic example:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Stack !! Code&lt;br /&gt;
|-&lt;br /&gt;
| || OP_NO_SKIP OP_PUSHDATA1 1 OP_1NEGATE OP_ADD&lt;br /&gt;
|-&lt;br /&gt;
| || OP_PUSHDATA1 1 OP_1NEGATE  OP_ADD&lt;br /&gt;
|-&lt;br /&gt;
| 79 || OP_1NEGATE OP_ADD&lt;br /&gt;
|-&lt;br /&gt;
| 79 -1 || OP_ADD&lt;br /&gt;
|-&lt;br /&gt;
| 78 ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Pay to script example:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Stack !! Code&lt;br /&gt;
|-&lt;br /&gt;
| || 32 &amp;lt;sig&amp;gt; OP_NO_SKIP 22 &amp;lt;OP_SWAP 1 [pubkey] 2&amp;gt; OP_CHECKMULTISIGVERIFY OP_HASH160 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;sig&amp;gt; || OP_NO_SKIP 22 &amp;lt;OP_SWAP 1 [pubkey] 2&amp;gt; OP_CHECKMULTISIGVERIFY  OP_HASH160 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;sig&amp;gt; || 22 &amp;lt;OP_SWAP 1 [pubkey] 2&amp;gt; OP_CHECKMULTISIGVERIFY OP_HASH160 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;OP_SWAP 1 [pubkey] 2&amp;gt; || OP_SWAP 1 [pubkey] 2 OP_CHECKMULTISIGVERIFY OP_HASH160 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;OP_SWAP 1 [pubkey] 2&amp;gt; &amp;lt;sig&amp;gt; || 1 [pubkey] 2 OP_CHECKMULTISIGVERIFY OP_HASH160 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;OP_SWAP 1 [pubkey] 2&amp;gt; || OP_HASH160 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;scriptHashA&amp;gt; || 20 &amp;lt;scriptHash&amp;gt; OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;scriptHashA&amp;gt; &amp;lt;scriptHash&amp;gt; || OP_EQUAL &lt;br /&gt;
|-&lt;br /&gt;
| 1 ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Rationale==&lt;br /&gt;
&lt;br /&gt;
This BIP replaces BIP 12 (&amp;quot;P2SH&amp;quot;) and BIP 16, (&amp;quot;OP_EVAL&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
The rationale for pay to script functionality has been discussed in the other proposals, the general consensus is this functionality is desired and should be implemented ASAP.&lt;br /&gt;
&lt;br /&gt;
A number of potential issues have been found with the proposals thus far:&lt;br /&gt;
&lt;br /&gt;
* CHV/CHC require the scriptPubKey interacts with data from scriptSig which has not been push onto the stack&lt;br /&gt;
* OP_EVAL essentially makes the scripting language turing complete, something which Satoshi deliberately avoided during its design. &lt;br /&gt;
* P2SH requires that standard templates become a mandatory part of the scripting language, meaning they can never be fully depreciated in future.&lt;br /&gt;
&lt;br /&gt;
OP_NO_SKIP is designed to be a simple compromise that enables pay to script functionality without giving the language any extra expressive powers or violating the rules of a simple stack based language.&lt;br /&gt;
&lt;br /&gt;
==Backwards Compatibility==&lt;br /&gt;
&lt;br /&gt;
These transactions are non-standard to old implementations, which will (typically) not relay them or include them in blocks.&lt;br /&gt;
&lt;br /&gt;
Old implementations will push the script onto the stack and verify it&#039;s hash value matches, but will do no other validation. New client will push the script on to the stack AND execute it.&lt;br /&gt;
&lt;br /&gt;
Avoiding a block-chain split by malicious pay-to-script transactions requires careful handling of one case:&lt;br /&gt;
&lt;br /&gt;
* A pay-to-script-hash transaction that is invalid for new clients/miners but valid for old clients/miners.&lt;br /&gt;
&lt;br /&gt;
To gracefully upgrade and ensure no long-lasting block-chain split occurs, more than 50% of miners must support full validation of the new transaction type and must switch from the old validation rules to the new rules at the same time. &lt;br /&gt;
&lt;br /&gt;
To judge whether or not more than 50% of hashing power supports this BIP, miners are asked to upgrade their software and put the string &amp;quot;/OPNOSKIP/&amp;quot; in the input of the coinbase transaction for blocks that they create.&lt;br /&gt;
&lt;br /&gt;
On February 1, 2012, the block-chain will be examined to determine the number of blocks supporting pay-to-script-hash for the previous 7 days. If 550 or more contain &amp;quot;/OPNOSKIP/&amp;quot; in their coinbase, then all blocks with timestamps after 15 Feb 2012, 00:00:00 GMT shall have their pay-to-script-hash transactions fully validated. Approximately 1,000 blocks are created in a week; 550 should, therefore, be approximately 55% of the network supporting the new feature.&lt;br /&gt;
&lt;br /&gt;
If a majority of hashing power does not support the new validation rules, then rollout will be postponed (or rejected if it becomes clear that a majority will never be achieved).&lt;br /&gt;
&lt;br /&gt;
==Reference Implementation==&lt;br /&gt;
&lt;br /&gt;
https://github.com/zootreeves/bitcoin/commits/master&lt;br /&gt;
&lt;br /&gt;
==Reason for Rejection==&lt;br /&gt;
&lt;br /&gt;
Any miner can easily confiscate transactions by replacing the legitmate signature script:&lt;br /&gt;
&lt;br /&gt;
   OP_0  &amp;lt;sig&amp;gt; OP_NO_SKIP &amp;lt;OP_SWAP {1 [pubkey1] [pubkey2] 2} &amp;gt;&lt;br /&gt;
&lt;br /&gt;
with &lt;br /&gt;
&lt;br /&gt;
   &amp;lt;OP_SWAP {1 [pubkey1] [pubkey2] 2} &amp;gt; OP_0 &amp;lt;miner&#039;s_sig&amp;gt; OP_1 &amp;lt;miner&#039;s_pubkey&amp;gt; OP_1&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* https://bitcointalk.org/index.php?topic=46538&lt;br /&gt;
* The [[BIP 0013|Address format for Pay to Script Hash BIP]]&lt;br /&gt;
* M-of-N Multisignature Transactions [[BIP 0011|BIP 11]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=21318</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=21318"/>
		<updated>2011-12-27T06:40:01Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: documenting how OP_VERIF and OP_VERNOTIF behave in an unexecuted OP_IF branch&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some are currently disabled for security reasons.&lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|0x00&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|0x01-0x4b&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|0x4c&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|0x4d&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|0x4e&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|0x4f&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|0x51&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|0x52-0x60&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|0x61&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
|0x63&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
|0x64&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
|0x67&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
|0x68&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|0x69&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|0x6a&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|0x6b&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|0x6c&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|0x73&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the input is true or false, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|0x74&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|0x75&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|0x76&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|0x77&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|0x78&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|0x79&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|0x7a&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|0x7b&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|0x7c&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|0x7d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|0x6d&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|0x6e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|0x6f&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|0x70&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|0x71&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|0x72&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|0x7e&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|0x7f&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|0x80&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|0x81&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|0x82&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|0x83&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|0x84&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|0x85&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|0x86&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|0x87&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|0x88&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|0x8b&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|0x8c&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|0x8d&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|0x8e&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|0x8f&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|0x90&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|0x91&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|0x92&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|0x93&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|0x94&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|0x95&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|0x96&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|0x97&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|0x98&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|0x99&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|0x9a&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|0x9b&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|0x9c&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|0x9d&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|0x9e&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|0x9f&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|0xa0&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|0xa1&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|0xa2&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|0xa3&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|0xa4&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|0xa5&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|0xa6&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|0xa7&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|0xa8&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|0xa9&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|0xaa&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|0xab&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|0xac&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|0xad&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|0xae&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|0xaf&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|0xfd&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|0xfe&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|0xff&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Hex&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|0x50&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|0x62&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|0x65&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|0x66&lt;br /&gt;
|Transaction is invalid even when occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|0x89&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|0x8a&lt;br /&gt;
|Transaction is invalid unless occuring in an unexecuted OP_IF branch&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|0xb0-0xb9&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Standard Generation / transaction to IP address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Transaction with a message ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to add arbitrary data to any transaction by just adding some data along with OP_DROP. Scripts are limited to 10,000 bytes and 201 instructions/values, and each individual instruction/value is limited to 520 bytes.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt;&lt;br /&gt;
|OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|The message has been put.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|Top stack item has been removed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
|Checking signature against the public key.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Stack holds the value of signature check now.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example non standard transaction on Testnet ===&lt;br /&gt;
&lt;br /&gt;
These 2 links below show a non standard transaction. It just prepends the hex of &amp;quot;bob&amp;quot; and the operation OP_DROP&lt;br /&gt;
which just removes it. As you can see they can be spent as normal.&lt;br /&gt;
&lt;br /&gt;
Input non-std transaction:&lt;br /&gt;
http://blockexplorer.com/testnet/t/6ttfeb55B1&lt;br /&gt;
&lt;br /&gt;
Spent by:&lt;br /&gt;
http://blockexplorer.com/testnet/t/AFdRB1CHS3&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19413</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19413"/>
		<updated>2011-11-15T04:10:39Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: Notes on representation of data types&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian.&lt;br /&gt;
&lt;br /&gt;
The stacks hold byte vectors.  Byte vectors are interpreted as little-endian integers with the most significant bit determining the sign of the integer.  Thus 0x81 represents -1.  0x80 is another representation of zero (so called negative 0).  Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some are currently disabled for security reasons.&lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the input is true or false, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Standard Generation / transaction to IP address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Transaction with a message ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to add arbitrary data to any transaction by just adding some data along with OP_DROP. Scripts are limited to 10,000 bytes and 201 instructions/values, and each individual instruction/value is limited to 520 bytes.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt;&lt;br /&gt;
|OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|The message has been put.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|Top stack item has been removed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
|Checking signature against the public key.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Stack holds the value of signature check now.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example non standard transaction on Testnet ===&lt;br /&gt;
&lt;br /&gt;
These 2 links below show a non standard transaction. It just prepends the hex of &amp;quot;bob&amp;quot; and the operation OP_DROP&lt;br /&gt;
which just removes it. As you can see they can be spent as normal.&lt;br /&gt;
&lt;br /&gt;
Input non-std transaction:&lt;br /&gt;
http://blockexplorer.com/testnet/t/6ttfeb55B1&lt;br /&gt;
&lt;br /&gt;
Spent by:&lt;br /&gt;
http://blockexplorer.com/testnet/t/AFdRB1CHS3&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19406</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19406"/>
		<updated>2011-11-15T01:26:42Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: OP_ELSE can occur multiple times in an IF statement.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian. (Is all data, also?)&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some are currently disabled for security reasons.&lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are and if the preceding OP_IF or OP_NOTIF or OP_ELSE was executed then these statements are not. &lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]]* endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the input is true or false, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Standard Generation / transaction to IP address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Transaction with a message ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to add arbitrary data to any transaction by just adding some data along with OP_DROP. Scripts are limited to 10,000 bytes and 201 instructions/values, and each individual instruction/value is limited to 520 bytes.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt;&lt;br /&gt;
|OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|The message has been put.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|Top stack item has been removed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
|Checking signature against the public key.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Stack holds the value of signature check now.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example non standard transaction on Testnet ===&lt;br /&gt;
&lt;br /&gt;
These 2 links below show a non standard transaction. It just prepends the hex of &amp;quot;bob&amp;quot; and the operation OP_DROP&lt;br /&gt;
which just removes it. As you can see they can be spent as normal.&lt;br /&gt;
&lt;br /&gt;
Input non-std transaction:&lt;br /&gt;
http://blockexplorer.com/testnet/t/6ttfeb55B1&lt;br /&gt;
&lt;br /&gt;
Spent by:&lt;br /&gt;
http://blockexplorer.com/testnet/t/AFdRB1CHS3&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19405</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19405"/>
		<updated>2011-11-15T01:19:20Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: scripting language does have nesting if statements.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian. (Is all data, also?)&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some are currently disabled for security reasons.&lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF was not executed then these statements are.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the input is true or false, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Standard Generation / transaction to IP address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Transaction with a message ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to add arbitrary data to any transaction by just adding some data along with OP_DROP. Scripts are limited to 10,000 bytes and 201 instructions/values, and each individual instruction/value is limited to 520 bytes.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt;&lt;br /&gt;
|OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|The message has been put.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|Top stack item has been removed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
|Checking signature against the public key.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Stack holds the value of signature check now.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example non standard transaction on Testnet ===&lt;br /&gt;
&lt;br /&gt;
These 2 links below show a non standard transaction. It just prepends the hex of &amp;quot;bob&amp;quot; and the operation OP_DROP&lt;br /&gt;
which just removes it. As you can see they can be spent as normal.&lt;br /&gt;
&lt;br /&gt;
Input non-std transaction:&lt;br /&gt;
http://blockexplorer.com/testnet/t/6ttfeb55B1&lt;br /&gt;
&lt;br /&gt;
Spent by:&lt;br /&gt;
http://blockexplorer.com/testnet/t/AFdRB1CHS3&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
	<entry>
		<id>https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19404</id>
		<title>Script</title>
		<link rel="alternate" type="text/html" href="https://en.bitcoin.it/w/index.php?title=Script&amp;diff=19404"/>
		<updated>2011-11-15T01:15:40Z</updated>

		<summary type="html">&lt;p&gt;Roconnor: true is anything non-zero&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Bitcoin uses a scripting system for [[transactions]]. [[Wikipedia:FORTH|Forth]]-like, Script is simple, stack-based, and processed from left to right. It is purposefully not Turing-complete, with no loops or nesting &#039;&#039;if&#039;&#039; statements.&lt;br /&gt;
&lt;br /&gt;
A script is essentially a list of instructions recorded with each transaction that describe how the next person wanting to spend the Bitcoins being transferred can gain access to them.  The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide&lt;br /&gt;
# a public key that, when hashed, yields destination address D embedded in the script, and&lt;br /&gt;
# a signature to show evidence of the private key corresponding to the public key just provided.&lt;br /&gt;
&lt;br /&gt;
Scripting provides the flexibility to change the parameters of what&#039;s needed to spend transferred Bitcoins.  For example, the scripting system could be used to require two private keys, or a combination of several, or even no keys at all.&lt;br /&gt;
&lt;br /&gt;
A transaction is valid if nothing in the combined script triggers failure and the top stack item is true (non-zero).  The party who originally &#039;&#039;sent&#039;&#039; the Bitcoins now being spent, dictates the script operations that will occur &#039;&#039;last&#039;&#039; in order to release them for use in another transaction.  The party wanting to spend them must provide the input(s) to the previously recorded script that results in those operations occurring last leaving behind true (non-zero).&lt;br /&gt;
&lt;br /&gt;
Scripts are big-endian. (Is all data, also?)&lt;br /&gt;
&lt;br /&gt;
== Words ==&lt;br /&gt;
This is a list of all Script words (commands/functions). Some are currently disabled for security reasons.&lt;br /&gt;
&lt;br /&gt;
True=1 and False=0.&lt;br /&gt;
&lt;br /&gt;
=== Constants ===&lt;br /&gt;
When talking about scripts, these value-pushing words are usually omitted.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_0, OP_FALSE&lt;br /&gt;
|0&lt;br /&gt;
|Nothing.&lt;br /&gt;
|(empty value)&lt;br /&gt;
|An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)&lt;br /&gt;
|-&lt;br /&gt;
|N/A&lt;br /&gt;
|1-75&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next &#039;&#039;opcode&#039;&#039; bytes is data to be pushed onto the stack&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA1&lt;br /&gt;
|76&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next byte contains the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA2&lt;br /&gt;
|77&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next two bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUSHDATA4&lt;br /&gt;
|78&lt;br /&gt;
|(special)&lt;br /&gt;
|data&lt;br /&gt;
|The next four bytes contain the number of bytes to be pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1NEGATE&lt;br /&gt;
|79&lt;br /&gt;
|Nothing.&lt;br /&gt;
| -1&lt;br /&gt;
|The number -1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1, OP_TRUE&lt;br /&gt;
|81&lt;br /&gt;
|Nothing.&lt;br /&gt;
|1&lt;br /&gt;
|The number 1 is pushed onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2-OP_16&lt;br /&gt;
|82-96&lt;br /&gt;
|Nothing.&lt;br /&gt;
|2-16&lt;br /&gt;
|The number in the word name (2-16) is pushed onto the stack.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Flow control ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP&lt;br /&gt;
|97&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|Does nothing.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IF&lt;br /&gt;
|99&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|If the top stack value is not 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOTIF&lt;br /&gt;
|100&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|If the top stack value is 0, the statements are executed. The top stack value is removed.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ELSE&lt;br /&gt;
|103&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|If the preceding OP_IF or OP_NOTIF was not executed then these statements are.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ENDIF&lt;br /&gt;
|104&lt;br /&gt;
| colspan=&amp;quot;2&amp;quot;|&amp;lt;expression&amp;gt; if [statements] [else [statements]] endif&lt;br /&gt;
|Ends an if/else block.&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIFY&lt;br /&gt;
|105&lt;br /&gt;
|True / false&lt;br /&gt;
|Nothing / False&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039; if top stack value is not true. True is removed, but false is not.&lt;br /&gt;
|-&lt;br /&gt;
|OP_RETURN&lt;br /&gt;
|106&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|&#039;&#039;&#039;Marks transaction as invalid&#039;&#039;&#039;. &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Stack ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_TOALTSTACK&lt;br /&gt;
|107&lt;br /&gt;
|x1&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|Puts the input onto the top of the alt stack. Removes it from the main stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_FROMALTSTACK&lt;br /&gt;
|108&lt;br /&gt;
|(alt)x1&lt;br /&gt;
|x1&lt;br /&gt;
|Puts the input onto the top of the main stack. Removes it from the alt stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_IFDUP&lt;br /&gt;
|115&lt;br /&gt;
|x&lt;br /&gt;
|x / x x&lt;br /&gt;
|If the input is true or false, duplicate it.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DEPTH&lt;br /&gt;
|116&lt;br /&gt;
|Nothing&lt;br /&gt;
|&amp;lt;Stack size&amp;gt;&lt;br /&gt;
|Puts the number of stack items onto the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DROP&lt;br /&gt;
|117&lt;br /&gt;
|x&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_DUP&lt;br /&gt;
|118&lt;br /&gt;
|x&lt;br /&gt;
|x x&lt;br /&gt;
|Duplicates the top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NIP&lt;br /&gt;
|119&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2&lt;br /&gt;
|Removes the second-to-top stack item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_OVER&lt;br /&gt;
|120&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1&lt;br /&gt;
|Copies the second-to-top stack item to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PICK&lt;br /&gt;
|121&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|xn ... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is copied to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROLL&lt;br /&gt;
|122&lt;br /&gt;
|xn ... x2 x1 x0 &amp;lt;n&amp;gt;&lt;br /&gt;
|... x2 x1 x0 xn&lt;br /&gt;
|The item &#039;&#039;n&#039;&#039; back in the stack is moved to the top.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ROT&lt;br /&gt;
|123&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x2 x3 x1&lt;br /&gt;
|The top three items on the stack are rotated to the left.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SWAP&lt;br /&gt;
|124&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1&lt;br /&gt;
|The top two items on the stack are swapped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_TUCK&lt;br /&gt;
|125&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x2 x1 x2&lt;br /&gt;
|The item at the top of the stack is copied and inserted before the second-to-top item.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DROP&lt;br /&gt;
|109&lt;br /&gt;
|x1 x2&lt;br /&gt;
|Nothing&lt;br /&gt;
|Removes the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DUP&lt;br /&gt;
|110&lt;br /&gt;
|x1 x2&lt;br /&gt;
|x1 x2 x1 x2&lt;br /&gt;
|Duplicates the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_3DUP&lt;br /&gt;
|111&lt;br /&gt;
|x1 x2 x3&lt;br /&gt;
|x1 x2 x3 x1 x2 x3&lt;br /&gt;
|Duplicates the top three stack items.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2OVER&lt;br /&gt;
|112&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x1 x2 x3 x4 x1 x2&lt;br /&gt;
|Copies the pair of items two spaces back in the stack to the front.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2ROT&lt;br /&gt;
|113&lt;br /&gt;
|x1 x2 x3 x4 x5 x6&lt;br /&gt;
|x3 x4 x5 x6 x1 x2&lt;br /&gt;
|The fifth and sixth items back are moved to the top of the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2SWAP&lt;br /&gt;
|114&lt;br /&gt;
|x1 x2 x3 x4&lt;br /&gt;
|x3 x4 x1 x2&lt;br /&gt;
|Swaps the top two pairs of items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Splice ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_CAT&lt;br /&gt;
|126&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Concatenates two strings. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUBSTR&lt;br /&gt;
|127&lt;br /&gt;
|in begin size&lt;br /&gt;
|out&lt;br /&gt;
|Returns a section of a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LEFT&lt;br /&gt;
|128&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters left of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIGHT&lt;br /&gt;
|129&lt;br /&gt;
|in size&lt;br /&gt;
|out&lt;br /&gt;
|Keeps only characters right of the specified point in a string. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_SIZE&lt;br /&gt;
|130&lt;br /&gt;
|in&lt;br /&gt;
|in size&lt;br /&gt;
|Returns the length of the input string.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Bitwise logic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVERT&lt;br /&gt;
|131&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Flips all of the bits in the input. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_AND&lt;br /&gt;
|132&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;and&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_OR&lt;br /&gt;
|133&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_XOR&lt;br /&gt;
|134&lt;br /&gt;
|x1 x2&lt;br /&gt;
|out&lt;br /&gt;
|Boolean &#039;&#039;exclusive or&#039;&#039; between each bit in the inputs. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUAL&lt;br /&gt;
|135&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Returns 1 if the inputs are exactly equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_EQUALVERIFY&lt;br /&gt;
|136&lt;br /&gt;
|x1 x2&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_EQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Arithmetic ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_1ADD&lt;br /&gt;
|139&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is added to the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_1SUB&lt;br /&gt;
|140&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|1 is subtracted from the input.&lt;br /&gt;
|-&lt;br /&gt;
|OP_2MUL&lt;br /&gt;
|141&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is multiplied by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_2DIV&lt;br /&gt;
|142&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is divided by 2. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_NEGATE&lt;br /&gt;
|143&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The sign of the input is flipped.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ABS&lt;br /&gt;
|144&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|The input is made positive.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOT&lt;br /&gt;
|145&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|If the input is 0 or 1, it is flipped. Otherwise the output will be 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_0NOTEQUAL&lt;br /&gt;
|146&lt;br /&gt;
|in&lt;br /&gt;
|out&lt;br /&gt;
|Returns 0 if the input is 0. 1 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_ADD&lt;br /&gt;
|147&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is added to b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SUB&lt;br /&gt;
|148&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|b is subtracted from a.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MUL&lt;br /&gt;
|149&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is multiplied by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_DIV&lt;br /&gt;
|150&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|a is divided by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_MOD&lt;br /&gt;
|151&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the remainder after dividing a by b. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_LSHIFT&lt;br /&gt;
|152&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a left b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_RSHIFT&lt;br /&gt;
|153&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Shifts a right b bits, preserving sign. &#039;&#039;Currently disabled.&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLAND&lt;br /&gt;
|154&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If both a and b are not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_BOOLOR&lt;br /&gt;
|155&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|If a or b is not 0, the output is 1. Otherwise 0.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUAL&lt;br /&gt;
|156&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMEQUALVERIFY&lt;br /&gt;
|157&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_NUMNOTEQUAL&lt;br /&gt;
|158&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if the numbers are not equal, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHAN&lt;br /&gt;
|159&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHAN&lt;br /&gt;
|160&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_LESSTHANOREQUAL&lt;br /&gt;
|161&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is less than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_GREATERTHANOREQUAL&lt;br /&gt;
|162&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if a is greater than or equal to b, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MIN&lt;br /&gt;
|163&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the smaller of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_MAX&lt;br /&gt;
|164&lt;br /&gt;
|a b&lt;br /&gt;
|out&lt;br /&gt;
|Returns the larger of a and b.&lt;br /&gt;
|-&lt;br /&gt;
|OP_WITHIN&lt;br /&gt;
|165&lt;br /&gt;
|x min max&lt;br /&gt;
|out&lt;br /&gt;
|Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Crypto ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Input&lt;br /&gt;
!Output&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_RIPEMD160&lt;br /&gt;
|166&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA1&lt;br /&gt;
|167&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-1.&lt;br /&gt;
|-&lt;br /&gt;
|OP_SHA256&lt;br /&gt;
|168&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed using SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH160&lt;br /&gt;
|169&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed twice: first with SHA-256 and then with RIPEMD-160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_HASH256&lt;br /&gt;
|170&lt;br /&gt;
|in&lt;br /&gt;
|hash&lt;br /&gt;
|The input is hashed two times with SHA-256.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CODESEPARATOR&lt;br /&gt;
|171&lt;br /&gt;
|Nothing&lt;br /&gt;
|Nothing&lt;br /&gt;
|All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.&lt;br /&gt;
|-&lt;br /&gt;
|[[OP_CHECKSIG]]&lt;br /&gt;
|172&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|The entire transaction&#039;s outputs, inputs, and script (from the most recently-executed OP_CODESEPARATOR to the end) are hashed. The signature used by OP_CHECKSIG must be a valid signature for this hash and public key. If it is, 1 is returned, 0 otherwise.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKSIGVERIFY&lt;br /&gt;
|173&lt;br /&gt;
|sig pubkey&lt;br /&gt;
|True / false&lt;br /&gt;
|Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIG&lt;br /&gt;
|174&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|For each signature and public key pair, OP_CHECKSIG is executed. If more public keys than signatures are listed, some key/sig pairs can fail. All signatures need to match a public key. If all signatures are valid, 1 is returned, 0 otherwise. Due to a bug, one extra unused value is removed from the stack.&lt;br /&gt;
|-&lt;br /&gt;
|OP_CHECKMULTISIGVERIFY&lt;br /&gt;
|175&lt;br /&gt;
|x sig1 sig2 ... &amp;lt;number of signatures&amp;gt; pub1 pub2 ... &amp;lt;number of public keys&amp;gt;&lt;br /&gt;
|True / False&lt;br /&gt;
|Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Pseudo-words===&lt;br /&gt;
These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEYHASH&lt;br /&gt;
|253&lt;br /&gt;
|Represents a public key hashed with OP_HASH160.&lt;br /&gt;
|-&lt;br /&gt;
|OP_PUBKEY&lt;br /&gt;
|254&lt;br /&gt;
|Represents a public key compatible with OP_CHECKSIG.&lt;br /&gt;
|-&lt;br /&gt;
|OP_INVALIDOPCODE&lt;br /&gt;
|255&lt;br /&gt;
|Matches any opcode that is not yet assigned.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Reserved words ===&lt;br /&gt;
Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
!Word&lt;br /&gt;
!Opcode&lt;br /&gt;
!When used...&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED&lt;br /&gt;
|80&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VER&lt;br /&gt;
|98&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERIF&lt;br /&gt;
|101&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_VERNOTIF&lt;br /&gt;
|102&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED1&lt;br /&gt;
|137&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_RESERVED2&lt;br /&gt;
|138&lt;br /&gt;
|Transaction is invalid&lt;br /&gt;
|-&lt;br /&gt;
|OP_NOP1-OP_NOP10&lt;br /&gt;
|176-185&lt;br /&gt;
|The word is ignored.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Scripts ==&lt;br /&gt;
This is a list of interesting scripts. Keep in mind that all constants actually use the data-pushing commands above.&lt;br /&gt;
&lt;br /&gt;
=== Standard Transaction to Bitcoin address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To demonstrate how scripts look on the wire, here is a raw scriptPubKey:&lt;br /&gt;
&amp;lt;pre&amp;gt;  76       A9             14&lt;br /&gt;
OP_DUP OP_HASH160    Bytes to push&lt;br /&gt;
&lt;br /&gt;
89 AB CD EF AB BA AB BA AB BA AB BA AB BA AB BA AB BA AB BA   88         AC&lt;br /&gt;
                      Data to push                     OP_EQUALVERIFY OP_CHECKSIG&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is how each word is processed:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
| &amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_DUP OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_HASH160 &amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG &lt;br /&gt;
| Top stack item is duplicated.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt;&lt;br /&gt;
|&amp;lt;pubKeyHash&amp;gt; OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Top stack item is hashed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; &amp;lt;pubHashA&amp;gt; &amp;lt;pubKeyHash&amp;gt;&lt;br /&gt;
|OP_EQUALVERIFY OP_CHECKSIG&lt;br /&gt;
| Constant added.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
| Equality is checked between the top two stack items.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Standard Generation / transaction to IP address ===&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checking process:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig and scriptPubKey are combined.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
| OP_CHECKSIG&lt;br /&gt;
|Constants are added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Signature is checked for top two stack items.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Transaction with a message ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to add arbitrary data to any transaction by just adding some data along with OP_DROP. Scripts are limited to 10,000 bytes and 201 instructions/values, and each individual instruction/value is limited to 520 bytes.&lt;br /&gt;
&lt;br /&gt;
 scriptPubKey: &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
 scriptSig: &amp;lt;sig&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
|-&lt;br /&gt;
! Stack &lt;br /&gt;
! Script &lt;br /&gt;
! Description &lt;br /&gt;
|-&lt;br /&gt;
|Empty.&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;message&amp;gt; OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|scriptSig added to the stack.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;message&amp;gt;&lt;br /&gt;
|OP_DROP &amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|The message has been put.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt;&lt;br /&gt;
|&amp;lt;pubKey&amp;gt; OP_CHECKSIG&lt;br /&gt;
|Top stack item has been removed.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;sig&amp;gt; &amp;lt;pubKey&amp;gt;&lt;br /&gt;
|OP_CHECKSIG&lt;br /&gt;
|Checking signature against the public key.&lt;br /&gt;
|-&lt;br /&gt;
|true&lt;br /&gt;
|Empty.&lt;br /&gt;
|Stack holds the value of signature check now.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Example non standard transaction on Testnet ===&lt;br /&gt;
&lt;br /&gt;
These 2 links below show a non standard transaction. It just prepends the hex of &amp;quot;bob&amp;quot; and the operation OP_DROP&lt;br /&gt;
which just removes it. As you can see they can be spent as normal.&lt;br /&gt;
&lt;br /&gt;
Input non-std transaction:&lt;br /&gt;
http://blockexplorer.com/testnet/t/6ttfeb55B1&lt;br /&gt;
&lt;br /&gt;
Spent by:&lt;br /&gt;
http://blockexplorer.com/testnet/t/AFdRB1CHS3&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
* [[Contracts]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Technical]]&lt;br /&gt;
[[Category:Vocabulary]]&lt;/div&gt;</summary>
		<author><name>Roconnor</name></author>
	</entry>
</feed>