-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopcodes.bscript
More file actions
134 lines (113 loc) Β· 3.01 KB
/
opcodes.bscript
File metadata and controls
134 lines (113 loc) Β· 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// ========================================================
// CONSTANTS
OP_0 β
OP_FALSE
// Stack :
// let a = bytes[] ---push--> STACK[]
// STACK[ a ]
NO_WORD // but opcode given a value β
// Stack :
// 0x05 ---push--> STACK[]
// STACK[ 0x05 ]
OP_PUSHDATA1 [β οΈ deprecated]
// Eg ==>
// OP_PUSHDATA1
// Input :
// 0A
// 00112233445566778899
// 0A, 00112233445566778899
// [bytes size to be pushed into stack], [data]
// Stack :
// 10_bytes(00112233445566778899) ---push--> STACK[]
// STACK[ 00112233445566778899 ]
OP_PUSHDATA2 [β οΈ deprecated]
// Eg ==>
// OP_PUSHDATA2
// Input :
// 0A00
// 00112233445566778899
// [bytes size (2 bytes representation) to be pushed into stack (little endian format)], [data]
// Stack :
// 10_bytes(00112233445566778899) ---push--> STACK[]
// STACK[ 00112233445566778899 ]
OP_PUSHDATA4 [β οΈ deprecated]
// Eg ==>
// OP_PUSHDATA4
// Input :
// 0A000000
// 00112233445566778899
// [bytes size (4 bytes representation) to be pushed into stack (little endian format)], [data]
// Stack :
// 10_bytes(00112233445566778899) ---push--> STACK[]
// STACK[ 00112233445566778899 ]
OP_1NEGATE
// Stack :
// -1 ---push--> STACK[]
// STACK[ -1 ]
OP_1
OP_TRUE β
// Stack :
// 1 ---push--> STACK[]
// STACK[ 1 ]
OP_2 // till OP_16 β
// Stack :
// Pushes the number into the stack
// OP_4
// STACK[ 4 ]
OP_RESERVED β
// Terminates the program immediately
// ========================================================
// FLOW CONTROL β
// <condition> OP_IF
// <script if condition is true>
// OP_ELSE
// <script if condition is false>
// OP_ENDIF
/*
if(condition) {
2
}
*/
OP_1 OP_IF OP_2 OP_ENDIF
/*
if(condition) {
2
}else{
3
}
*/
OP_0 OP_IF OP_2 OP_ELSE OP_3 OP_ENDIF
/*
!if(condition) {
2
}
*/
OP_0 OP_NOTIF OP_2 OP_ENDIF
/*
!if(condition) {
2
}else{
3
}
*/
OP_1 OP_IF OP_2 OP_ELSE OP_3 OP_ENDIF
// ========================================================
OP_VERIFY β
// - Marks transaction as invalid if top stack value is not true. The top stack value is removed.
// ========================================================
OP_RETURN β
// - OP_RETURN can also be used to create "False Return" outputs with a scriptPubKey consisting of OP_FALSE OP_RETURN followed by data.
// - Such outputs are provably unspendable and should be given a value of zero Satoshis. These outputs can be pruned from storage in the UTXO set, reducing its size.
// - Currently the BitcoinSV network supports multiple FALSE RETURN outputs in a given transaction with each one capable of holding up to 100kB of data. After the Genesis upgrade in 2020 miners will be free to mine transactions containing FALSE RETURN outputs of any size.
// ========================================================
OP_EQUAL β
// - Returns 1 if the inputs are exactly equal, 0 otherwise.
// => OP_EQUAL
// => STACK = [ 1 1 ]
// => STACK = [ 1 2 ]
// ...
// STACK = [ 1 ]
// STACK = [ 0 ] !! FAILED
// ========================================================
OP_EQUALVERIFY β
// - same as OP_EQUAL but (OP_EQUAL + OP_VERIFY)