@btc-vision/bitcoin 6.5.1 → 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-BE4vwHhV.js → payments-CgasufRS.js} +410 -408
- package/browser/chunks/psbt-BIwOrKer.js +4096 -0
- package/browser/chunks/{script-COWGdiOo.js → script-CROJPzz_.js} +96 -96
- package/browser/chunks/{transaction-BiXwH2v4.js → transaction-DchBu35N.js} +158 -147
- package/browser/chunks/{utils-BKmkTzNZ.js → utils-CO5kmxe9.js} +225 -223
- package/browser/crypto.d.ts +1 -1
- package/browser/hooks/HookedSigner.d.ts +1 -1
- package/browser/index.d.ts +23 -1
- package/browser/index.js +6 -6
- 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 +23 -1
- 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 +30 -59
- 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 +34 -12
- 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/vitest.config.ts +16 -0
- package/.babelrc +0 -13
- package/.mocharc.json +0 -13
- package/browser/chunks/crypto-C6FlKKmp.js +0 -2006
- package/browser/chunks/psbt-Dlosf9CT.js +0 -3853
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as _ } from "./crypto-
|
|
2
|
-
import { u as
|
|
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
3
|
const o = {
|
|
4
4
|
OP_FALSE: 0,
|
|
5
5
|
OP_0: 0,
|
|
@@ -122,84 +122,84 @@ const o = {
|
|
|
122
122
|
OP_INVALIDOPCODE: 255
|
|
123
123
|
}, T = {};
|
|
124
124
|
for (const t of Object.keys(o)) {
|
|
125
|
-
const
|
|
126
|
-
T[
|
|
125
|
+
const n = o[t];
|
|
126
|
+
T[n] = t;
|
|
127
127
|
}
|
|
128
|
-
function G(t,
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
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
134
|
throw new Error("Non-minimally encoded script number");
|
|
135
|
-
if (
|
|
135
|
+
if (r === 5) {
|
|
136
136
|
const P = t.readUInt32LE(0), i = t.readUInt8(4);
|
|
137
137
|
return i & 128 ? -((i & -129) * 4294967296 + P) : i * 4294967296 + P;
|
|
138
138
|
}
|
|
139
|
-
let
|
|
140
|
-
for (let P = 0; P <
|
|
141
|
-
|
|
142
|
-
return t[
|
|
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
143
|
}
|
|
144
144
|
function v(t) {
|
|
145
145
|
return t > 2147483647 ? 5 : t > 8388607 ? 4 : t > 32767 ? 3 : t > 127 ? 2 : t > 0 ? 1 : 0;
|
|
146
146
|
}
|
|
147
147
|
function R(t) {
|
|
148
|
-
let
|
|
149
|
-
const
|
|
150
|
-
for (let P = 0; P <
|
|
151
|
-
|
|
152
|
-
return
|
|
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
153
|
}
|
|
154
|
-
const
|
|
154
|
+
const b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
155
155
|
__proto__: null,
|
|
156
156
|
decode: G,
|
|
157
157
|
encode: R
|
|
158
|
-
}, Symbol.toStringTag, { value: "Module" })), { typeforce:
|
|
158
|
+
}, Symbol.toStringTag, { value: "Module" })), { typeforce: $ } = d, f = _.alloc(1, 0);
|
|
159
159
|
function A(t) {
|
|
160
|
-
let
|
|
161
|
-
for (; t[
|
|
162
|
-
return
|
|
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
163
|
}
|
|
164
164
|
function S(t) {
|
|
165
|
-
t[0] === 0 && (t = t.
|
|
166
|
-
const
|
|
167
|
-
return t.copy(
|
|
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
168
|
}
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
throw new Error(
|
|
173
|
-
const
|
|
174
|
-
return { signature: _.concat([
|
|
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
175
|
}
|
|
176
|
-
function
|
|
177
|
-
if (
|
|
176
|
+
function Q(t, n) {
|
|
177
|
+
if ($(
|
|
178
178
|
{
|
|
179
|
-
signature:
|
|
180
|
-
hashType:
|
|
179
|
+
signature: H(64),
|
|
180
|
+
hashType: C
|
|
181
181
|
},
|
|
182
|
-
{ signature: t, hashType:
|
|
183
|
-
), !
|
|
184
|
-
throw new Error(
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
return _.concat([L(
|
|
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
189
|
}
|
|
190
|
-
const
|
|
190
|
+
const Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
191
191
|
__proto__: null,
|
|
192
|
-
decode:
|
|
193
|
-
encode:
|
|
192
|
+
decode: j,
|
|
193
|
+
encode: Q
|
|
194
194
|
}, Symbol.toStringTag, { value: "Module" })), { typeforce: s } = d, U = o.OP_RESERVED;
|
|
195
|
-
function
|
|
195
|
+
function z(t) {
|
|
196
196
|
return K(t) && (t === o.OP_0 || t >= o.OP_1 && t <= o.OP_16 || t === o.OP_1NEGATE);
|
|
197
197
|
}
|
|
198
198
|
function N(t) {
|
|
199
|
-
return I(t) ||
|
|
199
|
+
return I(t) || z(t);
|
|
200
200
|
}
|
|
201
201
|
function p(t) {
|
|
202
|
-
return
|
|
202
|
+
return u(t) && t.every(N);
|
|
203
203
|
}
|
|
204
204
|
function W(t) {
|
|
205
205
|
return t.length - t.filter(N).length;
|
|
@@ -215,104 +215,104 @@ function D(t) {
|
|
|
215
215
|
return _.isBuffer(t);
|
|
216
216
|
}
|
|
217
217
|
function X(t) {
|
|
218
|
-
return
|
|
218
|
+
return u(t);
|
|
219
219
|
}
|
|
220
220
|
function E(t) {
|
|
221
221
|
return _.isBuffer(t);
|
|
222
222
|
}
|
|
223
223
|
function g(t) {
|
|
224
224
|
if (D(t)) return t;
|
|
225
|
-
s(
|
|
226
|
-
const
|
|
227
|
-
let
|
|
228
|
-
if (t.forEach((
|
|
229
|
-
if (E(
|
|
230
|
-
const P = c(
|
|
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
231
|
if (P !== void 0) {
|
|
232
|
-
|
|
232
|
+
e.writeUInt8(P, r), r += 1;
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
|
|
235
|
+
r += M(e, O.length, r), O.copy(e, r), r += O.length;
|
|
236
236
|
} else
|
|
237
|
-
|
|
238
|
-
}),
|
|
239
|
-
return
|
|
237
|
+
e.writeUInt8(O, r), r += 1;
|
|
238
|
+
}), r !== e.length) throw new Error("Could not decode chunks");
|
|
239
|
+
return e;
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function l(t) {
|
|
242
242
|
if (X(t)) return t;
|
|
243
243
|
s(I, t);
|
|
244
|
-
const
|
|
245
|
-
let
|
|
246
|
-
for (;
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
251
|
-
const P = t.
|
|
252
|
-
|
|
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
253
|
const i = c(P);
|
|
254
|
-
i !== void 0 ?
|
|
254
|
+
i !== void 0 ? n.push(i) : n.push(P);
|
|
255
255
|
} else
|
|
256
|
-
|
|
256
|
+
n.push(r), e += 1;
|
|
257
257
|
}
|
|
258
|
-
return
|
|
258
|
+
return n;
|
|
259
259
|
}
|
|
260
260
|
function Z(t) {
|
|
261
|
-
if (D(t) && (t =
|
|
261
|
+
if (D(t) && (t = l(t)), !t)
|
|
262
262
|
throw new Error("Could not convert invalid chunks to ASM");
|
|
263
|
-
return t.map((
|
|
264
|
-
if (E(
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
|
|
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
268
|
}
|
|
269
|
-
return T[
|
|
269
|
+
return T[n];
|
|
270
270
|
}).join(" ");
|
|
271
271
|
}
|
|
272
272
|
function q(t) {
|
|
273
273
|
return s(w, t), g(
|
|
274
|
-
t.split(" ").map((
|
|
274
|
+
t.split(" ").map((n) => o[n] !== void 0 ? o[n] : (s(B, n), _.from(n, "hex")))
|
|
275
275
|
);
|
|
276
276
|
}
|
|
277
277
|
function J(t) {
|
|
278
|
-
return 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
279
|
}
|
|
280
280
|
function x(t) {
|
|
281
281
|
return F(t);
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
const
|
|
285
|
-
return
|
|
283
|
+
function a(t) {
|
|
284
|
+
const n = t & -129;
|
|
285
|
+
return n > 0 && n < 4;
|
|
286
286
|
}
|
|
287
287
|
function k(t) {
|
|
288
|
-
return !_.isBuffer(t) || !
|
|
288
|
+
return !_.isBuffer(t) || !a(t[t.length - 1]) ? !1 : m(t.subarray(0, -1));
|
|
289
289
|
}
|
|
290
|
-
const tt =
|
|
290
|
+
const tt = b, nt = Y, Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
291
291
|
__proto__: null,
|
|
292
292
|
compile: g,
|
|
293
293
|
countNonPushOnlyOPs: W,
|
|
294
|
-
decompile:
|
|
294
|
+
decompile: l,
|
|
295
295
|
fromASM: q,
|
|
296
296
|
isCanonicalPubKey: x,
|
|
297
297
|
isCanonicalScriptSignature: k,
|
|
298
|
-
isDefinedHashType:
|
|
298
|
+
isDefinedHashType: a,
|
|
299
299
|
isPushOnly: p,
|
|
300
300
|
number: tt,
|
|
301
301
|
opcodes: o,
|
|
302
|
-
signature:
|
|
302
|
+
signature: nt,
|
|
303
303
|
toASM: Z,
|
|
304
304
|
toStack: J
|
|
305
305
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
306
306
|
export {
|
|
307
307
|
x as a,
|
|
308
|
-
|
|
308
|
+
Ot as b,
|
|
309
309
|
g as c,
|
|
310
|
-
|
|
310
|
+
l as d,
|
|
311
311
|
W as e,
|
|
312
312
|
p as f,
|
|
313
313
|
J as g,
|
|
314
314
|
k as i,
|
|
315
315
|
o,
|
|
316
|
-
|
|
316
|
+
nt as s,
|
|
317
317
|
Z as t
|
|
318
318
|
};
|