-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.d.ts
More file actions
876 lines (764 loc) · 23.2 KB
/
Copy pathindex.d.ts
File metadata and controls
876 lines (764 loc) · 23.2 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
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
/* eslint-disable @typescript-eslint/ban-types */
// Type definitions for bsv 1.5.5
// Project: https://github.com/moneybutton/bsv
// Forked From: https://github.com/bitpay/bitcore-lib
// Definitions by: Lautaro Dragan <https://github.com/lautarodragan>
// Definitions extended by: David Case <https://github.com/shruggr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import BN_P = require('bn.js');
/// <reference types="bn.js" />
declare module 'bsv' {
class Opcode {
static OP_0: number;
static OP_PUSHDATA1: number;
static OP_PUSHDATA2: number;
static OP_PUSHDATA4: number;
static OP_1NEGATE: number;
static OP_RESERVED: number;
static OP_TRUE: number;
static OP_1: number;
static OP_2: number;
static OP_3: number;
static OP_4: number;
static OP_5: number;
static OP_6: number;
static OP_7: number;
static OP_8: number;
static OP_9: number;
static OP_10: number;
static OP_11: number;
static OP_12: number;
static OP_13: number;
static OP_14: number;
static OP_15: number;
static OP_16: number;
// control
static OP_NOP: number;
static OP_VER: number;
static OP_IF: number;
static OP_NOTIF: number;
static OP_VERIF: number;
static OP_VERNOTIF: number;
static OP_ELSE: number;
static OP_ENDIF: number;
static OP_VERIFY: number;
static OP_RETURN: number;
// stack ops
static OP_TOALTSTACK: number;
static OP_FROMALTSTACK: number;
static OP_2DROP: number;
static OP_2DUP: number;
static OP_3DUP: number;
static OP_2OVER: number;
static OP_2ROT: number;
static OP_2SWAP: number;
static OP_IFDUP: number;
static OP_DEPTH: number;
static OP_DROP: number;
static OP_DUP: number;
static OP_NIP: number;
static OP_OVER: number;
static OP_PICK: number;
static OP_ROLL: number;
static OP_ROT: number;
static OP_SWAP: number;
static OP_TUCK: number;
// splice ops
static OP_CAT: number;
static OP_SPLIT: number;
static OP_NUM2BIN: number;
static OP_BIN2NUM: 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;
}
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;
}
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: number): this;
writeUInt64LEBN(n: number): 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;
}
class BN extends BN_P {
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;
//toBuffer(opts?: IOpts): Buffer;
static fromHex(hex: string, opts?: IOpts): 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;
toString(): string;
toBuffer(): Buffer;
toDER(): Buffer;
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: object);
setScript(script: Script | string | Buffer): this;
inspect(): string;
toObject(): { satoshis: number; script: string };
getSize(): number;
toBufferWriter(writer: encoding.BufferWriter): encoding.BufferWriter;
}
class Input {
readonly prevTxId: Buffer;
readonly outputIndex: number;
readonly sequenceNumber: number;
readonly script: Script;
output?: Output;
constructor(params: object);
isValidSignature(tx: Transaction, sig: any): boolean;
setScript(script: Script): this;
}
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,
satoshisBN: crypto.BN,
flags?: number
): Buffer;
function sign(
transaction: Transaction,
privateKey: PrivateKey,
sighashType: number,
inputIndex: number,
subscript: Script,
satoshisBN: crypto.BN,
flags?: number
): crypto.Signature;
function verify(
transaction: Transaction,
signature: Signature,
publicKey: PublicKey,
inputIndex: number,
subscript: Script,
satoshisBN: crypto.BN,
flags?: number
): boolean;
}
}
export class Transaction {
inputs: Transaction.Input[];
outputs: Transaction.Output[];
readonly id: string;
readonly hash: string;
readonly inputAmount: number;
readonly outputAmount: number;
nid: string;
nLockTime: number;
constructor(serialized?: any);
from(
utxos: Transaction.IUnspentOutput | Transaction.IUnspentOutput[]
): 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: crypto.Signature): this;
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;
getLockTime(): Date | number;
verify(): string | boolean;
isCoinbase(): boolean;
enableRBF(): this;
isRBF(): boolean;
inspect(): string;
serialize(opts?: object): string;
uncheckedSerialize(): string;
toObject(): any;
toBuffer(): Buffer;
isFullySigned(): boolean;
getSerializationError(opts?: object): any;
_getUnspentValue(): number;
_estimateFee(): number;
_estimateSize: number;
}
export class ECIES {
constructor(opts?: any, algorithm?: string);
privateKey(privateKey: PrivateKey): ECIES;
publicKey(publicKey: PublicKey): ECIES;
encrypt(message: string | Buffer): Buffer;
decrypt(encbuf: Buffer): Buffer;
}
export class Block {
hash: string;
height: number;
transactions: Transaction[];
header: {
time: number;
prevHash: string;
};
constructor(data: Buffer | object);
}
export class PrivateKey {
constructor(key?: string | PrivateKey, network?: Networks.Type);
readonly bn: crypto.BN;
readonly publicKey: PublicKey;
readonly compressed: boolean;
readonly network: Networks.Network;
toAddress(network: Networks.Type): Address;
toPublicKey(): PublicKey;
toString(): string;
toObject(): object;
toJSON(): object;
toWIF(): string;
toHex(): string;
toBigNumber(): any; //BN;
toBuffer(): Buffer;
inspect(): string;
static fromString(str: string): PrivateKey;
static fromWIF(str: string): PrivateKey;
static fromRandom(netowrk?: string): PrivateKey;
static fromBuffer(buf: Buffer, network: Networks.Type): PrivateKey;
static fromHex(hex: string, network: Networks.Type): PrivateKey;
static getValidationError(data: string): any | null;
static isValid(data: string): boolean;
}
export class PublicKey {
constructor(source: string | PublicKey | crypto.Point, extra?: object);
readonly point: crypto.Point;
readonly compressed: boolean;
readonly network: Networks.Network;
toDER(): Buffer;
toObject(): object;
toBuffer(): Buffer;
toAddress(network?: Networks.Type): Address;
toString(): string;
toHex(): string;
inspect(): string;
static fromPrivateKey(privateKey: PrivateKey): PublicKey;
static fromBuffer(buf: Buffer, strict?: boolean): PublicKey;
static fromDER(buf: Buffer, strict?: boolean): PublicKey;
//static fromPoint(point: Point, compressed: boolean): PublicKey;
//static fromX(odd: boolean, x: Point): PublicKey;
static fromString(str: string): PublicKey;
static fromHex(hex: string): PublicKey;
static getValidationError(data: string): any | null;
static isValid(data: string): boolean;
}
export class Message {
constructor(message: string | Buffer);
readonly messageBuffer: Buffer;
sign(privateKey: PrivateKey): string;
verify(address: string | Address, signature: string): boolean;
toObject(): object;
toJSON(): string;
toString(): string;
inspect(): string;
static sign(message: string | Buffer, privateKey: PrivateKey): string;
static verify(
message: string | Buffer,
address: string | Address,
signature: string
): boolean;
static MAGIC_BYTES: Buffer;
static magicHash(): string;
static fromString(str: string): Message;
static fromJSON(json: string): Message;
static fromObject(obj: object): Message;
}
export class Mnemonic {
constructor(data: string | Array<string>, wordList?: Array<string>);
readonly wordList: Array<string>;
readonly phrase: string;
toSeed(passphrase?: string): Buffer;
toHDPrivateKey(passphrase: string, network: Networks.Type): HDPrivateKey;
toString(): string;
inspect(): string;
static fromRandom(wordlist?: Array<string>): Mnemonic;
static fromString(mnemonic: string, wordList?: Array<string>): Mnemonic;
static isValid(mnemonic: string, wordList?: Array<string>): boolean;
static fromSeed(seed: Buffer, wordlist: Array<string>): Mnemonic;
}
export class HDPrivateKey {
constructor(data?: string | Buffer | object);
readonly hdPublicKey: HDPublicKey;
readonly xprivkey: Buffer;
readonly xpubkey: Buffer;
readonly network: Networks.Network;
readonly depth: number;
readonly privateKey: PrivateKey;
readonly publicKey: PublicKey;
readonly fingerPrint: Buffer;
derive(arg: string | number, hardened?: boolean): HDPrivateKey;
deriveChild(arg: string | number, hardened?: boolean): HDPrivateKey;
deriveNonCompliantChild(
arg: string | number,
hardened?: boolean
): HDPrivateKey;
toString(): string;
toObject(): object;
toJSON(): object;
toBuffer(): Buffer;
toHex(): string;
inspect(): string;
static fromRandom(): HDPrivateKey;
static fromString(str: string): HDPrivateKey;
static fromObject(obj: object): HDPrivateKey;
static fromSeed(
hexa: string | Buffer,
network: string | Networks.Type
): HDPrivateKey;
static fromBuffer(buf: Buffer): HDPrivateKey;
static fromHex(hex: string): HDPrivateKey;
static isValidPath(arg: string | number, hardened: boolean): boolean;
static isValidSerialized(
data: string | Buffer,
network?: string | Networks.Type
): boolean;
static getSerializedError(
data: string | Buffer,
network?: string | Networks.Type
): any | null;
}
export class HDPublicKey {
constructor(arg: string | Buffer | object);
readonly xpubkey: Buffer;
readonly network: Networks.Network;
readonly depth: number;
readonly publicKey: PublicKey;
readonly fingerPrint: Buffer;
derive(arg: string | number, hardened?: boolean): HDPublicKey;
deriveChild(arg: string | number, hardened?: boolean): HDPublicKey;
toString(): string;
toObject(): object;
toJSON(): object;
toBuffer(): Buffer;
toHex(): string;
inspect(): string;
static fromString(str: string): HDPublicKey;
static fromObject(obj: object): HDPublicKey;
static fromBuffer(buf: Buffer): HDPublicKey;
static fromHex(hex: string): HDPublicKey;
static fromHDPrivateKey(hdPrivateKey: HDPrivateKey): HDPublicKey;
static isValidPath(arg: string | number): boolean;
static isValidSerialized(
data: string | Buffer,
network?: string | Networks.Type
): boolean;
static getSerializedError(
data: string | Buffer,
network?: string | Networks.Type
): any | null;
}
export namespace Script {
const types: {
DATA_OUT: string;
};
interface IOpChunk {
buf: Buffer;
len: number;
opcodenum: number;
}
function buildMultisigOut(
publicKeys: PublicKey[],
threshold: number,
opts: object
): Script;
function buildMultisigIn(
pubkeys: PublicKey[],
threshold: number,
signatures: Buffer[],
opts: object
): Script;
function buildPublicKeyHashOut(
address: Address | PublicKey | string
): Script;
function buildPublicKeyOut(pubkey: PublicKey): Script;
function buildSafeDataOut(
data: string | Buffer | Array<string | Buffer>,
encoding?: string
): Script;
function buildScriptHashOut(script: Script): Script;
function buildPublicKeyIn(
signature: crypto.Signature | Buffer,
sigtype: number
): Script;
function buildPublicKeyHashIn(
publicKey: PublicKey,
signature: crypto.Signature | Buffer,
sigtype: number
): Script;
function fromAddress(address: string | Address): Script;
function fromASM(str: string): Script;
function fromHex(hex: string): Script;
function fromString(str: string): Script;
function fromBuffer(buf: Buffer): Script;
function toASM(): string;
function toBuffer(): Buffer;
function toHex(): string;
function toString(): string;
function empty(): Script;
namespace Interpreter {
interface InterpretState {
step: any;
mainstack: any;
altstack: any;
}
type StepListenerFunction = (
step: any,
stack: any[],
altstack: any[]
) => void;
}
export class Interpreter {
static SCRIPT_ENABLE_MAGNETIC_OPCODES: number;
static SCRIPT_ENABLE_MONOLITH_OPCODES: number;
static SCRIPT_VERIFY_STRICTENC: number;
static SCRIPT_ENABLE_SIGHASH_FORKID: number;
static SCRIPT_VERIFY_LOW_S: number;
static SCRIPT_VERIFY_NULLFAIL: number;
static SCRIPT_VERIFY_DERSIG: number;
static SCRIPT_VERIFY_MINIMALDATA: number;
static SCRIPT_VERIFY_NULLDUMMY: number;
static SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS: number;
static SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY: number;
static SCRIPT_VERIFY_CHECKSEQUENCEVERIFY: number;
stepListener?: Interpreter.StepListenerFunction;
errstr?: string;
verify: (
inputScript: Script,
outputScript: Script,
txn: Transaction,
nin: number,
flags: any,
satoshisBN: crypto.BN
) => boolean;
}
}
export class Script {
constructor(data: string | object);
chunks: Array<Script.IOpChunk>;
set(obj: object): this;
toBuffer(): Buffer;
toASM(): string;
toString(): string;
toHex(): string;
isPublicKeyHashOut(): boolean;
isPublicKeyHashIn(): boolean;
getPublicKey(): Buffer;
getPublicKeyHash(): Buffer;
isPublicKeyOut(): boolean;
isPublicKeyIn(): boolean;
isScriptHashOut(): boolean;
isWitnessScriptHashOut(): boolean;
isWitnessPublicKeyHashOut(): boolean;
isWitnessProgram(): boolean;
isScriptHashIn(): boolean;
isMultisigOut(): boolean;
isMultisigIn(): boolean;
isDataOut(): boolean;
isSafeDataOut(): boolean;
getData(): Buffer;
isPushOnly(): boolean;
classify(): string;
classifyInput(): string;
classifyOutput(): string;
isStandard(): boolean;
prepend(obj: any): this;
add(obj: any): this;
hasCodeseparators(): boolean;
removeCodeseparators(): this;
equals(script: Script): boolean;
getAddressInfo(): Address | boolean;
findAndDelete(script: Script): this;
checkMinimalPush(i: number): boolean;
getSignatureOperationsCount(accurate: boolean): number;
toAddress(network?: Networks.Type): Address;
}
export interface Util {
readonly buffer: {
reverse(a: any): any;
};
}
export namespace Networks {
interface Network {
readonly name: string;
readonly alias: string;
}
type Type = 'livenet' | 'testnet' | Network;
const livenet: Network;
const mainnet: Network;
const testnet: Network;
const defaultNetwork: Network;
function add(data: any): Network;
function remove(network: Networks.Type): void;
function get(
args: string | number | Networks.Type,
keys: string | string[]
): Network;
}
export class Address {
readonly hashBuffer: Buffer;
readonly network: Networks.Network;
readonly type: string;
constructor(
data: Buffer | Uint8Array | string | object,
network?: Networks.Type | string,
type?: string
);
static fromString(address: string, network: Networks.Type): Address;
static fromPublicKey(data: PublicKey, network: Networks.Type): Address;
static fromPrivateKey(
privateKey: PrivateKey,
network: Networks.Type
): Address;
static fromPublicKeyHash(
hash: Buffer | Uint8Array,
network: Networks.Type
): Address;
static fromScriptHash(
hash: Buffer | Uint8Array,
network: Networks.Type
): Address;
isValid(
data: Buffer | Uint8Array | string | object,
network?: Networks.Type | string,
type?: string
): boolean;
toBuffer(): Buffer;
toHex(): string;
toString(): string;
toObject(): {
hash: string;
type: string;
network: string;
};
}
export class Unit {
static fromBTC(amount: number): Unit;
static fromMilis(amount: number): Unit;
static fromBits(amount: number): Unit;
static fromSatoshis(amount: number): Unit;
constructor(amount: number, unitPreference: string);
toBTC(): number;
toMilis(): number;
toBits(): number;
toSatoshis(): number;
}
export class BlockHeader {
constructor(arg: Buffer | JSON | object);
toObject(): {
hash: string;
version: number;
prevHash: string;
merkleRoot: string;
time: number;
bits: number;
nonce: number;
};
}
export class MerkleBlock {
constructor(arg: Buffer | JSON | object);
toObject(): {
header: {
hash: string;
version: number;
prevHash: string;
merkleRoot: string;
time: number;
bits: number;
nonce: number;
};
numTransactions: number;
hashes: Array<string>;
flags: Array<number>;
};
}
}