smartledger-bsv 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +123 -1
  2. package/README.md +233 -277
  3. package/bsv.bundle.js +39 -0
  4. package/bsv.min.js +8 -8
  5. package/docs/ADVANCED_COVENANT_DEVELOPMENT.md +533 -0
  6. package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +169 -0
  7. package/docs/CUSTOM_SCRIPT_DEVELOPMENT.md +320 -0
  8. package/docs/README.md +201 -0
  9. package/docs/block.md +46 -0
  10. package/docs/ecies.md +102 -0
  11. package/docs/index.md +104 -0
  12. package/docs/nchain.md +958 -0
  13. package/docs/networks.md +55 -0
  14. package/docs/preimage.md +126 -0
  15. package/docs/script.md +139 -0
  16. package/docs/transaction.md +174 -0
  17. package/docs/unspentoutput.md +32 -0
  18. package/examples/README.md +200 -0
  19. package/examples/basic/transaction-creation.js +534 -0
  20. package/examples/basic/transaction_signature_api_gap.js +178 -0
  21. package/examples/covenants/advanced_covenant_demo.js +219 -0
  22. package/examples/covenants/covenant_interface_demo.js +270 -0
  23. package/examples/covenants/covenant_manual_signature_resolved.js +212 -0
  24. package/examples/covenants/covenant_signature_template.js +117 -0
  25. package/examples/covenants2/covenant_bidirectional_example.js +262 -0
  26. package/examples/covenants2/covenant_utils_demo.js +120 -0
  27. package/examples/covenants2/preimage_covenant_utils.js +287 -0
  28. package/examples/covenants2/production_integration.js +256 -0
  29. package/examples/data/covenant_utxos.json +28 -0
  30. package/examples/data/utxos.json +26 -0
  31. package/examples/preimage/README.md +178 -0
  32. package/examples/preimage/extract_preimage_bidirectional.js +421 -0
  33. package/examples/preimage/generate_sample_preimage.js +208 -0
  34. package/examples/preimage/generate_sighash_examples.js +152 -0
  35. package/examples/preimage/parse_preimage.js +117 -0
  36. package/examples/preimage/test_preimage_extractor.js +53 -0
  37. package/examples/preimage/test_varint_extraction.js +95 -0
  38. package/examples/scripts/custom_script_helper_example.js +273 -0
  39. package/examples/scripts/custom_script_signature_test.js +344 -0
  40. package/examples/scripts/script_interpreter.js +193 -0
  41. package/examples/smart_contract/complete_workflow_demo.js +343 -0
  42. package/examples/smart_contract/covenant_builder_demo.js +176 -0
  43. package/examples/smart_contract/script_testing_integration.js +198 -0
  44. package/index.js +3 -0
  45. package/lib/covenant-interface.js +713 -0
  46. package/lib/opcode.js +14 -7
  47. package/lib/smart_contract/API_REFERENCE.md +754 -0
  48. package/lib/smart_contract/DOCUMENTATION_SUMMARY.md +201 -0
  49. package/lib/smart_contract/EXAMPLES.md +751 -0
  50. package/lib/smart_contract/QUICK_START.md +549 -0
  51. package/lib/smart_contract/README.md +395 -0
  52. package/lib/smart_contract/builder.js +452 -0
  53. package/lib/smart_contract/covenant.js +336 -0
  54. package/lib/smart_contract/covenant_builder.js +512 -0
  55. package/lib/smart_contract/index.js +311 -0
  56. package/lib/smart_contract/opcode_list.js +30 -0
  57. package/lib/smart_contract/opcode_map.js +1174 -0
  58. package/lib/smart_contract/opcodes.md +1173 -0
  59. package/lib/smart_contract/preimage.js +903 -0
  60. package/lib/smart_contract/script_tester.js +487 -0
  61. package/lib/smart_contract/script_utils.js +609 -0
  62. package/lib/smart_contract/sighash.js +310 -0
  63. package/lib/smart_contract/smartledger-opcode_review.md +70 -0
  64. package/lib/smart_contract/test_integration.js +269 -0
  65. package/lib/smart_contract/utxo_generator.js +367 -0
  66. package/package.json +43 -10
  67. package/utilities/blockchain-state.json +20478 -3
