-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
1511 lines (1378 loc) · 45.7 KB
/
index.d.ts
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* eslint-disable @typescript-eslint/ban-types */
// Type definitions for bitcoire-lib
// Definitions by: Mihael Šinkec <https://github.com/msinkec>
// TypeScript Version: 3.0
/// <reference types="node" />
declare module 'scrypt-bitcore-lib' {
/**
* Opcode class, representing opcodes used in Bitcoin Script
* @constructor
* @param {number} op_code
* @class
*/
class Opcode {
/**
* An empty array of bytes is pushed onto the stack. (This is not a no-op: an item is added to the stack.)
* @opcode {`0`}
* @hex {`0x00`}
* @input Nothing
* @output empty
* @static
*/
static OP_0: number;
/**
* The next byte contains the number of bytes to be pushed onto the stack.
* @opcode {`76`}
* @hex {`0x4c`}
* @input special
* @output data
* @static
*/
static OP_PUSHDATA1: number;
/**
* The next two bytes contain the number of bytes to be pushed onto the stack in little endian order.
* @opcode {`77`}
* @hex {`0x4d`}
* @input special
* @output data
* @static
*/
static OP_PUSHDATA2: number;
/**
* The next four bytes contain the number of bytes to be pushed onto the stack in little endian order.
* @opcode {`78`}
* @hex {`0x4e`}
* @input special
* @output data
* @static
*/
static OP_PUSHDATA4: number;
/**
* The number -1 is pushed onto the stack.
* @opcode {`79`}
* @hex {`0x4f`}
* @input Nothing
* @output `-1`
* @static
*/
static OP_1NEGATE: number;
/**
* Reserved words, Using an unassigned opcode makes the transaction invalid.
* @opcode {`80`}
* @hex {`0x50`}
* @input Nothing
* @output Nothing
* @static
*/
static OP_RESERVED: number;
/**
* The number 1 is pushed onto the stack.
* @opcode {`81`}
* @hex {`0x51`}
* @input Nothing
* @output `1`
* @static
*/
static OP_TRUE: number;
/**
* The number 1 is pushed onto the stack.
* @opcode {`81`}
* @hex {`0x51`}
* @input Nothing
* @output `1`
* @static
*/
static OP_1: number;
/**
* The number in the word name 2 is pushed onto the stack.
* @opcode {`82`}
* @hex {`0x52`}
* @input Nothing
* @output `2`
* @static
*/
static OP_2: number;
/**
* The number in the word name 3 is pushed onto the stack.
* @opcode {`83`}
* @hex {`0x53`}
* @input Nothing
* @output `3`
* @static
*/
static OP_3: number;
/**
* The number in the word name 4 is pushed onto the stack.
* @opcode {`84`}
* @hex {`0x54`}
* @input Nothing
* @output `4`
* @static
*/
static OP_4: number;
/**
* The number in the word name 5 is pushed onto the stack.
* @opcode {`85`}
* @hex {`0x55`}
* @input Nothing
* @output `5`
* @static
*/
static OP_5: number;
/**
* The number in the word name 6 is pushed onto the stack.
* @opcode {`86`}
* @hex {`0x56`}
* @input Nothing
* @output `6`
* @static
*/
static OP_6: number;
/**
* The number in the word name 7 is pushed onto the stack.
* @opcode {`87`}
* @hex {`0x57`}
* @input Nothing
* @output `7`
* @static
*/
static OP_7: number;
/**
* The number in the word name 8 is pushed onto the stack.
* @opcode {`88`}
* @hex {`0x58`}
* @input Nothing
* @output `8`
* @static
*/
static OP_8: number;
/**
* The number in the word name 9 is pushed onto the stack.
* @opcode {`89`}
* @hex {`0x59`}
* @input Nothing
* @output `9`
* @static
*/
static OP_9: number;
/**
* The number in the word name 10 is pushed onto the stack.
* @opcode {`90`}
* @hex {`0x5a`}
* @input Nothing
* @output `10`
* @static
*/
static OP_10: number;
/**
* The number in the word name 11 is pushed onto the stack.
* @opcode {`91`}
* @hex {`0x5b`}
* @input Nothing
* @output `11`
* @static
*/
static OP_11: number;
/**
* The number in the word name 12 is pushed onto the stack.
* @opcode {`92`}
* @hex {`0x5c`}
* @input Nothing
* @output `12`
* @static
*/
static OP_12: number;
/**
* The number in the word name 13 is pushed onto the stack.
* @opcode {`93`}
* @hex {`0x5d`}
* @input Nothing
* @output `13`
* @static
*/
static OP_13: number;
/**
* The number in the word name 14 is pushed onto the stack.
* @opcode {`94`}
* @hex {`0x5e`}
* @input Nothing
* @output `14`
* @static
*/
static OP_14: number;
/**
* The number in the word name 15 is pushed onto the stack.
* @opcode {`95`}
* @hex {`0x5f`}
* @input Nothing
* @output `15`
* @static
*/
static OP_15: number;
/**
* The number in the word name 16 is pushed onto the stack.
* @opcode {`96`}
* @hex {`0x60`}
* @input Nothing
* @output `16`
* @static
*/
static OP_16: number;
/**
* Does nothing.
* @opcode {`97`}
* @hex {`0x61`}
* @input Nothing
* @output Nothing
* @static
*/
static OP_NOP: number;
/**
* DISABLED.Puts the version of the protocol under which this transaction will be evaluated onto the stack.
* @opcode {`99`}
* @hex {`0x62`}
* @input Nothing
* @output Protocol version
* @static
*/
static OP_VER: number;
/**
* If the top stack value is TRUE, statement 1 is executed.
* 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.
* @opcode {`99`}
* @hex {`0x63`}
* @example
* `[expression] IF
* [statement 1]
* ENDIF`
* OR
* `[expression] IF
* [statement 1]
* ELSE
* [statement 2]
* ENDIF`
* @static
*/
static OP_IF: number;
/**
* If the top stack value is FALSE, statement 1 is executed.
* 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.
* @opcode {`100`}
* @hex {`0x64`}
* @example
* `[expression] NOTIF
* [statement 1]
* ENDIF`
* OR
* `[expression] NOTIF
* [statement 1]
* ELSE
* [statement 2]
* ENDIF`
* @static
*/
static OP_NOTIF: number;
/**
* DISABLED
* @opcode {`101`}
* @hex {`0x65`}
* @static
*/
static OP_VERIF: number;
/**
* DISABLED
* @opcode {`102`}
* @hex {`0x66`}
* @static
*/
static OP_VERNOTIF: number;
/**
* If the preceding IF or NOTIF check was not valid then statement 2 is executed.
* @opcode {`103`}
* @hex {`0x67`}
* @example
* `[expression] IF
* [statement 1]
* ELSE
* [statement 2]
* ENDIF`
* @static
*/
static OP_ELSE: number;
/**
* 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.
* @opcode {`104`}
* @hex {`0x68`}
* @example
* `[expression] IF
* [statement 1]
* ELSE
* [statement 2]
* ENDIF`
* @static
*/
static OP_ENDIF: number;
/**
* Marks transaction as invalid if top stack value is not true. The top stack value is removed.
* @opcode {`105`}
* @hex {`0x69`}
* @input True / false
* @output Nothing / fail
* @static
*/
static OP_VERIFY: number;
/**
* 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. After the Genesis upgrade in 2020 miners will be free to mine transactions
* containing FALSE RETURN outputs of any size.
* @opcode {`106`}
* @hex {`0x6a`}
* @input Nothing
* @output Ends script with top value on stack as final result
* @static
*/
static OP_RETURN: number;
// stack ops
/**
* Puts the input onto the top of the alt stack. Removes it from the main stack.
* @opcode {`107`}
* @hex {`0x6b`}
* @input x1
* @output (alt)x1
* @static
*/
static OP_TOALTSTACK: number;
/**
* Puts the input onto the top of the main stack. Removes it from the alt stack.
* @opcode {`108`}
* @hex {`0x6c`}
* @input (alt)x1
* @output x1
* @static
*/
static OP_FROMALTSTACK: number;
/**
* Removes the top two stack items.
* @opcode {`109`}
* @hex {`0x6d`}
* @input x1 x2
* @output Nothing
* @static
*/
static OP_2DROP: number;
/**
* Duplicates the top two stack items.
* @opcode {`110`}
* @hex {`0x6e`}
* @input x1 x2
* @output x1 x2 x1 x2
* @static
*/
static OP_2DUP: number;
/**
* Duplicates the top three stack items.
* @opcode {`111`}
* @hex {`0x6f`}
* @input x1 x2 x3
* @output x1 x2 x3 x1 x2 x3
* @static
*/
static OP_3DUP: number;
/**
* Copies the pair of items two spaces back in the stack to the front.
* @opcode {`112`}
* @hex {`0x70`}
* @input x1 x2 x3 x4
* @output x1 x2 x3 x4 x1 x2
* @static
*/
static OP_2OVER: number;
/**
* The fifth and sixth items back are moved to the top of the stack.
* @opcode {`113`}
* @hex {`0x71`}
* @input x1 x2 x3 x4 x5 x6
* @output x3 x4 x5 x6 x1 x2
* @static
*/
static OP_2ROT: number;
/**
* Swaps the top two pairs of items.
* @opcode {`114`}
* @hex {`0x72`}
* @input x1 x2 x3 x4
* @output x3 x4 x1 x2
* @static
*/
static OP_2SWAP: number;
/**
* If the top stack value is not 0, duplicate it.
* @opcode {`115`}
* @hex {`0x73`}
* @input x
* @output x / x x
* @static
*/
static OP_IFDUP: number;
/**
* Counts the number of stack items onto the stack and places the value on the top
* @opcode {`116`}
* @hex {`0x74`}
* @input Nothing
* @output Stack size
* @static
*/
static OP_DEPTH: number;
/**
* Removes the top stack item.
* @opcode {`117`}
* @hex {`0x75`}
* @input x
* @output Nothing
* @static
*/
static OP_DROP: number;
/**
* Removes the top stack item.
* @opcode {`118`}
* @hex {`0x76`}
* @input x
* @output x x
* @static
*/
static OP_DUP: number;
/**
* Removes the second-to-top stack item.
* @opcode {`119`}
* @hex {`0x77`}
* @input x1 x2
* @output x2
* @static
*/
static OP_NIP: number;
/**
* Copies the second-to-top stack item to the top.
* @opcode {`120`}
* @hex {`0x78`}
* @input x1 x2
* @output x1 x2 x1
* @static
*/
static OP_OVER: number;
/**
* The item `n` back in the stack is copied to the top.
* @opcode {`121`}
* @hex {`0x79`}
* @input xn ... x2 x1 x0 {n}
* @output xn ... x2 x1 x0 xn
* @static
*/
static OP_PICK: number;
/**
* The item `n` back in the stack is copied to the top.
* @opcode {`122`}
* @hex {`0x7a`}
* @input xn ... x2 x1 x0 {n}
* @output ... x2 x1 x0 xn
* @static
*/
static OP_ROLL: number;
/**
* The top three items on the stack are rotated to the left.
* @opcode {`123`}
* @hex {`0x7b`}
* @input x1 x2 x3
* @output x2 x3 x1
* @static
*/
static OP_ROT: number;
/**
* The top two items on the stack are swapped.
* @opcode {`124`}
* @hex {`0x7c`}
* @input x1 x2
* @output x2 x1
* @static
*/
static OP_SWAP: number;
/**
* The item at the top of the stack is copied and inserted before the second-to-top item.
* @opcode {`125`}
* @hex {`0x7d`}
* @input x1 x2
* @output x2 x1 x2
* @static
*/
static OP_TUCK: number;
// splice ops
static OP_CAT: number;
static OP_SUBSTR: number;
static OP_LEFT: number;
static OP_RIGHT: number;
static OP_SIZE: number;
// bit logic
static OP_INVERT: number;
static OP_AND: number;
static OP_OR: number;
static OP_XOR: number;
static OP_EQUAL: number;
static OP_EQUALVERIFY: number;
static OP_RESERVED1: number;
static OP_RESERVED2: number;
// numeric
static OP_1ADD: number;
static OP_1SUB: number;
static OP_2MUL: number;
static OP_2DIV: number;
static OP_NEGATE: number;
static OP_ABS: number;
static OP_NOT: number;
static OP_0NOTEQUAL: number;
static OP_ADD: number;
static OP_SUB: number;
static OP_MUL: number;
static OP_DIV: number;
static OP_MOD: number;
static OP_LSHIFT: number;
static OP_RSHIFT: number;
static OP_BOOLAND: number;
static OP_BOOLOR: number;
static OP_NUMEQUAL: number;
static OP_NUMEQUALVERIFY: number;
static OP_NUMNOTEQUAL: number;
static OP_LESSTHAN: number;
static OP_GREATERTHAN: number;
static OP_LESSTHANOREQUAL: number;
static OP_GREATERTHANOREQUAL: number;
static OP_MIN: number;
static OP_MAX: number;
static OP_WITHIN: number;
// crypto
static OP_RIPEMD160: number;
static OP_SHA1: number;
static OP_SHA256: number;
static OP_HASH160: number;
static OP_HASH256: number;
static OP_CODESEPARATOR: number;
static OP_CHECKSIG: number;
static OP_CHECKSIGVERIFY: number;
static OP_CHECKMULTISIG: number;
static OP_CHECKMULTISIGVERIFY: number;
static OP_CHECKLOCKTIMEVERIFY: number;
static OP_CHECKSEQUENCEVERIFY: number;
// expansion
static OP_NOP1: number;
static OP_NOP2: number;
static OP_NOP3: number;
static OP_NOP4: number;
static OP_NOP5: number;
static OP_NOP6: number;
static OP_NOP7: number;
static OP_NOP8: number;
static OP_NOP9: number;
static OP_NOP10: number;
// template matching params
static OP_PUBKEYHASH: number;
static OP_PUBKEY: number;
static OP_INVALIDOPCODE: number;
constructor(op_code: number);
}
export namespace encoding {
class Base58 { }
class Base58Check { }
class BufferReader {
constructor(buf: Buffer);
read(len: number): Buffer;
readUInt8(): number;
readUInt16BE(): number;
readUInt16LE(): number;
readUInt32BE(): number;
readUInt32LE(): number;
readInt32LE(): number;
readUInt64BEBN(): number;
readUInt64LEBN(): number;
readVarintNum(): number;
readVarLengthBuffer(): Buffer;
readVarintBuf(): Buffer;
readVarintBN(): crypto.BN;
reverse(): this;
readReverse(len?: number): Buffer;
readAll(): Buffer;
eof(): boolean;
remaining(): number;
pos: number;
}
class BufferWriter {
write(buf: Buffer): this;
writeUInt8(n: number): this;
writeUInt16BE(n: number): this;
writeUInt16LE(n: number): this;
writeUInt32BE(n: number): this;
writeUInt32LE(n: number): this;
writeInt32LE(n: number): this;
writeUInt64BEBN(n: crypto.BN): this;
writeUInt64LEBN(n: crypto.BN): this;
writeVarintNum(n: number): this;
writeVarintBN(n: crypto.BN): this;
writeReverse(buf: Buffer): this;
toBuffer(): Buffer;
}
class Varint { }
}
export namespace crypto {
interface IOpts {
endian: 'big' | 'little';
size?: number;
}
type Endianness = "le" | "be";
class BN {
constructor(
number: number | bigint | string | number[] | ReadonlyArray<number> | Buffer | BN,
base?: number,
endian?: Endianness,
);
static Zero: BN;
static One: BN;
static Minus1: BN;
clone(): BN;
toString(base?: number | 'hex', length?: number): string;
toNumber(): number;
toJSON(): string;
toArray(endian?: Endianness, length?: number): number[];
toBuffer(opts?: IOpts): Buffer;
bitLength(): number;
zeroBits(): number;
byteLength(): number;
isNeg(): boolean;
isEven(): boolean;
isOdd(): boolean;
isZero(): boolean;
isBN(): boolean;
cmp(b: any): number;
lt(b: any): boolean;
lte(b: any): boolean;
gt(b: any): boolean;
gte(b: any): boolean;
eq(b: any): boolean;
eqn(b: any): boolean;
gten(b: any): boolean;
lten(b: any): boolean;
isBN(b: any): boolean;
neg(): BN;
abs(): BN;
add(b: BN): BN;
sub(b: BN): BN;
mul(b: BN): BN;
sqr(): BN;
pow(b: BN): BN;
div(b: BN): BN;
mod(b: BN): BN;
divRound(b: BN): BN;
or(b: BN): BN;
and(b: BN): BN;
xor(b: BN): BN;
setn(b: number): BN;
shln(b: number): BN;
shrn(b: number): BN;
testn(b: number): boolean;
maskn(b: number): BN;
bincn(b: number): BN;
notn(w: number): BN;
gcd(b: BN): BN;
egcd(b: BN): { a: BN; b: BN; gcd: BN };
invm(b: BN): BN;
static fromSM(buf: Buffer, opts?: IOpts): BN;
neg(): BN;
add(one: BN): BN;
toSM(opts?: IOpts): Buffer;
toNumber(): number;
static fromBuffer(buf: Buffer, opts?: IOpts): BN;
static fromNumber(n: number): BN;
static fromHex(hex: string, opts?: IOpts): BN;
static fromString(hex: string, base?: number): BN;
}
namespace ECDSA {
function sign(message: Buffer, key: PrivateKey): Signature;
function verify(
hashbuf: Buffer,
sig: Signature,
pubkey: PublicKey,
endian?: 'little'
): boolean;
}
namespace Hash {
function sha1(buffer: Buffer): Buffer;
function sha256(buffer: Buffer): Buffer;
function sha256sha256(buffer: Buffer): Buffer;
function sha256ripemd160(buffer: Buffer): Buffer;
function sha512(buffer: Buffer): Buffer;
function ripemd160(buffer: Buffer): Buffer;
function sha256hmac(data: Buffer, key: Buffer): Buffer;
function sha512hmac(data: Buffer, key: Buffer): Buffer;
}
namespace Random {
function getRandomBuffer(size: number): Buffer;
}
class Point {
static fromX(odd: boolean, x: crypto.BN | string): Point;
static getG(): any;
static getN(): crypto.BN;
getX(): crypto.BN;
getY(): crypto.BN;
validate(): this;
mul(n: crypto.BN): Point;
}
class Signature {
static fromDER(sig: Buffer): Signature;
static fromTxFormat(buf: Buffer): Signature;
static fromString(data: string): Signature;
static SIGHASH_ALL: number;
static SIGHASH_NONE: number;
static SIGHASH_SINGLE: number;
static SIGHASH_FORKID: number;
static SIGHASH_ANYONECANPAY: number;
static ALL: number;
static NONE: number;
static SINGLE: number;
static ANYONECANPAY_ALL: number;
static ANYONECANPAY_NONE: number;
static ANYONECANPAY_SINGLE: number;
nhashtype: number;
toString(): string;
toBuffer(): Buffer;
toDER(): Buffer;
hasDefinedHashtype(): boolean;
static isTxDER(buf: Buffer): boolean;
hasLowS(): boolean;
toTxFormat(): Buffer;
}
}
export namespace Transaction {
interface IUnspentOutput {
address?: string;
txId: string;
outputIndex: number;
script: string;
satoshis: number;
}
class UnspentOutput {
static fromObject(o: IUnspentOutput): UnspentOutput;
constructor(data: IUnspentOutput);
inspect(): string;
toObject(): IUnspentOutput;
toString(): string;
}
class Output {
readonly script: Script;
readonly satoshis: number;
readonly satoshisBN: crypto.BN;
spentTxId: string | null;
constructor(data: {
script: Script,
satoshis: number
});
setScript(script: Script | string | Buffer): this;
inspect(): string;
toObject(): { satoshis: number; script: string };
getSize(): number;
toBufferWriter(writer?: encoding.BufferWriter): encoding.BufferWriter;
static fromBufferReader(reader: encoding.BufferReader): Output
}
class Input {
readonly prevTxId: Buffer;
readonly outputIndex: number;
readonly witnesses: Buffer[];
sequenceNumber: number;
readonly script: Script;
output?: Output;
constructor(params: object);
isValidSignature(tx: Transaction, sig: any): boolean;
setScript(script: Script): this;
setWitnesses(witnesses: Buffer[] | Script, witnessScript?: Script);
getSignatures(tx: Transaction, privateKey: PrivateKey, inputIndex: number, sigtype?: number): any;
getPreimage(tx: Transaction, inputIndex: number, sigtype?: number, isLowS?: boolean): any;
}
namespace Input {
class PublicKeyHash extends Input {
}
}
class Signature {
constructor(arg: Signature | string | object);
signature: crypto.Signature;
publicKey: PublicKey;
prevTxId: Buffer;
outputIndex: number;
inputIndex: number;
sigtype: number;
}
namespace Sighash {
function sighashPreimage(
transaction: Transaction,
sighashType: number,
inputNumber: number,
subscript: Script,
satoshisBN: crypto.BN,
flags?: number
): Buffer;
function sighash(
transaction: Transaction,
sighashType: number,
inputNumber: number,
subscript: Script
): Buffer;
function sign(
transaction: Transaction,
privateKey: PrivateKey,
sighashType: number,
inputIndex: number,
subscript: Script,
signingMethod: string
): crypto.Signature;
function verify(
transaction: Transaction,
signature: Signature,
publicKey: PublicKey,
inputIndex: number,
subscript: Script,
signingMethod: string
): boolean;
}
namespace SighashWitness {
function sighash(
transaction: Transaction,
sighashType: number,
inputNumber: number,
scriptCode: Buffer,
satoshisBuffer: Buffer
): Buffer;
function sign(
transaction: Transaction,
privateKey: PrivateKey,
sighashType: number,
inputIndex: number,
scriptCode: Buffer,
satoshisBuffer: Buffer,
signingMethod: string
): crypto.Signature;
function verify(
transaction: Transaction,
signature: Signature,
publicKey: PublicKey,
inputIndex: number,
scriptCode: Script,
satoshisBuffer: Buffer,
signingMethod: string
): boolean;
}
}
export class Transaction {
static DUMMY_PRIVATEKEY: PrivateKey;
inputs: Transaction.Input[];
outputs: Transaction.Output[];
readonly id: string;
readonly hash: string;
readonly inputAmount: number;
readonly outputAmount: number;
nid: string;
nLockTime: number;
constructor(raw?: string);
from(
utxos: Transaction.IUnspentOutput | Transaction.IUnspentOutput[]
): this;
fromString(rawTxHex: string): this;
fromBuffer(buffer: Buffer): this;
to(address: Address[] | Address | string, amount: number): this;
change(address: Address | string): this;
fee(amount: number): this;
feePerKb(amount: number): this;
sign(
privateKey: PrivateKey[] | string[] | PrivateKey | string,
sigtype?: number
): this;
applySignature(sig: { inputIndex: number, sigtype: number, publicKey: PublicKey, signature: crypto.Signature}): this;
verifySignature(sig: crypto.Signature, pubkey: PublicKey, nin: number, subscript: Script, satoshisBN: crypto.BN, flags: number): boolean;
addInput(
input: Transaction.Input,
outputScript?: Script | string,
satoshis?: number
): this;
addOutput(output: Transaction.Output): this;
addData(value: Buffer | string): this;
lockUntilDate(time: Date | number): this;
lockUntilBlockHeight(height: number): this;
hasWitnesses(): boolean;
getFee(): number;
getChangeOutput(): Transaction.Output | null;
getChangeAddress(): Address | null;
getLockTime(): Date | number;
setLockTime(t: number): this;
verify(): string | true;
isCoinbase(): boolean;
enableRBF(): this;
isRBF(): boolean;
inspect(): string;
serialize(unsafe?: boolean): string;
uncheckedSerialize(): string;
toObject(): any;
toBuffer(): Buffer;
isFullySigned(): boolean;
getSerializationError(opts?: object): any;
_getUnspentValue(): number;
_estimateFee(): number;
_estimateSize: number;
setInputScript(inputIndex: number | {
inputIndex: number,
privateKey?: PrivateKey | Array<PrivateKey>,
sigtype?: number,
isLowS?: boolean
}, unlockingScript: Script | ((tx: Transaction, outputInPrevTx: Transaction.Output) => Script)): this;
setInputScriptAsync(inputIndex: number | {
inputIndex: number,
sigtype?: number,
isLowS?: boolean
}, callback: (tx: Transaction, outputInPrevTx: Transaction.Output) => Promise<Script>): Promise<this>;
setInputSequence(inputIndex: number, sequence: number): this;
setOutput(outputIndex: number, output: Transaction.Output | ((tx: Transaction) => Transaction.Output)): this;
seal(): this;
sealAsync(): Promise<this>;
isSealed(): boolean;
getChangeAmount(): number;
getEstimateFee(): number;