@btc-vision/transaction 1.7.25 → 1.7.26
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/_version.d.ts +1 -1
- package/browser/btc-vision-bitcoin.js +12 -13
- package/browser/index.js +456 -443
- package/browser/noble-curves.js +1045 -1016
- package/browser/noble-hashes.js +918 -728
- package/browser/vendors.js +11418 -15799
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/crypto/crypto-browser.js +9 -16
- package/vite.config.browser.ts +30 -29
- package/browser/bip39.js +0 -204
- package/browser/bitcoin-utils.js +0 -3172
- package/browser/btc-vision-bip32.js +0 -805
- package/browser/btc-vision-logger.js +0 -86
- package/browser/btc-vision-post-quantum.js +0 -542
- package/browser/polyfills.js +0 -4952
- package/browser/scure-base.js +0 -410
- package/webpack.config.js +0 -220
package/browser/scure-base.js
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import { a as ue } from "./bip39.js";
|
|
2
|
-
function A(e) {
|
|
3
|
-
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array";
|
|
4
|
-
}
|
|
5
|
-
function H(e) {
|
|
6
|
-
if (!A(e))
|
|
7
|
-
throw new Error("Uint8Array expected");
|
|
8
|
-
}
|
|
9
|
-
function K(e, r) {
|
|
10
|
-
return Array.isArray(r) ? r.length === 0 ? !0 : e ? r.every((n) => typeof n == "string") : r.every((n) => Number.isSafeInteger(n)) : !1;
|
|
11
|
-
}
|
|
12
|
-
function D(e) {
|
|
13
|
-
if (typeof e != "function")
|
|
14
|
-
throw new Error("function expected");
|
|
15
|
-
return !0;
|
|
16
|
-
}
|
|
17
|
-
function b(e, r) {
|
|
18
|
-
if (typeof r != "string")
|
|
19
|
-
throw new Error(`${e}: string expected`);
|
|
20
|
-
return !0;
|
|
21
|
-
}
|
|
22
|
-
function m(e) {
|
|
23
|
-
if (!Number.isSafeInteger(e))
|
|
24
|
-
throw new Error(`invalid integer: ${e}`);
|
|
25
|
-
}
|
|
26
|
-
function k(e) {
|
|
27
|
-
if (!Array.isArray(e))
|
|
28
|
-
throw new Error("array expected");
|
|
29
|
-
}
|
|
30
|
-
function R(e, r) {
|
|
31
|
-
if (!K(!0, r))
|
|
32
|
-
throw new Error(`${e}: array of strings expected`);
|
|
33
|
-
}
|
|
34
|
-
function M(e, r) {
|
|
35
|
-
if (!K(!1, r))
|
|
36
|
-
throw new Error(`${e}: array of numbers expected`);
|
|
37
|
-
}
|
|
38
|
-
// @__NO_SIDE_EFFECTS__
|
|
39
|
-
function f(...e) {
|
|
40
|
-
const r = (o) => o, n = (o, s) => (i) => o(s(i)), c = e.map((o) => o.encode).reduceRight(n, r), t = e.map((o) => o.decode).reduce(n, r);
|
|
41
|
-
return { encode: c, decode: t };
|
|
42
|
-
}
|
|
43
|
-
// @__NO_SIDE_EFFECTS__
|
|
44
|
-
function u(e) {
|
|
45
|
-
const r = typeof e == "string" ? e.split("") : e, n = r.length;
|
|
46
|
-
R("alphabet", r);
|
|
47
|
-
const c = new Map(r.map((t, o) => [t, o]));
|
|
48
|
-
return {
|
|
49
|
-
encode: (t) => (k(t), t.map((o) => {
|
|
50
|
-
if (!Number.isSafeInteger(o) || o < 0 || o >= n)
|
|
51
|
-
throw new Error(`alphabet.encode: digit index outside alphabet "${o}". Allowed: ${e}`);
|
|
52
|
-
return r[o];
|
|
53
|
-
})),
|
|
54
|
-
decode: (t) => (k(t), t.map((o) => {
|
|
55
|
-
b("alphabet.decode", o);
|
|
56
|
-
const s = c.get(o);
|
|
57
|
-
if (s === void 0)
|
|
58
|
-
throw new Error(`Unknown letter: "${o}". Allowed: ${e}`);
|
|
59
|
-
return s;
|
|
60
|
-
}))
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
// @__NO_SIDE_EFFECTS__
|
|
64
|
-
function l(e = "") {
|
|
65
|
-
return b("join", e), {
|
|
66
|
-
encode: (r) => (R("join.decode", r), r.join(e)),
|
|
67
|
-
decode: (r) => (b("join.decode", r), r.split(e))
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// @__NO_SIDE_EFFECTS__
|
|
71
|
-
function T(e, r = "=") {
|
|
72
|
-
return m(e), b("padding", r), {
|
|
73
|
-
encode(n) {
|
|
74
|
-
for (R("padding.encode", n); n.length * e % 8; )
|
|
75
|
-
n.push(r);
|
|
76
|
-
return n;
|
|
77
|
-
},
|
|
78
|
-
decode(n) {
|
|
79
|
-
R("padding.decode", n);
|
|
80
|
-
let c = n.length;
|
|
81
|
-
if (c * e % 8)
|
|
82
|
-
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
83
|
-
for (; c > 0 && n[c - 1] === r; c--)
|
|
84
|
-
if ((c - 1) * e % 8 === 0)
|
|
85
|
-
throw new Error("padding: invalid, string has too much padding");
|
|
86
|
-
return n.slice(0, c);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
// @__NO_SIDE_EFFECTS__
|
|
91
|
-
function V(e) {
|
|
92
|
-
return D(e), { encode: (r) => r, decode: (r) => e(r) };
|
|
93
|
-
}
|
|
94
|
-
function O(e, r, n) {
|
|
95
|
-
if (r < 2)
|
|
96
|
-
throw new Error(`convertRadix: invalid from=${r}, base cannot be less than 2`);
|
|
97
|
-
if (n < 2)
|
|
98
|
-
throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);
|
|
99
|
-
if (k(e), !e.length)
|
|
100
|
-
return [];
|
|
101
|
-
let c = 0;
|
|
102
|
-
const t = [], o = Array.from(e, (i) => {
|
|
103
|
-
if (m(i), i < 0 || i >= r)
|
|
104
|
-
throw new Error(`invalid integer: ${i}`);
|
|
105
|
-
return i;
|
|
106
|
-
}), s = o.length;
|
|
107
|
-
for (; ; ) {
|
|
108
|
-
let i = 0, g = !0;
|
|
109
|
-
for (let p = c; p < s; p++) {
|
|
110
|
-
const x = o[p], d = r * i, a = d + x;
|
|
111
|
-
if (!Number.isSafeInteger(a) || d / r !== i || a - x !== d)
|
|
112
|
-
throw new Error("convertRadix: carry overflow");
|
|
113
|
-
const y = a / n;
|
|
114
|
-
i = a % n;
|
|
115
|
-
const h = Math.floor(y);
|
|
116
|
-
if (o[p] = h, !Number.isSafeInteger(h) || h * n + i !== a)
|
|
117
|
-
throw new Error("convertRadix: carry overflow");
|
|
118
|
-
if (g)
|
|
119
|
-
h ? g = !1 : c = p;
|
|
120
|
-
else continue;
|
|
121
|
-
}
|
|
122
|
-
if (t.push(i), g)
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
for (let i = 0; i < e.length - 1 && e[i] === 0; i++)
|
|
126
|
-
t.push(0);
|
|
127
|
-
return t.reverse();
|
|
128
|
-
}
|
|
129
|
-
const J = (e, r) => r === 0 ? e : J(r, e % r), S = /* @__NO_SIDE_EFFECTS__ */ (e, r) => e + (r - J(e, r)), C = /* @__PURE__ */ (() => {
|
|
130
|
-
let e = [];
|
|
131
|
-
for (let r = 0; r < 40; r++)
|
|
132
|
-
e.push(2 ** r);
|
|
133
|
-
return e;
|
|
134
|
-
})();
|
|
135
|
-
function N(e, r, n, c) {
|
|
136
|
-
if (k(e), r <= 0 || r > 32)
|
|
137
|
-
throw new Error(`convertRadix2: wrong from=${r}`);
|
|
138
|
-
if (n <= 0 || n > 32)
|
|
139
|
-
throw new Error(`convertRadix2: wrong to=${n}`);
|
|
140
|
-
if (/* @__PURE__ */ S(r, n) > 32)
|
|
141
|
-
throw new Error(`convertRadix2: carry overflow from=${r} to=${n} carryBits=${/* @__PURE__ */ S(r, n)}`);
|
|
142
|
-
let t = 0, o = 0;
|
|
143
|
-
const s = C[r], i = C[n] - 1, g = [];
|
|
144
|
-
for (const p of e) {
|
|
145
|
-
if (m(p), p >= s)
|
|
146
|
-
throw new Error(`convertRadix2: invalid data word=${p} from=${r}`);
|
|
147
|
-
if (t = t << r | p, o + r > 32)
|
|
148
|
-
throw new Error(`convertRadix2: carry overflow pos=${o} from=${r}`);
|
|
149
|
-
for (o += r; o >= n; o -= n)
|
|
150
|
-
g.push((t >> o - n & i) >>> 0);
|
|
151
|
-
const x = C[o];
|
|
152
|
-
if (x === void 0)
|
|
153
|
-
throw new Error("invalid carry");
|
|
154
|
-
t &= x - 1;
|
|
155
|
-
}
|
|
156
|
-
if (t = t << n - o & i, !c && o >= r)
|
|
157
|
-
throw new Error("Excess padding");
|
|
158
|
-
if (!c && t > 0)
|
|
159
|
-
throw new Error(`Non-zero padding: ${t}`);
|
|
160
|
-
return c && o > 0 && g.push(t >>> 0), g;
|
|
161
|
-
}
|
|
162
|
-
// @__NO_SIDE_EFFECTS__
|
|
163
|
-
function Q(e) {
|
|
164
|
-
m(e);
|
|
165
|
-
const r = 2 ** 8;
|
|
166
|
-
return {
|
|
167
|
-
encode: (n) => {
|
|
168
|
-
if (!A(n))
|
|
169
|
-
throw new Error("radix.encode input should be Uint8Array");
|
|
170
|
-
return O(Array.from(n), r, e);
|
|
171
|
-
},
|
|
172
|
-
decode: (n) => (M("radix.decode", n), Uint8Array.from(O(n, e, r)))
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
// @__NO_SIDE_EFFECTS__
|
|
176
|
-
function w(e, r = !1) {
|
|
177
|
-
if (m(e), e <= 0 || e > 32)
|
|
178
|
-
throw new Error("radix2: bits should be in (0..32]");
|
|
179
|
-
if (/* @__PURE__ */ S(8, e) > 32 || /* @__PURE__ */ S(e, 8) > 32)
|
|
180
|
-
throw new Error("radix2: carry overflow");
|
|
181
|
-
return {
|
|
182
|
-
encode: (n) => {
|
|
183
|
-
if (!A(n))
|
|
184
|
-
throw new Error("radix2.encode input should be Uint8Array");
|
|
185
|
-
return N(Array.from(n), 8, e, !r);
|
|
186
|
-
},
|
|
187
|
-
decode: (n) => (M("radix2.decode", n), Uint8Array.from(N(n, e, 8, r)))
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
function F(e) {
|
|
191
|
-
return D(e), function(...r) {
|
|
192
|
-
try {
|
|
193
|
-
return e.apply(null, r);
|
|
194
|
-
} catch {
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function Z(e, r) {
|
|
199
|
-
return m(e), D(r), {
|
|
200
|
-
encode(n) {
|
|
201
|
-
if (!A(n))
|
|
202
|
-
throw new Error("checksum.encode: input should be Uint8Array");
|
|
203
|
-
const c = r(n).slice(0, e), t = new Uint8Array(n.length + e);
|
|
204
|
-
return t.set(n), t.set(c, n.length), t;
|
|
205
|
-
},
|
|
206
|
-
decode(n) {
|
|
207
|
-
if (!A(n))
|
|
208
|
-
throw new Error("checksum.decode: input should be Uint8Array");
|
|
209
|
-
const c = n.slice(0, -e), t = n.slice(-e), o = r(c).slice(0, e);
|
|
210
|
-
for (let s = 0; s < e; s++)
|
|
211
|
-
if (o[s] !== t[s])
|
|
212
|
-
throw new Error("Invalid checksum");
|
|
213
|
-
return c;
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
const le = {
|
|
218
|
-
alphabet: u,
|
|
219
|
-
chain: f,
|
|
220
|
-
checksum: Z,
|
|
221
|
-
convertRadix: O,
|
|
222
|
-
convertRadix2: N,
|
|
223
|
-
radix: Q,
|
|
224
|
-
radix2: w,
|
|
225
|
-
join: l,
|
|
226
|
-
padding: T
|
|
227
|
-
}, X = /* @__PURE__ */ f(/* @__PURE__ */ w(4), /* @__PURE__ */ u("0123456789ABCDEF"), /* @__PURE__ */ l("")), Y = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), /* @__PURE__ */ T(5), /* @__PURE__ */ l("")), he = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), /* @__PURE__ */ l("")), we = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("0123456789ABCDEFGHIJKLMNOPQRSTUV"), /* @__PURE__ */ T(5), /* @__PURE__ */ l("")), pe = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("0123456789ABCDEFGHIJKLMNOPQRSTUV"), /* @__PURE__ */ l("")), ye = /* @__PURE__ */ f(/* @__PURE__ */ w(5), /* @__PURE__ */ u("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), /* @__PURE__ */ l(""), /* @__PURE__ */ V((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1"))), q = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", ee = (e, r) => {
|
|
228
|
-
b("base64", e);
|
|
229
|
-
const n = r ? /^[A-Za-z0-9=_-]+$/ : /^[A-Za-z0-9=+/]+$/, c = r ? "base64url" : "base64";
|
|
230
|
-
if (e.length > 0 && !n.test(e))
|
|
231
|
-
throw new Error("invalid base64");
|
|
232
|
-
return Uint8Array.fromBase64(e, { alphabet: c, lastChunkHandling: "strict" });
|
|
233
|
-
}, re = q ? {
|
|
234
|
-
encode(e) {
|
|
235
|
-
return H(e), e.toBase64();
|
|
236
|
-
},
|
|
237
|
-
decode(e) {
|
|
238
|
-
return ee(e, !1);
|
|
239
|
-
}
|
|
240
|
-
} : /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ T(6), /* @__PURE__ */ l("")), ge = /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ l("")), ne = q ? {
|
|
241
|
-
encode(e) {
|
|
242
|
-
return H(e), e.toBase64({ alphabet: "base64url" });
|
|
243
|
-
},
|
|
244
|
-
decode(e) {
|
|
245
|
-
return ee(e, !0);
|
|
246
|
-
}
|
|
247
|
-
} : /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), /* @__PURE__ */ T(6), /* @__PURE__ */ l("")), be = /* @__PURE__ */ f(/* @__PURE__ */ w(6), /* @__PURE__ */ u("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), /* @__PURE__ */ l("")), P = /* @__NO_SIDE_EFFECTS__ */ (e) => /* @__PURE__ */ f(/* @__PURE__ */ Q(58), /* @__PURE__ */ u(e), /* @__PURE__ */ l("")), U = /* @__PURE__ */ P("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"), xe = /* @__PURE__ */ P("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"), Ee = /* @__PURE__ */ P("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz"), G = [0, 2, 3, 5, 6, 7, 9, 10, 11], oe = {
|
|
248
|
-
encode(e) {
|
|
249
|
-
let r = "";
|
|
250
|
-
for (let n = 0; n < e.length; n += 8) {
|
|
251
|
-
const c = e.subarray(n, n + 8);
|
|
252
|
-
r += U.encode(c).padStart(G[c.length], "1");
|
|
253
|
-
}
|
|
254
|
-
return r;
|
|
255
|
-
},
|
|
256
|
-
decode(e) {
|
|
257
|
-
let r = [];
|
|
258
|
-
for (let n = 0; n < e.length; n += 11) {
|
|
259
|
-
const c = e.slice(n, n + 11), t = G.indexOf(c.length), o = U.decode(c);
|
|
260
|
-
for (let s = 0; s < o.length - t; s++)
|
|
261
|
-
if (o[s] !== 0)
|
|
262
|
-
throw new Error("base58xmr: wrong padding");
|
|
263
|
-
r = r.concat(Array.from(o.slice(o.length - t)));
|
|
264
|
-
}
|
|
265
|
-
return Uint8Array.from(r);
|
|
266
|
-
}
|
|
267
|
-
}, te = (e) => /* @__PURE__ */ f(Z(4, (r) => e(e(r))), U), Ae = te, I = /* @__PURE__ */ f(/* @__PURE__ */ u("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ l("")), _ = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
268
|
-
function B(e) {
|
|
269
|
-
const r = e >> 25;
|
|
270
|
-
let n = (e & 33554431) << 5;
|
|
271
|
-
for (let c = 0; c < _.length; c++)
|
|
272
|
-
(r >> c & 1) === 1 && (n ^= _[c]);
|
|
273
|
-
return n;
|
|
274
|
-
}
|
|
275
|
-
function z(e, r, n = 1) {
|
|
276
|
-
const c = e.length;
|
|
277
|
-
let t = 1;
|
|
278
|
-
for (let o = 0; o < c; o++) {
|
|
279
|
-
const s = e.charCodeAt(o);
|
|
280
|
-
if (s < 33 || s > 126)
|
|
281
|
-
throw new Error(`Invalid prefix (${e})`);
|
|
282
|
-
t = B(t) ^ s >> 5;
|
|
283
|
-
}
|
|
284
|
-
t = B(t);
|
|
285
|
-
for (let o = 0; o < c; o++)
|
|
286
|
-
t = B(t) ^ e.charCodeAt(o) & 31;
|
|
287
|
-
for (let o of r)
|
|
288
|
-
t = B(t) ^ o;
|
|
289
|
-
for (let o = 0; o < 6; o++)
|
|
290
|
-
t = B(t);
|
|
291
|
-
return t ^= n, I.encode(N([t % C[30]], 30, 5, !1));
|
|
292
|
-
}
|
|
293
|
-
// @__NO_SIDE_EFFECTS__
|
|
294
|
-
function ce(e) {
|
|
295
|
-
const r = e === "bech32" ? 1 : 734539939, n = /* @__PURE__ */ w(5), c = n.decode, t = n.encode, o = F(c);
|
|
296
|
-
function s(d, a, y = 90) {
|
|
297
|
-
b("bech32.encode prefix", d), A(a) && (a = Array.from(a)), M("bech32.encode", a);
|
|
298
|
-
const h = d.length;
|
|
299
|
-
if (h === 0)
|
|
300
|
-
throw new TypeError(`Invalid prefix length ${h}`);
|
|
301
|
-
const E = h + 7 + a.length;
|
|
302
|
-
if (y !== !1 && E > y)
|
|
303
|
-
throw new TypeError(`Length ${E} exceeds limit ${y}`);
|
|
304
|
-
const v = d.toLowerCase(), $ = z(v, a, r);
|
|
305
|
-
return `${v}1${I.encode(a)}${$}`;
|
|
306
|
-
}
|
|
307
|
-
function i(d, a = 90) {
|
|
308
|
-
b("bech32.decode input", d);
|
|
309
|
-
const y = d.length;
|
|
310
|
-
if (y < 8 || a !== !1 && y > a)
|
|
311
|
-
throw new TypeError(`invalid string length: ${y} (${d}). Expected (8..${a})`);
|
|
312
|
-
const h = d.toLowerCase();
|
|
313
|
-
if (d !== h && d !== d.toUpperCase())
|
|
314
|
-
throw new Error("String must be lowercase or uppercase");
|
|
315
|
-
const E = h.lastIndexOf("1");
|
|
316
|
-
if (E === 0 || E === -1)
|
|
317
|
-
throw new Error('Letter "1" must be present between prefix and data only');
|
|
318
|
-
const v = h.slice(0, E), $ = h.slice(E + 1);
|
|
319
|
-
if ($.length < 6)
|
|
320
|
-
throw new Error("Data must be at least 6 characters long");
|
|
321
|
-
const j = I.decode($).slice(0, -6), W = z(v, j, r);
|
|
322
|
-
if (!$.endsWith(W))
|
|
323
|
-
throw new Error(`Invalid checksum in ${d}: expected "${W}"`);
|
|
324
|
-
return { prefix: v, words: j };
|
|
325
|
-
}
|
|
326
|
-
const g = F(i);
|
|
327
|
-
function p(d) {
|
|
328
|
-
const { prefix: a, words: y } = i(d, !1);
|
|
329
|
-
return { prefix: a, words: y, bytes: c(y) };
|
|
330
|
-
}
|
|
331
|
-
function x(d, a) {
|
|
332
|
-
return s(d, t(a));
|
|
333
|
-
}
|
|
334
|
-
return {
|
|
335
|
-
encode: s,
|
|
336
|
-
decode: i,
|
|
337
|
-
encodeFromBytes: x,
|
|
338
|
-
decodeToBytes: p,
|
|
339
|
-
decodeUnsafe: g,
|
|
340
|
-
fromWords: c,
|
|
341
|
-
fromWordsUnsafe: o,
|
|
342
|
-
toWords: t
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
const me = /* @__PURE__ */ ce("bech32"), ve = /* @__PURE__ */ ce("bech32m"), se = {
|
|
346
|
-
encode: (e) => new TextDecoder().decode(e),
|
|
347
|
-
decode: (e) => new TextEncoder().encode(e)
|
|
348
|
-
}, $e = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Be = {
|
|
349
|
-
encode(e) {
|
|
350
|
-
return H(e), e.toHex();
|
|
351
|
-
},
|
|
352
|
-
decode(e) {
|
|
353
|
-
return b("hex", e), Uint8Array.fromHex(e);
|
|
354
|
-
}
|
|
355
|
-
}, ie = $e ? Be : /* @__PURE__ */ f(/* @__PURE__ */ w(4), /* @__PURE__ */ u("0123456789abcdef"), /* @__PURE__ */ l(""), /* @__PURE__ */ V((e) => {
|
|
356
|
-
if (typeof e != "string" || e.length % 2 !== 0)
|
|
357
|
-
throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);
|
|
358
|
-
return e.toLowerCase();
|
|
359
|
-
})), L = {
|
|
360
|
-
utf8: se,
|
|
361
|
-
hex: ie,
|
|
362
|
-
base16: X,
|
|
363
|
-
base32: Y,
|
|
364
|
-
base64: re,
|
|
365
|
-
base64url: ne,
|
|
366
|
-
base58: U,
|
|
367
|
-
base58xmr: oe
|
|
368
|
-
}, ae = "Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr", de = (e, r) => {
|
|
369
|
-
if (typeof e != "string" || !L.hasOwnProperty(e))
|
|
370
|
-
throw new TypeError(ae);
|
|
371
|
-
if (!A(r))
|
|
372
|
-
throw new TypeError("bytesToString() expects Uint8Array");
|
|
373
|
-
return L[e].encode(r);
|
|
374
|
-
}, Ue = de, fe = (e, r) => {
|
|
375
|
-
if (!L.hasOwnProperty(e))
|
|
376
|
-
throw new TypeError(ae);
|
|
377
|
-
if (typeof r != "string")
|
|
378
|
-
throw new TypeError("stringToBytes() expects string");
|
|
379
|
-
return L[e].decode(r);
|
|
380
|
-
}, Te = fe, Ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
381
|
-
__proto__: null,
|
|
382
|
-
base16: X,
|
|
383
|
-
base32: Y,
|
|
384
|
-
base32crockford: ye,
|
|
385
|
-
base32hex: we,
|
|
386
|
-
base32hexnopad: pe,
|
|
387
|
-
base32nopad: he,
|
|
388
|
-
base58: U,
|
|
389
|
-
base58check: Ae,
|
|
390
|
-
base58flickr: xe,
|
|
391
|
-
base58xmr: oe,
|
|
392
|
-
base58xrp: Ee,
|
|
393
|
-
base64: re,
|
|
394
|
-
base64nopad: ge,
|
|
395
|
-
base64url: ne,
|
|
396
|
-
base64urlnopad: be,
|
|
397
|
-
bech32: me,
|
|
398
|
-
bech32m: ve,
|
|
399
|
-
bytes: Te,
|
|
400
|
-
bytesToString: de,
|
|
401
|
-
createBase58check: te,
|
|
402
|
-
hex: ie,
|
|
403
|
-
str: Ue,
|
|
404
|
-
stringToBytes: fe,
|
|
405
|
-
utf8: se,
|
|
406
|
-
utils: le
|
|
407
|
-
}, Symbol.toStringTag, { value: "Module" })), Re = /* @__PURE__ */ ue(Ce);
|
|
408
|
-
export {
|
|
409
|
-
Re as r
|
|
410
|
-
};
|
package/webpack.config.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import webpack from 'webpack';
|
|
2
|
-
import TerserPlugin from 'terser-webpack-plugin';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
mode: 'production',
|
|
6
|
-
target: 'web',
|
|
7
|
-
entry: {
|
|
8
|
-
index: {
|
|
9
|
-
import: './src/index.ts',
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
watch: false,
|
|
13
|
-
output: {
|
|
14
|
-
filename: '[name].js',
|
|
15
|
-
chunkFilename: 'chunks/[name].js',
|
|
16
|
-
path: import.meta.dirname + '/browser',
|
|
17
|
-
libraryTarget: 'module',
|
|
18
|
-
chunkFormat: 'module',
|
|
19
|
-
chunkLoading: 'import',
|
|
20
|
-
},
|
|
21
|
-
node: {
|
|
22
|
-
__dirname: false,
|
|
23
|
-
},
|
|
24
|
-
experiments: {
|
|
25
|
-
outputModule: true,
|
|
26
|
-
asyncWebAssembly: false,
|
|
27
|
-
syncWebAssembly: true,
|
|
28
|
-
},
|
|
29
|
-
resolve: {
|
|
30
|
-
extensionAlias: {
|
|
31
|
-
'.js': ['.js', '.ts'],
|
|
32
|
-
},
|
|
33
|
-
modules: ['.', 'node_modules'],
|
|
34
|
-
extensions: ['.*', '.js', '.jsx', '.tsx', '.ts', '.wasm'],
|
|
35
|
-
alias: {
|
|
36
|
-
// Dedupe noble/curves to single version
|
|
37
|
-
'@noble/curves': import.meta.dirname + '/node_modules/@noble/curves',
|
|
38
|
-
},
|
|
39
|
-
fallback: {
|
|
40
|
-
buffer: import.meta.resolve('buffer/'),
|
|
41
|
-
assert: import.meta.resolve('assert/'),
|
|
42
|
-
crypto: import.meta.resolve('./src/crypto/crypto-browser.js'),
|
|
43
|
-
http: import.meta.resolve('stream-http/'),
|
|
44
|
-
https: import.meta.resolve('https-browserify/'),
|
|
45
|
-
os: import.meta.resolve('os-browserify/browser/'),
|
|
46
|
-
stream: import.meta.resolve('stream-browserify'),
|
|
47
|
-
process: import.meta.resolve('process/browser'),
|
|
48
|
-
zlib: import.meta.resolve('browserify-zlib'),
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
cache: false,
|
|
52
|
-
module: {
|
|
53
|
-
rules: [
|
|
54
|
-
{
|
|
55
|
-
test: /\.(js|jsx|tsx|ts)$/,
|
|
56
|
-
exclude: [/node_modules/, /test/, /__tests__/],
|
|
57
|
-
resolve: {
|
|
58
|
-
fullySpecified: false,
|
|
59
|
-
},
|
|
60
|
-
use: [
|
|
61
|
-
{
|
|
62
|
-
loader: 'babel-loader',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
loader: 'ts-loader',
|
|
66
|
-
options: {
|
|
67
|
-
configFile: 'tsconfig.webpack.json',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
},
|
|
74
|
-
optimization: {
|
|
75
|
-
usedExports: true,
|
|
76
|
-
minimize: true,
|
|
77
|
-
minimizer: [
|
|
78
|
-
new TerserPlugin({
|
|
79
|
-
terserOptions: {
|
|
80
|
-
compress: {
|
|
81
|
-
drop_console: false,
|
|
82
|
-
drop_debugger: true,
|
|
83
|
-
passes: 3,
|
|
84
|
-
pure_funcs: ['console.debug'],
|
|
85
|
-
dead_code: true,
|
|
86
|
-
unused: true,
|
|
87
|
-
},
|
|
88
|
-
mangle: {
|
|
89
|
-
safari10: true,
|
|
90
|
-
},
|
|
91
|
-
format: {
|
|
92
|
-
comments: false,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
extractComments: false,
|
|
96
|
-
}),
|
|
97
|
-
],
|
|
98
|
-
concatenateModules: true,
|
|
99
|
-
sideEffects: true,
|
|
100
|
-
providedExports: true,
|
|
101
|
-
innerGraph: true,
|
|
102
|
-
splitChunks: {
|
|
103
|
-
chunks: 'all',
|
|
104
|
-
minSize: 1000,
|
|
105
|
-
maxInitialRequests: Infinity,
|
|
106
|
-
cacheGroups: {
|
|
107
|
-
// Noble cryptographic libraries (curves + hashes)
|
|
108
|
-
nobleCurves: {
|
|
109
|
-
test: /[\\/]node_modules[\\/]@noble[\\/]curves[\\/]/,
|
|
110
|
-
name: 'noble-curves',
|
|
111
|
-
priority: 50,
|
|
112
|
-
reuseExistingChunk: true,
|
|
113
|
-
},
|
|
114
|
-
nobleHashes: {
|
|
115
|
-
test: /[\\/]node_modules[\\/]@noble[\\/]hashes[\\/]/,
|
|
116
|
-
name: 'noble-hashes',
|
|
117
|
-
priority: 49,
|
|
118
|
-
reuseExistingChunk: true,
|
|
119
|
-
},
|
|
120
|
-
nobleSecp: {
|
|
121
|
-
test: /[\\/]node_modules[\\/]@noble[\\/]secp256k1[\\/]/,
|
|
122
|
-
name: 'noble-secp256k1',
|
|
123
|
-
priority: 48,
|
|
124
|
-
reuseExistingChunk: true,
|
|
125
|
-
},
|
|
126
|
-
// Separate @btc-vision packages
|
|
127
|
-
btcBitcoin: {
|
|
128
|
-
test: /[\\/]node_modules[\\/]@btc-vision[\\/]bitcoin[\\/]/,
|
|
129
|
-
name: 'btc-vision-bitcoin',
|
|
130
|
-
priority: 45,
|
|
131
|
-
reuseExistingChunk: true,
|
|
132
|
-
},
|
|
133
|
-
btcBip32: {
|
|
134
|
-
test: /[\\/]node_modules[\\/]@btc-vision[\\/]bip32[\\/]/,
|
|
135
|
-
name: 'btc-vision-bip32',
|
|
136
|
-
priority: 44,
|
|
137
|
-
reuseExistingChunk: true,
|
|
138
|
-
},
|
|
139
|
-
btcPostQuantum: {
|
|
140
|
-
test: /[\\/]node_modules[\\/]@btc-vision[\\/]post-quantum[\\/]/,
|
|
141
|
-
name: 'btc-vision-post-quantum',
|
|
142
|
-
priority: 43,
|
|
143
|
-
reuseExistingChunk: true,
|
|
144
|
-
},
|
|
145
|
-
btcLogger: {
|
|
146
|
-
test: /[\\/]node_modules[\\/]@btc-vision[\\/]logger[\\/]/,
|
|
147
|
-
name: 'btc-vision-logger',
|
|
148
|
-
priority: 42,
|
|
149
|
-
reuseExistingChunk: true,
|
|
150
|
-
},
|
|
151
|
-
// Valibot validation library
|
|
152
|
-
valibot: {
|
|
153
|
-
test: /[\\/]node_modules[\\/]valibot[\\/]/,
|
|
154
|
-
name: 'valibot',
|
|
155
|
-
priority: 40,
|
|
156
|
-
reuseExistingChunk: true,
|
|
157
|
-
},
|
|
158
|
-
// Pako compression
|
|
159
|
-
pako: {
|
|
160
|
-
test: /[\\/]node_modules[\\/]pako[\\/]/,
|
|
161
|
-
name: 'pako',
|
|
162
|
-
priority: 39,
|
|
163
|
-
reuseExistingChunk: true,
|
|
164
|
-
},
|
|
165
|
-
// BIP39 mnemonic (wordlists are stripped via IgnorePlugin)
|
|
166
|
-
bip39: {
|
|
167
|
-
test: /[\\/]node_modules[\\/]bip39[\\/]/,
|
|
168
|
-
name: 'bip39',
|
|
169
|
-
priority: 38,
|
|
170
|
-
reuseExistingChunk: true,
|
|
171
|
-
},
|
|
172
|
-
// Bitcoin utilities
|
|
173
|
-
bitcoin: {
|
|
174
|
-
test: /[\\/]node_modules[\\/](bip174|bech32|ecpair|@bitcoinerlab)[\\/]/,
|
|
175
|
-
name: 'bitcoin-utils',
|
|
176
|
-
priority: 35,
|
|
177
|
-
reuseExistingChunk: true,
|
|
178
|
-
},
|
|
179
|
-
// Scure base encoding
|
|
180
|
-
scure: {
|
|
181
|
-
test: /[\\/]node_modules[\\/]@scure[\\/]/,
|
|
182
|
-
name: 'scure-base',
|
|
183
|
-
priority: 34,
|
|
184
|
-
reuseExistingChunk: true,
|
|
185
|
-
},
|
|
186
|
-
// Buffer and stream polyfills
|
|
187
|
-
polyfills: {
|
|
188
|
-
test: /[\\/]node_modules[\\/](buffer|stream-browserify|browserify-zlib|process|assert|os-browserify|https-browserify|stream-http)[\\/]/,
|
|
189
|
-
name: 'polyfills',
|
|
190
|
-
priority: 25,
|
|
191
|
-
reuseExistingChunk: true,
|
|
192
|
-
},
|
|
193
|
-
// Remaining vendor code
|
|
194
|
-
vendors: {
|
|
195
|
-
test: /[\\/]node_modules[\\/]/,
|
|
196
|
-
name: 'vendors',
|
|
197
|
-
priority: 10,
|
|
198
|
-
reuseExistingChunk: true,
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
plugins: [
|
|
204
|
-
new webpack.ProvidePlugin({
|
|
205
|
-
Buffer: ['buffer', 'Buffer'],
|
|
206
|
-
process: 'process/browser',
|
|
207
|
-
stream: 'stream-browserify',
|
|
208
|
-
zlib: 'browserify-zlib',
|
|
209
|
-
bitcoin: '@btc-vision/bitcoin',
|
|
210
|
-
}),
|
|
211
|
-
// Strip unused bip39 wordlists (keep only English) - saves ~150KB
|
|
212
|
-
new webpack.IgnorePlugin({
|
|
213
|
-
resourceRegExp: /^\.\/wordlists\/(?!english)/,
|
|
214
|
-
contextRegExp: /bip39/,
|
|
215
|
-
}),
|
|
216
|
-
],
|
|
217
|
-
// Externals config for dependent packages to avoid duplication
|
|
218
|
-
// Other packages can set these externals and import chunks from @btc-vision/transaction
|
|
219
|
-
externalsType: 'module',
|
|
220
|
-
};
|