xpi-ts 0.2.13 → 0.2.15
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/address.js +75 -74
- package/dist/cjs/lib/bitcore/block/block.js +124 -126
- package/dist/cjs/lib/bitcore/block/blockheader.js +142 -208
- package/dist/cjs/lib/bitcore/block/index.js +3 -1
- package/dist/cjs/lib/bitcore/block/merkleblock.js +301 -0
- package/dist/cjs/lib/bitcore/crypto/bn.js +18 -22
- package/dist/cjs/lib/bitcore/crypto/ecdsa.js +50 -49
- package/dist/cjs/lib/bitcore/crypto/hash.js +25 -22
- package/dist/cjs/lib/bitcore/crypto/musig2.js +86 -92
- package/dist/cjs/lib/bitcore/crypto/point.js +42 -35
- package/dist/cjs/lib/bitcore/crypto/random.js +3 -2
- package/dist/cjs/lib/bitcore/crypto/schnorr.js +46 -55
- package/dist/cjs/lib/bitcore/crypto/signature.js +67 -55
- package/dist/cjs/lib/bitcore/crypto/sigtype.js +1 -1
- package/dist/cjs/lib/bitcore/encoding/base58.js +5 -4
- package/dist/cjs/lib/bitcore/encoding/base58check.js +14 -57
- package/dist/cjs/lib/bitcore/encoding/bufferreader.js +17 -17
- package/dist/cjs/lib/bitcore/encoding/bufferwriter.js +22 -26
- package/dist/cjs/lib/bitcore/encoding/varint.js +12 -11
- package/dist/cjs/lib/bitcore/errors.js +1 -0
- package/dist/cjs/lib/bitcore/hdprivatekey.js +74 -66
- package/dist/cjs/lib/bitcore/hdpublickey.js +96 -116
- package/dist/cjs/lib/bitcore/index.js +165 -172
- package/dist/cjs/lib/bitcore/message.js +36 -35
- package/dist/cjs/lib/bitcore/mnemonic/mnemonic.js +4 -3
- package/dist/cjs/lib/bitcore/mnemonic/pbkdf2.js +6 -5
- package/dist/cjs/lib/bitcore/mnemonic/words/french.js +2053 -0
- package/dist/cjs/lib/bitcore/mnemonic/words/index.js +2 -0
- package/dist/cjs/lib/bitcore/musig2/session.js +26 -25
- package/dist/cjs/lib/bitcore/musig2/signer.js +17 -16
- package/dist/cjs/lib/bitcore/networks.js +4 -3
- package/dist/cjs/lib/bitcore/opcode.js +11 -7
- package/dist/cjs/lib/bitcore/privatekey.js +42 -42
- package/dist/cjs/lib/bitcore/publickey.js +61 -57
- package/dist/cjs/lib/bitcore/script/interpreter/condition-stack.js +41 -0
- package/dist/cjs/lib/bitcore/script/interpreter/index.js +25 -0
- package/dist/cjs/lib/bitcore/script/interpreter/interpreter.js +1362 -0
- package/dist/cjs/lib/bitcore/script/interpreter/script-num.js +200 -0
- package/dist/cjs/lib/bitcore/script/interpreter/types.js +96 -0
- package/dist/cjs/lib/bitcore/{taproot.js → script/taproot.js} +107 -95
- package/dist/cjs/lib/bitcore/script.js +163 -104
- package/dist/cjs/lib/bitcore/taproot/musig2.js +51 -42
- package/dist/cjs/lib/bitcore/transaction/index.js +21 -21
- package/dist/cjs/lib/bitcore/transaction/input/multisig.js +10 -0
- package/dist/cjs/lib/bitcore/transaction/input/multisigscripthash.js +10 -0
- package/dist/cjs/lib/bitcore/transaction/input/publickey.js +10 -0
- package/dist/cjs/lib/bitcore/transaction/input/publickeyhash.js +10 -0
- package/dist/cjs/lib/bitcore/transaction/input/taproot.js +20 -0
- package/dist/cjs/lib/bitcore/transaction/input.js +145 -166
- package/dist/cjs/lib/bitcore/transaction/outpoint.js +89 -0
- package/dist/cjs/lib/bitcore/transaction/output.js +13 -8
- package/dist/cjs/lib/bitcore/transaction/sighash.js +96 -96
- package/dist/cjs/lib/bitcore/transaction/signature.js +39 -40
- package/dist/cjs/lib/bitcore/transaction/transaction.js +130 -118
- package/dist/cjs/lib/bitcore/transaction/unspentoutput.js +27 -23
- package/dist/cjs/lib/bitcore/util/bits.js +33 -0
- package/dist/cjs/lib/bitcore/util/buffer.js +29 -18
- package/dist/cjs/lib/bitcore/util/js.js +0 -3
- package/dist/cjs/lib/bitcore/util/merkle.js +53 -0
- package/dist/cjs/lib/bitcore/util/preconditions.js +8 -7
- package/dist/cjs/lib/bitcore/xaddress.js +27 -23
- package/dist/cjs/lib/{bitcore/taproot/nft.js → nft.js} +98 -29
- package/dist/cjs/lib/rank/index.js +28 -27
- package/dist/cjs/lib/rank/script.js +2 -1
- package/dist/cjs/lib/rank/transaction.js +2 -1
- package/dist/cjs/utils/string.js +6 -5
- package/dist/esm/lib/bitcore/address.js +42 -41
- package/dist/esm/lib/bitcore/block/block.js +126 -128
- package/dist/esm/lib/bitcore/block/blockheader.js +141 -207
- package/dist/esm/lib/bitcore/block/index.js +1 -0
- package/dist/esm/lib/bitcore/block/merkleblock.js +295 -0
- package/dist/esm/lib/bitcore/crypto/bn.js +18 -22
- package/dist/esm/lib/bitcore/crypto/ecdsa.js +25 -24
- package/dist/esm/lib/bitcore/crypto/hash.js +25 -22
- package/dist/esm/lib/bitcore/crypto/musig2.js +60 -66
- package/dist/esm/lib/bitcore/crypto/point.js +22 -15
- package/dist/esm/lib/bitcore/crypto/random.js +3 -2
- package/dist/esm/lib/bitcore/crypto/schnorr.js +35 -44
- package/dist/esm/lib/bitcore/crypto/signature.js +61 -49
- package/dist/esm/lib/bitcore/crypto/sigtype.js +1 -1
- package/dist/esm/lib/bitcore/encoding/base58.js +5 -4
- package/dist/esm/lib/bitcore/encoding/base58check.js +11 -57
- package/dist/esm/lib/bitcore/encoding/bufferreader.js +7 -7
- package/dist/esm/lib/bitcore/encoding/bufferwriter.js +18 -21
- package/dist/esm/lib/bitcore/encoding/varint.js +7 -6
- package/dist/esm/lib/bitcore/errors.js +1 -0
- package/dist/esm/lib/bitcore/hdprivatekey.js +47 -39
- package/dist/esm/lib/bitcore/hdpublickey.js +77 -97
- package/dist/esm/lib/bitcore/index.js +42 -45
- package/dist/esm/lib/bitcore/message.js +16 -15
- package/dist/esm/lib/bitcore/mnemonic/mnemonic.js +4 -3
- package/dist/esm/lib/bitcore/mnemonic/pbkdf2.js +5 -4
- package/dist/esm/lib/bitcore/mnemonic/words/french.js +2050 -0
- package/dist/esm/lib/bitcore/mnemonic/words/index.js +2 -0
- package/dist/esm/lib/bitcore/musig2/session.js +17 -16
- package/dist/esm/lib/bitcore/musig2/signer.js +19 -18
- package/dist/esm/lib/bitcore/networks.js +4 -3
- package/dist/esm/lib/bitcore/opcode.js +9 -5
- package/dist/esm/lib/bitcore/privatekey.js +25 -25
- package/dist/esm/lib/bitcore/publickey.js +46 -42
- package/dist/esm/lib/bitcore/script/interpreter/condition-stack.js +37 -0
- package/dist/esm/lib/bitcore/script/interpreter/index.js +4 -0
- package/dist/esm/lib/bitcore/script/interpreter/interpreter.js +1356 -0
- package/dist/esm/lib/bitcore/script/interpreter/script-num.js +195 -0
- package/dist/esm/lib/bitcore/script/interpreter/types.js +93 -0
- package/dist/esm/lib/bitcore/{taproot.js → script/taproot.js} +92 -81
- package/dist/esm/lib/bitcore/script.js +163 -102
- package/dist/esm/lib/bitcore/taproot/musig2.js +36 -27
- package/dist/esm/lib/bitcore/transaction/index.js +6 -6
- package/dist/esm/lib/bitcore/transaction/input/multisig.js +6 -0
- package/dist/esm/lib/bitcore/transaction/input/multisigscripthash.js +6 -0
- package/dist/esm/lib/bitcore/transaction/input/publickey.js +6 -0
- package/dist/esm/lib/bitcore/transaction/input/publickeyhash.js +6 -0
- package/dist/esm/lib/bitcore/transaction/input/taproot.js +16 -0
- package/dist/esm/lib/bitcore/transaction/input.js +55 -76
- package/dist/esm/lib/bitcore/transaction/outpoint.js +85 -0
- package/dist/esm/lib/bitcore/transaction/output.js +13 -8
- package/dist/esm/lib/bitcore/transaction/sighash.js +22 -22
- package/dist/esm/lib/bitcore/transaction/signature.js +16 -17
- package/dist/esm/lib/bitcore/transaction/transaction.js +58 -46
- package/dist/esm/lib/bitcore/transaction/unspentoutput.js +15 -11
- package/dist/esm/lib/bitcore/util/bits.js +27 -0
- package/dist/esm/lib/bitcore/util/buffer.js +20 -9
- package/dist/esm/lib/bitcore/util/js.js +0 -3
- package/dist/esm/lib/bitcore/util/merkle.js +47 -0
- package/dist/esm/lib/bitcore/util/preconditions.js +3 -2
- package/dist/esm/lib/bitcore/xaddress.js +16 -12
- package/dist/esm/lib/{bitcore/taproot/nft.js → nft.js} +97 -28
- package/dist/esm/lib/rank/index.js +15 -14
- package/dist/esm/lib/rank/script.js +1 -0
- package/dist/esm/lib/rank/transaction.js +1 -0
- package/dist/esm/utils/string.js +1 -0
- package/dist/types/lib/bitcore/address.d.ts +4 -3
- package/dist/types/lib/bitcore/address.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/block.d.ts +11 -19
- package/dist/types/lib/bitcore/block/block.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/blockheader.d.ts +30 -32
- package/dist/types/lib/bitcore/block/blockheader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/index.d.ts +2 -0
- package/dist/types/lib/bitcore/block/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/block/merkleblock.d.ts +53 -0
- package/dist/types/lib/bitcore/block/merkleblock.d.ts.map +1 -0
- package/dist/types/lib/bitcore/crypto/bn.d.ts +2 -2
- package/dist/types/lib/bitcore/crypto/bn.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts +5 -4
- package/dist/types/lib/bitcore/crypto/ecdsa.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/hash.d.ts +3 -1
- package/dist/types/lib/bitcore/crypto/hash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/musig2.d.ts +22 -30
- package/dist/types/lib/bitcore/crypto/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/point.d.ts +8 -3
- package/dist/types/lib/bitcore/crypto/point.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/random.d.ts +1 -0
- package/dist/types/lib/bitcore/crypto/random.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts +5 -4
- package/dist/types/lib/bitcore/crypto/schnorr.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/signature.d.ts +4 -1
- package/dist/types/lib/bitcore/crypto/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts +1 -0
- package/dist/types/lib/bitcore/crypto/sigtype.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58.d.ts +1 -0
- package/dist/types/lib/bitcore/encoding/base58.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/base58check.d.ts +1 -2
- package/dist/types/lib/bitcore/encoding/base58check.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts +2 -1
- package/dist/types/lib/bitcore/encoding/bufferreader.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts +2 -2
- package/dist/types/lib/bitcore/encoding/bufferwriter.d.ts.map +1 -1
- package/dist/types/lib/bitcore/encoding/varint.d.ts +3 -2
- package/dist/types/lib/bitcore/encoding/varint.d.ts.map +1 -1
- package/dist/types/lib/bitcore/errors.d.ts +3 -0
- package/dist/types/lib/bitcore/errors.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdprivatekey.d.ts +5 -4
- package/dist/types/lib/bitcore/hdprivatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/hdpublickey.d.ts +4 -3
- package/dist/types/lib/bitcore/hdpublickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/index.d.ts +55 -60
- package/dist/types/lib/bitcore/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/message.d.ts +7 -4
- package/dist/types/lib/bitcore/message.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts +2 -0
- package/dist/types/lib/bitcore/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts +1 -0
- package/dist/types/lib/bitcore/mnemonic/pbkdf2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts +2 -0
- package/dist/types/lib/bitcore/mnemonic/words/french.d.ts.map +1 -0
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts +1 -0
- package/dist/types/lib/bitcore/mnemonic/words/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/session.d.ts +8 -7
- package/dist/types/lib/bitcore/musig2/session.d.ts.map +1 -1
- package/dist/types/lib/bitcore/musig2/signer.d.ts +10 -9
- package/dist/types/lib/bitcore/musig2/signer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/networks.d.ts +1 -0
- package/dist/types/lib/bitcore/networks.d.ts.map +1 -1
- package/dist/types/lib/bitcore/opcode.d.ts +5 -0
- package/dist/types/lib/bitcore/opcode.d.ts.map +1 -1
- package/dist/types/lib/bitcore/privatekey.d.ts +5 -4
- package/dist/types/lib/bitcore/privatekey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/publickey.d.ts +13 -6
- package/dist/types/lib/bitcore/publickey.d.ts.map +1 -1
- package/dist/types/lib/bitcore/{chunk.d.ts → script/chunk.d.ts} +1 -0
- package/dist/types/lib/bitcore/script/chunk.d.ts.map +1 -0
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts +11 -0
- package/dist/types/lib/bitcore/script/interpreter/condition-stack.d.ts.map +1 -0
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts +5 -0
- package/dist/types/lib/bitcore/script/interpreter/index.d.ts.map +1 -0
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts +21 -0
- package/dist/types/lib/bitcore/script/interpreter/interpreter.d.ts.map +1 -0
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts +35 -0
- package/dist/types/lib/bitcore/script/interpreter/script-num.d.ts.map +1 -0
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts +101 -0
- package/dist/types/lib/bitcore/script/interpreter/types.d.ts.map +1 -0
- package/dist/types/lib/bitcore/{taproot.d.ts → script/taproot.d.ts} +20 -7
- package/dist/types/lib/bitcore/script/taproot.d.ts.map +1 -0
- package/dist/types/lib/bitcore/script.d.ts +12 -11
- package/dist/types/lib/bitcore/script.d.ts.map +1 -1
- package/dist/types/lib/bitcore/taproot/musig2.d.ts +17 -16
- package/dist/types/lib/bitcore/taproot/musig2.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/index.d.ts +11 -11
- package/dist/types/lib/bitcore/transaction/index.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts +5 -0
- package/dist/types/lib/bitcore/transaction/input/multisig.d.ts.map +1 -0
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts +5 -0
- package/dist/types/lib/bitcore/transaction/input/multisigscripthash.d.ts.map +1 -0
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts +5 -0
- package/dist/types/lib/bitcore/transaction/input/publickey.d.ts.map +1 -0
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts +6 -0
- package/dist/types/lib/bitcore/transaction/input/publickeyhash.d.ts.map +1 -0
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts +18 -0
- package/dist/types/lib/bitcore/transaction/input/taproot.d.ts.map +1 -0
- package/dist/types/lib/bitcore/transaction/input.d.ts +27 -35
- package/dist/types/lib/bitcore/transaction/input.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts +32 -0
- package/dist/types/lib/bitcore/transaction/outpoint.d.ts.map +1 -0
- package/dist/types/lib/bitcore/transaction/output.d.ts +3 -1
- package/dist/types/lib/bitcore/transaction/output.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/sighash.d.ts +8 -7
- package/dist/types/lib/bitcore/transaction/sighash.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/signature.d.ts +3 -2
- package/dist/types/lib/bitcore/transaction/signature.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/transaction.d.ts +18 -15
- package/dist/types/lib/bitcore/transaction/transaction.d.ts.map +1 -1
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts +9 -7
- package/dist/types/lib/bitcore/transaction/unspentoutput.d.ts.map +1 -1
- package/dist/types/lib/bitcore/unit.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/base32.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/bits.d.ts +5 -0
- package/dist/types/lib/bitcore/util/bits.d.ts.map +1 -0
- package/dist/types/lib/bitcore/util/buffer.d.ts +10 -2
- package/dist/types/lib/bitcore/util/buffer.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/js.d.ts +0 -1
- package/dist/types/lib/bitcore/util/js.d.ts.map +1 -1
- package/dist/types/lib/bitcore/util/merkle.d.ts +6 -0
- package/dist/types/lib/bitcore/util/merkle.d.ts.map +1 -0
- package/dist/types/lib/bitcore/util/preconditions.d.ts.map +1 -1
- package/dist/types/lib/bitcore/xaddress.d.ts +1 -0
- package/dist/types/lib/bitcore/xaddress.d.ts.map +1 -1
- package/dist/types/lib/{bitcore/taproot/nft.d.ts → nft.d.ts} +26 -12
- package/dist/types/lib/nft.d.ts.map +1 -0
- package/dist/types/lib/rank/index.d.ts +1 -0
- package/dist/types/lib/rank/index.d.ts.map +1 -1
- package/dist/types/lib/rank/script.d.ts +1 -0
- package/dist/types/lib/rank/script.d.ts.map +1 -1
- package/dist/types/lib/rank/transaction.d.ts +1 -0
- package/dist/types/lib/rank/transaction.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/string.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/cjs/lib/bitcore/script/interpreter.js +0 -1757
- package/dist/esm/lib/bitcore/script/interpreter.js +0 -1753
- package/dist/types/lib/bitcore/chunk.d.ts.map +0 -1
- package/dist/types/lib/bitcore/script/interpreter.d.ts +0 -101
- package/dist/types/lib/bitcore/script/interpreter.d.ts.map +0 -1
- package/dist/types/lib/bitcore/taproot/nft.d.ts.map +0 -1
- package/dist/types/lib/bitcore/taproot.d.ts.map +0 -1
- /package/dist/cjs/lib/bitcore/{chunk.js → script/chunk.js} +0 -0
- /package/dist/esm/lib/bitcore/{chunk.js → script/chunk.js} +0 -0
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PublicKey = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
3
|
+
exports.PublicKey = exports.PUBKEY_PREFIX_UNCOMPRESSED = exports.PUBKEY_PREFIX_ODD = exports.PUBKEY_PREFIX_EVEN = void 0;
|
|
4
|
+
const bn_1 = require("./crypto/bn");
|
|
5
|
+
const point_1 = require("./crypto/point");
|
|
6
|
+
const hash_1 = require("./crypto/hash");
|
|
7
|
+
const buffer_1 = require("./util/buffer");
|
|
8
|
+
const js_1 = require("./util/js");
|
|
9
|
+
const networks_1 = require("./networks");
|
|
10
|
+
const privatekey_1 = require("./privatekey");
|
|
11
|
+
const address_1 = require("./address");
|
|
12
|
+
exports.PUBKEY_PREFIX_EVEN = 0x02;
|
|
13
|
+
exports.PUBKEY_PREFIX_ODD = 0x03;
|
|
14
|
+
exports.PUBKEY_PREFIX_UNCOMPRESSED = 0x04;
|
|
11
15
|
class PublicKey {
|
|
12
16
|
point;
|
|
13
17
|
compressed;
|
|
14
18
|
network;
|
|
19
|
+
static PrefixOddY = buffer_1.BufferUtil.from([exports.PUBKEY_PREFIX_ODD]);
|
|
20
|
+
static PrefixEvenY = buffer_1.BufferUtil.from([exports.PUBKEY_PREFIX_EVEN]);
|
|
21
|
+
static PrefixUncompressed = buffer_1.BufferUtil.from([
|
|
22
|
+
exports.PUBKEY_PREFIX_UNCOMPRESSED,
|
|
23
|
+
]);
|
|
15
24
|
constructor(data, extra) {
|
|
16
25
|
if (data instanceof PublicKey) {
|
|
17
26
|
return data;
|
|
@@ -22,17 +31,17 @@ class PublicKey {
|
|
|
22
31
|
extra = extra || {};
|
|
23
32
|
const info = this._classifyArgs(data, extra);
|
|
24
33
|
info.point?.validate();
|
|
25
|
-
|
|
34
|
+
js_1.JSUtil.defineImmutable(this, {
|
|
26
35
|
point: info.point,
|
|
27
36
|
compressed: info.compressed,
|
|
28
|
-
network: info.network ||
|
|
37
|
+
network: info.network || networks_1.defaultNetwork,
|
|
29
38
|
});
|
|
30
39
|
}
|
|
31
40
|
_classifyArgs(data, extra) {
|
|
32
41
|
const info = {
|
|
33
42
|
compressed: extra.compressed === undefined ? true : extra.compressed,
|
|
34
43
|
};
|
|
35
|
-
if (data instanceof
|
|
44
|
+
if (data instanceof point_1.Point) {
|
|
36
45
|
info.point = data;
|
|
37
46
|
}
|
|
38
47
|
else if (typeof data === 'object' &&
|
|
@@ -43,7 +52,7 @@ class PublicKey {
|
|
|
43
52
|
Object.assign(info, objectInfo);
|
|
44
53
|
}
|
|
45
54
|
else if (typeof data === 'string') {
|
|
46
|
-
const derInfo = PublicKey._transformDER(
|
|
55
|
+
const derInfo = PublicKey._transformDER(buffer_1.BufferUtil.from(data, 'hex'));
|
|
47
56
|
Object.assign(info, derInfo);
|
|
48
57
|
}
|
|
49
58
|
else if (PublicKey._isBuffer(data)) {
|
|
@@ -58,7 +67,7 @@ class PublicKey {
|
|
|
58
67
|
throw new TypeError('First argument is an unrecognized data format.');
|
|
59
68
|
}
|
|
60
69
|
if (!info.network) {
|
|
61
|
-
info.network = extra.network ? (0,
|
|
70
|
+
info.network = extra.network ? (0, networks_1.get)(extra.network) : undefined;
|
|
62
71
|
}
|
|
63
72
|
if (!info.point) {
|
|
64
73
|
throw new Error('Failed to derive a valid point from the input data');
|
|
@@ -66,17 +75,17 @@ class PublicKey {
|
|
|
66
75
|
return info;
|
|
67
76
|
}
|
|
68
77
|
static _isPrivateKey(param) {
|
|
69
|
-
return param instanceof
|
|
78
|
+
return param instanceof privatekey_1.PrivateKey;
|
|
70
79
|
}
|
|
71
80
|
static _isBuffer(param) {
|
|
72
|
-
return
|
|
81
|
+
return buffer_1.BufferUtil.isBuffer(param) || param instanceof Uint8Array;
|
|
73
82
|
}
|
|
74
83
|
static _transformPrivateKey(privkey) {
|
|
75
84
|
if (!PublicKey._isPrivateKey(privkey)) {
|
|
76
85
|
throw new Error('Must be an instance of PrivateKey');
|
|
77
86
|
}
|
|
78
87
|
return {
|
|
79
|
-
point:
|
|
88
|
+
point: point_1.Point.getG().mul(privkey.bn),
|
|
80
89
|
compressed: privkey.compressed,
|
|
81
90
|
network: privkey.network,
|
|
82
91
|
};
|
|
@@ -91,28 +100,23 @@ class PublicKey {
|
|
|
91
100
|
let y;
|
|
92
101
|
let xbuf;
|
|
93
102
|
let ybuf;
|
|
94
|
-
if (buf[0] ===
|
|
95
|
-
|
|
96
|
-
|
|
103
|
+
if (buf[0] === exports.PUBKEY_PREFIX_UNCOMPRESSED ||
|
|
104
|
+
(!strict && (buf[0] === 0x06 || buf[0] === 0x07))) {
|
|
105
|
+
xbuf = buf.slice(1, 33);
|
|
106
|
+
ybuf = buf.slice(33, 65);
|
|
97
107
|
if (xbuf.length !== 32 || ybuf.length !== 32 || buf.length !== 65) {
|
|
98
108
|
throw new TypeError('Length of x and y must be 32 bytes');
|
|
99
109
|
}
|
|
100
|
-
x =
|
|
101
|
-
y =
|
|
102
|
-
point = new
|
|
110
|
+
x = bn_1.BN.fromBuffer(xbuf);
|
|
111
|
+
y = bn_1.BN.fromBuffer(ybuf);
|
|
112
|
+
point = new point_1.Point(x, y);
|
|
103
113
|
compressed = false;
|
|
104
114
|
}
|
|
105
|
-
else if (buf[0] ===
|
|
106
|
-
xbuf = buf.
|
|
107
|
-
x =
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
compressed = true;
|
|
111
|
-
}
|
|
112
|
-
else if (buf[0] === 0x02) {
|
|
113
|
-
xbuf = buf.subarray(1);
|
|
114
|
-
x = new bn_js_1.BN(xbuf, 'be');
|
|
115
|
-
const xInfo = PublicKey._transformX(false, x);
|
|
115
|
+
else if (buf[0] === exports.PUBKEY_PREFIX_ODD || buf[0] === exports.PUBKEY_PREFIX_EVEN) {
|
|
116
|
+
xbuf = buf.slice(1);
|
|
117
|
+
x = bn_1.BN.fromBuffer(xbuf);
|
|
118
|
+
const isOdd = buf[0] === exports.PUBKEY_PREFIX_ODD;
|
|
119
|
+
const xInfo = PublicKey._transformX(isOdd, x);
|
|
116
120
|
point = xInfo.point;
|
|
117
121
|
compressed = true;
|
|
118
122
|
}
|
|
@@ -129,14 +133,14 @@ class PublicKey {
|
|
|
129
133
|
throw new Error('Must specify whether y is odd or not (true or false)');
|
|
130
134
|
}
|
|
131
135
|
return {
|
|
132
|
-
point:
|
|
136
|
+
point: point_1.Point.fromX(odd, x),
|
|
133
137
|
compressed: true,
|
|
134
138
|
};
|
|
135
139
|
}
|
|
136
140
|
static _transformObject(json) {
|
|
137
|
-
const x =
|
|
138
|
-
const y =
|
|
139
|
-
const point = new
|
|
141
|
+
const x = bn_1.BN.fromString(json.x, 'hex');
|
|
142
|
+
const y = bn_1.BN.fromString(json.y, 'hex');
|
|
143
|
+
const point = new point_1.Point(x, y);
|
|
140
144
|
return {
|
|
141
145
|
point: point,
|
|
142
146
|
compressed: json.compressed,
|
|
@@ -165,7 +169,7 @@ class PublicKey {
|
|
|
165
169
|
return PublicKey.fromDER(buf, strict);
|
|
166
170
|
}
|
|
167
171
|
static fromPoint(point, compressed) {
|
|
168
|
-
if (!(point instanceof
|
|
172
|
+
if (!(point instanceof point_1.Point)) {
|
|
169
173
|
throw new Error('First argument must be an instance of Point.');
|
|
170
174
|
}
|
|
171
175
|
return new PublicKey(point, {
|
|
@@ -173,7 +177,7 @@ class PublicKey {
|
|
|
173
177
|
});
|
|
174
178
|
}
|
|
175
179
|
static fromString(str, encoding) {
|
|
176
|
-
const buf =
|
|
180
|
+
const buf = buffer_1.BufferUtil.from(str, encoding || 'hex');
|
|
177
181
|
const info = PublicKey._transformDER(buf);
|
|
178
182
|
return new PublicKey(info.point, {
|
|
179
183
|
compressed: info.compressed,
|
|
@@ -202,8 +206,8 @@ class PublicKey {
|
|
|
202
206
|
}
|
|
203
207
|
toObject() {
|
|
204
208
|
return {
|
|
205
|
-
x: this.point.
|
|
206
|
-
y: this.point.
|
|
209
|
+
x: this.point.x.toString(16).padStart(64, '0'),
|
|
210
|
+
y: this.point.y.toString(16).padStart(64, '0'),
|
|
207
211
|
compressed: this.compressed,
|
|
208
212
|
};
|
|
209
213
|
}
|
|
@@ -211,37 +215,37 @@ class PublicKey {
|
|
|
211
215
|
return this.toObject();
|
|
212
216
|
}
|
|
213
217
|
toBigNumber() {
|
|
214
|
-
return this.point.
|
|
218
|
+
return this.point.x;
|
|
215
219
|
}
|
|
216
220
|
toBuffer() {
|
|
217
221
|
return this.toDER();
|
|
218
222
|
}
|
|
219
223
|
toDER() {
|
|
220
|
-
const x = this.point.
|
|
221
|
-
const y = this.point.
|
|
222
|
-
const xbuf = x.
|
|
223
|
-
const ybuf = y.
|
|
224
|
+
const x = this.point.x;
|
|
225
|
+
const y = this.point.y;
|
|
226
|
+
const xbuf = x.toBuffer({ size: 32 });
|
|
227
|
+
const ybuf = y.toBuffer({ size: 32 });
|
|
224
228
|
let prefix;
|
|
225
229
|
if (!this.compressed) {
|
|
226
|
-
prefix =
|
|
227
|
-
return
|
|
230
|
+
prefix = buffer_1.BufferUtil.from([0x04]);
|
|
231
|
+
return buffer_1.BufferUtil.concat([prefix, xbuf, ybuf]);
|
|
228
232
|
}
|
|
229
233
|
else {
|
|
230
|
-
const odd = y.mod(new
|
|
234
|
+
const odd = y.mod(new bn_1.BN(2)).eq(bn_1.BN.One);
|
|
231
235
|
if (odd) {
|
|
232
|
-
prefix =
|
|
236
|
+
prefix = PublicKey.PrefixOddY;
|
|
233
237
|
}
|
|
234
238
|
else {
|
|
235
|
-
prefix =
|
|
239
|
+
prefix = PublicKey.PrefixEvenY;
|
|
236
240
|
}
|
|
237
|
-
return
|
|
241
|
+
return buffer_1.BufferUtil.concat([prefix, xbuf]);
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
_getID() {
|
|
241
|
-
return
|
|
245
|
+
return hash_1.Hash.sha256ripemd160(this.toBuffer());
|
|
242
246
|
}
|
|
243
247
|
toAddress(network) {
|
|
244
|
-
return
|
|
248
|
+
return address_1.Address.fromPublicKey(this, network);
|
|
245
249
|
}
|
|
246
250
|
toString() {
|
|
247
251
|
return this.toDER().toString('hex');
|
|
@@ -250,8 +254,8 @@ class PublicKey {
|
|
|
250
254
|
return `<PublicKey: ${this.toString()}${this.compressed ? '' : ', uncompressed'}>`;
|
|
251
255
|
}
|
|
252
256
|
addScalar(scalar) {
|
|
253
|
-
const scalarBN =
|
|
254
|
-
const G =
|
|
257
|
+
const scalarBN = buffer_1.BufferUtil.isBuffer(scalar) ? new bn_1.BN(scalar) : scalar;
|
|
258
|
+
const G = point_1.Point.getG();
|
|
255
259
|
const tweakPoint = G.mul(scalarBN);
|
|
256
260
|
const tweakedPoint = this.point.add(tweakPoint);
|
|
257
261
|
tweakedPoint.validate();
|
|
@@ -261,7 +265,7 @@ class PublicKey {
|
|
|
261
265
|
});
|
|
262
266
|
}
|
|
263
267
|
static getN() {
|
|
264
|
-
return
|
|
268
|
+
return point_1.Point.getN();
|
|
265
269
|
}
|
|
266
270
|
}
|
|
267
271
|
exports.PublicKey = PublicKey;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConditionStack = void 0;
|
|
4
|
+
class ConditionStack {
|
|
5
|
+
static NO_FALSE = 0xffffffff;
|
|
6
|
+
_size = 0;
|
|
7
|
+
_firstFalsePos = ConditionStack.NO_FALSE;
|
|
8
|
+
isEmpty() {
|
|
9
|
+
return this._size === 0;
|
|
10
|
+
}
|
|
11
|
+
allTrue() {
|
|
12
|
+
return this._firstFalsePos === ConditionStack.NO_FALSE;
|
|
13
|
+
}
|
|
14
|
+
pushBack(value) {
|
|
15
|
+
if (this._firstFalsePos === ConditionStack.NO_FALSE && !value) {
|
|
16
|
+
this._firstFalsePos = this._size;
|
|
17
|
+
}
|
|
18
|
+
this._size++;
|
|
19
|
+
}
|
|
20
|
+
popBack() {
|
|
21
|
+
if (this._size === 0) {
|
|
22
|
+
throw new Error('ConditionStack: pop from empty stack');
|
|
23
|
+
}
|
|
24
|
+
this._size--;
|
|
25
|
+
if (this._firstFalsePos === this._size) {
|
|
26
|
+
this._firstFalsePos = ConditionStack.NO_FALSE;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
toggleTop() {
|
|
30
|
+
if (this._size === 0) {
|
|
31
|
+
throw new Error('ConditionStack: toggle on empty stack');
|
|
32
|
+
}
|
|
33
|
+
if (this._firstFalsePos === ConditionStack.NO_FALSE) {
|
|
34
|
+
this._firstFalsePos = this._size - 1;
|
|
35
|
+
}
|
|
36
|
+
else if (this._firstFalsePos === this._size - 1) {
|
|
37
|
+
this._firstFalsePos = ConditionStack.NO_FALSE;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.ConditionStack = ConditionStack;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Interpreter = exports.verifyScript = exports.evalScript = exports.ConditionStack = exports.ScriptNumError = exports.ScriptNum = exports.NULL_SIGNATURE_CHECKER = exports.ScriptError = exports.ScriptFlags = exports.STANDARD_SCRIPT_VERIFY_FLAGS = exports.SCRIPTNUM_MAX_ELEMENT_SIZE = exports.LOCKTIME_THRESHOLD = exports.MAX_NUM2BIN_SIZE = exports.MAX_STACK_SIZE = exports.MAX_SCRIPT_SIZE = exports.MAX_PUBKEYS_PER_MULTISIG = exports.MAX_OPS_PER_SCRIPT = exports.MAX_SCRIPT_ELEMENT_SIZE = void 0;
|
|
4
|
+
var types_1 = require("./types");
|
|
5
|
+
Object.defineProperty(exports, "MAX_SCRIPT_ELEMENT_SIZE", { enumerable: true, get: function () { return types_1.MAX_SCRIPT_ELEMENT_SIZE; } });
|
|
6
|
+
Object.defineProperty(exports, "MAX_OPS_PER_SCRIPT", { enumerable: true, get: function () { return types_1.MAX_OPS_PER_SCRIPT; } });
|
|
7
|
+
Object.defineProperty(exports, "MAX_PUBKEYS_PER_MULTISIG", { enumerable: true, get: function () { return types_1.MAX_PUBKEYS_PER_MULTISIG; } });
|
|
8
|
+
Object.defineProperty(exports, "MAX_SCRIPT_SIZE", { enumerable: true, get: function () { return types_1.MAX_SCRIPT_SIZE; } });
|
|
9
|
+
Object.defineProperty(exports, "MAX_STACK_SIZE", { enumerable: true, get: function () { return types_1.MAX_STACK_SIZE; } });
|
|
10
|
+
Object.defineProperty(exports, "MAX_NUM2BIN_SIZE", { enumerable: true, get: function () { return types_1.MAX_NUM2BIN_SIZE; } });
|
|
11
|
+
Object.defineProperty(exports, "LOCKTIME_THRESHOLD", { enumerable: true, get: function () { return types_1.LOCKTIME_THRESHOLD; } });
|
|
12
|
+
Object.defineProperty(exports, "SCRIPTNUM_MAX_ELEMENT_SIZE", { enumerable: true, get: function () { return types_1.SCRIPTNUM_MAX_ELEMENT_SIZE; } });
|
|
13
|
+
Object.defineProperty(exports, "STANDARD_SCRIPT_VERIFY_FLAGS", { enumerable: true, get: function () { return types_1.STANDARD_SCRIPT_VERIFY_FLAGS; } });
|
|
14
|
+
Object.defineProperty(exports, "ScriptFlags", { enumerable: true, get: function () { return types_1.ScriptFlags; } });
|
|
15
|
+
Object.defineProperty(exports, "ScriptError", { enumerable: true, get: function () { return types_1.ScriptError; } });
|
|
16
|
+
Object.defineProperty(exports, "NULL_SIGNATURE_CHECKER", { enumerable: true, get: function () { return types_1.NULL_SIGNATURE_CHECKER; } });
|
|
17
|
+
var script_num_1 = require("./script-num");
|
|
18
|
+
Object.defineProperty(exports, "ScriptNum", { enumerable: true, get: function () { return script_num_1.ScriptNum; } });
|
|
19
|
+
Object.defineProperty(exports, "ScriptNumError", { enumerable: true, get: function () { return script_num_1.ScriptNumError; } });
|
|
20
|
+
var condition_stack_1 = require("./condition-stack");
|
|
21
|
+
Object.defineProperty(exports, "ConditionStack", { enumerable: true, get: function () { return condition_stack_1.ConditionStack; } });
|
|
22
|
+
var interpreter_1 = require("./interpreter");
|
|
23
|
+
Object.defineProperty(exports, "evalScript", { enumerable: true, get: function () { return interpreter_1.evalScript; } });
|
|
24
|
+
Object.defineProperty(exports, "verifyScript", { enumerable: true, get: function () { return interpreter_1.verifyScript; } });
|
|
25
|
+
Object.defineProperty(exports, "Interpreter", { enumerable: true, get: function () { return interpreter_1.Interpreter; } });
|