@btc-vision/bitcoin 6.4.11 → 6.5.2
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/browser/chunks/crypto-0PweVewC.js +2033 -0
- package/browser/chunks/payments-CgasufRS.js +1047 -0
- package/browser/chunks/psbt-BIwOrKer.js +4096 -0
- package/browser/chunks/script-CROJPzz_.js +318 -0
- package/browser/chunks/transaction-DchBu35N.js +432 -0
- package/browser/chunks/utils-CO5kmxe9.js +761 -0
- package/browser/crypto/crypto.d.ts +1 -1
- package/browser/crypto.d.ts +1 -1
- package/browser/hooks/HookedSigner.d.ts +1 -1
- package/browser/index.d.ts +6 -4
- package/browser/index.js +92 -2
- package/browser/payments/index.d.ts +2 -2
- package/browser/payments/lazy.d.ts +1 -1
- package/browser/psbt/bip371.d.ts +5 -1
- package/browser/psbt.d.ts +1 -1
- package/browser/typeforce.d.ts +38 -0
- package/browser/types.d.ts +22 -20
- package/build/address.js +2 -2
- package/build/bip66.js +2 -2
- package/build/block.js +2 -2
- package/build/crypto.d.ts +1 -1
- package/build/crypto.js +2 -3
- package/build/hooks/HookedSigner.d.ts +1 -1
- package/build/index.d.ts +6 -4
- package/build/index.js +2 -2
- package/build/payments/bip341.js +1 -1
- package/build/payments/index.d.ts +2 -2
- package/build/payments/lazy.d.ts +1 -1
- package/build/payments/p2op.js +3 -3
- package/build/payments/p2pk.js +1 -1
- package/build/payments/p2pkh.js +3 -3
- package/build/payments/p2sh.js +3 -3
- package/build/payments/p2tr.js +9 -5
- package/build/payments/p2wpkh.js +3 -3
- package/build/payments/p2wsh.js +2 -2
- package/build/psbt/bip371.d.ts +5 -1
- package/build/psbt/bip371.js +10 -7
- package/build/psbt/psbtutils.js +5 -4
- package/build/psbt.d.ts +1 -1
- package/build/psbt.js +78 -45
- package/build/script.js +2 -2
- package/build/script_signature.js +7 -7
- package/build/transaction.js +22 -10
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/types.d.ts +22 -20
- package/build/types.js +10 -9
- package/package.json +37 -63
- package/src/address.ts +2 -2
- package/src/bip66.ts +2 -2
- package/src/block.ts +8 -5
- package/src/crypto.ts +3 -4
- package/src/ecc_lib.ts +1 -1
- package/src/hooks/HookedSigner.ts +1 -1
- package/src/index.ts +6 -6
- package/src/payments/bip341.ts +1 -1
- package/src/payments/embed.ts +1 -2
- package/src/payments/index.ts +4 -4
- package/src/payments/lazy.ts +3 -3
- package/src/payments/p2op.ts +4 -3
- package/src/payments/p2pk.ts +1 -1
- package/src/payments/p2pkh.ts +3 -3
- package/src/payments/p2sh.ts +13 -5
- package/src/payments/p2tr.ts +8 -9
- package/src/payments/p2wpkh.ts +3 -3
- package/src/payments/p2wsh.ts +4 -4
- package/src/psbt/bip371.ts +22 -13
- package/src/psbt/psbtutils.ts +8 -5
- package/src/psbt.ts +127 -80
- package/src/script.ts +4 -4
- package/src/script_signature.ts +7 -7
- package/src/transaction.ts +31 -18
- package/src/typeforce.d.ts +38 -0
- package/src/types.ts +34 -29
- package/test/address.spec.ts +12 -4
- package/test/bitcoin.core.spec.ts +1 -1
- package/test/block.spec.ts +1 -1
- package/test/bufferutils.spec.ts +1 -1
- package/test/crypto.spec.ts +3 -2
- package/test/fixtures/address.json +1 -1
- package/test/integration/addresses.spec.ts +1 -1
- package/test/integration/bip32.spec.ts +2 -2
- package/test/integration/blocks.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +3 -3
- package/test/integration/csv.spec.ts +3 -3
- package/test/integration/payments.spec.ts +1 -1
- package/test/integration/taproot.spec.ts +8 -7
- package/test/integration/transactions.spec.ts +2 -2
- package/test/payments.spec.ts +4 -3
- package/test/psbt.spec.ts +106 -74
- package/test/script.spec.ts +73 -7
- package/test/script_number.spec.ts +1 -1
- package/test/script_signature.spec.ts +1 -1
- package/test/transaction.spec.ts +1 -1
- package/test/tsconfig.json +1 -1
- package/test/types.spec.ts +1 -1
- package/vite.config.browser.ts +93 -0
- package/vitest.config.ts +16 -0
- package/.babelrc +0 -4
- package/.mocharc.json +0 -13
- package/browser/index.js.LICENSE.txt +0 -14
- package/cjs/package.json +0 -3
- package/gulpfile.js +0 -42
- package/src/crypto/crypto-browser.js +0 -75
- package/test/ts-node-register.js +0 -7
- package/webpack.config.js +0 -79
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { B as _ } from "./crypto-0PweVewC.js";
|
|
2
|
+
import { u as y, k as d, U as C, v as H, x as L, A as u, y as h, z as M, o as I, C as V, D as w, E as B, j as F, G as m, p as K } from "./utils-CO5kmxe9.js";
|
|
3
|
+
const o = {
|
|
4
|
+
OP_FALSE: 0,
|
|
5
|
+
OP_0: 0,
|
|
6
|
+
OP_PUSHDATA1: 76,
|
|
7
|
+
OP_PUSHDATA2: 77,
|
|
8
|
+
OP_PUSHDATA4: 78,
|
|
9
|
+
OP_1NEGATE: 79,
|
|
10
|
+
OP_RESERVED: 80,
|
|
11
|
+
OP_TRUE: 81,
|
|
12
|
+
OP_1: 81,
|
|
13
|
+
OP_2: 82,
|
|
14
|
+
OP_3: 83,
|
|
15
|
+
OP_4: 84,
|
|
16
|
+
OP_5: 85,
|
|
17
|
+
OP_6: 86,
|
|
18
|
+
OP_7: 87,
|
|
19
|
+
OP_8: 88,
|
|
20
|
+
OP_9: 89,
|
|
21
|
+
OP_10: 90,
|
|
22
|
+
OP_11: 91,
|
|
23
|
+
OP_12: 92,
|
|
24
|
+
OP_13: 93,
|
|
25
|
+
OP_14: 94,
|
|
26
|
+
OP_15: 95,
|
|
27
|
+
OP_16: 96,
|
|
28
|
+
OP_NOP: 97,
|
|
29
|
+
OP_VER: 98,
|
|
30
|
+
OP_IF: 99,
|
|
31
|
+
OP_NOTIF: 100,
|
|
32
|
+
OP_VERIF: 101,
|
|
33
|
+
OP_VERNOTIF: 102,
|
|
34
|
+
OP_ELSE: 103,
|
|
35
|
+
OP_ENDIF: 104,
|
|
36
|
+
OP_VERIFY: 105,
|
|
37
|
+
OP_RETURN: 106,
|
|
38
|
+
OP_TOALTSTACK: 107,
|
|
39
|
+
OP_FROMALTSTACK: 108,
|
|
40
|
+
OP_2DROP: 109,
|
|
41
|
+
OP_2DUP: 110,
|
|
42
|
+
OP_3DUP: 111,
|
|
43
|
+
OP_2OVER: 112,
|
|
44
|
+
OP_2ROT: 113,
|
|
45
|
+
OP_2SWAP: 114,
|
|
46
|
+
OP_IFDUP: 115,
|
|
47
|
+
OP_DEPTH: 116,
|
|
48
|
+
OP_DROP: 117,
|
|
49
|
+
OP_DUP: 118,
|
|
50
|
+
OP_NIP: 119,
|
|
51
|
+
OP_OVER: 120,
|
|
52
|
+
OP_PICK: 121,
|
|
53
|
+
OP_ROLL: 122,
|
|
54
|
+
OP_ROT: 123,
|
|
55
|
+
OP_SWAP: 124,
|
|
56
|
+
OP_TUCK: 125,
|
|
57
|
+
OP_CAT: 126,
|
|
58
|
+
OP_SUBSTR: 127,
|
|
59
|
+
OP_LEFT: 128,
|
|
60
|
+
OP_RIGHT: 129,
|
|
61
|
+
OP_SIZE: 130,
|
|
62
|
+
OP_INVERT: 131,
|
|
63
|
+
OP_AND: 132,
|
|
64
|
+
OP_OR: 133,
|
|
65
|
+
OP_XOR: 134,
|
|
66
|
+
OP_EQUAL: 135,
|
|
67
|
+
OP_EQUALVERIFY: 136,
|
|
68
|
+
OP_RESERVED1: 137,
|
|
69
|
+
OP_RESERVED2: 138,
|
|
70
|
+
OP_1ADD: 139,
|
|
71
|
+
OP_1SUB: 140,
|
|
72
|
+
OP_2MUL: 141,
|
|
73
|
+
OP_2DIV: 142,
|
|
74
|
+
OP_NEGATE: 143,
|
|
75
|
+
OP_ABS: 144,
|
|
76
|
+
OP_NOT: 145,
|
|
77
|
+
OP_0NOTEQUAL: 146,
|
|
78
|
+
OP_ADD: 147,
|
|
79
|
+
OP_SUB: 148,
|
|
80
|
+
OP_MUL: 149,
|
|
81
|
+
OP_DIV: 150,
|
|
82
|
+
OP_MOD: 151,
|
|
83
|
+
OP_LSHIFT: 152,
|
|
84
|
+
OP_RSHIFT: 153,
|
|
85
|
+
OP_BOOLAND: 154,
|
|
86
|
+
OP_BOOLOR: 155,
|
|
87
|
+
OP_NUMEQUAL: 156,
|
|
88
|
+
OP_NUMEQUALVERIFY: 157,
|
|
89
|
+
OP_NUMNOTEQUAL: 158,
|
|
90
|
+
OP_LESSTHAN: 159,
|
|
91
|
+
OP_GREATERTHAN: 160,
|
|
92
|
+
OP_LESSTHANOREQUAL: 161,
|
|
93
|
+
OP_GREATERTHANOREQUAL: 162,
|
|
94
|
+
OP_MIN: 163,
|
|
95
|
+
OP_MAX: 164,
|
|
96
|
+
OP_WITHIN: 165,
|
|
97
|
+
OP_RIPEMD160: 166,
|
|
98
|
+
OP_SHA1: 167,
|
|
99
|
+
OP_SHA256: 168,
|
|
100
|
+
OP_HASH160: 169,
|
|
101
|
+
OP_HASH256: 170,
|
|
102
|
+
OP_CODESEPARATOR: 171,
|
|
103
|
+
OP_CHECKSIG: 172,
|
|
104
|
+
OP_CHECKSIGVERIFY: 173,
|
|
105
|
+
OP_CHECKMULTISIG: 174,
|
|
106
|
+
OP_CHECKMULTISIGVERIFY: 175,
|
|
107
|
+
OP_NOP1: 176,
|
|
108
|
+
OP_NOP2: 177,
|
|
109
|
+
OP_CHECKLOCKTIMEVERIFY: 177,
|
|
110
|
+
OP_NOP3: 178,
|
|
111
|
+
OP_CHECKSEQUENCEVERIFY: 178,
|
|
112
|
+
OP_NOP4: 179,
|
|
113
|
+
OP_NOP5: 180,
|
|
114
|
+
OP_NOP6: 181,
|
|
115
|
+
OP_NOP7: 182,
|
|
116
|
+
OP_NOP8: 183,
|
|
117
|
+
OP_NOP9: 184,
|
|
118
|
+
OP_NOP10: 185,
|
|
119
|
+
OP_CHECKSIGADD: 186,
|
|
120
|
+
OP_PUBKEYHASH: 253,
|
|
121
|
+
OP_PUBKEY: 254,
|
|
122
|
+
OP_INVALIDOPCODE: 255
|
|
123
|
+
}, T = {};
|
|
124
|
+
for (const t of Object.keys(o)) {
|
|
125
|
+
const n = o[t];
|
|
126
|
+
T[n] = t;
|
|
127
|
+
}
|
|
128
|
+
function G(t, n, e) {
|
|
129
|
+
n = n || 4, e = e === void 0 ? !0 : e;
|
|
130
|
+
const r = t.length;
|
|
131
|
+
if (r === 0) return 0;
|
|
132
|
+
if (r > n) throw new TypeError("Script number overflow");
|
|
133
|
+
if (e && (t[r - 1] & 127) === 0 && (r <= 1 || (t[r - 2] & 128) === 0))
|
|
134
|
+
throw new Error("Non-minimally encoded script number");
|
|
135
|
+
if (r === 5) {
|
|
136
|
+
const P = t.readUInt32LE(0), i = t.readUInt8(4);
|
|
137
|
+
return i & 128 ? -((i & -129) * 4294967296 + P) : i * 4294967296 + P;
|
|
138
|
+
}
|
|
139
|
+
let O = 0;
|
|
140
|
+
for (let P = 0; P < r; ++P)
|
|
141
|
+
O |= t[P] << 8 * P;
|
|
142
|
+
return t[r - 1] & 128 ? -(O & ~(128 << 8 * (r - 1))) : O;
|
|
143
|
+
}
|
|
144
|
+
function v(t) {
|
|
145
|
+
return t > 2147483647 ? 5 : t > 8388607 ? 4 : t > 32767 ? 3 : t > 127 ? 2 : t > 0 ? 1 : 0;
|
|
146
|
+
}
|
|
147
|
+
function R(t) {
|
|
148
|
+
let n = Math.abs(t);
|
|
149
|
+
const e = v(n), r = _.allocUnsafe(e), O = t < 0;
|
|
150
|
+
for (let P = 0; P < e; ++P)
|
|
151
|
+
r.writeUInt8(n & 255, P), n >>= 8;
|
|
152
|
+
return r[e - 1] & 128 ? r.writeUInt8(O ? 128 : 0, e - 1) : O && (r[e - 1] |= 128), r;
|
|
153
|
+
}
|
|
154
|
+
const b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
155
|
+
__proto__: null,
|
|
156
|
+
decode: G,
|
|
157
|
+
encode: R
|
|
158
|
+
}, Symbol.toStringTag, { value: "Module" })), { typeforce: $ } = d, f = _.alloc(1, 0);
|
|
159
|
+
function A(t) {
|
|
160
|
+
let n = 0;
|
|
161
|
+
for (; t[n] === 0; ) ++n;
|
|
162
|
+
return n === t.length ? f : (t = t.subarray(n), t[0] & 128 ? _.concat([f, t], 1 + t.length) : t);
|
|
163
|
+
}
|
|
164
|
+
function S(t) {
|
|
165
|
+
t[0] === 0 && (t = t.subarray(1));
|
|
166
|
+
const n = _.alloc(32, 0), e = Math.max(0, 32 - t.length);
|
|
167
|
+
return t.copy(n, e), n;
|
|
168
|
+
}
|
|
169
|
+
function j(t) {
|
|
170
|
+
const n = t.readUInt8(t.length - 1);
|
|
171
|
+
if (!a(n))
|
|
172
|
+
throw new Error(`Invalid hashType ${n}`);
|
|
173
|
+
const e = y(t.subarray(0, -1)), r = S(e.r), O = S(e.s);
|
|
174
|
+
return { signature: _.concat([r, O], 64), hashType: n };
|
|
175
|
+
}
|
|
176
|
+
function Q(t, n) {
|
|
177
|
+
if ($(
|
|
178
|
+
{
|
|
179
|
+
signature: H(64),
|
|
180
|
+
hashType: C
|
|
181
|
+
},
|
|
182
|
+
{ signature: t, hashType: n }
|
|
183
|
+
), !a(n))
|
|
184
|
+
throw new Error(`Invalid hashType ${n}`);
|
|
185
|
+
const e = _.allocUnsafe(1);
|
|
186
|
+
e.writeUInt8(n, 0);
|
|
187
|
+
const r = A(t.subarray(0, 32)), O = A(t.subarray(32, 64));
|
|
188
|
+
return _.concat([L(r, O), e]);
|
|
189
|
+
}
|
|
190
|
+
const Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
191
|
+
__proto__: null,
|
|
192
|
+
decode: j,
|
|
193
|
+
encode: Q
|
|
194
|
+
}, Symbol.toStringTag, { value: "Module" })), { typeforce: s } = d, U = o.OP_RESERVED;
|
|
195
|
+
function z(t) {
|
|
196
|
+
return K(t) && (t === o.OP_0 || t >= o.OP_1 && t <= o.OP_16 || t === o.OP_1NEGATE);
|
|
197
|
+
}
|
|
198
|
+
function N(t) {
|
|
199
|
+
return I(t) || z(t);
|
|
200
|
+
}
|
|
201
|
+
function p(t) {
|
|
202
|
+
return u(t) && t.every(N);
|
|
203
|
+
}
|
|
204
|
+
function W(t) {
|
|
205
|
+
return t.length - t.filter(N).length;
|
|
206
|
+
}
|
|
207
|
+
function c(t) {
|
|
208
|
+
if (t.length === 0) return o.OP_0;
|
|
209
|
+
if (t.length === 1) {
|
|
210
|
+
if (t[0] >= 1 && t[0] <= 16) return U + t[0];
|
|
211
|
+
if (t[0] === 129) return o.OP_1NEGATE;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function D(t) {
|
|
215
|
+
return _.isBuffer(t);
|
|
216
|
+
}
|
|
217
|
+
function X(t) {
|
|
218
|
+
return u(t);
|
|
219
|
+
}
|
|
220
|
+
function E(t) {
|
|
221
|
+
return _.isBuffer(t);
|
|
222
|
+
}
|
|
223
|
+
function g(t) {
|
|
224
|
+
if (D(t)) return t;
|
|
225
|
+
s(u, t);
|
|
226
|
+
const n = t.reduce((O, P) => E(P) ? P.length === 1 && c(P) !== void 0 ? O + 1 : O + h(P.length) + P.length : O + 1, 0), e = _.allocUnsafe(n);
|
|
227
|
+
let r = 0;
|
|
228
|
+
if (t.forEach((O) => {
|
|
229
|
+
if (E(O)) {
|
|
230
|
+
const P = c(O);
|
|
231
|
+
if (P !== void 0) {
|
|
232
|
+
e.writeUInt8(P, r), r += 1;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
r += M(e, O.length, r), O.copy(e, r), r += O.length;
|
|
236
|
+
} else
|
|
237
|
+
e.writeUInt8(O, r), r += 1;
|
|
238
|
+
}), r !== e.length) throw new Error("Could not decode chunks");
|
|
239
|
+
return e;
|
|
240
|
+
}
|
|
241
|
+
function l(t) {
|
|
242
|
+
if (X(t)) return t;
|
|
243
|
+
s(I, t);
|
|
244
|
+
const n = [];
|
|
245
|
+
let e = 0;
|
|
246
|
+
for (; e < t.length; ) {
|
|
247
|
+
const r = t[e];
|
|
248
|
+
if (r > o.OP_0 && r <= o.OP_PUSHDATA4) {
|
|
249
|
+
const O = V(t, e);
|
|
250
|
+
if (O === null || (e += O.size, e + O.number > t.length)) return null;
|
|
251
|
+
const P = t.subarray(e, e + O.number);
|
|
252
|
+
e += O.number;
|
|
253
|
+
const i = c(P);
|
|
254
|
+
i !== void 0 ? n.push(i) : n.push(P);
|
|
255
|
+
} else
|
|
256
|
+
n.push(r), e += 1;
|
|
257
|
+
}
|
|
258
|
+
return n;
|
|
259
|
+
}
|
|
260
|
+
function Z(t) {
|
|
261
|
+
if (D(t) && (t = l(t)), !t)
|
|
262
|
+
throw new Error("Could not convert invalid chunks to ASM");
|
|
263
|
+
return t.map((n) => {
|
|
264
|
+
if (E(n)) {
|
|
265
|
+
const e = c(n);
|
|
266
|
+
if (e === void 0) return n.toString("hex");
|
|
267
|
+
n = e;
|
|
268
|
+
}
|
|
269
|
+
return T[n];
|
|
270
|
+
}).join(" ");
|
|
271
|
+
}
|
|
272
|
+
function q(t) {
|
|
273
|
+
return s(w, t), g(
|
|
274
|
+
t.split(" ").map((n) => o[n] !== void 0 ? o[n] : (s(B, n), _.from(n, "hex")))
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
function J(t) {
|
|
278
|
+
return t = l(t), s(p, t), t.map((n) => E(n) ? n : n === o.OP_0 ? _.allocUnsafe(0) : R(n - U));
|
|
279
|
+
}
|
|
280
|
+
function x(t) {
|
|
281
|
+
return F(t);
|
|
282
|
+
}
|
|
283
|
+
function a(t) {
|
|
284
|
+
const n = t & -129;
|
|
285
|
+
return n > 0 && n < 4;
|
|
286
|
+
}
|
|
287
|
+
function k(t) {
|
|
288
|
+
return !_.isBuffer(t) || !a(t[t.length - 1]) ? !1 : m(t.subarray(0, -1));
|
|
289
|
+
}
|
|
290
|
+
const tt = b, nt = Y, Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
291
|
+
__proto__: null,
|
|
292
|
+
compile: g,
|
|
293
|
+
countNonPushOnlyOPs: W,
|
|
294
|
+
decompile: l,
|
|
295
|
+
fromASM: q,
|
|
296
|
+
isCanonicalPubKey: x,
|
|
297
|
+
isCanonicalScriptSignature: k,
|
|
298
|
+
isDefinedHashType: a,
|
|
299
|
+
isPushOnly: p,
|
|
300
|
+
number: tt,
|
|
301
|
+
opcodes: o,
|
|
302
|
+
signature: nt,
|
|
303
|
+
toASM: Z,
|
|
304
|
+
toStack: J
|
|
305
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
306
|
+
export {
|
|
307
|
+
x as a,
|
|
308
|
+
Ot as b,
|
|
309
|
+
g as c,
|
|
310
|
+
l as d,
|
|
311
|
+
W as e,
|
|
312
|
+
p as f,
|
|
313
|
+
J as g,
|
|
314
|
+
k as i,
|
|
315
|
+
o,
|
|
316
|
+
nt as s,
|
|
317
|
+
Z as t
|
|
318
|
+
};
|