@btc-vision/bitcoin 6.4.11 → 6.5.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.
@@ -0,0 +1,318 @@
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";
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 e = o[t];
126
+ T[e] = t;
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))
134
+ throw new Error("Non-minimally encoded script number");
135
+ if (O === 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 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;
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 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;
153
+ }
154
+ const j = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
155
+ __proto__: null,
156
+ decode: G,
157
+ encode: R
158
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: Q } = d, u = _.alloc(1, 0);
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);
163
+ }
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;
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 };
175
+ }
176
+ function z(t, e) {
177
+ if (Q(
178
+ {
179
+ signature: y(64),
180
+ hashType: H
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]);
189
+ }
190
+ const $ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
191
+ __proto__: null,
192
+ decode: Y,
193
+ encode: z
194
+ }, Symbol.toStringTag, { value: "Module" })), { typeforce: s } = d, U = o.OP_RESERVED;
195
+ function b(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) || b(t);
200
+ }
201
+ function p(t) {
202
+ return f(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 f(t);
219
+ }
220
+ function E(t) {
221
+ return _.isBuffer(t);
222
+ }
223
+ function g(t) {
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);
231
+ if (P !== void 0) {
232
+ n.writeUInt8(P, O), O += 1;
233
+ return;
234
+ }
235
+ O += M(n, r.length, O), r.copy(n, O), O += r.length;
236
+ } else
237
+ n.writeUInt8(r, O), O += 1;
238
+ }), O !== n.length) throw new Error("Could not decode chunks");
239
+ return n;
240
+ }
241
+ function a(t) {
242
+ if (X(t)) return t;
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;
253
+ const i = c(P);
254
+ i !== void 0 ? e.push(i) : e.push(P);
255
+ } else
256
+ e.push(O), n += 1;
257
+ }
258
+ return e;
259
+ }
260
+ function Z(t) {
261
+ if (D(t) && (t = a(t)), !t)
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;
268
+ }
269
+ return T[e];
270
+ }).join(" ");
271
+ }
272
+ function q(t) {
273
+ return s(w, t), g(
274
+ t.split(" ").map((e) => o[e] !== void 0 ? o[e] : (s(B, e), _.from(e, "hex")))
275
+ );
276
+ }
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));
279
+ }
280
+ function x(t) {
281
+ return F(t);
282
+ }
283
+ function l(t) {
284
+ const e = t & -129;
285
+ return e > 0 && e < 4;
286
+ }
287
+ function k(t) {
288
+ return !_.isBuffer(t) || !l(t[t.length - 1]) ? !1 : m(t.slice(0, -1));
289
+ }
290
+ const tt = j, et = $, rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
291
+ __proto__: null,
292
+ compile: g,
293
+ countNonPushOnlyOPs: W,
294
+ decompile: a,
295
+ fromASM: q,
296
+ isCanonicalPubKey: x,
297
+ isCanonicalScriptSignature: k,
298
+ isDefinedHashType: l,
299
+ isPushOnly: p,
300
+ number: tt,
301
+ opcodes: o,
302
+ signature: et,
303
+ toASM: Z,
304
+ toStack: J
305
+ }, Symbol.toStringTag, { value: "Module" }));
306
+ export {
307
+ x as a,
308
+ rt as b,
309
+ g as c,
310
+ a as d,
311
+ W as e,
312
+ p as f,
313
+ J as g,
314
+ k as i,
315
+ o,
316
+ et as s,
317
+ Z as t
318
+ };