xpi-ts 0.2.22 → 0.2.24
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.
- package/dist/cjs/lib/bitcore/crypto/point.js +2 -2
- package/dist/cjs/lib/bitcore/index.js +162 -162
- package/dist/esm/lib/bitcore/crypto/point.js +2 -2
- package/dist/esm/lib/bitcore/index.js +42 -42
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/address.d.ts +116 -0
- package/dist/types/lib/bitcore/address.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/block.d.ts +214 -0
- package/dist/types/lib/bitcore/block/block.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/blockheader.d.ts +220 -0
- package/dist/types/lib/bitcore/block/blockheader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/merkleblock.d.ts +206 -0
- package/dist/types/lib/bitcore/block/merkleblock.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/bn.d.ts +224 -0
- package/dist/types/lib/bitcore/crypto/bn.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts +122 -0
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/hash.d.ts +56 -0
- package/dist/types/lib/bitcore/crypto/hash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/index.d.ts +4 -0
- package/dist/types/lib/bitcore/crypto/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/musig2.d.ts +282 -0
- package/dist/types/lib/bitcore/crypto/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/point.d.ts +87 -0
- package/dist/types/lib/bitcore/crypto/point.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/random.d.ts +48 -0
- package/dist/types/lib/bitcore/crypto/random.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts +203 -0
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/signature.d.ts +452 -0
- package/dist/types/lib/bitcore/crypto/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts +46 -0
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58.d.ts +68 -0
- package/dist/types/lib/bitcore/encoding/base58.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58check.d.ts +58 -0
- package/dist/types/lib/bitcore/encoding/base58check.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts +112 -0
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts +144 -0
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/varint.d.ts +86 -0
- package/dist/types/lib/bitcore/encoding/varint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/errors.d.ts +4 -0
- package/dist/types/lib/bitcore/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdprivatekey.d.ts +59 -0
- package/dist/types/lib/bitcore/hdprivatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdpublickey.d.ts +145 -0
- package/dist/types/lib/bitcore/hdpublickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/index.d.ts +58 -54
- package/dist/types/lib/bitcore/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/message.d.ts +63 -0
- package/dist/types/lib/bitcore/message.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/errors.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/index.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts +106 -0
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts +13 -0
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/english.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/words/english.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts +5 -0
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts +4 -0
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/index.d.ts +14 -0
- package/dist/types/lib/bitcore/musig2/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/session.d.ts +254 -0
- package/dist/types/lib/bitcore/musig2/session.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/signer.d.ts +212 -0
- package/dist/types/lib/bitcore/musig2/signer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/networks.d.ts +17 -0
- package/dist/types/lib/bitcore/networks.d.ts.map +1 -1
- package/dist/types/lib/bitcore/opcode.d.ts +151 -0
- package/dist/types/lib/bitcore/opcode.d.ts.map +1 -1
- package/dist/types/lib/bitcore/privatekey.d.ts +80 -0
- package/dist/types/lib/bitcore/privatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/publickey.d.ts +195 -0
- package/dist/types/lib/bitcore/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/chunk.d.ts +51 -0
- package/dist/types/lib/bitcore/script/chunk.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts +60 -0
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts +23 -0
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts +86 -0
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts +115 -0
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts +119 -0
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script/taproot.d.ts +297 -0
- package/dist/types/lib/bitcore/script/taproot.d.ts.map +1 -1
- package/dist/types/lib/bitcore/script.d.ts +510 -0
- package/dist/types/lib/bitcore/script.d.ts.map +1 -1
- package/dist/types/lib/bitcore/taproot/musig2.d.ts +153 -0
- package/dist/types/lib/bitcore/taproot/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts +8 -0
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts +14 -0
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts +22 -0
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input.d.ts +418 -0
- package/dist/types/lib/bitcore/transaction/input.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts +110 -0
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/output.d.ts +83 -0
- package/dist/types/lib/bitcore/transaction/output.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/sighash.d.ts +69 -0
- package/dist/types/lib/bitcore/transaction/sighash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/signature.d.ts +98 -0
- package/dist/types/lib/bitcore/transaction/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/transaction.d.ts +379 -0
- package/dist/types/lib/bitcore/transaction/transaction.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts +61 -0
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts.map +1 -1
- package/dist/types/lib/bitcore/unit.d.ts +140 -0
- package/dist/types/lib/bitcore/unit.d.ts.map +1 -1
- package/dist/types/lib/bitcore/uri.d.ts +34 -0
- package/dist/types/lib/bitcore/uri.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/base32.d.ts +55 -0
- package/dist/types/lib/bitcore/util/base32.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/bits.d.ts +76 -0
- package/dist/types/lib/bitcore/util/bits.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/buffer.d.ts +135 -0
- package/dist/types/lib/bitcore/util/buffer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/convertBits.d.ts +15 -0
- package/dist/types/lib/bitcore/util/convertBits.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/js.d.ts +19 -0
- package/dist/types/lib/bitcore/util/js.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/merkle.d.ts +85 -0
- package/dist/types/lib/bitcore/util/merkle.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/preconditions.d.ts +29 -0
- package/dist/types/lib/bitcore/util/preconditions.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util.d.ts +7 -0
- package/dist/types/lib/bitcore/util.d.ts.map +1 -1
- package/dist/types/lib/bitcore/xaddress.d.ts +117 -0
- package/dist/types/lib/bitcore/xaddress.d.ts.map +1 -1
- package/dist/types/lib/lokad.d.ts +292 -0
- package/dist/types/lib/lokad.d.ts.map +1 -1
- package/dist/types/lib/nft.d.ts +434 -0
- package/dist/types/lib/nft.d.ts.map +1 -1
- package/dist/types/lib/rank/api.d.ts +13 -0
- package/dist/types/lib/rank/api.d.ts.map +1 -1
- package/dist/types/lib/rank/index.d.ts +153 -0
- package/dist/types/lib/rank/index.d.ts.map +1 -1
- package/dist/types/lib/rank/opcode.d.ts +6 -2
- package/dist/types/lib/rank/opcode.d.ts.map +1 -1
- package/dist/types/lib/rank/script.d.ts +10 -0
- package/dist/types/lib/rank/script.d.ts.map +1 -1
- package/dist/types/lib/rank/transaction.d.ts +11 -0
- package/dist/types/lib/rank/transaction.d.ts.map +1 -1
- package/dist/types/lib/rpc.d.ts +176 -0
- package/dist/types/lib/rpc.d.ts.map +1 -1
- package/dist/types/utils/constants.d.ts +27 -0
- package/dist/types/utils/constants.d.ts.map +1 -1
- package/dist/types/utils/env.d.ts +15 -0
- package/dist/types/utils/env.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +57 -0
- package/dist/types/utils/string.d.ts.map +1 -1
- package/dist/types/utils/wallet.d.ts +43 -1
- package/dist/types/utils/wallet.d.ts.map +1 -1
- package/package.json +1 -1
- package/tsconfig.types.json +2 -1
|
@@ -1,8 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base58Check encoding/decoding utilities
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support
|
|
4
|
+
*
|
|
5
|
+
* Uses @noble/hashes for browser compatibility and bs58 for Base58 encoding
|
|
6
|
+
*/
|
|
1
7
|
import type { Buffer } from 'buffer/';
|
|
8
|
+
/**
|
|
9
|
+
* Base58Check encoding/decoding class
|
|
10
|
+
*
|
|
11
|
+
* Provides utilities for encoding and decoding data using Base58Check encoding,
|
|
12
|
+
* which adds a 4-byte checksum to detect errors in addresses and other data.
|
|
13
|
+
* This is commonly used in Lotus and other cryptocurrencies for addresses,
|
|
14
|
+
* WIF private keys, and extended keys.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // Encode a buffer to Base58Check string
|
|
18
|
+
* const encoded = Base58Check.encode(Buffer.from([0x00, ...pubkeyHash]))
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Decode a Base58Check string to buffer
|
|
22
|
+
* const decoded = Base58Check.decode('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2')
|
|
23
|
+
*/
|
|
2
24
|
export declare class Base58Check {
|
|
25
|
+
/**
|
|
26
|
+
* Encodes a buffer to a Base58Check string
|
|
27
|
+
*
|
|
28
|
+
* Appends a 4-byte checksum (first 4 bytes of double SHA-256) to the input
|
|
29
|
+
* buffer before encoding with Base58.
|
|
30
|
+
*
|
|
31
|
+
* @param buf - Buffer to encode
|
|
32
|
+
* @returns Base58Check encoded string
|
|
33
|
+
* @throws Error if input is not a Buffer
|
|
34
|
+
*/
|
|
3
35
|
static encode(buf: Buffer): string;
|
|
36
|
+
/**
|
|
37
|
+
* Decodes a Base58Check string to a buffer
|
|
38
|
+
*
|
|
39
|
+
* Validates the checksum and returns the original data without the checksum bytes.
|
|
40
|
+
*
|
|
41
|
+
* @param str - Base58Check encoded string to decode
|
|
42
|
+
* @returns Decoded buffer (without checksum)
|
|
43
|
+
* @throws Error if input is not a string
|
|
44
|
+
* @throws Error if input string is too short (less than 4 bytes)
|
|
45
|
+
* @throws Error if checksum validation fails
|
|
46
|
+
*/
|
|
4
47
|
static decode(str: string): Buffer;
|
|
48
|
+
/**
|
|
49
|
+
* Calculates the checksum for the given data
|
|
50
|
+
*
|
|
51
|
+
* The checksum is the first 4 bytes of the double SHA-256 hash of the data.
|
|
52
|
+
*
|
|
53
|
+
* @param data - Buffer to calculate checksum for
|
|
54
|
+
* @returns 4-byte checksum buffer
|
|
55
|
+
*/
|
|
5
56
|
static checksum(data: Buffer): Buffer;
|
|
57
|
+
/**
|
|
58
|
+
* Validates a checksum against the given data
|
|
59
|
+
*
|
|
60
|
+
* @param data - Original data buffer
|
|
61
|
+
* @param checksum - Checksum buffer to validate (4 bytes)
|
|
62
|
+
* @returns True if the checksum is valid, false otherwise
|
|
63
|
+
*/
|
|
6
64
|
static validChecksum(data: Buffer, checksum: Buffer): boolean;
|
|
7
65
|
}
|
|
8
66
|
//# sourceMappingURL=base58check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base58check.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/base58check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base58check.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/base58check.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,WAAW;IACtB;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAYlC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAqBlC;;;;;;;OAOG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAKrC;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;CAI9D"}
|
|
@@ -4,32 +4,144 @@ export interface BufferReaderData {
|
|
|
4
4
|
buf?: Buffer;
|
|
5
5
|
pos?: number;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* BufferReader class for reading binary data from a buffer
|
|
9
|
+
* Provides methods to read various data types in different byte orders
|
|
10
|
+
* Migrated from bitcore-lib-xpi with ESM support and TypeScript
|
|
11
|
+
*/
|
|
7
12
|
export declare class BufferReader {
|
|
13
|
+
/** The underlying buffer being read */
|
|
8
14
|
buf: Buffer;
|
|
15
|
+
/** Current position in the buffer */
|
|
9
16
|
pos: number;
|
|
17
|
+
/**
|
|
18
|
+
* Create a new BufferReader instance
|
|
19
|
+
* @param buf - Buffer, hex string, or BufferReaderData object to read from
|
|
20
|
+
* @throws {TypeError} If the argument is not a valid buffer, hex string, or object
|
|
21
|
+
*/
|
|
10
22
|
constructor(buf?: Buffer | string | BufferReaderData);
|
|
23
|
+
/**
|
|
24
|
+
* Factory function to create a BufferReader without using 'new'
|
|
25
|
+
* @param buf - Buffer, hex string, or BufferReaderData object to read from
|
|
26
|
+
* @returns A new BufferReader instance
|
|
27
|
+
*/
|
|
11
28
|
static create(buf?: Buffer | string | BufferReaderData): BufferReader;
|
|
29
|
+
/**
|
|
30
|
+
* Set the buffer and position from a BufferReaderData object
|
|
31
|
+
* @param obj - Object containing buf and/or pos properties
|
|
32
|
+
* @returns This BufferReader instance for chaining
|
|
33
|
+
*/
|
|
12
34
|
set(obj: BufferReaderData): BufferReader;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the reader has reached the end of the buffer
|
|
37
|
+
* @returns True if position is at or past the end of the buffer
|
|
38
|
+
*/
|
|
13
39
|
eof(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Alias for eof() - check if reading is finished
|
|
42
|
+
* @returns True if position is at or past the end of the buffer
|
|
43
|
+
*/
|
|
14
44
|
finished(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Read a specified number of bytes from the buffer
|
|
47
|
+
* @param len - Number of bytes to read
|
|
48
|
+
* @returns Buffer containing the read bytes
|
|
49
|
+
* @throws {Error} If len is undefined
|
|
50
|
+
*/
|
|
15
51
|
read(len: number): Buffer;
|
|
52
|
+
/**
|
|
53
|
+
* Read all remaining bytes from the buffer
|
|
54
|
+
* @returns Buffer containing all remaining bytes
|
|
55
|
+
*/
|
|
16
56
|
readAll(): Buffer;
|
|
57
|
+
/**
|
|
58
|
+
* Read an unsigned 8-bit integer
|
|
59
|
+
* @returns The unsigned 8-bit integer value
|
|
60
|
+
*/
|
|
17
61
|
readUInt8(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Read an unsigned 16-bit integer in big-endian format
|
|
64
|
+
* @returns The unsigned 16-bit integer value
|
|
65
|
+
*/
|
|
18
66
|
readUInt16BE(): number;
|
|
67
|
+
/**
|
|
68
|
+
* Read an unsigned 16-bit integer in little-endian format
|
|
69
|
+
* @returns The unsigned 16-bit integer value
|
|
70
|
+
*/
|
|
19
71
|
readUInt16LE(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Read an unsigned 32-bit integer in big-endian format
|
|
74
|
+
* @returns The unsigned 32-bit integer value
|
|
75
|
+
*/
|
|
20
76
|
readUInt32BE(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Read an unsigned 32-bit integer in little-endian format
|
|
79
|
+
* @returns The unsigned 32-bit integer value
|
|
80
|
+
*/
|
|
21
81
|
readUInt32LE(): number;
|
|
82
|
+
/**
|
|
83
|
+
* Read an unsigned 48-bit integer in little-endian format
|
|
84
|
+
* @returns The unsigned 48-bit integer value
|
|
85
|
+
*/
|
|
22
86
|
readUInt48LE(): number;
|
|
87
|
+
/**
|
|
88
|
+
* Read an unsigned 56-bit integer in little-endian format as a BN
|
|
89
|
+
* @returns BN instance containing the 56-bit value
|
|
90
|
+
*/
|
|
23
91
|
readUInt56LEBN(): BN;
|
|
92
|
+
/**
|
|
93
|
+
* Read a signed 32-bit integer in little-endian format
|
|
94
|
+
* @returns The signed 32-bit integer value
|
|
95
|
+
*/
|
|
24
96
|
readInt32LE(): number;
|
|
97
|
+
/**
|
|
98
|
+
* Read an unsigned 64-bit integer in big-endian format as a BN
|
|
99
|
+
* @returns BN instance containing the 64-bit value
|
|
100
|
+
*/
|
|
25
101
|
readUInt64BEBN(): BN;
|
|
102
|
+
/**
|
|
103
|
+
* Read an unsigned 64-bit integer in little-endian format as a BN
|
|
104
|
+
* Uses optimized path for values that fit in JavaScript's safe integer range
|
|
105
|
+
* @returns BN instance containing the 64-bit value
|
|
106
|
+
*/
|
|
26
107
|
readUInt64LEBN(): BN;
|
|
108
|
+
/**
|
|
109
|
+
* Read an unsigned 32-bit integer in little-endian format as a BN
|
|
110
|
+
* @returns BN instance containing the 32-bit value
|
|
111
|
+
*/
|
|
27
112
|
readUInt32LEBN(): BN;
|
|
113
|
+
/**
|
|
114
|
+
* Read a variable-length integer (varint) as a number
|
|
115
|
+
* @returns The varint value as a number
|
|
116
|
+
* @throws {Error} If the value is too large to retain precision as a number
|
|
117
|
+
*/
|
|
28
118
|
readVarintNum(): number;
|
|
119
|
+
/**
|
|
120
|
+
* Read a length-prepended buffer where the length is encoded as a varint
|
|
121
|
+
* @returns Buffer containing the data
|
|
122
|
+
* @throws {Error} If the read buffer length doesn't match the expected length
|
|
123
|
+
*/
|
|
29
124
|
readVarLengthBuffer(): Buffer;
|
|
125
|
+
/**
|
|
126
|
+
* Read a varint as a raw buffer including the prefix byte
|
|
127
|
+
* @returns Buffer containing the varint bytes
|
|
128
|
+
*/
|
|
30
129
|
readVarintBuf(): Buffer;
|
|
130
|
+
/**
|
|
131
|
+
* Read a variable-length integer (varint) as a BN
|
|
132
|
+
* @returns BN instance containing the varint value
|
|
133
|
+
*/
|
|
31
134
|
readVarintBN(): BN;
|
|
135
|
+
/**
|
|
136
|
+
* Reverse the entire buffer in place
|
|
137
|
+
* @returns This BufferReader instance for chaining
|
|
138
|
+
*/
|
|
32
139
|
reverse(): BufferReader;
|
|
140
|
+
/**
|
|
141
|
+
* Read bytes and return them in reversed order
|
|
142
|
+
* @param len - Number of bytes to read (defaults to remaining buffer length)
|
|
143
|
+
* @returns Buffer containing the read bytes in reversed order
|
|
144
|
+
*/
|
|
33
145
|
readReverse(len?: number): Buffer;
|
|
34
146
|
}
|
|
35
147
|
//# sourceMappingURL=bufferreader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferreader.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/bufferreader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC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;OAGG;IACH,WAAW,IAAI,MAAM;IAMrB;;;OAGG;IACH,cAAc,IAAI,EAAE;IAOpB;;;;OAIG;IACH,cAAc,IAAI,EAAE;IAqBpB;;;OAGG;IACH,cAAc,IAAI,EAAE;IAMpB;;;;OAIG;IACH,aAAa,IAAI,MAAM;IAuBvB;;;;OAIG;IACH,mBAAmB,IAAI,MAAM;IAc7B;;;OAGG;IACH,aAAa,IAAI,MAAM;IAcvB;;;OAGG;IACH,YAAY,IAAI,EAAE;IAclB;;;OAGG;IACH,OAAO,IAAI,YAAY;IASvB;;;;OAIG;IACH,WAAW,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;CAQlC"}
|
|
@@ -1,36 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Buffer writer utility module
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support and TypeScript
|
|
4
|
+
*/
|
|
1
5
|
import { BN } from '../crypto/bn';
|
|
2
6
|
import type { Buffer } from 'buffer/';
|
|
7
|
+
/**
|
|
8
|
+
* Data structure for initializing a BufferWriter
|
|
9
|
+
*/
|
|
3
10
|
export interface BufferWriterData {
|
|
11
|
+
/** Array of buffers to initialize with */
|
|
4
12
|
bufs?: Buffer[];
|
|
5
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* BufferWriter utility class for building binary data
|
|
16
|
+
* Provides methods for writing various data types to a buffer
|
|
17
|
+
* Migrated from bitcore-lib-xpi with ESM support and TypeScript
|
|
18
|
+
*/
|
|
6
19
|
export declare class BufferWriter {
|
|
20
|
+
/** Array of buffers that have been written */
|
|
7
21
|
bufs: Buffer[];
|
|
22
|
+
/** Total length of all buffers combined */
|
|
8
23
|
bufLen: number;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new BufferWriter instance
|
|
26
|
+
* @param obj - Optional initialization data
|
|
27
|
+
*/
|
|
9
28
|
constructor(obj?: BufferWriterData);
|
|
29
|
+
/**
|
|
30
|
+
* Factory function to allow calling BufferWriter() without 'new'
|
|
31
|
+
* @param obj - Optional initialization data
|
|
32
|
+
* @returns A new BufferWriter instance
|
|
33
|
+
*/
|
|
10
34
|
static create(obj?: BufferWriterData): BufferWriter;
|
|
35
|
+
/**
|
|
36
|
+
* Set the BufferWriter state from an object
|
|
37
|
+
* @param obj - Object containing buffer data
|
|
38
|
+
* @returns This BufferWriter instance for chaining
|
|
39
|
+
*/
|
|
11
40
|
set(obj: BufferWriterData): BufferWriter;
|
|
41
|
+
/**
|
|
42
|
+
* Convert all written buffers to a single Buffer
|
|
43
|
+
* @returns Concatenated buffer of all written data
|
|
44
|
+
*/
|
|
12
45
|
toBuffer(): Buffer;
|
|
46
|
+
/**
|
|
47
|
+
* Concatenate all buffers into a single Buffer
|
|
48
|
+
* @returns Concatenated buffer of all written data
|
|
49
|
+
*/
|
|
13
50
|
concat(): Buffer;
|
|
51
|
+
/**
|
|
52
|
+
* Write a buffer to the writer
|
|
53
|
+
* @param buf - Buffer to write
|
|
54
|
+
* @returns This BufferWriter instance for chaining
|
|
55
|
+
* @throws Error if buf is not a Buffer
|
|
56
|
+
*/
|
|
14
57
|
write(buf: Buffer): BufferWriter;
|
|
58
|
+
/**
|
|
59
|
+
* Write a buffer in reverse byte order
|
|
60
|
+
* @param buf - Buffer to write reversed
|
|
61
|
+
* @returns This BufferWriter instance for chaining
|
|
62
|
+
* @throws Error if buf is not a Buffer
|
|
63
|
+
*/
|
|
15
64
|
writeReverse(buf: Buffer): BufferWriter;
|
|
65
|
+
/**
|
|
66
|
+
* Write an unsigned 8-bit integer
|
|
67
|
+
* @param n - Number to write (0-255)
|
|
68
|
+
* @returns This BufferWriter instance for chaining
|
|
69
|
+
*/
|
|
16
70
|
writeUInt8(n: number): BufferWriter;
|
|
71
|
+
/**
|
|
72
|
+
* Write an unsigned 16-bit integer in big-endian format
|
|
73
|
+
* @param n - Number to write (0-65535)
|
|
74
|
+
* @returns This BufferWriter instance for chaining
|
|
75
|
+
*/
|
|
17
76
|
writeUInt16BE(n: number): BufferWriter;
|
|
77
|
+
/**
|
|
78
|
+
* Write an unsigned 16-bit integer in little-endian format
|
|
79
|
+
* @param n - Number to write (0-65535)
|
|
80
|
+
* @returns This BufferWriter instance for chaining
|
|
81
|
+
*/
|
|
18
82
|
writeUInt16LE(n: number): BufferWriter;
|
|
83
|
+
/**
|
|
84
|
+
* Write an unsigned 32-bit integer in big-endian format
|
|
85
|
+
* @param n - Number to write (0-4294967295)
|
|
86
|
+
* @returns This BufferWriter instance for chaining
|
|
87
|
+
*/
|
|
19
88
|
writeUInt32BE(n: number): BufferWriter;
|
|
89
|
+
/**
|
|
90
|
+
* Write a signed 32-bit integer in little-endian format
|
|
91
|
+
* @param n - Number to write (-2147483648 to 2147483647)
|
|
92
|
+
* @returns This BufferWriter instance for chaining
|
|
93
|
+
*/
|
|
20
94
|
writeInt32LE(n: number): BufferWriter;
|
|
95
|
+
/**
|
|
96
|
+
* Write an unsigned 32-bit integer in little-endian format
|
|
97
|
+
* @param n - Number to write (0-4294967295)
|
|
98
|
+
* @returns This BufferWriter instance for chaining
|
|
99
|
+
*/
|
|
21
100
|
writeUInt32LE(n: number): BufferWriter;
|
|
101
|
+
/**
|
|
102
|
+
* Write an unsigned 48-bit integer in little-endian format
|
|
103
|
+
* @param n - Number to write (0-281474976710655)
|
|
104
|
+
* @returns This BufferWriter instance for chaining
|
|
105
|
+
*/
|
|
22
106
|
writeUInt48LE(n: number): BufferWriter;
|
|
107
|
+
/**
|
|
108
|
+
* Write an unsigned 56-bit integer in little-endian format
|
|
109
|
+
* @param n - Number to write
|
|
110
|
+
* @returns This BufferWriter instance for chaining
|
|
111
|
+
*/
|
|
23
112
|
writeUInt56LE(n: number): BufferWriter;
|
|
113
|
+
/**
|
|
114
|
+
* Write an unsigned 64-bit integer from a BN in big-endian format
|
|
115
|
+
* @param bn - BN instance containing the number to write
|
|
116
|
+
* @returns This BufferWriter instance for chaining
|
|
117
|
+
*/
|
|
24
118
|
writeUInt64BEBN(bn: BN): BufferWriter;
|
|
119
|
+
/**
|
|
120
|
+
* Write an unsigned 56-bit integer from a BN in little-endian format
|
|
121
|
+
* @param bn - BN instance containing the number to write
|
|
122
|
+
* @returns This BufferWriter instance for chaining
|
|
123
|
+
*/
|
|
25
124
|
writeUInt56LEBN(bn: BN): BufferWriter;
|
|
125
|
+
/**
|
|
126
|
+
* Write an unsigned 64-bit integer from a BN in little-endian format
|
|
127
|
+
* @param bn - BN instance containing the number to write
|
|
128
|
+
* @returns This BufferWriter instance for chaining
|
|
129
|
+
*/
|
|
26
130
|
writeUInt64LEBN(bn: BN): BufferWriter;
|
|
131
|
+
/**
|
|
132
|
+
* Write an unsigned 64-bit integer from a BigInt in little-endian format
|
|
133
|
+
* @param value - BigInt value to write
|
|
134
|
+
* @returns This BufferWriter instance for chaining
|
|
135
|
+
*/
|
|
27
136
|
writeUInt64LEBigInt(value: bigint): BufferWriter;
|
|
137
|
+
/**
|
|
138
|
+
* Write an unsigned 32-bit integer from a BN in little-endian format
|
|
139
|
+
* @param bn - BN instance containing the number to write
|
|
140
|
+
* @returns This BufferWriter instance for chaining
|
|
141
|
+
*/
|
|
28
142
|
writeUInt32LEBN(bn: BN): BufferWriter;
|
|
143
|
+
/**
|
|
144
|
+
* Write an unsigned 32-bit integer from a number in little-endian format
|
|
145
|
+
* @param value - Number to write
|
|
146
|
+
* @returns This BufferWriter instance for chaining
|
|
147
|
+
*/
|
|
29
148
|
writeUInt32LENumber(value: number): BufferWriter;
|
|
149
|
+
/**
|
|
150
|
+
* Write a variable-length integer (varint) from a number
|
|
151
|
+
* @param n - Number to write as varint
|
|
152
|
+
* @returns This BufferWriter instance for chaining
|
|
153
|
+
*/
|
|
30
154
|
writeVarintNum(n: number): BufferWriter;
|
|
155
|
+
/**
|
|
156
|
+
* Write a variable-length integer (varint) from a BN
|
|
157
|
+
* @param bn - BN instance to write as varint
|
|
158
|
+
* @returns This BufferWriter instance for chaining
|
|
159
|
+
*/
|
|
31
160
|
writeVarintBN(bn: BN): BufferWriter;
|
|
161
|
+
/**
|
|
162
|
+
* Write a length-prefixed buffer (varint length followed by data)
|
|
163
|
+
* @param buf - Buffer to write with length prefix
|
|
164
|
+
* @returns This BufferWriter instance for chaining
|
|
165
|
+
*/
|
|
32
166
|
writeVarLengthBuffer(buf: Buffer): BufferWriter;
|
|
167
|
+
/**
|
|
168
|
+
* Create a varint buffer from a number
|
|
169
|
+
* @param n - Number to encode as varint
|
|
170
|
+
* @returns Buffer containing the varint-encoded number
|
|
171
|
+
*/
|
|
33
172
|
static varintBufNum(n: number): Buffer;
|
|
173
|
+
/**
|
|
174
|
+
* Create a varint buffer from a BN
|
|
175
|
+
* @param bn - BN instance to encode as varint
|
|
176
|
+
* @returns Buffer containing the varint-encoded number
|
|
177
|
+
*/
|
|
34
178
|
static varintBufBN(bn: BN): Buffer;
|
|
35
179
|
}
|
|
36
180
|
//# sourceMappingURL=bufferwriter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bufferwriter.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/bufferwriter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bufferwriter.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/bufferwriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED;;;;GAIG;AACH,qBAAa,YAAY;IACvB,8CAA8C;IAC9C,IAAI,EAAE,MAAM,EAAE,CAAK;IACnB,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAI;IAElB;;;OAGG;gBACS,GAAG,CAAC,EAAE,gBAAgB;IASlC;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,GAAG,CA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CAAC,EAAE,MAAM,GAAG,YAAY;IAMvC;;;;OAIG;IACH,aAAa,CAAC,EAAE,EAAE,EAAE,GAAG,YAAY;IAMnC;;;;OAIG;IACH,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAM/C;;;;OAIG;IACH,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAsBtC;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM;CAuBnC"}
|
|
@@ -1,21 +1,107 @@
|
|
|
1
1
|
import { BufferReader } from './bufferreader';
|
|
2
2
|
import { BN } from '../crypto/bn';
|
|
3
3
|
import type { Buffer } from 'buffer/';
|
|
4
|
+
/**
|
|
5
|
+
* Data interface for Varint construction.
|
|
6
|
+
* Used when creating a Varint from an object with a buffer property.
|
|
7
|
+
*/
|
|
4
8
|
export interface VarintData {
|
|
9
|
+
/** The buffer containing the varint-encoded data */
|
|
5
10
|
buf?: Buffer;
|
|
6
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Varint (Variable-length integer) class for encoding and decoding
|
|
14
|
+
* variable-length integers used in Bitcoin protocol.
|
|
15
|
+
*
|
|
16
|
+
* Variable integers are used throughout the Bitcoin protocol to encode
|
|
17
|
+
* lengths and counts. They can represent values from 0 to 2^64-1 using
|
|
18
|
+
* 1 to 9 bytes depending on the magnitude of the value.
|
|
19
|
+
*
|
|
20
|
+
* Encoding scheme:
|
|
21
|
+
* - 0x00-0xFC: 1 byte (value as-is)
|
|
22
|
+
* - 0xFD followed by 2 bytes: values 0xFD to 0xFFFF (little-endian)
|
|
23
|
+
* - 0xFE followed by 4 bytes: values 0x10000 to 0xFFFFFFFF (little-endian)
|
|
24
|
+
* - 0xFF followed by 8 bytes: values 0x100000000 to 0xFFFFFFFFFFFFFFFF (little-endian)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Create from number
|
|
28
|
+
* const varint = new Varint(100)
|
|
29
|
+
*
|
|
30
|
+
* // Create from BN
|
|
31
|
+
* const varint = new Varint(new BN(1000000))
|
|
32
|
+
*
|
|
33
|
+
* // Create from buffer
|
|
34
|
+
* const varint = new Varint(buffer)
|
|
35
|
+
*
|
|
36
|
+
* // Convert to number
|
|
37
|
+
* const num = varint.toNumber()
|
|
38
|
+
*
|
|
39
|
+
* // Convert to BN
|
|
40
|
+
* const bn = varint.toBN()
|
|
41
|
+
*/
|
|
7
42
|
export declare class Varint {
|
|
43
|
+
/**
|
|
44
|
+
* The buffer containing the varint-encoded data.
|
|
45
|
+
* Initialized to an empty buffer by default.
|
|
46
|
+
*/
|
|
8
47
|
buf: Buffer;
|
|
9
48
|
constructor(buf?: Buffer | number | BN | VarintData);
|
|
49
|
+
/**
|
|
50
|
+
* Set the varint from a VarintData object
|
|
51
|
+
* @param obj - Object containing buffer data
|
|
52
|
+
* @returns This Varint instance for chaining
|
|
53
|
+
*/
|
|
10
54
|
set(obj: VarintData): Varint;
|
|
55
|
+
/**
|
|
56
|
+
* Create a Varint from a hex string
|
|
57
|
+
* @param str - Hex string representation of the varint
|
|
58
|
+
* @returns This Varint instance for chaining
|
|
59
|
+
*/
|
|
11
60
|
fromString(str: string): Varint;
|
|
61
|
+
/**
|
|
62
|
+
* Convert the varint to a hex string
|
|
63
|
+
* @returns Hex string representation of the varint
|
|
64
|
+
*/
|
|
12
65
|
toString(): string;
|
|
66
|
+
/**
|
|
67
|
+
* Create a Varint from a buffer
|
|
68
|
+
* @param buf - Buffer containing varint-encoded data
|
|
69
|
+
* @returns This Varint instance for chaining
|
|
70
|
+
*/
|
|
13
71
|
fromBuffer(buf: Buffer): Varint;
|
|
72
|
+
/**
|
|
73
|
+
* Create a Varint by reading from a BufferReader
|
|
74
|
+
* @param br - BufferReader to read the varint from
|
|
75
|
+
* @returns This Varint instance for chaining
|
|
76
|
+
*/
|
|
14
77
|
fromBufferReader(br: BufferReader): Varint;
|
|
78
|
+
/**
|
|
79
|
+
* Create a Varint from a BN (big number)
|
|
80
|
+
* @param bn - BN instance to encode as varint
|
|
81
|
+
* @returns This Varint instance for chaining
|
|
82
|
+
*/
|
|
15
83
|
fromBN(bn: BN): Varint;
|
|
84
|
+
/**
|
|
85
|
+
* Create a Varint from a number
|
|
86
|
+
* @param num - Number to encode as varint
|
|
87
|
+
* @returns This Varint instance for chaining
|
|
88
|
+
*/
|
|
16
89
|
fromNumber(num: number): Varint;
|
|
90
|
+
/**
|
|
91
|
+
* Convert the varint to a buffer
|
|
92
|
+
* @returns Buffer containing the varint-encoded data
|
|
93
|
+
*/
|
|
17
94
|
toBuffer(): Buffer;
|
|
95
|
+
/**
|
|
96
|
+
* Convert the varint to a BN (big number)
|
|
97
|
+
* @returns BN instance containing the decoded value
|
|
98
|
+
*/
|
|
18
99
|
toBN(): BN;
|
|
100
|
+
/**
|
|
101
|
+
* Convert the varint to a number
|
|
102
|
+
* @returns The decoded varint value as a number
|
|
103
|
+
* @throws {Error} If the value is too large to retain precision as a number
|
|
104
|
+
*/
|
|
19
105
|
toNumber(): number;
|
|
20
106
|
}
|
|
21
107
|
//# sourceMappingURL=varint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"varint.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/varint.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"varint.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/encoding/varint.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,MAAM;IACjB;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAsB;gBAErB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,EAAE,GAAG,UAAU;IAgBnD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM;IAK5B;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAO/B;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK/B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,MAAM;IAK1C;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM;IAKtB;;;;OAIG;IACH,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAK/B;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,IAAI,IAAI,EAAE;IAIV;;;;OAIG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiDH,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC,CAAA;IAClD,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;CAC3B;AAoSD,qBAAa,YAAa,SAAQ,KAAK;gBACzB,OAAO,CAAC,EAAE,MAAM;IAM5B,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,eAAe,GAAG,QAAQ;IAK9C,MAAM,CAAC,cAAc,EAAE,KAAK,OAAO,CAAC,EAAE,MAAM,KAAK,YAAY,CAAA;IAC7D,MAAM,CAAC,WAAW,EAAE;QAClB,iBAAiB,EAAE,UAAU,YAAY,CAAA;KAC1C,CAAA;IACD,MAAM,CAAC,MAAM,EAAE;QACb,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,YAAY,CAAA;QACnD,mBAAmB,EAAE,KAAK,OAAO,EAAE,OAAO,KAAK,YAAY,CAAA;QAC3D,iBAAiB,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,YAAY,CAAA;QACvD,mBAAmB,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,YAAY,CAAA;KAC1D,CAAA;IACD,MAAM,CAAC,YAAY,EAAE;QACnB,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,YAAY,CAAA;QACnD,eAAe,EAAE,KACf,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,KACd,YAAY,CAAA;QACjB,mBAAmB,EAAE,KACnB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,GAAG,QAAQ,EACvB,YAAY,CAAC,EAAE,MAAM,KAClB,YAAY,CAAA;KAClB,CAAA;IACD,MAAM,CAAC,WAAW,EAAE;QAClB,KAAK,EAAE;YACL,aAAa,EAAE,UAAU,YAAY,CAAA;SACtC,CAAA;KACF,CAAA;CACF"}
|
|
@@ -58,24 +58,83 @@ export declare class HDPrivateKey {
|
|
|
58
58
|
private static _getRandomData;
|
|
59
59
|
private static _fromSeed;
|
|
60
60
|
private _buildFromObject;
|
|
61
|
+
/**
|
|
62
|
+
* Check if path is valid
|
|
63
|
+
*/
|
|
61
64
|
isValidPath(arg: string | number, hardened?: boolean): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Internal function that splits a string path into a derivation index array.
|
|
67
|
+
* It will return null if the string path is malformed.
|
|
68
|
+
* It does not validate if indexes are in bounds.
|
|
69
|
+
*/
|
|
62
70
|
private static _getDerivationIndexes;
|
|
71
|
+
/**
|
|
72
|
+
* Check if serialized data is valid
|
|
73
|
+
*/
|
|
63
74
|
static isValidSerialized(data: string | Buffer): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Get serialization error
|
|
77
|
+
*/
|
|
64
78
|
getSerializedError(data: string | Buffer): Error | null;
|
|
79
|
+
/**
|
|
80
|
+
* Derive child key
|
|
81
|
+
*/
|
|
65
82
|
derive(arg: string | number, hardened?: boolean): HDPrivateKey;
|
|
83
|
+
/**
|
|
84
|
+
* Derive from string path
|
|
85
|
+
*/
|
|
66
86
|
private _deriveFromString;
|
|
87
|
+
/**
|
|
88
|
+
* Derive with number index
|
|
89
|
+
*/
|
|
67
90
|
private _deriveWithNumber;
|
|
91
|
+
/**
|
|
92
|
+
* Derive child key (alias for derive)
|
|
93
|
+
*/
|
|
68
94
|
deriveChild(arg: string | number, hardened?: boolean): HDPrivateKey;
|
|
95
|
+
/**
|
|
96
|
+
* Derive non-compliant child (for compatibility)
|
|
97
|
+
*/
|
|
69
98
|
deriveNonCompliantChild(arg: string | number, hardened?: boolean): HDPrivateKey;
|
|
99
|
+
/**
|
|
100
|
+
* Convert to string
|
|
101
|
+
*/
|
|
70
102
|
toString(): string;
|
|
103
|
+
/**
|
|
104
|
+
* Convert to object
|
|
105
|
+
*/
|
|
71
106
|
toObject(): HDPrivateKeyObject;
|
|
107
|
+
/**
|
|
108
|
+
* Convert to JSON
|
|
109
|
+
*/
|
|
72
110
|
toJSON(): HDPrivateKeyObject;
|
|
111
|
+
/**
|
|
112
|
+
* Convert to buffer
|
|
113
|
+
*/
|
|
73
114
|
toBuffer(): Buffer;
|
|
115
|
+
/**
|
|
116
|
+
* Create from buffer
|
|
117
|
+
*/
|
|
74
118
|
static fromBuffer(arg: Buffer): HDPrivateKey;
|
|
119
|
+
/**
|
|
120
|
+
* Create from string
|
|
121
|
+
*/
|
|
75
122
|
static fromString(arg: string): HDPrivateKey;
|
|
123
|
+
/**
|
|
124
|
+
* Create from object
|
|
125
|
+
*/
|
|
76
126
|
static fromObject(obj: HDPrivateKeyObject): HDPrivateKey;
|
|
127
|
+
/**
|
|
128
|
+
* Create from seed
|
|
129
|
+
*/
|
|
77
130
|
static fromSeed(hexa: string | Buffer, network?: Network | NetworkName): HDPrivateKey;
|
|
131
|
+
/**
|
|
132
|
+
* Create a random HDPrivateKey for the specified network
|
|
133
|
+
*/
|
|
78
134
|
static fromRandom(network?: Network | NetworkName): HDPrivateKey;
|
|
135
|
+
/**
|
|
136
|
+
* Get string representation for console
|
|
137
|
+
*/
|
|
79
138
|
inspect(): string;
|
|
80
139
|
}
|
|
81
140
|
//# sourceMappingURL=hdprivatekey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hdprivatekey.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/hdprivatekey.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAGvC,OAAO,EACL,OAAO,EAGP,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AAMnB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EA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