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,6 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merkle tree utility functions
|
|
3
|
+
* Migrated from bitcore-lib-xpi with TypeScript enhancements
|
|
4
|
+
*
|
|
5
|
+
* These utilities provide general-purpose merkle tree calculations
|
|
6
|
+
* used across the bitcore block modules.
|
|
7
|
+
*/
|
|
1
8
|
import type { Buffer } from 'buffer/';
|
|
9
|
+
/**
|
|
10
|
+
* Calculate the width of a merkle tree at a given height.
|
|
11
|
+
*
|
|
12
|
+
* This determines how many nodes exist at a specific level in the tree,
|
|
13
|
+
* accounting for the fact that merkle trees may have odd numbers of leaves
|
|
14
|
+
* which get paired with duplicates.
|
|
15
|
+
*
|
|
16
|
+
* @param nLeaves - Total number of leaves (transaction hashes) in the tree
|
|
17
|
+
* @param height - Height at which to calculate tree width (0 = leaves)
|
|
18
|
+
* @returns Number of nodes at the specified height
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Block with 5 transactions
|
|
23
|
+
* const widthAtLeaves = calcTreeWidth(10, 0) // 10 (hash + txid pairs)
|
|
24
|
+
* const widthAtLevel1 = calcTreeWidth(10, 1) // 5
|
|
25
|
+
* const widthAtRoot = calcTreeWidth(10, 3) // 1
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* This matches the implementation in lotusd (CPartialMerkleTree::CalcTreeWidth)
|
|
30
|
+
* and Bitcoin Core (merkleblock.h).
|
|
31
|
+
*/
|
|
2
32
|
export declare function calcTreeWidth(nLeaves: number, height: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Calculate the height of a merkle tree given the number of leaves.
|
|
35
|
+
*
|
|
36
|
+
* @param nLeaves - Total number of leaves in the tree
|
|
37
|
+
* @returns Height of the tree (0 for single leaf, increases with tree depth)
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* calcTreeHeight(1) // 0 (single tx)
|
|
42
|
+
* calcTreeHeight(2) // 1
|
|
43
|
+
* calcTreeHeight(5) // 3
|
|
44
|
+
* calcTreeHeight(10) // 4
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
3
47
|
export declare function calcTreeHeight(nLeaves: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Calculate the hash of a node in the merkle tree.
|
|
50
|
+
*
|
|
51
|
+
* At height 0, returns the leaf hash directly. At higher heights,
|
|
52
|
+
* recursively calculates the hash by combining left and right child hashes.
|
|
53
|
+
*
|
|
54
|
+
* @param height - Current height in the tree (0 = leaves)
|
|
55
|
+
* @param pos - Position at this height
|
|
56
|
+
* @param hashes - Array of all leaf hashes
|
|
57
|
+
* @param nullHash - Optional null hash buffer for padding (defaults to 32 zero bytes)
|
|
58
|
+
* @returns The calculated hash as a hex string
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* const hashes = ['abc...', 'def...', 'ghi...']
|
|
63
|
+
* const rootHash = calcMerkleHash(2, 0, hashes)
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
4
66
|
export declare function calcMerkleHash(height: number, pos: number, hashes: string[], nullHash?: Buffer): string;
|
|
67
|
+
/**
|
|
68
|
+
* Traverse and build a partial merkle tree.
|
|
69
|
+
*
|
|
70
|
+
* Recursively traverses the merkle tree, determining which nodes are parents
|
|
71
|
+
* of matched transactions, and builds the arrays of flag bits and hashes
|
|
72
|
+
* needed for a MerkleBlock.
|
|
73
|
+
*
|
|
74
|
+
* @param height - Current height in the tree
|
|
75
|
+
* @param pos - Current position at this height
|
|
76
|
+
* @param nLeaves - Total number of leaves in the tree
|
|
77
|
+
* @param hashes - Array of all leaf hashes
|
|
78
|
+
* @param vfMatch - Boolean array indicating which leaves match
|
|
79
|
+
* @param vBits - Output array for flag bits (mutated)
|
|
80
|
+
* @param vHash - Output array for hashes (mutated)
|
|
81
|
+
* @param nullHash - Optional null hash buffer for padding
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const vBits: boolean[] = []
|
|
86
|
+
* const vHash: string[] = []
|
|
87
|
+
* traverseAndBuild(height, 0, nLeaves, hashes, vfMatch, vBits, vHash)
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
5
90
|
export declare function traverseAndBuild(height: number, pos: number, nLeaves: number, hashes: string[], vfMatch: boolean[], vBits: boolean[], vHash: string[], nullHash?: Buffer): void;
|
|
6
91
|
//# sourceMappingURL=merkle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merkle.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/util/merkle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merkle.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/util/merkle.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,GAAE,MAA6B,GACtC,MAAM,CAoBR;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,OAAO,EAAE,EAClB,KAAK,EAAE,OAAO,EAAE,EAChB,KAAK,EAAE,MAAM,EAAE,EACf,QAAQ,GAAE,MAA6B,GACtC,IAAI,CAwCN"}
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preconditions utility module
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support and TypeScript
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Utility class for checking preconditions
|
|
7
|
+
* Provides methods to validate state, arguments, and argument types
|
|
8
|
+
*/
|
|
1
9
|
export declare class Preconditions {
|
|
10
|
+
/**
|
|
11
|
+
* Check that a state condition is satisfied
|
|
12
|
+
* @param condition - The condition to check
|
|
13
|
+
* @param message - Error message if condition is false
|
|
14
|
+
* @throws {BitcoreError.Precondition.InvalidState} If condition is false
|
|
15
|
+
*/
|
|
2
16
|
static checkState(condition: boolean, message: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Check that an argument satisfies a condition
|
|
19
|
+
* @param condition - The condition to check
|
|
20
|
+
* @param argumentName - The name of the argument being checked
|
|
21
|
+
* @param message - Optional error message
|
|
22
|
+
* @param docsPath - Optional documentation path
|
|
23
|
+
* @throws {BitcoreError.Precondition.InvalidArgument} If condition is false
|
|
24
|
+
*/
|
|
3
25
|
static checkArgument(condition: boolean, argumentName: string, message?: string, docsPath?: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Check that an argument is of the expected type
|
|
28
|
+
* @param argument - The argument to check
|
|
29
|
+
* @param type - The expected type (string name like 'string', 'number', 'Buffer', or a constructor function)
|
|
30
|
+
* @param argumentName - Optional name of the argument for error messages
|
|
31
|
+
* @throws {BitcoreError.Precondition.InvalidArgumentType} If argument is not of the expected type
|
|
32
|
+
*/
|
|
4
33
|
static checkArgumentType(argument: unknown, type: string | ((...args: unknown[]) => unknown), argumentName?: string): void;
|
|
5
34
|
}
|
|
6
35
|
//# sourceMappingURL=preconditions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/util/preconditions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/util/preconditions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,qBAAa,aAAa;IACxB;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAM5D;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAClB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAUP;;;;;;OAMG;IACH,MAAM,CAAC,iBAAiB,CACtB,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,EAChD,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI;CAgCR"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions namespace
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support
|
|
4
|
+
*
|
|
5
|
+
* This module provides a namespace for utility functions,
|
|
6
|
+
* organizing them by category to match the reference implementation.
|
|
7
|
+
*/
|
|
1
8
|
import { BufferUtil } from './util/buffer.js';
|
|
2
9
|
import { JSUtil } from './util/js.js';
|
|
3
10
|
import { Preconditions } from './util/preconditions.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/util.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,eAAO,MAAM,IAAI;;;;;;CAMhB,CAAA;AAGD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,46 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XAddress implementation
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support and TypeScript
|
|
4
|
+
*/
|
|
1
5
|
import { Buffer } from 'buffer/';
|
|
2
6
|
import { Network, type NetworkName } from './networks.js';
|
|
3
7
|
import { PublicKey } from './publickey.js';
|
|
8
|
+
/**
|
|
9
|
+
* Represents the data to create, validate, or serialize an XAddress.
|
|
10
|
+
* This structure contains all the information needed to construct or check an xaddress.
|
|
11
|
+
*/
|
|
4
12
|
export interface XAddressData {
|
|
13
|
+
/**
|
|
14
|
+
* Buffer containing the hash that the address refers to.
|
|
15
|
+
*/
|
|
5
16
|
hashBuffer?: Buffer;
|
|
17
|
+
/**
|
|
18
|
+
* Network object describing the network (livenet, testnet, regtest).
|
|
19
|
+
*/
|
|
6
20
|
network?: Network;
|
|
21
|
+
/**
|
|
22
|
+
* String indicating what the address refers to. Valid values are:
|
|
23
|
+
* - 'pubkeyhash' for a public key hash / Pay-to-Public-Key-Hash
|
|
24
|
+
* - 'scripthash' for a script hash / Pay-to-Script-Hash
|
|
25
|
+
*/
|
|
7
26
|
type?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Token or network prefix to be used in the address.
|
|
29
|
+
*/
|
|
8
30
|
prefix?: string;
|
|
9
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Interface type definition for describing components of an address object.
|
|
34
|
+
* This structure represents the minimal information needed to reconstruct an address object.
|
|
35
|
+
*/
|
|
10
36
|
export interface XAddressObject {
|
|
37
|
+
/**
|
|
38
|
+
* The hex-encoded string representing the hash of the payload (the public key or script).
|
|
39
|
+
* This corresponds to the second part of the serialized address (after the type byte and network character).
|
|
40
|
+
*/
|
|
11
41
|
hash: string;
|
|
42
|
+
/**
|
|
43
|
+
* The type of the address, either "pubkeyhash" or "scripthash".
|
|
44
|
+
* This is the third part of the serialized address (the type byte).
|
|
45
|
+
*/
|
|
12
46
|
type: string;
|
|
47
|
+
/**
|
|
48
|
+
* The network identifier of the address (e.g., 'livenet', 'testnet', or 'regtest').
|
|
49
|
+
* This corresponds to the network character in the address.
|
|
50
|
+
*/
|
|
13
51
|
network: NetworkName;
|
|
52
|
+
/**
|
|
53
|
+
* The prefix of the address, which is the part before the network character.
|
|
54
|
+
* The default prefix is 'lotus' for mainnet, but can be customized.
|
|
55
|
+
*/
|
|
14
56
|
prefix?: string;
|
|
15
57
|
}
|
|
16
58
|
export type XAddressInput = string | Buffer | XAddressData | PublicKey;
|
|
17
59
|
export declare class XAddress {
|
|
60
|
+
/**
|
|
61
|
+
* The type of address that refers to a Pay-to-Public-Key-Hash (P2PKH)
|
|
62
|
+
*/
|
|
18
63
|
static readonly PayToPublicKeyHash = "pubkeyhash";
|
|
64
|
+
/**
|
|
65
|
+
* The type of address that refers to a Pay-to-Script-Hash (P2SH)
|
|
66
|
+
*/
|
|
19
67
|
static readonly PayToScriptHash = "scripthash";
|
|
68
|
+
/**
|
|
69
|
+
* The type of address that refers to Pay-to-Taproot (P2TR)
|
|
70
|
+
*/
|
|
20
71
|
static readonly PayToTaproot = "taproot";
|
|
21
72
|
readonly prefix: string;
|
|
22
73
|
readonly hashBuffer: Buffer;
|
|
23
74
|
readonly network: Network;
|
|
24
75
|
readonly type: string;
|
|
25
76
|
constructor(data?: XAddressInput, network?: Network | NetworkName, type?: string, prefix?: string);
|
|
77
|
+
/**
|
|
78
|
+
* Classifies the input data and returns a transformed object containing address components.
|
|
79
|
+
*
|
|
80
|
+
* @param data - The input data, which can be a string, buffer, object, or PublicKey.
|
|
81
|
+
* @param network - The network configuration (optional).
|
|
82
|
+
* @param type - The address type (optional).
|
|
83
|
+
* @param prefix - The address prefix (optional).
|
|
84
|
+
* @param networkExplicitlyProvided - Whether the network was explicitly provided by the caller.
|
|
85
|
+
* @returns An object containing the address hash, network, type, and prefix.
|
|
86
|
+
* @throws Throws a TypeError if the data format is unrecognized.
|
|
87
|
+
*/
|
|
26
88
|
private _classifyArguments;
|
|
89
|
+
/**
|
|
90
|
+
* Deserializes an address serialized through `XAddress#toObject()`
|
|
91
|
+
*/
|
|
27
92
|
private static _transformObject;
|
|
93
|
+
/**
|
|
94
|
+
* Internal function to discover the network and type based on the first data byte
|
|
95
|
+
*/
|
|
28
96
|
private static _classifyFromVersion;
|
|
97
|
+
/**
|
|
98
|
+
* Internal function to transform a lotus address string
|
|
99
|
+
*/
|
|
29
100
|
private static _transformString;
|
|
101
|
+
/**
|
|
102
|
+
* Internal function to transform a lotus address buffer
|
|
103
|
+
*/
|
|
30
104
|
private static _transformBuffer;
|
|
105
|
+
/**
|
|
106
|
+
* Instantiate an xaddress from an address string
|
|
107
|
+
*/
|
|
31
108
|
static fromString(str: string, network?: Network | NetworkName, type?: string): XAddress;
|
|
109
|
+
/**
|
|
110
|
+
* Instantiate an xaddress from an Object
|
|
111
|
+
*/
|
|
32
112
|
static fromObject(obj: XAddressObject): XAddress;
|
|
113
|
+
/**
|
|
114
|
+
* Will return a validation error if exists
|
|
115
|
+
*/
|
|
33
116
|
static getValidationError(data: XAddressInput, network?: Network | NetworkName, type?: string): Error | null;
|
|
117
|
+
/**
|
|
118
|
+
* Will return a boolean if an address is valid
|
|
119
|
+
*/
|
|
34
120
|
static isValid(data: XAddressInput, network?: Network | NetworkName, type?: string): boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Decode an xaddress string into its components
|
|
123
|
+
*/
|
|
35
124
|
static _decode(address: string): XAddressData;
|
|
125
|
+
/**
|
|
126
|
+
* Will return a buffer representation of the xaddress
|
|
127
|
+
*/
|
|
36
128
|
toBuffer(): Buffer;
|
|
129
|
+
/**
|
|
130
|
+
* Returns a plain object with the xaddress information
|
|
131
|
+
*/
|
|
37
132
|
toObject(): XAddressObject;
|
|
38
133
|
toJSON(): XAddressObject;
|
|
134
|
+
/**
|
|
135
|
+
* Converts the XAddress instance to an address string according to the XAddress specification.
|
|
136
|
+
* This method should build the address string by combining the prefix, network character, and encoded content.
|
|
137
|
+
*
|
|
138
|
+
* @returns {string} The properly formatted address string
|
|
139
|
+
*/
|
|
39
140
|
toXAddress(): string;
|
|
141
|
+
/**
|
|
142
|
+
* Wrapper function for `XAddress.toXAddress()`
|
|
143
|
+
* @returns
|
|
144
|
+
*/
|
|
40
145
|
toString(): string;
|
|
146
|
+
/**
|
|
147
|
+
* Check if this is a Pay-To-Public-Key-Hash address
|
|
148
|
+
*/
|
|
41
149
|
isPayToPublicKeyHash(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Check if this is a Pay-To-Script-Hash address
|
|
152
|
+
*/
|
|
42
153
|
isPayToScriptHash(): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Check if this is a Pay-To-Taproot address
|
|
156
|
+
*/
|
|
43
157
|
isPayToTaproot(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Will return a string formatted for the console
|
|
160
|
+
*/
|
|
44
161
|
inspect(): string;
|
|
45
162
|
}
|
|
46
163
|
//# sourceMappingURL=xaddress.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xaddress.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/xaddress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xaddress.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/xaddress.ts"],"names":[],"mappings":"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"}
|