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,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PrivateKey implementation for Lotus
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support and BigInt
|
|
4
|
+
*/
|
|
1
5
|
import { BN } from './crypto/bn';
|
|
2
6
|
import { Network, type NetworkName } from './networks';
|
|
3
7
|
import { PublicKey } from './publickey';
|
|
@@ -30,28 +34,104 @@ export declare class PrivateKey {
|
|
|
30
34
|
private _pubkey?;
|
|
31
35
|
constructor(data?: PrivateKeyInput, network?: Network | NetworkName);
|
|
32
36
|
get publicKey(): PublicKey;
|
|
37
|
+
/**
|
|
38
|
+
* Internal helper to instantiate PrivateKey internal `info` object from
|
|
39
|
+
* different kinds of arguments passed to the constructor.
|
|
40
|
+
*/
|
|
33
41
|
private _classifyArguments;
|
|
42
|
+
/**
|
|
43
|
+
* Internal function to get a random BigInt (synchronous version)
|
|
44
|
+
*/
|
|
34
45
|
private static _getRandomBN;
|
|
46
|
+
/**
|
|
47
|
+
* Internal function to transform a WIF Buffer into a private key
|
|
48
|
+
*/
|
|
35
49
|
private static _transformBuffer;
|
|
50
|
+
/**
|
|
51
|
+
* Internal function to transform a BN buffer into a private key
|
|
52
|
+
*/
|
|
36
53
|
private static _transformBNBuffer;
|
|
54
|
+
/**
|
|
55
|
+
* Internal function to transform a WIF string into a private key
|
|
56
|
+
*/
|
|
37
57
|
private static _transformWIF;
|
|
58
|
+
/**
|
|
59
|
+
* Internal function to transform a JSON string or plain object into a private key
|
|
60
|
+
*/
|
|
38
61
|
private static _transformObject;
|
|
62
|
+
/**
|
|
63
|
+
* Instantiate a PrivateKey from a Buffer with the DER or WIF representation
|
|
64
|
+
*/
|
|
39
65
|
static fromBuffer(arg: Buffer, network?: Network | NetworkName): PrivateKey;
|
|
66
|
+
/**
|
|
67
|
+
* Instantiate a PrivateKey from a WIF string
|
|
68
|
+
*/
|
|
40
69
|
static fromString(str: string, network?: Network | NetworkName): PrivateKey;
|
|
70
|
+
/**
|
|
71
|
+
* Instantiate a PrivateKey from a WIF string (alias for fromString)
|
|
72
|
+
* Automatically detects compressed vs uncompressed WIF format
|
|
73
|
+
* Network is detected from the WIF format; explicit network parameter is optional
|
|
74
|
+
*/
|
|
41
75
|
static fromWIF(str: string, network?: Network | NetworkName): PrivateKey;
|
|
76
|
+
/**
|
|
77
|
+
* Instantiate a PrivateKey from a plain JavaScript object
|
|
78
|
+
*/
|
|
42
79
|
static fromObject(obj: PrivateKeyObject, network?: Network | NetworkName): PrivateKey;
|
|
80
|
+
/**
|
|
81
|
+
* Instantiate a PrivateKey from random bytes
|
|
82
|
+
*/
|
|
43
83
|
static fromRandom(network?: Network | NetworkName): PrivateKey;
|
|
84
|
+
/**
|
|
85
|
+
* Check if there would be any errors when initializing a PrivateKey
|
|
86
|
+
*/
|
|
44
87
|
static getValidationError(data: PrivateKeyInput, network?: Network | NetworkName): Error | null;
|
|
88
|
+
/**
|
|
89
|
+
* Check if the parameters are valid
|
|
90
|
+
*/
|
|
45
91
|
static isValid(data: PrivateKeyInput, network?: Network | NetworkName): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Will output the PrivateKey encoded as hex string
|
|
94
|
+
*/
|
|
46
95
|
toString(): string;
|
|
96
|
+
/**
|
|
97
|
+
* Will output the PrivateKey to a WIF string
|
|
98
|
+
* @param compressed - If true (default), outputs compressed WIF (K/L prefix)
|
|
99
|
+
* If false, outputs uncompressed WIF (5 prefix)
|
|
100
|
+
*/
|
|
47
101
|
toWIF(compressed?: boolean): string;
|
|
102
|
+
/**
|
|
103
|
+
* Will return the private key as a BN instance
|
|
104
|
+
*/
|
|
48
105
|
toBigNumber(): BN;
|
|
106
|
+
/**
|
|
107
|
+
* Will return the private key as a Buffer
|
|
108
|
+
*/
|
|
49
109
|
toBuffer(): Buffer;
|
|
110
|
+
/**
|
|
111
|
+
* Will return the private key as a Buffer without leading zero padding
|
|
112
|
+
*/
|
|
50
113
|
toBufferNoPadding(): Buffer;
|
|
114
|
+
/**
|
|
115
|
+
* Will return the corresponding public key
|
|
116
|
+
*/
|
|
51
117
|
toPublicKey(): PublicKey;
|
|
118
|
+
/**
|
|
119
|
+
* Will return an address for the private key
|
|
120
|
+
* @param network - optional parameter specifying the desired network for the address
|
|
121
|
+
* @returns An address generated from the private key
|
|
122
|
+
*/
|
|
52
123
|
toAddress(network?: Network | NetworkName): Address;
|
|
124
|
+
/**
|
|
125
|
+
* Returns a plain object representation
|
|
126
|
+
*/
|
|
53
127
|
toObject(): PrivateKeySerialized;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a JSON representation (same as toObject)
|
|
130
|
+
*/
|
|
54
131
|
toJSON(): PrivateKeySerialized;
|
|
132
|
+
/**
|
|
133
|
+
* Will return a string formatted for the console
|
|
134
|
+
*/
|
|
55
135
|
inspect(): string;
|
|
56
136
|
}
|
|
57
137
|
//# sourceMappingURL=privatekey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privatekey.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/privatekey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"privatekey.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/privatekey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAMhC,OAAO,EACL,OAAO,EAGP,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,EAAE,CAAA;IACP,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,OAAO,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,cAAc,GACd,EAAE,GACF,gBAAgB,GAChB,uBAAuB,CAAA;AAE3B,qBAAa,UAAU;IACrB,QAAQ,CAAC,EAAE,EAAG,EAAE,CAAA;IAChB,QAAQ,CAAC,UAAU,EAAG,OAAO,CAAA;IAC7B,QAAQ,CAAC,OAAO,EAAG,OAAO,CAAA;IAC1B,OAA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OAAO;IAOV;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,KAAK,CAAC,UAAU,GAAE,OAAc,GAAG,MAAM;IAkBzC;;OAEG;IACH,WAAW,IAAI,EAAE;IAIjB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,iBAAiB,IAAI,MAAM;IAI3B;;OAEG;IACH,WAAW,IAAI,SAAS;IAOxB;;;;OAIG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO;IAKnD;;OAEG;IACH,QAAQ,IAAI,oBAAoB;IAQhC;;OAEG;IACH,MAAM,IAAI,oBAAoB;IAI9B;;OAEG;IACH,OAAO,IAAI,MAAM;CAIlB"}
|
|
@@ -1,66 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PublicKey implementation for Lotus
|
|
3
|
+
* Migrated from bitcore-lib-xpi with ESM support and BigInt
|
|
4
|
+
*/
|
|
1
5
|
import { BN } from './crypto/bn';
|
|
2
6
|
import { Point } from './crypto/point';
|
|
3
7
|
import { Network, type NetworkName } from './networks';
|
|
4
8
|
import { PrivateKey } from './privatekey';
|
|
5
9
|
import { Address } from './address';
|
|
6
10
|
import type { Buffer } from 'buffer/';
|
|
11
|
+
/**
|
|
12
|
+
* Internal data structure for public key information
|
|
13
|
+
* Used during public key construction and transformation
|
|
14
|
+
*/
|
|
7
15
|
export interface PublicKeyData {
|
|
16
|
+
/** The elliptic curve point representing the public key */
|
|
8
17
|
point: Point;
|
|
18
|
+
/** Whether the public key is in compressed format */
|
|
9
19
|
compressed: boolean;
|
|
20
|
+
/** Optional network the public key is associated with */
|
|
10
21
|
network?: Network;
|
|
11
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Additional options for public key construction
|
|
25
|
+
*/
|
|
12
26
|
export interface PublicKeyExtra {
|
|
27
|
+
/** Network to associate with the public key */
|
|
13
28
|
network?: Network | NetworkName;
|
|
29
|
+
/** Whether to use compressed format (default: true) */
|
|
14
30
|
compressed?: boolean;
|
|
15
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Plain object representation of a public key with hex-encoded coordinates
|
|
34
|
+
*/
|
|
16
35
|
export interface PublicKeyObject {
|
|
36
|
+
/** X coordinate as a hex string */
|
|
17
37
|
x: string;
|
|
38
|
+
/** Y coordinate as a hex string */
|
|
18
39
|
y: string;
|
|
40
|
+
/** Whether the public key is in compressed format */
|
|
19
41
|
compressed: boolean;
|
|
20
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Serialized format of a public key for JSON export
|
|
45
|
+
*/
|
|
21
46
|
export interface PublicKeySerialized {
|
|
47
|
+
/** X coordinate as a 64-character hex string (zero-padded) */
|
|
22
48
|
x: string;
|
|
49
|
+
/** Y coordinate as a 64-character hex string (zero-padded) */
|
|
23
50
|
y: string;
|
|
51
|
+
/** Whether the public key is in compressed format */
|
|
24
52
|
compressed: boolean;
|
|
25
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Valid input types for PublicKey constructor
|
|
56
|
+
* - Point: An elliptic curve point
|
|
57
|
+
* - PublicKeyObject: Object with x/y hex coordinates
|
|
58
|
+
* - string: Hex-encoded DER public key
|
|
59
|
+
* - Buffer: DER-encoded public key buffer
|
|
60
|
+
* - PrivateKey: Derive public key from private key
|
|
61
|
+
*/
|
|
26
62
|
export type PublicKeyInput = Point | PublicKeyObject | string | Buffer | PrivateKey;
|
|
63
|
+
/** Prefix byte for compressed public key with even Y-coordinate */
|
|
27
64
|
export declare const PUBKEY_PREFIX_EVEN = 2;
|
|
65
|
+
/** Prefix byte for compressed public key with odd Y-coordinate */
|
|
28
66
|
export declare const PUBKEY_PREFIX_ODD = 3;
|
|
67
|
+
/** Prefix byte for uncompressed public key */
|
|
29
68
|
export declare const PUBKEY_PREFIX_UNCOMPRESSED = 4;
|
|
69
|
+
/**
|
|
70
|
+
* PublicKey class for Lotus cryptocurrency
|
|
71
|
+
*
|
|
72
|
+
* Represents a public key on the secp256k1 elliptic curve. Public keys can be
|
|
73
|
+
* created from private keys, DER-encoded buffers, hex strings, or Point objects.
|
|
74
|
+
*
|
|
75
|
+
* Public keys can be in compressed (33 bytes) or uncompressed (65 bytes) format:
|
|
76
|
+
* - Compressed: prefix byte (0x02 for even Y, 0x03 for odd Y) + 32-byte X coordinate
|
|
77
|
+
* - Uncompressed: prefix byte (0x04) + 32-byte X + 32-byte Y coordinates
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // From private key
|
|
82
|
+
* const privKey = new PrivateKey()
|
|
83
|
+
* const pubKey = PublicKey.fromPrivateKey(privKey)
|
|
84
|
+
*
|
|
85
|
+
* // From hex string
|
|
86
|
+
* const pubKey = new PublicKey('02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc')
|
|
87
|
+
*
|
|
88
|
+
* // From buffer
|
|
89
|
+
* const pubKey = PublicKey.fromBuffer(buffer)
|
|
90
|
+
*
|
|
91
|
+
* // Get address
|
|
92
|
+
* const address = pubKey.toAddress()
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
30
95
|
export declare class PublicKey {
|
|
96
|
+
/** The elliptic curve point representing this public key */
|
|
31
97
|
readonly point: Point;
|
|
98
|
+
/** Whether this public key uses compressed format (33 bytes vs 65 bytes) */
|
|
32
99
|
readonly compressed: boolean;
|
|
100
|
+
/** The network this public key is associated with */
|
|
33
101
|
readonly network: Network;
|
|
102
|
+
/** Prefix byte for compressed public key with odd Y-coordinate (0x03) */
|
|
34
103
|
static readonly PrefixOddY: Buffer;
|
|
104
|
+
/** Prefix byte for compressed public key with even Y-coordinate (0x02) */
|
|
35
105
|
static readonly PrefixEvenY: Buffer;
|
|
106
|
+
/** Prefix byte for uncompressed public key (0x04) */
|
|
36
107
|
static readonly PrefixUncompressed: Buffer;
|
|
37
108
|
constructor(data: PublicKeyInput, extra?: PublicKeyExtra);
|
|
109
|
+
/**
|
|
110
|
+
* Internal function to differentiate between arguments passed to the constructor.
|
|
111
|
+
* Handles Point objects, PublicKeyObject with x/y coordinates, hex strings,
|
|
112
|
+
* DER-encoded buffers, and PrivateKey instances.
|
|
113
|
+
*
|
|
114
|
+
* @param data - The input data to classify and transform
|
|
115
|
+
* @param extra - Additional options like network and compression preference
|
|
116
|
+
* @returns The classified public key data with point, compressed flag, and optional network
|
|
117
|
+
* @throws {TypeError} If the data format is not recognized
|
|
118
|
+
* @throws {Error} If a valid point cannot be derived from the input
|
|
119
|
+
*/
|
|
38
120
|
private _classifyArgs;
|
|
121
|
+
/**
|
|
122
|
+
* Internal function to detect if an object is a PrivateKey
|
|
123
|
+
*/
|
|
39
124
|
private static _isPrivateKey;
|
|
125
|
+
/**
|
|
126
|
+
* Internal function to detect if an object is a Buffer
|
|
127
|
+
*/
|
|
40
128
|
private static _isBuffer;
|
|
129
|
+
/**
|
|
130
|
+
* Internal function to transform a private key into a public key point
|
|
131
|
+
*/
|
|
41
132
|
private static _transformPrivateKey;
|
|
133
|
+
/**
|
|
134
|
+
* Internal function to transform DER-encoded buffer into a public key point
|
|
135
|
+
*
|
|
136
|
+
* Handles three DER encoding formats:
|
|
137
|
+
* - 0x04: Uncompressed (65 bytes: prefix + 32-byte X + 32-byte Y)
|
|
138
|
+
* - 0x02: Compressed with even Y (33 bytes: prefix + 32-byte X)
|
|
139
|
+
* - 0x03: Compressed with odd Y (33 bytes: prefix + 32-byte X)
|
|
140
|
+
*
|
|
141
|
+
* In non-strict mode, also accepts:
|
|
142
|
+
* - 0x06, 0x07: Hybrid format (treated as uncompressed)
|
|
143
|
+
*
|
|
144
|
+
* @param buf - DER-encoded public key buffer
|
|
145
|
+
* @param strict - If true, only accept standard prefixes (0x02, 0x03, 0x04)
|
|
146
|
+
* @returns Public key data with point and compression flag
|
|
147
|
+
* @throws {Error} If buffer is not a valid buffer type
|
|
148
|
+
* @throws {TypeError} If buffer length is invalid or prefix is unrecognized
|
|
149
|
+
*/
|
|
42
150
|
private static _transformDER;
|
|
151
|
+
/**
|
|
152
|
+
* Internal function to transform X into a public key point
|
|
153
|
+
*/
|
|
43
154
|
private static _transformX;
|
|
155
|
+
/**
|
|
156
|
+
* Internal function to transform a JSON into a public key point
|
|
157
|
+
*/
|
|
44
158
|
private static _transformObject;
|
|
159
|
+
/**
|
|
160
|
+
* Instantiate a PublicKey from a PrivateKey
|
|
161
|
+
*/
|
|
45
162
|
static fromPrivateKey(privkey: PrivateKey): PublicKey;
|
|
163
|
+
/**
|
|
164
|
+
* Instantiate a PublicKey from a Buffer
|
|
165
|
+
*/
|
|
46
166
|
static fromDER(buf: Buffer, strict?: boolean): PublicKey;
|
|
167
|
+
/**
|
|
168
|
+
* Instantiate a PublicKey from a Buffer (alias for fromDER)
|
|
169
|
+
*/
|
|
47
170
|
static fromBuffer(buf: Buffer, strict?: boolean): PublicKey;
|
|
171
|
+
/**
|
|
172
|
+
* Instantiate a PublicKey from a Point
|
|
173
|
+
*/
|
|
48
174
|
static fromPoint(point: Point, compressed?: boolean): PublicKey;
|
|
175
|
+
/**
|
|
176
|
+
* Instantiate a PublicKey from a DER hex encoded string
|
|
177
|
+
*/
|
|
49
178
|
static fromString(str: string, encoding?: BufferEncoding): PublicKey;
|
|
179
|
+
/**
|
|
180
|
+
* Instantiate a PublicKey from an X Point
|
|
181
|
+
*/
|
|
50
182
|
static fromX(odd: boolean, x: BN): PublicKey;
|
|
183
|
+
/**
|
|
184
|
+
* Check if there would be any errors when initializing a PublicKey
|
|
185
|
+
*/
|
|
51
186
|
static getValidationError(data: PublicKeyInput): Error | null;
|
|
187
|
+
/**
|
|
188
|
+
* Check if the parameters are valid
|
|
189
|
+
*/
|
|
52
190
|
static isValid(data: PublicKeyInput): boolean;
|
|
53
191
|
static isValid(data: PublicKey): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Returns a plain object of the PublicKey
|
|
194
|
+
*/
|
|
54
195
|
toObject(): PublicKeySerialized;
|
|
196
|
+
/**
|
|
197
|
+
* Returns a JSON representation (same as toObject)
|
|
198
|
+
*/
|
|
55
199
|
toJSON(): PublicKeySerialized;
|
|
200
|
+
/**
|
|
201
|
+
* Will return the public key as a BN instance
|
|
202
|
+
*/
|
|
56
203
|
toBigNumber(): BN;
|
|
204
|
+
/**
|
|
205
|
+
* Will output the PublicKey to a DER Buffer
|
|
206
|
+
*/
|
|
57
207
|
toBuffer(): Buffer;
|
|
208
|
+
/**
|
|
209
|
+
* Will output the PublicKey to a DER Buffer
|
|
210
|
+
*/
|
|
58
211
|
toDER(): Buffer;
|
|
212
|
+
/**
|
|
213
|
+
* Will return a sha256 + ripemd160 hash of the serialized public key
|
|
214
|
+
*/
|
|
59
215
|
_getID(): Buffer;
|
|
216
|
+
/**
|
|
217
|
+
* Will return an address for the public key
|
|
218
|
+
*/
|
|
60
219
|
toAddress(network?: Network | NetworkName): Address;
|
|
220
|
+
/**
|
|
221
|
+
* Will output the PublicKey to a DER encoded hex string
|
|
222
|
+
*/
|
|
61
223
|
toString(): string;
|
|
224
|
+
/**
|
|
225
|
+
* Will return a string formatted for the console
|
|
226
|
+
*/
|
|
62
227
|
inspect(): string;
|
|
228
|
+
/**
|
|
229
|
+
* Add a scalar to this public key (for Taproot tweaking)
|
|
230
|
+
*
|
|
231
|
+
* Computes: this_pubkey + scalar * G
|
|
232
|
+
*
|
|
233
|
+
* This is used in Taproot to compute the tweaked public key:
|
|
234
|
+
* tweaked_pubkey = internal_pubkey + tagged_hash("TapTweak", ...) * G
|
|
235
|
+
*
|
|
236
|
+
* Reference: lotusd/src/pubkey.cpp CPubKey::AddScalar()
|
|
237
|
+
*
|
|
238
|
+
* @param scalar - 32-byte scalar value (as Buffer or BN)
|
|
239
|
+
* @returns New tweaked public key
|
|
240
|
+
* @throws Error if tweak results in invalid key
|
|
241
|
+
*/
|
|
63
242
|
addScalar(scalar: Buffer | BN): PublicKey;
|
|
243
|
+
/**
|
|
244
|
+
* Get the secp256k1 curve order N
|
|
245
|
+
*
|
|
246
|
+
* The curve order N is the number of points on the elliptic curve.
|
|
247
|
+
* All scalar operations (private keys, tweaks, nonces) must be performed modulo N.
|
|
248
|
+
*
|
|
249
|
+
* N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
|
|
250
|
+
*
|
|
251
|
+
* Used for:
|
|
252
|
+
* - Validating private keys are in range [1, N-1]
|
|
253
|
+
* - Modular arithmetic in signature generation (k, s values)
|
|
254
|
+
* - Computing low-S form: if s > N/2, use N - s
|
|
255
|
+
* - Taproot scalar tweaking operations
|
|
256
|
+
*
|
|
257
|
+
* @returns The curve order as a BN instance
|
|
258
|
+
*/
|
|
64
259
|
static getN(): BN;
|
|
65
260
|
}
|
|
66
261
|
//# sourceMappingURL=publickey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publickey.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/publickey.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publickey.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/publickey.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAItC,OAAO,EACL,OAAO,EAGP,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,KAAK,EAAE,KAAK,CAAA;IACZ,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAA;IACnB,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,+CA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B;;OAEG;IACH,WAAW,IAAI,EAAE;IAIjB;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,KAAK,IAAI,MAAM;IAsBf;;OAEG;IACH,MAAM,IAAI,MAAM;IAIhB;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,OAAO;IAInD;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,GAAG,SAAS;IAoBzC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,IAAI,IAAI,EAAE;CAGlB"}
|
|
@@ -1,19 +1,70 @@
|
|
|
1
1
|
import type { Buffer } from 'buffer/';
|
|
2
|
+
/**
|
|
3
|
+
* Chunk class for script operations
|
|
4
|
+
* Represents a single chunk in a Lotus script.
|
|
5
|
+
* A chunk can either be an opcode (no data) or a data push operation.
|
|
6
|
+
* Migrated from bitcore-lib-xpi with ESM support
|
|
7
|
+
*/
|
|
2
8
|
export declare class Chunk {
|
|
9
|
+
/**
|
|
10
|
+
* Optional data buffer for push operations
|
|
11
|
+
*/
|
|
3
12
|
buf?: Buffer;
|
|
13
|
+
/**
|
|
14
|
+
* Length of the data buffer
|
|
15
|
+
*/
|
|
4
16
|
len?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The opcode number for this chunk
|
|
19
|
+
* For data pushes, this indicates the push operation type
|
|
20
|
+
*/
|
|
5
21
|
opcodenum: number;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new Chunk instance
|
|
24
|
+
* @param data - Optional initialization data
|
|
25
|
+
* @param data.buf - Data buffer for push operations
|
|
26
|
+
* @param data.len - Length of the data buffer
|
|
27
|
+
* @param data.opcodenum - The opcode number
|
|
28
|
+
*/
|
|
6
29
|
constructor(data?: {
|
|
7
30
|
buf?: Buffer;
|
|
8
31
|
len?: number;
|
|
9
32
|
opcodenum: number;
|
|
10
33
|
});
|
|
34
|
+
/**
|
|
35
|
+
* Check if this chunk is an opcode (no data)
|
|
36
|
+
* @returns True if this chunk represents an opcode without data
|
|
37
|
+
*/
|
|
11
38
|
isOpCode(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Check if this chunk contains data
|
|
41
|
+
* @returns True if this chunk has an associated data buffer
|
|
42
|
+
*/
|
|
12
43
|
hasData(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get the length of the data buffer
|
|
46
|
+
* @returns The length of the data buffer, or 0 if no buffer exists
|
|
47
|
+
*/
|
|
13
48
|
getLength(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Get the data buffer
|
|
51
|
+
* @returns The data buffer, or undefined if this is an opcode-only chunk
|
|
52
|
+
*/
|
|
14
53
|
getBuffer(): Buffer | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Get the opcode number
|
|
56
|
+
* @returns The opcode number for this chunk
|
|
57
|
+
*/
|
|
15
58
|
getOpCode(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Convert to string representation
|
|
61
|
+
* @returns String representation of the chunk (opcode name or hex data)
|
|
62
|
+
*/
|
|
16
63
|
toString(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Convert to object representation
|
|
66
|
+
* @returns Plain object containing chunk properties
|
|
67
|
+
*/
|
|
17
68
|
toObject(): {
|
|
18
69
|
buf?: Buffer;
|
|
19
70
|
len?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/script/chunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../../../lib/bitcore/script/chunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAErC;;;;;GAKG;AACH,qBAAa,KAAK;IAChB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;;;OAMG;gBACS,IAAI,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAUpE;;;OAGG;IACH,QAAQ,IAAI,OAAO;IAInB;;;OAGG;IACH,OAAO,IAAI,OAAO;IAIlB;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,SAAS;IAI/B;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;OAGG;IACH,QAAQ,IAAI,MAAM;IASlB;;;OAGG;IACH,QAAQ,IAAI;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;CAO9D"}
|
|
@@ -1,11 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025-2026 The Lotusia Stewardship
|
|
3
|
+
* Github: https://github.com/LotusiaStewardship
|
|
4
|
+
* License: MIT
|
|
5
|
+
*
|
|
6
|
+
* Condition Stack for Script IF/ELSE/ENDIF Tracking
|
|
7
|
+
*
|
|
8
|
+
* An optimized data structure that tracks nested conditional execution
|
|
9
|
+
* during script evaluation. Instead of materializing a boolean stack,
|
|
10
|
+
* it tracks only the stack size and the position of the first false
|
|
11
|
+
* value, which is sufficient for all required operations.
|
|
12
|
+
*
|
|
13
|
+
* Reference: lotusd/src/script/interpreter.cpp (ConditionStack)
|
|
14
|
+
*
|
|
15
|
+
* @module ConditionStack
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Tracks nested IF/ELSE/ENDIF conditional execution state.
|
|
19
|
+
*
|
|
20
|
+
* Conceptually acts like a stack of booleans, one per nesting level.
|
|
21
|
+
* The interpreter only needs to know:
|
|
22
|
+
* 1. Whether the stack is empty (no active conditionals)
|
|
23
|
+
* 2. Whether all values are true (we're in an active branch)
|
|
24
|
+
* 3. Push/pop/toggle operations for IF/ELSE/ENDIF
|
|
25
|
+
*
|
|
26
|
+
* This implementation avoids allocating an actual boolean array by
|
|
27
|
+
* tracking only the size and the position of the first false value.
|
|
28
|
+
*/
|
|
1
29
|
export declare class ConditionStack {
|
|
30
|
+
/** Sentinel value indicating no false values exist */
|
|
2
31
|
private static readonly NO_FALSE;
|
|
32
|
+
/** The size of the implied boolean stack */
|
|
3
33
|
private _size;
|
|
34
|
+
/** Position of the first false value, or NO_FALSE if all true */
|
|
4
35
|
private _firstFalsePos;
|
|
36
|
+
/**
|
|
37
|
+
* Check if the condition stack is empty (no active conditionals).
|
|
38
|
+
*
|
|
39
|
+
* @returns true if no IF/ELSE/ENDIF blocks are active
|
|
40
|
+
*/
|
|
5
41
|
isEmpty(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Check if all conditions on the stack are true.
|
|
44
|
+
*
|
|
45
|
+
* When all conditions are true, the interpreter should execute
|
|
46
|
+
* opcodes normally. When any condition is false, only
|
|
47
|
+
* IF/ELSE/ENDIF opcodes are processed.
|
|
48
|
+
*
|
|
49
|
+
* @returns true if every condition on the stack is true
|
|
50
|
+
*/
|
|
6
51
|
allTrue(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Push a new condition value (entering an IF/NOTIF block).
|
|
54
|
+
*
|
|
55
|
+
* @param value - The evaluated condition (true = execute this branch)
|
|
56
|
+
*/
|
|
7
57
|
pushBack(value: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Pop the top condition (leaving an ENDIF block).
|
|
60
|
+
*
|
|
61
|
+
* @throws {Error} If the stack is empty
|
|
62
|
+
*/
|
|
8
63
|
popBack(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Toggle the top condition value (processing an ELSE block).
|
|
66
|
+
*
|
|
67
|
+
* @throws {Error} If the stack is empty
|
|
68
|
+
*/
|
|
9
69
|
toggleTop(): void;
|
|
10
70
|
}
|
|
11
71
|
//# sourceMappingURL=condition-stack.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition-stack.d.ts","sourceRoot":"","sources":["../../../../../../lib/bitcore/script/interpreter/condition-stack.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"condition-stack.d.ts","sourceRoot":"","sources":["../../../../../../lib/bitcore/script/interpreter/condition-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;GAWG;AACH,qBAAa,cAAc;IACzB,sDAAsD;IACtD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAa;IAE7C,4CAA4C;IAC5C,OAAO,CAAC,KAAK,CAAY;IAEzB,iEAAiE;IACjE,OAAO,CAAC,cAAc,CAAkC;IAExD;;;;OAIG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;;;;;OAQG;IACH,OAAO,IAAI,OAAO;IAIlB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAQ9B;;;;OAIG;IACH,OAAO,IAAI,IAAI;IAWf;;;;OAIG;IACH,SAAS,IAAI,IAAI;CAclB"}
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2025-2026 The Lotusia Stewardship
|
|
3
|
+
* Github: https://github.com/LotusiaStewardship
|
|
4
|
+
* License: MIT
|
|
5
|
+
*
|
|
6
|
+
* Script Interpreter Module Barrel Export
|
|
7
|
+
*
|
|
8
|
+
* Re-exports all public types, constants, and functions from the
|
|
9
|
+
* interpreter module for convenient consumption.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import {
|
|
14
|
+
* verifyScript,
|
|
15
|
+
* evalScript,
|
|
16
|
+
* ScriptError,
|
|
17
|
+
* ScriptFlags,
|
|
18
|
+
* STANDARD_SCRIPT_VERIFY_FLAGS,
|
|
19
|
+
* } from './script/interpreter-index'
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @module InterpreterIndex
|
|
23
|
+
*/
|
|
1
24
|
export { MAX_SCRIPT_ELEMENT_SIZE, MAX_OPS_PER_SCRIPT, MAX_PUBKEYS_PER_MULTISIG, MAX_SCRIPT_SIZE, MAX_STACK_SIZE, MAX_NUM2BIN_SIZE, LOCKTIME_THRESHOLD, SCRIPTNUM_MAX_ELEMENT_SIZE, STANDARD_SCRIPT_VERIFY_FLAGS, ScriptFlags, ScriptError, NULL_SIGNATURE_CHECKER, type ScriptResult, type ScriptExecutionMetrics, type ScriptExecutionData, type SignatureChecker, } from './types';
|
|
2
25
|
export { ScriptNum, ScriptNumError } from './script-num';
|
|
3
26
|
export { ConditionStack } from './condition-stack';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../lib/bitcore/script/interpreter/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../lib/bitcore/script/interpreter/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,EAC5B,WAAW,EACX,WAAW,EACX,sBAAsB,EACtB,KAAK,YAAY,EACjB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAA;AAGhB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAGlD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
|