xpi-ts 0.2.23 → 0.3.1
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/.mcp.json +8 -0
- package/README.md +9 -2
- package/dist/cjs/lib/bitcore/crypto/point.js +2 -2
- package/dist/cjs/lib/bitcore/script.js +16 -50
- package/dist/cjs/lib/bitcore/transaction/transaction.js +3 -0
- package/dist/esm/lib/bitcore/crypto/point.js +2 -2
- package/dist/esm/lib/bitcore/script.js +16 -50
- package/dist/esm/lib/bitcore/transaction/transaction.js +3 -0
- package/dist/esm/package.json +3 -1
- package/dist/types/gulpfile.d.ts +10 -0
- package/dist/types/gulpfile.d.ts.map +1 -0
- 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 +4 -0
- 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 +511 -1
- 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 +384 -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 +10 -7
- package/tsconfig.types.json +2 -1
package/.mcp.json
ADDED
package/README.md
CHANGED
|
@@ -423,10 +423,17 @@ npm run test:coverage
|
|
|
423
423
|
### Build
|
|
424
424
|
|
|
425
425
|
```bash
|
|
426
|
-
#
|
|
426
|
+
# Run full gulp build pipeline (clean + types + esm + cjs + export validation)
|
|
427
427
|
npm run build
|
|
428
428
|
|
|
429
|
-
#
|
|
429
|
+
# Run targeted pipeline stages
|
|
430
|
+
npm run build:clean
|
|
431
|
+
npm run build:types
|
|
432
|
+
npm run build:esm
|
|
433
|
+
npm run build:cjs
|
|
434
|
+
npm run build:validate
|
|
435
|
+
|
|
436
|
+
# Watch mode (rebuilds types + esm + cjs)
|
|
430
437
|
npm run build:watch
|
|
431
438
|
```
|
|
432
439
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Point = exports.PREFIX_Y_EVEN = exports.PREFIX_Y_ODD = void 0;
|
|
4
|
-
const
|
|
4
|
+
const elliptic = require("elliptic");
|
|
5
5
|
const bn_1 = require("./bn");
|
|
6
6
|
const util_1 = require("../util");
|
|
7
|
-
const ecInstance = new
|
|
7
|
+
const ecInstance = new (elliptic.default || elliptic).ec('secp256k1');
|
|
8
8
|
const ecPoint = ecInstance.curve.point.bind(ecInstance.curve);
|
|
9
9
|
const ecPointFromX = ecInstance.curve.pointFromX.bind(ecInstance.curve);
|
|
10
10
|
exports.PREFIX_Y_ODD = 0x03;
|
|
@@ -139,21 +139,20 @@ class Script {
|
|
|
139
139
|
if (opcodenum === undefined) {
|
|
140
140
|
const buf = buffer_js_1.BufferUtil.from(tokens[i], 'hex');
|
|
141
141
|
let opcodenum;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
opcodenum = len;
|
|
142
|
+
if (buf.length >= 0 && buf.length < opcode_js_1.Opcode.OP_PUSHDATA1) {
|
|
143
|
+
opcodenum = buf.length;
|
|
145
144
|
}
|
|
146
|
-
else if (
|
|
145
|
+
else if (buf.length <= 0xff) {
|
|
147
146
|
opcodenum = opcode_js_1.Opcode.OP_PUSHDATA1;
|
|
148
147
|
}
|
|
149
|
-
else if (
|
|
148
|
+
else if (buf.length <= 0xffff) {
|
|
150
149
|
opcodenum = opcode_js_1.Opcode.OP_PUSHDATA2;
|
|
151
150
|
}
|
|
152
|
-
else
|
|
151
|
+
else {
|
|
153
152
|
opcodenum = opcode_js_1.Opcode.OP_PUSHDATA4;
|
|
154
153
|
}
|
|
155
|
-
|
|
156
|
-
throw new Error(
|
|
154
|
+
if (!opcodenum) {
|
|
155
|
+
throw new Error(`Invalid script chunk buffer length (${buf.length})`);
|
|
157
156
|
}
|
|
158
157
|
script.chunks.push(new chunk_js_1.Chunk({
|
|
159
158
|
buf: buf,
|
|
@@ -468,39 +467,7 @@ class Script {
|
|
|
468
467
|
return script;
|
|
469
468
|
}
|
|
470
469
|
add(chunk) {
|
|
471
|
-
|
|
472
|
-
this.chunks.push(new chunk_js_1.Chunk({
|
|
473
|
-
opcodenum: chunk.num,
|
|
474
|
-
}));
|
|
475
|
-
}
|
|
476
|
-
else if (buffer_js_1.BufferUtil.isBuffer(chunk)) {
|
|
477
|
-
const chunkObj = {
|
|
478
|
-
buf: chunk,
|
|
479
|
-
len: chunk.length,
|
|
480
|
-
opcodenum: chunk.length,
|
|
481
|
-
};
|
|
482
|
-
if (chunk.length < opcode_js_1.Opcode.OP_PUSHDATA1) {
|
|
483
|
-
chunkObj.opcodenum = chunk.length;
|
|
484
|
-
}
|
|
485
|
-
else if (chunk.length <= 0xff) {
|
|
486
|
-
chunkObj.opcodenum = opcode_js_1.Opcode.OP_PUSHDATA1;
|
|
487
|
-
}
|
|
488
|
-
else if (chunk.length <= 0xffff) {
|
|
489
|
-
chunkObj.opcodenum = opcode_js_1.Opcode.OP_PUSHDATA2;
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
chunkObj.opcodenum = opcode_js_1.Opcode.OP_PUSHDATA4;
|
|
493
|
-
}
|
|
494
|
-
this.chunks.push(new chunk_js_1.Chunk(chunkObj));
|
|
495
|
-
}
|
|
496
|
-
else if (typeof chunk === 'number') {
|
|
497
|
-
this.chunks.push(new chunk_js_1.Chunk({
|
|
498
|
-
opcodenum: chunk,
|
|
499
|
-
}));
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
throw new TypeError('Invalid chunk type');
|
|
503
|
-
}
|
|
470
|
+
this._addByType(chunk, false);
|
|
504
471
|
return this;
|
|
505
472
|
}
|
|
506
473
|
addTaprootState(state) {
|
|
@@ -1104,25 +1071,24 @@ class Script {
|
|
|
1104
1071
|
}
|
|
1105
1072
|
_addBuffer(buf, prepend) {
|
|
1106
1073
|
let opcodenum;
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
opcodenum = len;
|
|
1074
|
+
if (buf.length >= 0 && buf.length < opcode_js_1.Opcode.OP_PUSHDATA1) {
|
|
1075
|
+
opcodenum = buf.length;
|
|
1110
1076
|
}
|
|
1111
|
-
else if (
|
|
1077
|
+
else if (buf.length <= 0xff) {
|
|
1112
1078
|
opcodenum = opcode_js_1.Opcode.OP_PUSHDATA1;
|
|
1113
1079
|
}
|
|
1114
|
-
else if (
|
|
1080
|
+
else if (buf.length <= 0xffff) {
|
|
1115
1081
|
opcodenum = opcode_js_1.Opcode.OP_PUSHDATA2;
|
|
1116
1082
|
}
|
|
1117
|
-
else
|
|
1083
|
+
else {
|
|
1118
1084
|
opcodenum = opcode_js_1.Opcode.OP_PUSHDATA4;
|
|
1119
1085
|
}
|
|
1120
|
-
|
|
1121
|
-
throw new Error(
|
|
1086
|
+
if (!opcodenum) {
|
|
1087
|
+
throw new Error(`Invalid script chunk buffer length (${buf.length})`);
|
|
1122
1088
|
}
|
|
1123
1089
|
this._insertAtPosition({
|
|
1124
1090
|
buf: buf,
|
|
1125
|
-
len:
|
|
1091
|
+
len: buf.length,
|
|
1126
1092
|
opcodenum: opcodenum,
|
|
1127
1093
|
}, prepend);
|
|
1128
1094
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as elliptic from 'elliptic';
|
|
2
2
|
import { BN } from './bn';
|
|
3
3
|
import { BufferUtil } from '../util';
|
|
4
|
-
const ecInstance = new ec('secp256k1');
|
|
4
|
+
const ecInstance = new (elliptic.default || elliptic).ec('secp256k1');
|
|
5
5
|
const ecPoint = ecInstance.curve.point.bind(ecInstance.curve);
|
|
6
6
|
const ecPointFromX = ecInstance.curve.pointFromX.bind(ecInstance.curve);
|
|
7
7
|
export const PREFIX_Y_ODD = 0x03;
|
|
@@ -136,21 +136,20 @@ export class Script {
|
|
|
136
136
|
if (opcodenum === undefined) {
|
|
137
137
|
const buf = BufferUtil.from(tokens[i], 'hex');
|
|
138
138
|
let opcodenum;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
opcodenum = len;
|
|
139
|
+
if (buf.length >= 0 && buf.length < Opcode.OP_PUSHDATA1) {
|
|
140
|
+
opcodenum = buf.length;
|
|
142
141
|
}
|
|
143
|
-
else if (
|
|
142
|
+
else if (buf.length <= 0xff) {
|
|
144
143
|
opcodenum = Opcode.OP_PUSHDATA1;
|
|
145
144
|
}
|
|
146
|
-
else if (
|
|
145
|
+
else if (buf.length <= 0xffff) {
|
|
147
146
|
opcodenum = Opcode.OP_PUSHDATA2;
|
|
148
147
|
}
|
|
149
|
-
else
|
|
148
|
+
else {
|
|
150
149
|
opcodenum = Opcode.OP_PUSHDATA4;
|
|
151
150
|
}
|
|
152
|
-
|
|
153
|
-
throw new Error(
|
|
151
|
+
if (!opcodenum) {
|
|
152
|
+
throw new Error(`Invalid script chunk buffer length (${buf.length})`);
|
|
154
153
|
}
|
|
155
154
|
script.chunks.push(new Chunk({
|
|
156
155
|
buf: buf,
|
|
@@ -465,39 +464,7 @@ export class Script {
|
|
|
465
464
|
return script;
|
|
466
465
|
}
|
|
467
466
|
add(chunk) {
|
|
468
|
-
|
|
469
|
-
this.chunks.push(new Chunk({
|
|
470
|
-
opcodenum: chunk.num,
|
|
471
|
-
}));
|
|
472
|
-
}
|
|
473
|
-
else if (BufferUtil.isBuffer(chunk)) {
|
|
474
|
-
const chunkObj = {
|
|
475
|
-
buf: chunk,
|
|
476
|
-
len: chunk.length,
|
|
477
|
-
opcodenum: chunk.length,
|
|
478
|
-
};
|
|
479
|
-
if (chunk.length < Opcode.OP_PUSHDATA1) {
|
|
480
|
-
chunkObj.opcodenum = chunk.length;
|
|
481
|
-
}
|
|
482
|
-
else if (chunk.length <= 0xff) {
|
|
483
|
-
chunkObj.opcodenum = Opcode.OP_PUSHDATA1;
|
|
484
|
-
}
|
|
485
|
-
else if (chunk.length <= 0xffff) {
|
|
486
|
-
chunkObj.opcodenum = Opcode.OP_PUSHDATA2;
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
chunkObj.opcodenum = Opcode.OP_PUSHDATA4;
|
|
490
|
-
}
|
|
491
|
-
this.chunks.push(new Chunk(chunkObj));
|
|
492
|
-
}
|
|
493
|
-
else if (typeof chunk === 'number') {
|
|
494
|
-
this.chunks.push(new Chunk({
|
|
495
|
-
opcodenum: chunk,
|
|
496
|
-
}));
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
throw new TypeError('Invalid chunk type');
|
|
500
|
-
}
|
|
467
|
+
this._addByType(chunk, false);
|
|
501
468
|
return this;
|
|
502
469
|
}
|
|
503
470
|
addTaprootState(state) {
|
|
@@ -1101,25 +1068,24 @@ export class Script {
|
|
|
1101
1068
|
}
|
|
1102
1069
|
_addBuffer(buf, prepend) {
|
|
1103
1070
|
let opcodenum;
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
opcodenum = len;
|
|
1071
|
+
if (buf.length >= 0 && buf.length < Opcode.OP_PUSHDATA1) {
|
|
1072
|
+
opcodenum = buf.length;
|
|
1107
1073
|
}
|
|
1108
|
-
else if (
|
|
1074
|
+
else if (buf.length <= 0xff) {
|
|
1109
1075
|
opcodenum = Opcode.OP_PUSHDATA1;
|
|
1110
1076
|
}
|
|
1111
|
-
else if (
|
|
1077
|
+
else if (buf.length <= 0xffff) {
|
|
1112
1078
|
opcodenum = Opcode.OP_PUSHDATA2;
|
|
1113
1079
|
}
|
|
1114
|
-
else
|
|
1080
|
+
else {
|
|
1115
1081
|
opcodenum = Opcode.OP_PUSHDATA4;
|
|
1116
1082
|
}
|
|
1117
|
-
|
|
1118
|
-
throw new Error(
|
|
1083
|
+
if (!opcodenum) {
|
|
1084
|
+
throw new Error(`Invalid script chunk buffer length (${buf.length})`);
|
|
1119
1085
|
}
|
|
1120
1086
|
this._insertAtPosition({
|
|
1121
1087
|
buf: buf,
|
|
1122
|
-
len:
|
|
1088
|
+
len: buf.length,
|
|
1123
1089
|
opcodenum: opcodenum,
|
|
1124
1090
|
}, prepend);
|
|
1125
1091
|
}
|
package/dist/esm/package.json
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default build;
|
|
2
|
+
export function clean(): Promise<void>;
|
|
3
|
+
declare function buildTypes(): Promise<any>;
|
|
4
|
+
declare const buildEsm: any;
|
|
5
|
+
declare function buildCjs(): Promise<any>;
|
|
6
|
+
export function validate(): Promise<void>;
|
|
7
|
+
export const build: any;
|
|
8
|
+
declare function buildWatch(): any;
|
|
9
|
+
export { buildTypes as _build_types, buildEsm as _build_esm, buildCjs as _build_cjs, buildWatch as watch };
|
|
10
|
+
//# sourceMappingURL=gulpfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gulpfile.d.ts","sourceRoot":"","sources":["../../gulpfile.js"],"names":[],"mappings":";AAmCA,uCAEC;AAED,4CAEC;AAeD,4BAA0D;AAE1D,0CAEC;AA8CD,0CASC;AAED,wBAA+E;AAE/E,mCAMC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA"}
|
|
@@ -27,41 +27,157 @@ export declare class Address {
|
|
|
27
27
|
readonly type: string;
|
|
28
28
|
constructor(data?: AddressInput, network?: Network | NetworkName, type?: string);
|
|
29
29
|
private _classifyArguments;
|
|
30
|
+
/**
|
|
31
|
+
* Internal function to discover the network and type based on the first data byte
|
|
32
|
+
*/
|
|
30
33
|
private static _classifyFromVersion;
|
|
34
|
+
/**
|
|
35
|
+
* Internal function to transform a Lotus address string
|
|
36
|
+
*/
|
|
31
37
|
private static _transformString;
|
|
38
|
+
/**
|
|
39
|
+
* Internal function to transform a legacy bitcoin address string
|
|
40
|
+
*/
|
|
32
41
|
private static _transformLegacyString;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a string is an XAddress format
|
|
44
|
+
*/
|
|
33
45
|
private static _isXAddress;
|
|
46
|
+
/**
|
|
47
|
+
* Internal function to transform an XAddress string
|
|
48
|
+
*/
|
|
34
49
|
private static _transformXAddressString;
|
|
50
|
+
/**
|
|
51
|
+
* Internal function to transform a hash buffer (20 bytes)
|
|
52
|
+
*/
|
|
35
53
|
private static _transformHash;
|
|
54
|
+
/**
|
|
55
|
+
* Internal function to transform a bitcoin address buffer (21 bytes)
|
|
56
|
+
*/
|
|
36
57
|
private static _transformBuffer;
|
|
58
|
+
/**
|
|
59
|
+
* Internal function to transform a public key
|
|
60
|
+
*/
|
|
37
61
|
private static _transformPublicKey;
|
|
62
|
+
/**
|
|
63
|
+
* Internal function to transform a Script into an info object
|
|
64
|
+
*/
|
|
38
65
|
private static _transformScript;
|
|
66
|
+
/**
|
|
67
|
+
* Deserializes an address serialized through `Address#toObject()`
|
|
68
|
+
*/
|
|
39
69
|
private static _transformObject;
|
|
70
|
+
/**
|
|
71
|
+
* Create a multisig address
|
|
72
|
+
*/
|
|
40
73
|
static createMultisig(publicKeys: PublicKey[], threshold: number, network?: Network | NetworkName): Address;
|
|
74
|
+
/**
|
|
75
|
+
* Create address from public key
|
|
76
|
+
*/
|
|
41
77
|
static fromPublicKey(data: PublicKey, network?: Network | NetworkName): Address;
|
|
78
|
+
/**
|
|
79
|
+
* Create address from public key hash
|
|
80
|
+
*/
|
|
42
81
|
static fromPublicKeyHash(hash: Buffer, network?: Network | NetworkName): Address;
|
|
82
|
+
/**
|
|
83
|
+
* Create address from script hash
|
|
84
|
+
*/
|
|
43
85
|
static fromScriptHash(hash: Buffer, network?: Network | NetworkName): Address;
|
|
86
|
+
/**
|
|
87
|
+
* Create Taproot address from commitment public key
|
|
88
|
+
*
|
|
89
|
+
* For Taproot, the "hash" is actually the 33-byte commitment public key.
|
|
90
|
+
*
|
|
91
|
+
* @param commitment - 33-byte commitment public key (tweaked)
|
|
92
|
+
* @param network - Network (livenet, testnet, regtest)
|
|
93
|
+
* @returns Taproot address
|
|
94
|
+
*/
|
|
44
95
|
static fromTaprootCommitment(commitment: PublicKey | Buffer, network: Network | NetworkName): Address;
|
|
96
|
+
/**
|
|
97
|
+
* Create address from buffer
|
|
98
|
+
*/
|
|
45
99
|
static fromBuffer(buffer: Buffer, network?: Network | NetworkName, type?: string): Address;
|
|
100
|
+
/**
|
|
101
|
+
* Takes an address string and transforms it into an `AddressData` object which
|
|
102
|
+
* contains the `hashBuffer`, `network`, and `type` parameters to instantiate the
|
|
103
|
+
* new `Address` object.
|
|
104
|
+
*/
|
|
46
105
|
static fromString(str: string, network?: Network | NetworkName): Address;
|
|
106
|
+
/**
|
|
107
|
+
* Create address from object
|
|
108
|
+
*/
|
|
47
109
|
static fromObject(obj: AddressObject): Address;
|
|
110
|
+
/**
|
|
111
|
+
* Extract address from a Script. The script must be of one
|
|
112
|
+
* of the following types: p2pkh input, p2pkh output, p2sh input
|
|
113
|
+
* or p2sh output.
|
|
114
|
+
*/
|
|
48
115
|
static fromScript(script: Script, network?: Network | NetworkName): Address;
|
|
116
|
+
/**
|
|
117
|
+
* Builds a p2sh address paying to script. This will hash the script and
|
|
118
|
+
* use that to create the address.
|
|
119
|
+
*/
|
|
49
120
|
static payingTo(script: Script, network?: Network | NetworkName): Address;
|
|
121
|
+
/**
|
|
122
|
+
* Will return a validation error if exists
|
|
123
|
+
*/
|
|
50
124
|
static getValidationError(data: AddressInput, network?: Network | NetworkName, type?: string): Error | null;
|
|
125
|
+
/**
|
|
126
|
+
* Will return a boolean if an address is valid
|
|
127
|
+
*/
|
|
51
128
|
static isValid(data: AddressInput, network?: Network | NetworkName, type?: string): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Check if address is pay to public key hash
|
|
131
|
+
*/
|
|
52
132
|
isPayToPublicKeyHash(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Check if address is pay to script hash
|
|
135
|
+
*/
|
|
53
136
|
isPayToScriptHash(): boolean;
|
|
137
|
+
/**
|
|
138
|
+
* Check if address is pay to taproot
|
|
139
|
+
*/
|
|
54
140
|
isPayToTaproot(): boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Will return a buffer representation of the address (hash buffer only)
|
|
143
|
+
*/
|
|
55
144
|
toBuffer(): Buffer;
|
|
145
|
+
/**
|
|
146
|
+
* Will return a full buffer representation of the address (version + hash)
|
|
147
|
+
*/
|
|
56
148
|
toFullBuffer(): Buffer;
|
|
149
|
+
/**
|
|
150
|
+
* Will return a cash address buffer representation
|
|
151
|
+
*/
|
|
57
152
|
toCashBuffer(): Buffer;
|
|
153
|
+
/**
|
|
154
|
+
* Returns a plain object with the address information
|
|
155
|
+
*/
|
|
58
156
|
toObject(): AddressObject;
|
|
59
157
|
toJSON(): AddressObject;
|
|
158
|
+
/**
|
|
159
|
+
* Wrapper method for `Address.toXAddress` method
|
|
160
|
+
*/
|
|
60
161
|
toString(network?: Network | NetworkName): string;
|
|
162
|
+
/**
|
|
163
|
+
* Will return a legacy address string
|
|
164
|
+
*/
|
|
61
165
|
toLegacyAddress(): string;
|
|
166
|
+
/**
|
|
167
|
+
* Will return a cash address string
|
|
168
|
+
*/
|
|
62
169
|
toCashAddress(): string;
|
|
170
|
+
/**
|
|
171
|
+
* Will return an X address string
|
|
172
|
+
*/
|
|
63
173
|
toXAddress(network?: Network | NetworkName): string;
|
|
174
|
+
/**
|
|
175
|
+
* Decode cash address
|
|
176
|
+
*/
|
|
64
177
|
static decodeCashAddress(address: string): CashAddressDecoding;
|
|
178
|
+
/**
|
|
179
|
+
* Inspect method for debugging
|
|
180
|
+
*/
|
|
65
181
|
inspect(): string;
|
|
66
182
|
}
|
|
67
183
|
//# sourceMappingURL=address.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../../../lib/bitcore/address.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,OAAO,EAGP,KAAK,WAAW,EACjB,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAGrC,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,MAAM,GACN,WAAW,GACX,SAAS,GACT,SAAS,EAAE,GACX,MAAM,CAAA;AAEV,qBAAa,OAAO;IAClB,MAAM,CAAC,QAAQ,CAAC,kBAAkB,gBAAe;IACjD,MAAM,CAAC,QAAQ,CAAC,eAAe,gBAAe;IAC9C,MAAM,CAAC,QAAQ,CAAC,YAAY,aAAY;IAExC,QAAQ,CAAC,UAAU,EAAG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