Skip to content

Latest commit

History

11 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

StackBasedScriptingLanguage

Implementation of stack based scripting language for validation of transactions(clearing)

Constants

WordOpcodeHexInputOutputDescription
OP_0, OP_FALSE00x00Nothing.(empty value)An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)
N/A1-750x01-0x4b(special)dataThe next opcode bytes is data to be pushed onto the stack
OP_PUSHDATA1760x4c(special)dataThe next byte contains the number of bytes to be pushed onto the stack.
OP_PUSHDATA2770x4d(special)dataThe next two bytes contain the number of bytes to be pushed onto the stack in little endian order.
OP_PUSHDATA4780x4e(special)dataThe next four bytes contain the number of bytes to be pushed onto the stack in little endian order.
OP_1NEGATE790x4fNothing.-1The number -1 is pushed onto the stack.
OP_1, OP_TRUE 810x51Nothing.1The number 1 is pushed onto the stack.
OP_2-OP_1682-960x52-0x60Nothing.2-16The number in the word name (2-16) is pushed onto the stack.

Flow control

WordOpcodeHexInputOutputDescription
OP_NOP970x61NothingNothingDoes nothing.
OP_IF990x63 if [statements] [else [statements]]* endif if [statements] [else [statements]]* endifIf the top stack value is not False, the statements are executed. The top stack value is removed.
OP_NOTIF1000x64 notif [statements] [else [statements]]* endif notif [statements] [else [statements]]* endifIf the top stack value is False, the statements are executed. The top stack value is removed.
OP_ELSE1030x67 if [statements] [else [statements]]* endif if [statements] [else [statements]]* endifIf 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.
OP_ENDIF1040x68 if [statements] [else [statements]]* endif if [statements] [else [statements]]* endifEnds an if/else block. All blocks must end, or the transaction is invalid. An OP_ENDIF without OP_IF earlier is also invalid.
OP_VERIFY1050x69True / falseNothing / failMarks transaction as invalid if top stack value is not true. The top stack value is removed.
OP_RETURN1060x6aNothingfailMarks transaction as invalid. Since bitcoin 0.9, 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 data. Such outputs are provably unspendable and specially discarded from storage in the UTXO set, reducing their cost to the network. Since 0.12, standard relay rules allow a single output with OP_RETURN, that contains any sequence of push statements (or OP_RESERVED[1]) after the OP_RETURN provided the total scriptPubKey length is at most 83 bytes.

Stack

WordOpcodeHexInputOutputDescription
OP_TOALTSTACK1070x6bx1(alt)x1Puts the input onto the top of the alt stack. Removes it from the main stack.
OP_FROMALTSTACK1080x6c(alt)x1x1Puts the input onto the top of the main stack. Removes it from the alt stack.
OP_IFDUP1150x73xx / x xIf the top stack value is not 0, duplicate it.
OP_DEPTH1160x74NothingPuts the number of stack items onto the stack.
OP_DROP1170x75xNothingRemoves the top stack item.
OP_DUP1180x76xx xDuplicates the top stack item.
OP_NIP1190x77x1 x2x2Removes the second-to-top stack item.
OP_OVER1200x78x1 x2x1 x2 x1Copies the second-to-top stack item to the top.
OP_PICK1210x79xn ... x2 x1 x0 xn ... x2 x1 x0 xnThe item n back in the stack is copied to the top.
OP_ROLL1220x7axn ... x2 x1 x0 ... x2 x1 x0 xnThe item n back in the stack is moved to the top.
OP_ROT1230x7bx1 x2 x3x2 x3 x1The top three items on the stack are rotated to the left.
OP_SWAP1240x7cx1 x2x2 x1The top two items on the stack are swapped.
OP_TUCK1250x7dx1 x2x2 x1 x2The item at the top of the stack is copied and inserted before the second-to-top item.
OP_2DROP1090x6dx1 x2NothingRemoves the top two stack items.
OP_2DUP1100x6ex1 x2x1 x2 x1 x2Duplicates the top two stack items.
OP_3DUP1110x6fx1 x2 x3x1 x2 x3 x1 x2 x3Duplicates the top three stack items.
OP_2OVER1120x70x1 x2 x3 x4x1 x2 x3 x4 x1 x2Copies the pair of items two spaces back in the stack to the front.
OP_2ROT1130x71x1 x2 x3 x4 x5 x6x3 x4 x5 x6 x1 x2The fifth and sixth items back are moved to the top of the stack.
OP_2SWAP1140x72x1 x2 x3 x4x3 x4 x1 x2Swaps the top two pairs of items.

About

Implementation of stack based scripting language for validation of transactions(clearing)

Resources

Stars

2 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages