@btc-vision/bitcoin 6.5.1 → 6.5.3

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.
Files changed (103) hide show
  1. package/browser/chunks/crypto-0PweVewC.js +2033 -0
  2. package/browser/chunks/{payments-BE4vwHhV.js → payments-CgasufRS.js} +410 -408
  3. package/browser/chunks/psbt-BIwOrKer.js +4096 -0
  4. package/browser/chunks/{script-COWGdiOo.js → script-CROJPzz_.js} +96 -96
  5. package/browser/chunks/{transaction-BiXwH2v4.js → transaction-DchBu35N.js} +158 -147
  6. package/browser/chunks/{utils-BKmkTzNZ.js → utils-CO5kmxe9.js} +225 -223
  7. package/browser/crypto.d.ts +1 -1
  8. package/browser/hooks/HookedSigner.d.ts +1 -1
  9. package/browser/index.d.ts +23 -1
  10. package/browser/index.js +6 -6
  11. package/browser/payments/index.d.ts +2 -2
  12. package/browser/payments/lazy.d.ts +1 -1
  13. package/browser/psbt/bip371.d.ts +5 -1
  14. package/browser/psbt.d.ts +1 -1
  15. package/browser/typeforce.d.ts +38 -0
  16. package/browser/types.d.ts +22 -20
  17. package/build/address.js +2 -2
  18. package/build/bip66.js +2 -2
  19. package/build/block.js +2 -2
  20. package/build/crypto.d.ts +1 -1
  21. package/build/crypto.js +2 -3
  22. package/build/hooks/HookedSigner.d.ts +1 -1
  23. package/build/index.d.ts +23 -1
  24. package/build/payments/bip341.js +1 -1
  25. package/build/payments/index.d.ts +2 -2
  26. package/build/payments/lazy.d.ts +1 -1
  27. package/build/payments/p2op.js +3 -3
  28. package/build/payments/p2pk.js +1 -1
  29. package/build/payments/p2pkh.js +3 -3
  30. package/build/payments/p2sh.js +3 -3
  31. package/build/payments/p2tr.js +9 -5
  32. package/build/payments/p2wpkh.js +3 -3
  33. package/build/payments/p2wsh.js +2 -2
  34. package/build/psbt/bip371.d.ts +5 -1
  35. package/build/psbt/bip371.js +10 -7
  36. package/build/psbt/psbtutils.js +5 -4
  37. package/build/psbt.d.ts +1 -1
  38. package/build/psbt.js +78 -45
  39. package/build/script.js +2 -2
  40. package/build/script_signature.js +7 -7
  41. package/build/transaction.js +22 -10
  42. package/build/tsconfig.tsbuildinfo +1 -0
  43. package/build/types.d.ts +22 -20
  44. package/build/types.js +10 -9
  45. package/package.json +32 -57
  46. package/src/address.ts +2 -2
  47. package/src/bip66.ts +2 -2
  48. package/src/block.ts +8 -5
  49. package/src/crypto.ts +3 -4
  50. package/src/ecc_lib.ts +1 -1
  51. package/src/hooks/HookedSigner.ts +1 -1
  52. package/src/index.ts +34 -12
  53. package/src/payments/bip341.ts +1 -1
  54. package/src/payments/embed.ts +1 -2
  55. package/src/payments/index.ts +4 -4
  56. package/src/payments/lazy.ts +3 -3
  57. package/src/payments/p2op.ts +4 -3
  58. package/src/payments/p2pk.ts +1 -1
  59. package/src/payments/p2pkh.ts +3 -3
  60. package/src/payments/p2sh.ts +13 -5
  61. package/src/payments/p2tr.ts +8 -9
  62. package/src/payments/p2wpkh.ts +3 -3
  63. package/src/payments/p2wsh.ts +4 -4
  64. package/src/psbt/bip371.ts +22 -13
  65. package/src/psbt/psbtutils.ts +8 -5
  66. package/src/psbt.ts +127 -80
  67. package/src/script.ts +4 -4
  68. package/src/script_signature.ts +7 -7
  69. package/src/transaction.ts +31 -18
  70. package/src/typeforce.d.ts +38 -0
  71. package/src/types.ts +34 -29
  72. package/test/address.spec.ts +12 -4
  73. package/test/bitcoin.core.spec.ts +1 -1
  74. package/test/block.spec.ts +1 -1
  75. package/test/bufferutils.spec.ts +1 -1
  76. package/test/crypto.spec.ts +3 -2
  77. package/test/fixtures/address.json +1 -1
  78. package/test/integration/addresses.spec.ts +1 -1
  79. package/test/integration/bip32.spec.ts +2 -2
  80. package/test/integration/blocks.spec.ts +1 -1
  81. package/test/integration/cltv.spec.ts +3 -3
  82. package/test/integration/csv.spec.ts +3 -3
  83. package/test/integration/payments.spec.ts +1 -1
  84. package/test/integration/taproot.spec.ts +8 -7
  85. package/test/integration/transactions.spec.ts +2 -2
  86. package/test/payments.spec.ts +4 -3
  87. package/test/psbt.spec.ts +106 -74
  88. package/test/script.spec.ts +73 -7
  89. package/test/script_number.spec.ts +1 -1
  90. package/test/script_signature.spec.ts +1 -1
  91. package/test/transaction.spec.ts +1 -1
  92. package/test/tsconfig.json +1 -1
  93. package/test/types.spec.ts +1 -1
  94. package/vitest.config.ts +16 -0
  95. package/.babelrc +0 -13
  96. package/.mocharc.json +0 -13
  97. package/browser/chunks/crypto-C6FlKKmp.js +0 -2006
  98. package/browser/chunks/psbt-Dlosf9CT.js +0 -3853
  99. package/cjs/package.json +0 -3
  100. package/gulpfile.js +0 -42
  101. package/src/crypto/crypto-browser.js +0 -75
  102. package/test/ts-node-register.js +0 -7
  103. package/webpack.config.js +0 -79
@@ -1,5 +1,5 @@
1
- import { B as _ } from "./crypto-C6FlKKmp.js";
2
- import { u as C, k as d, U as H, v as y, x as L, A as f, 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-BKmkTzNZ.js";
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 e = o[t];
126
- T[e] = t;
125
+ const n = o[t];
126
+ T[n] = t;
127
127
  }
128
- function G(t, e, n) {
129
- e = e || 4, n = n === void 0 ? !0 : n;
130
- const O = t.length;
131
- if (O === 0) return 0;
132
- if (O > e) throw new TypeError("Script number overflow");
133
- if (n && (t[O - 1] & 127) === 0 && (O <= 1 || (t[O - 2] & 128) === 0))
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 (O === 5) {
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 r = 0;
140
- for (let P = 0; P < O; ++P)
141
- r |= t[P] << 8 * P;
142
- return t[O - 1] & 128 ? -(r & ~(128 << 8 * (O - 1))) : r;
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 e = Math.abs(t);
149
- const n = v(e), O = _.allocUnsafe(n), r = t < 0;
150
- for (let P = 0; P < n; ++P)
151
- O.writeUInt8(e & 255, P), e >>= 8;
152
- return O[n - 1] & 128 ? O.writeUInt8(r ? 128 : 0, n - 1) : r && (O[n - 1] |= 128), O;
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 j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
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: Q } = d, u = _.alloc(1, 0);
158
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: $ } = d, f = _.alloc(1, 0);
159
159
  function A(t) {
160
- let e = 0;
161
- for (; t[e] === 0; ) ++e;
162
- return e === t.length ? u : (t = t.slice(e), t[0] & 128 ? _.concat([u, t], 1 + t.length) : 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
163
  }
164
164
  function S(t) {
165
- t[0] === 0 && (t = t.slice(1));
166
- const e = _.alloc(32, 0), n = Math.max(0, 32 - t.length);
167
- return t.copy(e, n), e;
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 Y(t) {
170
- const e = t.readUInt8(t.length - 1);
171
- if (!l(e))
172
- throw new Error("Invalid hashType " + e);
173
- const n = C(t.slice(0, -1)), O = S(n.r), r = S(n.s);
174
- return { signature: _.concat([O, r], 64), hashType: e };
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 z(t, e) {
177
- if (Q(
176
+ function Q(t, n) {
177
+ if ($(
178
178
  {
179
- signature: y(64),
180
- hashType: H
179
+ signature: H(64),
180
+ hashType: C
181
181
  },
182
- { signature: t, hashType: e }
183
- ), !l(e))
184
- throw new Error("Invalid hashType " + e);
185
- const n = _.allocUnsafe(1);
186
- n.writeUInt8(e, 0);
187
- const O = A(t.slice(0, 32)), r = A(t.slice(32, 64));
188
- return _.concat([L(O, r), n]);
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 $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
190
+ const Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
191
191
  __proto__: null,
192
- decode: Y,
193
- encode: z
192
+ decode: j,
193
+ encode: Q
194
194
  }, Symbol.toStringTag, { value: "Module" })), { typeforce: s } = d, U = o.OP_RESERVED;
195
- function b(t) {
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) || b(t);
199
+ return I(t) || z(t);
200
200
  }
201
201
  function p(t) {
202
- return f(t) && t.every(N);
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 f(t);
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(f, t);
226
- const e = t.reduce((r, P) => E(P) ? P.length === 1 && c(P) !== void 0 ? r + 1 : r + h(P.length) + P.length : r + 1, 0), n = _.allocUnsafe(e);
227
- let O = 0;
228
- if (t.forEach((r) => {
229
- if (E(r)) {
230
- const P = c(r);
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
- n.writeUInt8(P, O), O += 1;
232
+ e.writeUInt8(P, r), r += 1;
233
233
  return;
234
234
  }
235
- O += M(n, r.length, O), r.copy(n, O), O += r.length;
235
+ r += M(e, O.length, r), O.copy(e, r), r += O.length;
236
236
  } else
237
- n.writeUInt8(r, O), O += 1;
238
- }), O !== n.length) throw new Error("Could not decode chunks");
239
- return n;
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 a(t) {
241
+ function l(t) {
242
242
  if (X(t)) return t;
243
243
  s(I, t);
244
- const e = [];
245
- let n = 0;
246
- for (; n < t.length; ) {
247
- const O = t[n];
248
- if (O > o.OP_0 && O <= o.OP_PUSHDATA4) {
249
- const r = V(t, n);
250
- if (r === null || (n += r.size, n + r.number > t.length)) return null;
251
- const P = t.slice(n, n + r.number);
252
- n += r.number;
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 ? e.push(i) : e.push(P);
254
+ i !== void 0 ? n.push(i) : n.push(P);
255
255
  } else
256
- e.push(O), n += 1;
256
+ n.push(r), e += 1;
257
257
  }
258
- return e;
258
+ return n;
259
259
  }
260
260
  function Z(t) {
261
- if (D(t) && (t = a(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((e) => {
264
- if (E(e)) {
265
- const n = c(e);
266
- if (n === void 0) return e.toString("hex");
267
- e = n;
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[e];
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((e) => o[e] !== void 0 ? o[e] : (s(B, e), _.from(e, "hex")))
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 = a(t), s(p, t), t.map((e) => E(e) ? e : e === o.OP_0 ? _.allocUnsafe(0) : R(e - U));
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 l(t) {
284
- const e = t & -129;
285
- return e > 0 && e < 4;
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) || !l(t[t.length - 1]) ? !1 : m(t.slice(0, -1));
288
+ return !_.isBuffer(t) || !a(t[t.length - 1]) ? !1 : m(t.subarray(0, -1));
289
289
  }
290
- const tt = j, et = $, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
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: a,
294
+ decompile: l,
295
295
  fromASM: q,
296
296
  isCanonicalPubKey: x,
297
297
  isCanonicalScriptSignature: k,
298
- isDefinedHashType: l,
298
+ isDefinedHashType: a,
299
299
  isPushOnly: p,
300
300
  number: tt,
301
301
  opcodes: o,
302
- signature: et,
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
- rt as b,
308
+ Ot as b,
309
309
  g as c,
310
- a as d,
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
- et as s,
316
+ nt as s,
317
317
  Z as t
318
318
  };