@@ -0,0 +1,1173 @@
1
+ Opcodes used in Script
2
+
3
+ This is a list of all Script words, also known as opcodes, commands, or functions.
4
+
5
+ OP_NOP1-OP_NOP10 were originally set aside to be used when HASH and other security functions become insecure due to improvements in computing.
6
+
7
+ False is zero or negative zero (using any number of bytes) or an empty array, and True is anything else.
8
+
9
+ Opcodes that will be activated in the Chronicle Release are indicated by an asterisk (e.g. OP_VER*).
10
+ Constants
11
+
12
+ When talking about scripts, these value-pushing words are usually omitted.
13
+ Word
14
+ Opcode
15
+ Input
16
+ Output
17
+ Description
18
+
19
+ OP_0, OP_FALSE
20
+
21
+ 0
22
+ 0x00
23
+
24
+ Nothing.
25
+
26
+ (empty value)
27
+
28
+ An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)
29
+
30
+ Pushdata Bytelength
31
+
32
+ 1-75
33
+ 0x01-0x4b
34
+
35
+ (special)
36
+
37
+ data
38
+
39
+ The next opcode bytes is data to be pushed onto the stack
40
+
41
+ OP_PUSHDATA1
42
+
43
+ 76
44
+ 0x4c
45
+
46
+ (special)
47
+
48
+ data
49
+
50
+ The next byte contains the number of bytes to be pushed onto the stack.
51
+
52
+ OP_PUSHDATA2
53
+
54
+ 77
55
+ 0x4d
56
+
57
+ (special)
58
+
59
+ data
60
+
61
+ The next two bytes contain the number of bytes to be pushed onto the stack in little endian order.
62
+
63
+ OP_PUSHDATA4
64
+
65
+ 78
66
+ 0x4e
67
+
68
+ (special)
69
+
70
+ data
71
+
72
+ The next four bytes contain the number of bytes to be pushed onto the stack in little endian order.
73
+
74
+ OP_1NEGATE
75
+
76
+ 79
77
+ 0x4f
78
+
79
+ Nothing.
80
+
81
+ -1
82
+
83
+ The number -1 is pushed onto the stack.
84
+
85
+ OP_1, OP_TRUE
86
+
87
+ 81
88
+ 0x51
89
+
90
+ Nothing.
91
+
92
+ 1
93
+
94
+ The number 1 is pushed onto the stack.
95
+
96
+ OP_2-OP_16
97
+
98
+ 82-96
99
+ 0x52-0x60
100
+
101
+ Nothing.
102
+
103
+ 2-16
104
+
105
+ The number in the word name (2-16) is pushed onto the stack.
106
+ Flow control
107
+ Word
108
+ Opcode
109
+ Input
110
+ Output
111
+ Description
112
+
113
+ OP_NOP
114
+
115
+ 97
116
+ 0x61
117
+
118
+ Nothing
119
+
120
+ Nothing
121
+
122
+ Does nothing.
123
+
124
+ OP_VER*
125
+
126
+ 98
127
+ 0x62
128
+
129
+ Nothing
130
+
131
+ Transaction version
132
+
133
+ Puts the transaction version onto the stack.
134
+
135
+ OP_IF
136
+
137
+ 99
138
+ 0x63
139
+
140
+ [expression] IF
141
+
142
+ [statement 1]
143
+
144
+ ENDIF
145
+ OR [expression] IF
146
+
147
+ [statement 1]
148
+
149
+ ELSE
150
+
151
+ [statement 2]
152
+
153
+ ENDIF
154
+
155
+ If the top stack value is TRUE, statement 1 is executed.
156
+
157
+ If the top stack value is FALSE and ELSE is used, statement 2 is executed. If ELSE is NOT used, the script jumps to ENDIF. The top stack value is removed.
158
+
159
+ OP_NOTIF
160
+
161
+ 100
162
+ 0x64
163
+
164
+ [expression] NOTIF
165
+
166
+ [statement 1]
167
+
168
+ ENDIF
169
+ OR [expression] IF
170
+
171
+ [statement 1]
172
+
173
+ ELSE
174
+
175
+ [statement 2]
176
+
177
+ ENDIF
178
+
179
+ If the top stack value is FALSE, statement 1 is executed.
180
+
181
+ If the top stack value is TRUE and ELSE is used, statement 2 is executed. If ELSE is NOT used, the script jumps to ENDIF. The top stack value is removed.
182
+
183
+ OP_VERIF*
184
+
185
+ 101
186
+ 0x65
187
+
188
+ x1 = 4-byte array
189
+
190
+ Result of conditionally executed statement
191
+
192
+ Same semantics as: x1 transaction_version OP_EQUAL OP_IF [statements] [OP_ELSE [statements]] OP_ENDIF OP_DROP.
193
+
194
+ OP_VERNOTIF*
195
+
196
+ 102
197
+ 0x66
198
+
199
+ x1 = 4-byte array
200
+
201
+ Result of conditionally executed statement
202
+
203
+ Same semantics as: x1 transaction_version OP_EQUAL OP_IFNOT [statements] [OP_ELSE [statements]] OP_ENDIF OP_DROP.
204
+
205
+ OP_ELSE
206
+
207
+ 103
208
+ 0x67
209
+
210
+ [expression] IF
211
+
212
+ [statement 1]
213
+
214
+ ELSE
215
+
216
+ [statement 2]
217
+
218
+ ENDIF
219
+
220
+ If the preceding IF or NOTIF check was not valid then statement 2 is executed.
221
+
222
+ OP_ENDIF
223
+
224
+ 104
225
+ 0x68
226
+
227
+ [expression] IF
228
+ [statements]
229
+ ELSE
230
+
231
+ [statements]
232
+ ENDIF
233
+
234
+ Ends an if/else block. All blocks must end, or the transaction is invalid. An OP_ENDIF without a prior matching OP_IF or OP_NOTIF is also invalid.
235
+
236
+ OP_VERIFY
237
+
238
+ 105
239
+ 0x69
240
+
241
+ True / false
242
+
243
+ Nothing / fail
244
+
245
+ Marks transaction as invalid if top stack value is not true. The top stack value is removed.
246
+
247
+ OP_RETURN
248
+
249
+ 106
250
+ 0x6a
251
+
252
+ Nothing
253
+
254
+ Ends script with top value on stack as final result
255
+
256
+ 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.
257
+ Stack
258
+ Word
259
+ Opcode
260
+ Input
261
+ Output
262
+ Description
263
+
264
+ OP_TOALTSTACK
265
+
266
+ 107
267
+ 0x6b
268
+
269
+ x1
270
+
271
+ (alt)x1
272
+
273
+ Puts the input onto the top of the alt stack. Removes it from the main stack.
274
+
275
+ OP_FROMALTSTACK
276
+
277
+ 108
278
+ 0x6c
279
+
280
+ (alt)x1
281
+
282
+ x1
283
+
284
+ Puts the input onto the top of the main stack. Removes it from the alt stack.
285
+
286
+ OP_2DROP
287
+
288
+ 109
289
+ 0x6d
290
+
291
+ x1 x2
292
+
293
+ Nothing
294
+
295
+ Removes the top two stack items.
296
+
297
+ OP_2DUP
298
+
299
+ 110
300
+ 0x6e
301
+
302
+ x1 x2
303
+
304
+ x1 x2 x1 x2
305
+
306
+ Duplicates the top two stack items.
307
+
308
+ OP_3DUP
309
+
310
+ 111
311
+ 0x6f
312
+
313
+ x1 x2 x3
314
+
315
+ x1 x2 x3 x1 x2 x3
316
+
317
+ Duplicates the top three stack items.
318
+
319
+ OP_2OVER
320
+
321
+ 112
322
+ 0x70
323
+
324
+ x1 x2 x3 x4
325
+
326
+ x1 x2 x3 x4 x1 x2
327
+
328
+ Copies the pair of items two spaces back in the stack to the front.
329
+
330
+ OP_2ROT
331
+
332
+ 113
333
+ 0x71
334
+
335
+ x1 x2 x3 x4 x5 x6
336
+
337
+ x3 x4 x5 x6 x1 x2
338
+
339
+ The fifth and sixth items back are moved to the top of the stack.
340
+
341
+ OP_2SWAP
342
+
343
+ 114
344
+ 0x72
345
+
346
+ x1 x2 x3 x4
347
+
348
+ x3 x4 x1 x2
349
+
350
+ Swaps the top two pairs of items.
351
+
352
+ OP_IFDUP
353
+
354
+ 115
355
+ 0x73
356
+
357
+ x
358
+
359
+ x / x x
360
+
361
+ If the top stack value is not 0, duplicate it.
362
+
363
+ OP_DEPTH
364
+
365
+ 116
366
+ 0x74
367
+
368
+ Nothing
369
+
370
+ <Stack size>
371
+
372
+ Counts the number of stack items onto the stack and places the value on the top
373
+
374
+ OP_DROP
375
+
376
+ 117
377
+ 0x75
378
+
379
+ x
380
+
381
+ Nothing
382
+
383
+ Removes the top stack item.
384
+
385
+ OP_DUP
386
+
387
+ 118
388
+ 0x76
389
+
390
+ x
391
+
392
+ x x
393
+
394
+ Duplicates the top stack item.
395
+
396
+ OP_NIP
397
+
398
+ 119
399
+ 0x77
400
+
401
+ x1 x2
402
+
403
+ x2
404
+
405
+ Removes the second-to-top stack item.
406
+
407
+ OP_OVER
408
+
409
+ 120
410
+ 0x78
411
+
412
+ x1 x2
413
+
414
+ x1 x2 x1
415
+
416
+ Copies the second-to-top stack item to the top.
417
+
418
+ OP_PICK
419
+
420
+ 121
421
+ 0x79
422
+
423
+ xn ... x2 x1 x0 <n>
424
+
425
+ xn ... x2 x1 x0 xn
426
+
427
+ The item n back in the stack is copied to the top.
428
+
429
+ OP_ROLL
430
+
431
+ 122
432
+ 0x7a
433
+
434
+ xn ... x2 x1 x0 <n>
435
+
436
+ ... x2 x1 x0 xn
437
+
438
+ The item n back in the stack is moved to the top.
439
+
440
+ OP_ROT
441
+
442
+ 123
443
+ 0x7b
444
+
445
+ x1 x2 x3
446
+
447
+ x2 x3 x1
448
+
449
+ The top three items on the stack are rotated to the left.
450
+
451
+ OP_SWAP
452
+
453
+ 124
454
+ 0x7c
455
+
456
+ x1 x2
457
+
458
+ x2 x1
459
+
460
+ The top two items on the stack are swapped.
461
+
462
+ OP_TUCK
463
+
464
+ 125
465
+ 0x7d
466
+
467
+ x1 x2
468
+
469
+ x2 x1 x2
470
+
471
+ The item at the top of the stack is copied and inserted before the second-to-top item.
472
+ Data Manipulation
473
+ Word
474
+ Opcode
475
+ Input
476
+ Output
477
+ Description
478
+
479
+ OP_CAT
480
+
481
+ 126
482
+ 0x7e
483
+
484
+ x1 x2
485
+
486
+ out
487
+
488
+ Concatenates two strings.
489
+
490
+ OP_SPLIT
491
+
492
+ 127
493
+ 0x7f
494
+
495
+ x n
496
+
497
+ x1 x2
498
+
499
+ Splits byte sequence x at position n.
500
+
501
+ OP_NUM2BIN
502
+
503
+ 128
504
+ 0x80
505
+
506
+ a b
507
+
508
+ out
509
+
510
+ Converts numeric value a into byte sequence of length b.
511
+
512
+ OP_BIN2NUM
513
+
514
+ 129
515
+ 0x81
516
+
517
+ x
518
+
519
+ out
520
+
521
+ Converts byte sequence x into a numeric value.
522
+
523
+ OP_SIZE
524
+
525
+ 130
526
+ 0x82
527
+
528
+ in
529
+
530
+ in size
531
+
532
+ Pushes the string length of the top element of the stack (without popping it).
533
+ Bitwise logic
534
+ Word
535
+ Opcode
536
+ Input
537
+ Output
538
+ Description
539
+
540
+ OP_INVERT
541
+
542
+ 131
543
+ 0x83
544
+
545
+ in
546
+
547
+ out
548
+
549
+ Flips all of the bits in the input.
550
+
551
+ OP_AND
552
+
553
+ 132
554
+ 0x84
555
+
556
+ x1 x2
557
+
558
+ out
559
+
560
+ Boolean and between each bit in the inputs.
561
+
562
+ OP_OR
563
+
564
+ 133
565
+ 0x85
566
+
567
+ x1 x2
568
+
569
+ out
570
+
571
+ Boolean or between each bit in the inputs.
572
+
573
+ OP_XOR
574
+
575
+ 134
576
+ 0x86
577
+
578
+ x1 x2
579
+
580
+ out
581
+
582
+ Boolean exclusive or between each bit in the inputs.
583
+
584
+ OP_EQUAL
585
+
586
+ 135
587
+ 0x87
588
+
589
+ x1 x2
590
+
591
+ True / false
592
+
593
+ Returns 1 if the inputs are exactly equal, 0 otherwise.
594
+
595
+ OP_EQUALVERIFY
596
+
597
+ 136
598
+ 0x88
599
+
600
+ x1 x2
601
+
602
+ Nothing / fail
603
+
604
+ Same as OP_EQUAL, but runs OP_VERIFY afterward.
605
+ Arithmetic
606
+
607
+ BitcoinScript supports arithmetic on bignum values A bignum is a byte sequence that represents a numeric value. The length of the byte sequence must be less than or equal to 750,000 bytes. Byte sequences larger than 750,000 bytes are valid in Bitcoin however current rules dictate that they are not recognised as a valid numeric value.
608
+
609
+ Note that while some operations require parameters to be valid numeric values, they may produce byte sequences which are not valid numeric values (for example, OP_MUL may produce a byte sequence which is too large to validly represent a numeric value).
610
+ Word
611
+ Opcode
612
+ Input
613
+ Output
614
+ Description
615
+
616
+ OP_1ADD
617
+
618
+ 139
619
+ 0x8b
620
+
621
+ in
622
+
623
+ out
624
+
625
+ 1 is added to the input.
626
+
627
+ OP_1SUB
628
+
629
+ 140
630
+ 0x8c
631
+
632
+ in
633
+
634
+ out
635
+
636
+ 1 is subtracted from the input.
637
+
638
+ OP_2MUL*
639
+
640
+ 141
641
+ 0x8d
642
+
643
+ in
644
+
645
+ out
646
+
647
+ The input is multiplied by 2.
648
+
649
+ OP_2DIV*
650
+
651
+ 142
652
+ 0x8e
653
+
654
+ in
655
+
656
+ out
657
+
658
+ The input is divided by 2.
659
+
660
+ OP_NEGATE
661
+
662
+ 143
663
+ 0x8f
664
+
665
+ in
666
+
667
+ out
668
+
669
+ The sign of the input is flipped.
670
+
671
+ OP_ABS
672
+
673
+ 144
674
+ 0x90
675
+
676
+ in
677
+
678
+ out
679
+
680
+ The input is made positive.
681
+
682
+ OP_NOT
683
+
684
+ 145
685
+ 0x91
686
+
687
+ in
688
+
689
+ out
690
+
691
+ If the input is 0 or 1, it is flipped. Otherwise the output will be 0.
692
+
693
+ OP_0NOTEQUAL
694
+
695
+ 146
696
+ 0x92
697
+
698
+ in
699
+
700
+ out
701
+
702
+ Returns 0 if the input is 0. 1 otherwise.
703
+
704
+ OP_ADD
705
+
706
+ 147
707
+ 0x93
708
+
709
+ a b
710
+
711
+ out
712
+
713
+ a is added to b.
714
+
715
+ OP_SUB
716
+
717
+ 148
718
+ 0x94
719
+
720
+ a b
721
+
722
+ out
723
+
724
+ b is subtracted from a.
725
+
726
+ OP_MUL
727
+
728
+ 149
729
+ 0x95
730
+
731
+ a b
732
+
733
+ out
734
+
735
+ a is multiplied by b.
736
+
737
+ OP_DIV
738
+
739
+ 150
740
+ 0x96
741
+
742
+ a b
743
+
744
+ out
745
+
746
+ a is divided by b.
747
+
748
+ OP_MOD
749
+
750
+ 151
751
+ 0x97
752
+
753
+ a b
754
+
755
+ out
756
+
757
+ Returns the remainder after dividing a by b.
758
+
759
+ OP_LSHIFT
760
+
761
+ 152
762
+ 0x98
763
+
764
+ a b
765
+
766
+ out
767
+
768
+ Logical left shift b bits. Sign data is discarded
769
+
770
+ OP_RSHIFT
771
+
772
+ 153
773
+ 0x99
774
+
775
+ a b
776
+
777
+ out
778
+
779
+ Logical right shift b bits. Sign data is discarded
780
+
781
+ OP_BOOLAND
782
+
783
+ 154
784
+ 0x9a
785
+
786
+ a b
787
+
788
+ out
789
+
790
+ If both a and b are not 0, the output is 1. Otherwise 0.
791
+
792
+ OP_BOOLOR
793
+
794
+ 155
795
+ 0x9b
796
+
797
+ a b
798
+
799
+ out
800
+
801
+ If a or b is not 0, the output is 1. Otherwise 0.
802
+
803
+ OP_NUMEQUAL
804
+
805
+ 156
806
+ 0x9c
807
+
808
+ a b
809
+
810
+ out
811
+
812
+ Returns 1 if the numbers are equal, 0 otherwise.
813
+
814
+ OP_NUMEQUALVERIFY
815
+
816
+ 157
817
+ 0x9d
818
+
819
+ a b
820
+
821
+ Nothing / fail
822
+
823
+ Same as OP_NUMEQUAL, but runs OP_VERIFY afterward.
824
+
825
+ OP_NUMNOTEQUAL
826
+
827
+ 158
828
+ 0x9e
829
+
830
+ a b
831
+
832
+ out
833
+
834
+ Returns 1 if the numbers are not equal, 0 otherwise.
835
+
836
+ OP_LESSTHAN
837
+
838
+ 159
839
+ 0x9f
840
+
841
+ a b
842
+
843
+ out
844
+
845
+ Returns 1 if a is less than b, 0 otherwise.
846
+
847
+ OP_GREATERTHAN
848
+
849
+ 160
850
+ 0xa0
851
+
852
+ a b
853
+
854
+ out
855
+
856
+ Returns 1 if a is greater than b, 0 otherwise.
857
+
858
+ OP_LESSTHANOREQUAL
859
+
860
+ 161
861
+ 0xa1
862
+
863
+ a b
864
+
865
+ out
866
+
867
+ Returns 1 if a is less than or equal to b, 0 otherwise.
868
+
869
+ OP_GREATERTHANOREQUAL
870
+
871
+ 162
872
+ 0xa2
873
+
874
+ a b
875
+
876
+ out
877
+
878
+ Returns 1 if a is greater than or equal to b, 0 otherwise.
879
+
880
+ OP_MIN
881
+
882
+ 163
883
+ 0xa3
884
+
885
+ a b
886
+
887
+ out
888
+
889
+ Returns the smaller of a and b.
890
+
891
+ OP_MAX
892
+
893
+ 164
894
+ 0xa4
895
+
896
+ a b
897
+
898
+ out
899
+
900
+ Returns the larger of a and b.
901
+
902
+ OP_WITHIN
903
+
904
+ 165
905
+ 0xa5
906
+
907
+ x min max
908
+
909
+ out
910
+
911
+ Returns 1 if x is within the specified range (left-inclusive), 0 otherwise.
912
+ Cryptography
913
+ Word
914
+ Opcode
915
+ Input
916
+ Output
917
+ Description
918
+
919
+ OP_RIPEMD160
920
+
921
+ 166
922
+ 0xa6
923
+
924
+ in
925
+
926
+ hash
927
+
928
+ The input is hashed using RIPEMD-160.
929
+
930
+ OP_SHA1
931
+
932
+ 167
933
+ 0xa7
934
+
935
+ in
936
+
937
+ hash
938
+
939
+ The input is hashed using SHA-1.
940
+
941
+ OP_SHA256
942
+
943
+ 168
944
+ 0xa8
945
+
946
+ in
947
+
948
+ hash
949
+
950
+ The input is hashed using SHA-256.
951
+
952
+ OP_HASH160
953
+
954
+ 169
955
+ 0xa9
956
+
957
+ in
958
+
959
+ hash
960
+
961
+ The input is hashed twice: first with SHA-256 and then with RIPEMD-160.
962
+
963
+ OP_HASH256
964
+
965
+ 170
966
+ 0xaa
967
+
968
+ in
969
+
970
+ hash
971
+
972
+ The input is hashed two times with SHA-256.
973
+
974
+ OP_CODESEPARATOR
975
+
976
+ 171
977
+ 0xab
978
+
979
+ Nothing
980
+
981
+ Nothing
982
+
983
+ All of the signature checking words will only match signatures to the data after the most recently-executed OP_CODESEPARATOR.
984
+
985
+ OP_CHECKSIG
986
+
987
+ 172
988
+ 0xac
989
+
990
+ sig pubkey
991
+
992
+ True / false
993
+
994
+ The entire transaction'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.
995
+
996
+ OP_CHECKSIGVERIFY
997
+
998
+ 173
999
+ 0xad
1000
+
1001
+ sig pubkey
1002
+
1003
+ Nothing / fail
1004
+
1005
+ Same as OP_CHECKSIG, but OP_VERIFY is executed afterward.
1006
+
1007
+ OP_CHECKMULTISIG
1008
+
1009
+ 174
1010
+ 0xae
1011
+
1012
+ x sig1 sig2 ... <number of signatures> pub1 pub2 <number of public keys>
1013
+
1014
+ True / False
1015
+
1016
+ 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, an extra unused value (x) is removed from the stack. Script spenders must account for this by adding a junk value (typically zero) to the stack.
1017
+
1018
+ OP_CHECKMULTISIGVERIFY
1019
+
1020
+ 175
1021
+ 0xaf
1022
+
1023
+ x sig1 sig2 ... <number of signatures> pub1 pub2 ... <number of public keys>
1024
+
1025
+ Nothing / fail
1026
+
1027
+ Same as OP_CHECKMULTISIG, but OP_VERIFY is executed afterward.
1028
+ Used NOP opcode identifiers
1029
+
1030
+ In Bitcoin's history, new opcodes were added that used reserved NO_OP opcode identifiers. These opcodes have been reverted to the original OP_NOP functionality.
1031
+ Word
1032
+ Opcode
1033
+ Input
1034
+ Output
1035
+ Description
1036
+
1037
+ OP_NOP2
1038
+
1039
+ (previously OP_CHECKLOCKTIMEVERIFY)
1040
+
1041
+ 177
1042
+ 0xb1
1043
+
1044
+ Nothing
1045
+
1046
+ (Previously: x)
1047
+
1048
+ Nothing
1049
+
1050
+ (Previously: x or fail)
1051
+
1052
+ NO OPERATION
1053
+
1054
+ Evaluation process for UTXOs that pre-date genesis: Mark transaction as invalid if the top stack item is greater than the transaction'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's nLockTime field is less than 500000000, or vice versa; or 4. the input's nSequence field is equal to 0xffffffff. The precise semantics are described in BIP 0065.
1055
+
1056
+ OP_NOP3
1057
+
1058
+ (previously OP_CHECKSEQUENCEVERIFY)
1059
+
1060
+ 178
1061
+ 0xb2
1062
+
1063
+ Nothing
1064
+
1065
+ (Previously: x)
1066
+
1067
+ Nothing
1068
+
1069
+ (Previously: x or fail)
1070
+
1071
+ NO OPERATION
1072
+
1073
+ Evaluation process for UTXOs that pre-date genesis: Mark transaction as invalid 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.
1074
+ String operations
1075
+ Word
1076
+ Opcode
1077
+ Input
1078
+ Output
1079
+ Description
1080
+
1081
+ OP_SUBSTR*
1082
+
1083
+ 179
1084
+ 0xb3
1085
+
1086
+ x1 x2 x3
1087
+
1088
+ output string
1089
+
1090
+ The substring created from the string (x3) starting at the specified index (x2) and of the specified length (x1).
1091
+
1092
+ OP_LEFT*
1093
+
1094
+ 180
1095
+ 0xb4
1096
+
1097
+ x1 x2
1098
+
1099
+ output string
1100
+
1101
+ The substring created from the string (x2) starting at the begining of the string and of the specified length (x1).
1102
+
1103
+ OP_RIGHT*
1104
+
1105
+ 181
1106
+ 0xb5
1107
+
1108
+ x1 x2
1109
+
1110
+ output string
1111
+
1112
+ The substring created from the string (x2) using the specified number (x1) of rightmost characters.
1113
+ Pseudo-words
1114
+
1115
+ These words are used internally for assisting with transaction matching. They are invalid if used in actual scripts.
1116
+ Word
1117
+ Opcode
1118
+ Description
1119
+
1120
+ OP_PUBKEYHASH
1121
+
1122
+ 253
1123
+ 0xfd
1124
+
1125
+ Represents a public key hashed with OP_HASH160.
1126
+
1127
+ OP_PUBKEY
1128
+
1129
+ 254
1130
+ 0xfe
1131
+
1132
+ Represents a public key compatible with OP_CHECKSIG.
1133
+
1134
+ OP_INVALIDOPCODE
1135
+
1136
+ 255
1137
+ 0xff
1138
+
1139
+ Matches any opcode that is not yet assigned.
1140
+ Reserved words
1141
+
1142
+ Any opcode not assigned is also reserved. Using an unassigned opcode makes the transaction invalid.
1143
+ Word
1144
+ Opcode
1145
+ When used...
1146
+
1147
+ OP_RESERVED
1148
+
1149
+ 80
1150
+ 0x50
1151
+
1152
+ Transaction is invalid unless occuring in an unexecuted OP_IF branch
1153
+
1154
+ OP_RESERVED1
1155
+
1156
+ 137
1157
+ 0x89
1158
+
1159
+ Transaction is invalid unless occuring in an unexecuted OP_IF branch
1160
+
1161
+ OP_RESERVED2
1162
+
1163
+ 138
1164
+ 0x8a
1165
+
1166
+ Transaction is invalid unless occuring in an unexecuted OP_IF branch
1167
+
1168
+ OP_NOP1, OP_NOP4-OP_NOP10
1169
+
1170
+ 176, 179-185
1171
+ 0xb0, 0xb3-0xb9
1172
+
1173
+ The word is ignored. Does not mark transaction as invalid.