@btc-vision/transaction 1.8.7-beta.0 → 1.8.8
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/btc-vision-bitcoin.js +832 -828
- package/browser/index.js +1074 -947
- package/browser/noble-curves.js +1183 -2156
- package/browser/noble-hashes.js +88 -88
- package/browser/rolldown-runtime.js +26 -19
- package/browser/src/epoch/validator/EpochValidator.d.ts +28 -6
- package/browser/src/transaction/builders/TransactionBuilder.d.ts +1 -0
- package/browser/src/transaction/offline/OfflineTransactionManager.d.ts +50 -0
- package/browser/src/transaction/offline/interfaces/ISerializableState.d.ts +10 -2
- package/browser/vendors.js +3267 -3229
- package/build/epoch/validator/EpochValidator.d.ts +28 -6
- package/build/epoch/validator/EpochValidator.js +44 -10
- package/build/transaction/TransactionFactory.js +1 -1
- package/build/transaction/builders/FundingTransaction.js +17 -13
- package/build/transaction/builders/TransactionBuilder.d.ts +1 -0
- package/build/transaction/builders/TransactionBuilder.js +32 -7
- package/build/transaction/offline/OfflineTransactionManager.d.ts +50 -0
- package/build/transaction/offline/OfflineTransactionManager.js +142 -1
- package/build/transaction/offline/TransactionSerializer.js +9 -0
- package/build/transaction/offline/interfaces/ISerializableState.d.ts +10 -2
- package/build/transaction/offline/interfaces/ISerializableState.js +3 -2
- package/build/transaction/shared/TweakedTransaction.js +27 -5
- package/package.json +1 -1
- package/src/epoch/validator/EpochValidator.ts +67 -6
- package/src/transaction/TransactionFactory.ts +1 -1
- package/src/transaction/builders/FundingTransaction.ts +21 -16
- package/src/transaction/builders/TransactionBuilder.ts +46 -10
- package/src/transaction/offline/OfflineTransactionManager.ts +191 -1
- package/src/transaction/offline/TransactionSerializer.ts +11 -0
- package/src/transaction/offline/interfaces/ISerializableState.ts +10 -2
- package/src/transaction/shared/TweakedTransaction.ts +33 -5
- package/test/add-refund-output.test.ts +96 -11
- package/test/csv-multisig-offline-edges.test.ts +293 -0
- package/test/csv-multisig-offline.test.ts +202 -0
- package/test/transaction-builders.test.ts +69 -3
- package/tsconfig.build.tsbuildinfo +1 -1
package/browser/index.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as
|
|
3
|
-
import { A as
|
|
4
|
-
import { D as
|
|
5
|
-
var
|
|
6
|
-
typeof
|
|
7
|
-
typeof
|
|
8
|
-
var
|
|
9
|
-
function
|
|
10
|
-
return new Uint8Array(
|
|
1
|
+
import { a as ae, r as Ai } from "./rolldown-runtime.js";
|
|
2
|
+
import { a as bi, c as ce, d as xt, i as Le, l as ot, n as Ei, o as Ii, r as Pi, s as vt, t as vi, u as Re } from "./vendors.js";
|
|
3
|
+
import { A as Oi, B as D, C as E, D as _i, E as b, F as ht, I as Ie, L as qt, M as Ui, N as Bi, O as ki, P as Li, R as f, S as Rt, T as Ce, V as d, _ as Pe, a as Ke, b as y, c as Ri, d as C, f as Ci, g as Gt, h as Ki, i as H, j as Xt, k as g, l as Di, m as Mi, n as U, o as Ni, p as xi, r as Fi, s as it, t as N, u as Wi, v as Hi, w as L, x as Vi, y as O, z as zi } from "./btc-vision-bitcoin.js";
|
|
4
|
+
import { D as qi, T as Ft, a as zt, i as Gi, n as Xi, r as $i, t as Yi, w as ue } from "./noble-curves.js";
|
|
5
|
+
var Ct = Symbol;
|
|
6
|
+
typeof Ct.dispose != "symbol" && (Ct.dispose = /* @__PURE__ */ Symbol.for("Symbol.dispose"));
|
|
7
|
+
typeof Ct.asyncDispose != "symbol" && (Ct.asyncDispose = /* @__PURE__ */ Symbol.for("Symbol.asyncDispose"));
|
|
8
|
+
var ji = "1.8.7";
|
|
9
|
+
function Qi(e, t = {}) {
|
|
10
|
+
return new Uint8Array(xt.gzip(e, { level: t.level || 6 }));
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return new Uint8Array(
|
|
12
|
+
function Zi(e) {
|
|
13
|
+
return new Uint8Array(xt.ungzip(e));
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return new Uint8Array(
|
|
15
|
+
function Ji(e, t = {}) {
|
|
16
|
+
return new Uint8Array(xt.deflate(e, { level: t.level || 6 }));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
return new Uint8Array(
|
|
18
|
+
function tr(e) {
|
|
19
|
+
return new Uint8Array(xt.inflate(e));
|
|
20
20
|
}
|
|
21
|
-
var
|
|
22
|
-
gzipSync:
|
|
23
|
-
gunzipSync:
|
|
24
|
-
deflateSync:
|
|
25
|
-
inflateSync:
|
|
26
|
-
}, Z = class
|
|
21
|
+
var ve = {
|
|
22
|
+
gzipSync: Qi,
|
|
23
|
+
gunzipSync: Zi,
|
|
24
|
+
deflateSync: Ji,
|
|
25
|
+
inflateSync: tr
|
|
26
|
+
}, Z = class $t {
|
|
27
27
|
static zlibOptions = {
|
|
28
28
|
level: 9,
|
|
29
29
|
maxOutputLength: 1024 * 1024 * 16
|
|
30
30
|
};
|
|
31
31
|
static compress(t) {
|
|
32
|
-
return new Uint8Array(
|
|
32
|
+
return new Uint8Array(ve.gzipSync(t, $t.zlibOptions));
|
|
33
33
|
}
|
|
34
34
|
static decompress(t) {
|
|
35
|
-
return new Uint8Array(
|
|
35
|
+
return new Uint8Array(ve.gunzipSync(t, $t.zlibOptions));
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
|
|
39
|
-
var K =
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
if (!
|
|
46
|
-
var
|
|
38
|
+
vt();
|
|
39
|
+
var K = Ii(), er = K;
|
|
40
|
+
ki(er);
|
|
41
|
+
var v = /* @__PURE__ */ ae(bi(), 1);
|
|
42
|
+
vt();
|
|
43
|
+
ue();
|
|
44
|
+
var De = typeof v.default == "function" ? v.default : v.BIP32Factory;
|
|
45
|
+
if (!De) throw new Error("Failed to load BIP32 library");
|
|
46
|
+
var pt = Yi.Point, ir = pt.Fn.ORDER, Oe = Ft(new Uint8Array([
|
|
47
47
|
84,
|
|
48
48
|
97,
|
|
49
49
|
112,
|
|
@@ -53,14 +53,14 @@ var dt = Zi.Point, nr = dt.Fn.ORDER, Be = Ht(new Uint8Array([
|
|
|
53
53
|
97,
|
|
54
54
|
107
|
|
55
55
|
]));
|
|
56
|
-
function
|
|
57
|
-
return
|
|
56
|
+
function rr(e) {
|
|
57
|
+
return Ft(Gi(Oe, Oe, e));
|
|
58
58
|
}
|
|
59
|
-
var I = class
|
|
60
|
-
static BIP32 =
|
|
59
|
+
var I = class Yt {
|
|
60
|
+
static BIP32 = De(K);
|
|
61
61
|
static ECPairSigner = ot;
|
|
62
62
|
static {
|
|
63
|
-
|
|
63
|
+
pt.BASE.precompute(8);
|
|
64
64
|
}
|
|
65
65
|
static fromWIF(t, i = y.bitcoin) {
|
|
66
66
|
return ot.fromWIF(K, t, i);
|
|
@@ -74,11 +74,11 @@ var I = class Qt {
|
|
|
74
74
|
static generateMultiSigAddress(t, i, r = y.bitcoin) {
|
|
75
75
|
const s = this.verifyPubKeys(t, r);
|
|
76
76
|
if (s.length !== t.length) throw new Error("Contains invalid public keys");
|
|
77
|
-
const n =
|
|
77
|
+
const n = U.p2ms({
|
|
78
78
|
m: i,
|
|
79
79
|
pubkeys: s,
|
|
80
80
|
network: r
|
|
81
|
-
}), o =
|
|
81
|
+
}), o = U.p2wsh({
|
|
82
82
|
redeem: n,
|
|
83
83
|
network: r
|
|
84
84
|
}).address;
|
|
@@ -87,13 +87,13 @@ var I = class Qt {
|
|
|
87
87
|
}
|
|
88
88
|
static verifyPubKeys(t, i = y.bitcoin) {
|
|
89
89
|
return t.map((r) => {
|
|
90
|
-
const s =
|
|
90
|
+
const s = Yt.fromPublicKey(r, i);
|
|
91
91
|
if (!s) throw new Error("Failed to regenerate key");
|
|
92
92
|
return s.publicKey;
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
static getP2WPKHAddress(t, i = y.bitcoin) {
|
|
96
|
-
const r =
|
|
96
|
+
const r = U.p2wpkh({
|
|
97
97
|
pubkey: t.publicKey,
|
|
98
98
|
network: i
|
|
99
99
|
});
|
|
@@ -103,10 +103,10 @@ var I = class Qt {
|
|
|
103
103
|
static tweakedPubKeyToAddress(t, i) {
|
|
104
104
|
t.startsWith("0x") && (t = t.slice(2));
|
|
105
105
|
let r = g(t);
|
|
106
|
-
return r.length !== 32 && (r =
|
|
106
|
+
return r.length !== 32 && (r = O(r)), Yt.tweakedPubKeyBufferToAddress(r, i);
|
|
107
107
|
}
|
|
108
108
|
static tweakedPubKeyBufferToAddress(t, i) {
|
|
109
|
-
const { address: r } =
|
|
109
|
+
const { address: r } = U.p2tr({
|
|
110
110
|
pubkey: t,
|
|
111
111
|
network: i
|
|
112
112
|
});
|
|
@@ -114,15 +114,15 @@ var I = class Qt {
|
|
|
114
114
|
return r;
|
|
115
115
|
}
|
|
116
116
|
static p2op(t, i = y.bitcoin, r = 0) {
|
|
117
|
-
const s =
|
|
117
|
+
const s = ht([new Uint8Array([r]), it.crypto.hash160(t)]);
|
|
118
118
|
if (s.length < 2 || s.length > 40) throw new Error("Witness program must be 2-40 bytes.");
|
|
119
|
-
return
|
|
119
|
+
return Fi(b.compile([d.OP_16, s]), i);
|
|
120
120
|
}
|
|
121
121
|
static xOnlyTweakedPubKeyToAddress(t, i) {
|
|
122
122
|
t.startsWith("0x") && (t = t.slice(2));
|
|
123
123
|
const r = g(t);
|
|
124
124
|
if (r.length !== 32) throw new Error("Invalid xOnly public key length");
|
|
125
|
-
const { address: s } =
|
|
125
|
+
const { address: s } = U.p2tr({
|
|
126
126
|
pubkey: r,
|
|
127
127
|
network: i
|
|
128
128
|
});
|
|
@@ -131,18 +131,18 @@ var I = class Qt {
|
|
|
131
131
|
}
|
|
132
132
|
static tweakPublicKey(t) {
|
|
133
133
|
typeof t == "string" && t.startsWith("0x") && (t = t.slice(2));
|
|
134
|
-
const i = typeof t == "string" ? t : f(t), r =
|
|
135
|
-
return s.add(
|
|
134
|
+
const i = typeof t == "string" ? t : f(t), r = pt.fromHex(i), s = (r.y & 1n) === 0n ? r : r.negate(), n = Xi($i(rr(s.toBytes(!0).subarray(1))), ir);
|
|
135
|
+
return s.add(pt.BASE.multiply(n)).toBytes(!0);
|
|
136
136
|
}
|
|
137
137
|
static tweakBatchSharedT(t, i) {
|
|
138
|
-
const r =
|
|
138
|
+
const r = pt.BASE.multiply(i);
|
|
139
139
|
return t.map((s) => {
|
|
140
|
-
const n =
|
|
140
|
+
const n = pt.fromHex(f(s));
|
|
141
141
|
return (n.y % 2n === 0n ? n : n.negate()).add(r).toBytes(!0);
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
static generateWallet(t = y.bitcoin, i =
|
|
145
|
-
const r = ot.makeRandom(K, t, { rng: (o) =>
|
|
144
|
+
static generateWallet(t = y.bitcoin, i = v.MLDSASecurityLevel.LEVEL2) {
|
|
145
|
+
const r = ot.makeRandom(K, t, { rng: (o) => zt(o) }), s = this.getP2WPKHAddress(r, t);
|
|
146
146
|
if (!s) throw new Error("Failed to generate wallet");
|
|
147
147
|
const n = this.generateQuantumKeyPair(i, t);
|
|
148
148
|
return {
|
|
@@ -153,8 +153,8 @@ var I = class Qt {
|
|
|
153
153
|
quantumPublicKey: f(n.publicKey)
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
|
-
static generateQuantumKeyPair(t =
|
|
157
|
-
const r =
|
|
156
|
+
static generateQuantumKeyPair(t = v.MLDSASecurityLevel.LEVEL2, i = y.bitcoin) {
|
|
157
|
+
const r = zt(64), s = v.QuantumBIP32Factory.fromSeed(r, i, t);
|
|
158
158
|
if (!s.privateKey || !s.publicKey) throw new Error("Failed to generate quantum keypair");
|
|
159
159
|
return {
|
|
160
160
|
privateKey: new Uint8Array(s.privateKey),
|
|
@@ -165,8 +165,8 @@ var I = class Qt {
|
|
|
165
165
|
return !!H.toOutputScript(t, i);
|
|
166
166
|
}
|
|
167
167
|
static getLegacySegwitAddress(t, i = y.bitcoin) {
|
|
168
|
-
const r =
|
|
169
|
-
redeem:
|
|
168
|
+
const r = U.p2sh({
|
|
169
|
+
redeem: U.p2wpkh({
|
|
170
170
|
pubkey: t.publicKey,
|
|
171
171
|
network: i
|
|
172
172
|
}),
|
|
@@ -176,7 +176,7 @@ var I = class Qt {
|
|
|
176
176
|
return r.address;
|
|
177
177
|
}
|
|
178
178
|
static getLegacyAddress(t, i = y.bitcoin) {
|
|
179
|
-
const r =
|
|
179
|
+
const r = U.p2pkh({
|
|
180
180
|
pubkey: t.publicKey,
|
|
181
181
|
network: i
|
|
182
182
|
});
|
|
@@ -184,7 +184,7 @@ var I = class Qt {
|
|
|
184
184
|
return r.address;
|
|
185
185
|
}
|
|
186
186
|
static getP2PKH(t, i = y.bitcoin) {
|
|
187
|
-
const r =
|
|
187
|
+
const r = U.p2pkh({
|
|
188
188
|
pubkey: t,
|
|
189
189
|
network: i
|
|
190
190
|
});
|
|
@@ -192,7 +192,7 @@ var I = class Qt {
|
|
|
192
192
|
return r.address;
|
|
193
193
|
}
|
|
194
194
|
static getP2PKAddress(t, i = y.bitcoin) {
|
|
195
|
-
const r =
|
|
195
|
+
const r = U.p2pk({
|
|
196
196
|
pubkey: t.publicKey,
|
|
197
197
|
network: i
|
|
198
198
|
});
|
|
@@ -200,21 +200,21 @@ var I = class Qt {
|
|
|
200
200
|
return "0x" + f(r.output);
|
|
201
201
|
}
|
|
202
202
|
static generateRandomKeyPair(t = y.bitcoin) {
|
|
203
|
-
return ot.makeRandom(K, t, { rng: (i) =>
|
|
203
|
+
return ot.makeRandom(K, t, { rng: (i) => zt(i) });
|
|
204
204
|
}
|
|
205
205
|
static fromSeed(t, i = y.bitcoin) {
|
|
206
206
|
return this.BIP32.fromSeed(t, i);
|
|
207
207
|
}
|
|
208
208
|
static getTaprootAddress(t, i = y.bitcoin) {
|
|
209
|
-
const { address: r } =
|
|
210
|
-
internalPubkey:
|
|
209
|
+
const { address: r } = U.p2tr({
|
|
210
|
+
internalPubkey: O(t.publicKey),
|
|
211
211
|
network: i
|
|
212
212
|
});
|
|
213
213
|
if (!r) throw new Error("Failed to generate sender address for transaction");
|
|
214
214
|
return r;
|
|
215
215
|
}
|
|
216
216
|
static getTaprootAddressFromAddress(t, i = y.bitcoin) {
|
|
217
|
-
const { address: r } =
|
|
217
|
+
const { address: r } = U.p2tr({
|
|
218
218
|
address: t,
|
|
219
219
|
network: i
|
|
220
220
|
});
|
|
@@ -226,37 +226,37 @@ var I = class Qt {
|
|
|
226
226
|
if (!r) throw new Error("Failed to generate key pair");
|
|
227
227
|
return ot.fromPrivateKey(K, r, i);
|
|
228
228
|
}
|
|
229
|
-
},
|
|
229
|
+
}, q = /* @__PURE__ */ (function(e) {
|
|
230
230
|
return e[e.ACCESS_LIST = 1] = "ACCESS_LIST", e[e.EPOCH_SUBMISSION = 2] = "EPOCH_SUBMISSION", e[e.MLDSA_LINK_PUBKEY = 4] = "MLDSA_LINK_PUBKEY", e;
|
|
231
231
|
})({}), J = /* @__PURE__ */ (function(e) {
|
|
232
232
|
return e[e.ACCESS_LIST = 1] = "ACCESS_LIST", e[e.EPOCH_SUBMISSION = 2] = "EPOCH_SUBMISSION", e[e.MLDSA_LINK_PUBKEY = 3] = "MLDSA_LINK_PUBKEY", e;
|
|
233
233
|
})({}), jr = 32, Qr = 64, Zr = 64, Jr = 4, ts = 32, es = 16, is = 8, rs = 4, ss = 2, ns = 1, os = 32, as = 16, cs = 8, us = 4, ls = 2, hs = 1, ds = 1;
|
|
234
|
-
|
|
235
|
-
function
|
|
234
|
+
ue();
|
|
235
|
+
function sr(e, t, i, r) {
|
|
236
236
|
if (!e) throw new Error(`${t} (${i}: ${r})`);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function nr() {
|
|
239
239
|
if (typeof self < "u") return self;
|
|
240
240
|
if (typeof window < "u") return window;
|
|
241
241
|
if (typeof globalThis < "u") return globalThis;
|
|
242
242
|
throw new Error("unable to locate global object");
|
|
243
243
|
}
|
|
244
|
-
var
|
|
245
|
-
function
|
|
244
|
+
var _e = nr(), ps = _e.crypto || _e.msCrypto;
|
|
245
|
+
function jt(e) {
|
|
246
246
|
switch (e) {
|
|
247
247
|
case "sha256":
|
|
248
|
-
return
|
|
248
|
+
return Ft.create();
|
|
249
249
|
case "sha512":
|
|
250
|
-
return
|
|
250
|
+
return qi.create();
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
sr(!1, "invalid hashing algorithm name", "algorithm", e);
|
|
253
253
|
}
|
|
254
|
-
var
|
|
254
|
+
var or = /^[0-9a-fA-F]+$/, W = class Me {
|
|
255
255
|
static btcToSatoshi(t) {
|
|
256
256
|
return BigInt(t * 1e8);
|
|
257
257
|
}
|
|
258
258
|
static rndBytes() {
|
|
259
|
-
return
|
|
259
|
+
return Me.getSafeRandomValues(64);
|
|
260
260
|
}
|
|
261
261
|
static getSafeRandomValues(t) {
|
|
262
262
|
if (typeof globalThis.window < "u" && globalThis.window.crypto && typeof globalThis.window.crypto.getRandomValues == "function") {
|
|
@@ -269,15 +269,15 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
269
269
|
throw console.log("No secure random number generator available. Please upgrade your environment.", globalThis.window.crypto, globalThis.crypto), new Error("No secure random number generator available. Please upgrade your environment.");
|
|
270
270
|
}
|
|
271
271
|
static isValidHex(t) {
|
|
272
|
-
return
|
|
272
|
+
return or.test(t);
|
|
273
273
|
}
|
|
274
274
|
static opnetHash(t) {
|
|
275
|
-
const i =
|
|
275
|
+
const i = jt("sha512");
|
|
276
276
|
i.update(t);
|
|
277
277
|
const r = i.digest();
|
|
278
278
|
return `0x${f(new Uint8Array(r))}`;
|
|
279
279
|
}
|
|
280
|
-
},
|
|
280
|
+
}, X = class {
|
|
281
281
|
static isP2WDAUTXO(e) {
|
|
282
282
|
if (!e.witnessScript) return !1;
|
|
283
283
|
const t = e.witnessScript instanceof Uint8Array ? e.witnessScript : g(e.witnessScript);
|
|
@@ -285,7 +285,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
285
285
|
}
|
|
286
286
|
static isP2WDAWitnessScript(e) {
|
|
287
287
|
try {
|
|
288
|
-
const t =
|
|
288
|
+
const t = b.decompile(e);
|
|
289
289
|
if (!t || t.length !== 7) return !1;
|
|
290
290
|
for (let i = 0; i < 5; i++) if (t[i] !== d.OP_2DROP) return !1;
|
|
291
291
|
return t[5] instanceof Uint8Array && t[5].length === 33 && t[6] === d.OP_CHECKSIG;
|
|
@@ -295,7 +295,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
295
295
|
}
|
|
296
296
|
static generateP2WDAAddress(e, t) {
|
|
297
297
|
if (e.length !== 33) throw new Error("Public key must be 33 bytes (compressed)");
|
|
298
|
-
const i =
|
|
298
|
+
const i = b.compile([
|
|
299
299
|
d.OP_2DROP,
|
|
300
300
|
d.OP_2DROP,
|
|
301
301
|
d.OP_2DROP,
|
|
@@ -303,7 +303,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
303
303
|
d.OP_2DROP,
|
|
304
304
|
e,
|
|
305
305
|
d.OP_CHECKSIG
|
|
306
|
-
]), r =
|
|
306
|
+
]), r = U.p2wsh({
|
|
307
307
|
redeem: { output: i },
|
|
308
308
|
network: t
|
|
309
309
|
});
|
|
@@ -316,7 +316,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
316
316
|
}
|
|
317
317
|
static extractPublicKeyFromP2WDA(e) {
|
|
318
318
|
try {
|
|
319
|
-
const t =
|
|
319
|
+
const t = b.decompile(e);
|
|
320
320
|
if (!t || t.length !== 7) return null;
|
|
321
321
|
for (let i = 0; i < 5; i++) if (t[i] !== d.OP_2DROP) return null;
|
|
322
322
|
return t[5] instanceof Uint8Array && t[5].length === 33 && t[6] === d.OP_CHECKSIG ? t[5] : null;
|
|
@@ -326,7 +326,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
326
326
|
}
|
|
327
327
|
static createSimpleP2WDAWitness(e, t) {
|
|
328
328
|
const i = [e];
|
|
329
|
-
for (let r = 0; r < 10; r++) i.push(new Uint8Array(0));
|
|
329
|
+
for (let r = 0; r < 10; r++) i.push(/* @__PURE__ */ new Uint8Array(0));
|
|
330
330
|
return i.push(t), i;
|
|
331
331
|
}
|
|
332
332
|
static validateP2WDASignature(e, t, i) {
|
|
@@ -338,9 +338,9 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
338
338
|
static couldBeP2WDA(e) {
|
|
339
339
|
return e.length === 34 && e[0] === 0 && e[1] === 32;
|
|
340
340
|
}
|
|
341
|
-
},
|
|
341
|
+
}, ct = /* @__PURE__ */ (function(e) {
|
|
342
342
|
return e.P2PKH = "P2PKH", e.P2OP = "P2OP", e.P2SH_OR_P2SH_P2WPKH = "P2SH_OR_P2SH-P2WPKH", e.P2PK = "P2PK", e.P2TR = "P2TR", e.P2MR = "P2MR", e.P2WPKH = "P2WPKH", e.P2WSH = "P2WSH", e.P2WDA = "P2WDA", e;
|
|
343
|
-
})({}),
|
|
343
|
+
})({}), Et = class ft {
|
|
344
344
|
static isValidP2TRAddress(t, i) {
|
|
345
345
|
if (!t || t.length < 50) return !1;
|
|
346
346
|
let r = !1;
|
|
@@ -372,7 +372,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
372
372
|
return r;
|
|
373
373
|
}
|
|
374
374
|
static isP2WDAWitnessScript(t) {
|
|
375
|
-
return
|
|
375
|
+
return X.isP2WDAWitnessScript(t);
|
|
376
376
|
}
|
|
377
377
|
static isP2PKHOrP2SH(t, i) {
|
|
378
378
|
try {
|
|
@@ -405,11 +405,11 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
405
405
|
}
|
|
406
406
|
switch (i) {
|
|
407
407
|
case 1312:
|
|
408
|
-
return
|
|
408
|
+
return v.MLDSASecurityLevel.LEVEL2;
|
|
409
409
|
case 1952:
|
|
410
|
-
return
|
|
410
|
+
return v.MLDSASecurityLevel.LEVEL3;
|
|
411
411
|
case 2592:
|
|
412
|
-
return
|
|
412
|
+
return v.MLDSASecurityLevel.LEVEL5;
|
|
413
413
|
default:
|
|
414
414
|
return null;
|
|
415
415
|
}
|
|
@@ -435,33 +435,33 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
static detectAddressType(t, i) {
|
|
438
|
-
if (
|
|
438
|
+
if (ft.isValidPublicKey(t, i)) return "P2PK";
|
|
439
439
|
try {
|
|
440
440
|
const r = H.fromBase58Check(t);
|
|
441
|
-
if (r.version === i.pubKeyHash) return
|
|
442
|
-
if (r.version === i.scriptHash) return
|
|
441
|
+
if (r.version === i.pubKeyHash) return "P2PKH";
|
|
442
|
+
if (r.version === i.scriptHash) return "P2SH_OR_P2SH-P2WPKH";
|
|
443
443
|
} catch {
|
|
444
444
|
}
|
|
445
445
|
try {
|
|
446
446
|
const r = H.fromBech32(t);
|
|
447
|
-
if ((r.prefix === i.bech32Opnet || r.prefix === i.bech32) && r.version === 16 && r.data.length === 21) return
|
|
447
|
+
if ((r.prefix === i.bech32Opnet || r.prefix === i.bech32) && r.version === 16 && r.data.length === 21) return "P2OP";
|
|
448
448
|
if (r.prefix === i.bech32) {
|
|
449
|
-
if (r.version === 0 && r.data.length === 20) return
|
|
450
|
-
if (r.version === 0 && r.data.length === 32) return
|
|
451
|
-
if (r.version === 1 && r.data.length === 32) return
|
|
452
|
-
if (r.version === 2 && r.data.length === 32) return
|
|
449
|
+
if (r.version === 0 && r.data.length === 20) return "P2WPKH";
|
|
450
|
+
if (r.version === 0 && r.data.length === 32) return "P2WSH";
|
|
451
|
+
if (r.version === 1 && r.data.length === 32) return "P2TR";
|
|
452
|
+
if (r.version === 2 && r.data.length === 32) return "P2MR";
|
|
453
453
|
}
|
|
454
454
|
} catch {
|
|
455
455
|
}
|
|
456
456
|
return null;
|
|
457
457
|
}
|
|
458
458
|
static detectAddressTypeWithWitnessScript(t, i, r) {
|
|
459
|
-
const s =
|
|
460
|
-
return s ===
|
|
459
|
+
const s = ft.detectAddressType(t, i);
|
|
460
|
+
return s === "P2WSH" && r && ft.isP2WDAWitnessScript(r) ? "P2WDA" : s;
|
|
461
461
|
}
|
|
462
462
|
static validateP2WDAAddress(t, i, r) {
|
|
463
463
|
try {
|
|
464
|
-
if (
|
|
464
|
+
if (ft.detectAddressType(t, i) !== "P2WSH") return {
|
|
465
465
|
isValid: !1,
|
|
466
466
|
isPotentiallyP2WDA: !1,
|
|
467
467
|
isDefinitelyP2WDA: !1,
|
|
@@ -472,13 +472,13 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
472
472
|
isPotentiallyP2WDA: !0,
|
|
473
473
|
isDefinitelyP2WDA: !1
|
|
474
474
|
};
|
|
475
|
-
if (!
|
|
475
|
+
if (!ft.isP2WDAWitnessScript(r)) return {
|
|
476
476
|
isValid: !0,
|
|
477
477
|
isPotentiallyP2WDA: !0,
|
|
478
478
|
isDefinitelyP2WDA: !1,
|
|
479
479
|
error: "Witness script does not match P2WDA pattern"
|
|
480
480
|
};
|
|
481
|
-
if (
|
|
481
|
+
if (U.p2wsh({
|
|
482
482
|
redeem: { output: r },
|
|
483
483
|
network: i
|
|
484
484
|
}).address !== t) return {
|
|
@@ -487,7 +487,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
487
487
|
isDefinitelyP2WDA: !1,
|
|
488
488
|
error: "Witness script does not match address"
|
|
489
489
|
};
|
|
490
|
-
const s =
|
|
490
|
+
const s = X.extractPublicKeyFromP2WDA(r);
|
|
491
491
|
return s ? {
|
|
492
492
|
isValid: !0,
|
|
493
493
|
isPotentiallyP2WDA: !0,
|
|
@@ -508,7 +508,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
508
508
|
};
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
}, at = 115792089237316195423570985008687907853269984665640564039457584007908834671663n,
|
|
511
|
+
}, at = 115792089237316195423570985008687907853269984665640564039457584007908834671663n, Ne = class {
|
|
512
512
|
maxTries;
|
|
513
513
|
constructor(e = 1e4) {
|
|
514
514
|
this.maxTries = e;
|
|
@@ -531,7 +531,7 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
531
531
|
return e < t ? e : t;
|
|
532
532
|
}
|
|
533
533
|
getHybridPublicKey(e, t) {
|
|
534
|
-
const i = t % 2n === 0n ? 6 : 7, r = this.bigIntTo32Bytes(e), s = this.bigIntTo32Bytes(t), n = new Uint8Array(65);
|
|
534
|
+
const i = t % 2n === 0n ? 6 : 7, r = this.bigIntTo32Bytes(e), s = this.bigIntTo32Bytes(t), n = /* @__PURE__ */ new Uint8Array(65);
|
|
535
535
|
return n[0] = i, n.set(r, 1), n.set(s, 33), n;
|
|
536
536
|
}
|
|
537
537
|
isValidX(e) {
|
|
@@ -554,21 +554,21 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
554
554
|
return t;
|
|
555
555
|
}
|
|
556
556
|
bigIntTo32Bytes(e) {
|
|
557
|
-
const t = new Uint8Array(32);
|
|
557
|
+
const t = /* @__PURE__ */ new Uint8Array(32);
|
|
558
558
|
for (let i = 31; i >= 0; i--)
|
|
559
559
|
t[i] = Number(e & 255n), e >>= 8n;
|
|
560
560
|
return t;
|
|
561
561
|
}
|
|
562
|
-
},
|
|
563
|
-
deriver = new
|
|
562
|
+
}, ar = class {
|
|
563
|
+
deriver = new Ne();
|
|
564
564
|
generateHybridKeyFromHash(e) {
|
|
565
565
|
const t = this.deriver.findOrDeriveValidPoint(new Uint8Array(e), !1), i = this.deriver.getCanonicalY(t.y1, t.y2);
|
|
566
566
|
return new Uint8Array(this.deriver.getHybridPublicKey(t.x, i));
|
|
567
567
|
}
|
|
568
|
-
},
|
|
568
|
+
}, Qt = new ar(), nt = class gt {
|
|
569
569
|
static UNSPENDABLE_INTERNAL_KEY = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0");
|
|
570
570
|
static CSV_BLOCKS = 75;
|
|
571
|
-
static generateTimeLockAddress(t, i = y.bitcoin, r =
|
|
571
|
+
static generateTimeLockAddress(t, i = y.bitcoin, r = gt.CSV_BLOCKS) {
|
|
572
572
|
const s = this.generateTimeLockScript(t, r), n = it.payments.p2wsh({
|
|
573
573
|
redeem: { output: s },
|
|
574
574
|
network: i
|
|
@@ -579,31 +579,31 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
579
579
|
witnessScript: s
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
|
-
static generateTimeLockAddressP2TR(t, i = y.bitcoin, r =
|
|
582
|
+
static generateTimeLockAddressP2TR(t, i = y.bitcoin, r = gt.CSV_BLOCKS) {
|
|
583
583
|
if (t.length !== 32) throw new Error("Public key must be 32 bytes for Taproot");
|
|
584
584
|
const s = this.generateTimeLockScript(t, r), n = it.payments.p2tr({
|
|
585
585
|
redeem: { output: s },
|
|
586
586
|
network: i,
|
|
587
|
-
internalPubkey:
|
|
587
|
+
internalPubkey: gt.UNSPENDABLE_INTERNAL_KEY
|
|
588
588
|
});
|
|
589
589
|
if (!n.address) throw new Error("Failed to generate P2TR address");
|
|
590
590
|
return n.address;
|
|
591
591
|
}
|
|
592
|
-
static generateTimeLockAddressP2MR(t, i = y.bitcoin, r =
|
|
592
|
+
static generateTimeLockAddressP2MR(t, i = y.bitcoin, r = gt.CSV_BLOCKS) {
|
|
593
593
|
if (t.length !== 32) throw new Error("Public key must be 32 bytes for P2MR");
|
|
594
594
|
const s = {
|
|
595
595
|
output: this.generateTimeLockScript(t, r),
|
|
596
596
|
version: 192
|
|
597
|
-
}, n =
|
|
597
|
+
}, n = U.p2mr({
|
|
598
598
|
scriptTree: s,
|
|
599
599
|
network: i
|
|
600
600
|
});
|
|
601
601
|
if (!n.address) throw new Error("Failed to generate P2MR address");
|
|
602
602
|
return n.address;
|
|
603
603
|
}
|
|
604
|
-
static generateTimeLockScript(t, i =
|
|
605
|
-
return
|
|
606
|
-
|
|
604
|
+
static generateTimeLockScript(t, i = gt.CSV_BLOCKS) {
|
|
605
|
+
return b.compile([
|
|
606
|
+
b.number.encode(i),
|
|
607
607
|
d.OP_CHECKSEQUENCEVERIFY,
|
|
608
608
|
d.OP_DROP,
|
|
609
609
|
t,
|
|
@@ -611,12 +611,12 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
611
611
|
]);
|
|
612
612
|
}
|
|
613
613
|
};
|
|
614
|
-
|
|
615
|
-
var
|
|
614
|
+
ue();
|
|
615
|
+
var cr = [
|
|
616
616
|
1312,
|
|
617
617
|
1952,
|
|
618
618
|
2592
|
|
619
|
-
],
|
|
619
|
+
], z = class Y extends Uint8Array {
|
|
620
620
|
#t;
|
|
621
621
|
#e;
|
|
622
622
|
#n;
|
|
@@ -676,7 +676,7 @@ var hr = [
|
|
|
676
676
|
return this.#h;
|
|
677
677
|
}
|
|
678
678
|
static dead() {
|
|
679
|
-
return
|
|
679
|
+
return Y.fromString("0x0000000000000000000000000000000000000000000000000000000000000000", "0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f");
|
|
680
680
|
}
|
|
681
681
|
static fromString(t, i) {
|
|
682
682
|
if (!t) throw new Error("Invalid public key");
|
|
@@ -686,24 +686,25 @@ var hr = [
|
|
|
686
686
|
if (i.startsWith("0x") && (i = i.slice(2)), !W.isValidHex(i)) throw new Error('You must only pass classical public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');
|
|
687
687
|
r = g(i);
|
|
688
688
|
}
|
|
689
|
-
return new
|
|
689
|
+
return new Y(g(t), r);
|
|
690
690
|
}
|
|
691
691
|
static wrap(t) {
|
|
692
|
-
return new
|
|
692
|
+
return new Y(t);
|
|
693
693
|
}
|
|
694
694
|
static uncompressedToCompressed(t) {
|
|
695
|
-
const i = Uint8Array.from(t), r = i.slice(1, 33), s = i.slice(33), n = new Uint8Array(33);
|
|
695
|
+
const i = Uint8Array.from(t), r = i.slice(1, 33), s = i.slice(33), n = /* @__PURE__ */ new Uint8Array(33);
|
|
696
696
|
return n[0] = 2 + (s[s.length - 1] & 1), n.set(r, 1), n;
|
|
697
697
|
}
|
|
698
698
|
static fromBigInt(t, i) {
|
|
699
|
-
|
|
699
|
+
const r = Y.bigintToUint8Array(t), s = i !== void 0 ? Y.bigintToUint8Array(i) : void 0;
|
|
700
|
+
return new Y(r, s);
|
|
700
701
|
}
|
|
701
702
|
static fromUint64Array(t, i, r, s) {
|
|
702
|
-
const n = new Uint8Array(32), o = new DataView(n.buffer);
|
|
703
|
-
return o.setBigUint64(0, t, !1), o.setBigUint64(8, i, !1), o.setBigUint64(16, r, !1), o.setBigUint64(24, s, !1), new
|
|
703
|
+
const n = /* @__PURE__ */ new Uint8Array(32), o = new DataView(n.buffer);
|
|
704
|
+
return o.setBigUint64(0, t, !1), o.setBigUint64(8, i, !1), o.setBigUint64(16, r, !1), o.setBigUint64(24, s, !1), new Y(n);
|
|
704
705
|
}
|
|
705
706
|
static bigintToUint8Array(t) {
|
|
706
|
-
const i = new Uint8Array(32), r = new DataView(i.buffer);
|
|
707
|
+
const i = /* @__PURE__ */ new Uint8Array(32), r = new DataView(i.buffer);
|
|
707
708
|
return r.setBigUint64(0, t >> 192n & 18446744073709551615n, !1), r.setBigUint64(8, t >> 128n & 18446744073709551615n, !1), r.setBigUint64(16, t >> 64n & 18446744073709551615n, !1), r.setBigUint64(24, t & 18446744073709551615n, !1), i;
|
|
708
709
|
}
|
|
709
710
|
[Symbol.dispose]() {
|
|
@@ -800,7 +801,7 @@ var hr = [
|
|
|
800
801
|
isValidLegacyPublicKey(t) {
|
|
801
802
|
const i = this.legacyPublicKey;
|
|
802
803
|
if (!i) throw new Error("Legacy key not set.");
|
|
803
|
-
return
|
|
804
|
+
return Et.isValidPublicKey(f(i), t);
|
|
804
805
|
}
|
|
805
806
|
p2pk() {
|
|
806
807
|
return this.toHex();
|
|
@@ -835,7 +836,7 @@ var hr = [
|
|
|
835
836
|
const i = new Uint8Array(this.#i);
|
|
836
837
|
if (i.length !== 33) throw new Error("P2WDA requires a compressed public key (33 bytes)");
|
|
837
838
|
try {
|
|
838
|
-
const r =
|
|
839
|
+
const r = X.generateP2WDAAddress(i, t);
|
|
839
840
|
return this.#n = t, this.#d = r, {
|
|
840
841
|
address: r.address,
|
|
841
842
|
witnessScript: r.witnessScript
|
|
@@ -883,7 +884,7 @@ var hr = [
|
|
|
883
884
|
const t = this.#o;
|
|
884
885
|
if (t && t.length === 32 && !this.#i)
|
|
885
886
|
try {
|
|
886
|
-
this.#s =
|
|
887
|
+
this.#s = Qt.generateHybridKeyFromHash(t);
|
|
887
888
|
} catch {
|
|
888
889
|
}
|
|
889
890
|
}
|
|
@@ -892,9 +893,9 @@ var hr = [
|
|
|
892
893
|
const i = new Uint8Array(32);
|
|
893
894
|
i.set(t), super.set(i);
|
|
894
895
|
} else {
|
|
895
|
-
if (!
|
|
896
|
+
if (!cr.includes(t.length)) throw new Error(`Invalid ML-DSA public key length: ${t.length}. Expected 1312 (ML-DSA-44/LEVEL2), 1952 (ML-DSA-65/LEVEL3), or 2592 (ML-DSA-87/LEVEL5) bytes.`);
|
|
896
897
|
this.#a = new Uint8Array(t.length), this.#a.set(t);
|
|
897
|
-
const i =
|
|
898
|
+
const i = Ft(new Uint8Array(t)), r = new Uint8Array(32);
|
|
898
899
|
r.set(i), super.set(r);
|
|
899
900
|
}
|
|
900
901
|
}
|
|
@@ -906,15 +907,15 @@ var hr = [
|
|
|
906
907
|
}
|
|
907
908
|
autoFormat(t) {
|
|
908
909
|
const i = t[0];
|
|
909
|
-
i === 3 || i === 2 || (i === 4 || i === 6 || i === 7) && (t =
|
|
910
|
-
const r =
|
|
911
|
-
this.#s =
|
|
910
|
+
i === 3 || i === 2 || (i === 4 || i === 6 || i === 7) && (t = Y.uncompressedToCompressed(t)), this.#i = Uint8Array.from(t), this.#h = I.fromPublicKey(this.#i), this.#r = xi(this.#i);
|
|
911
|
+
const r = O(I.tweakPublicKey(this.#i));
|
|
912
|
+
this.#s = Qt.generateHybridKeyFromHash(r), this.#o = new Uint8Array(32), this.#o.set(r);
|
|
912
913
|
}
|
|
913
|
-
},
|
|
914
|
+
}, Wt = class xe {
|
|
914
915
|
_keys = [];
|
|
915
916
|
_values = {};
|
|
916
917
|
constructor(t) {
|
|
917
|
-
if (t instanceof
|
|
918
|
+
if (t instanceof xe) this.setAll(t);
|
|
918
919
|
else if (t) for (const [i, r] of t) this.set(i, r);
|
|
919
920
|
}
|
|
920
921
|
get size() {
|
|
@@ -966,10 +967,10 @@ var hr = [
|
|
|
966
967
|
*[Symbol.iterator]() {
|
|
967
968
|
for (const t of this._keys) yield [t, this._values[t]];
|
|
968
969
|
}
|
|
969
|
-
},
|
|
970
|
+
}, Fe = class {
|
|
970
971
|
items;
|
|
971
972
|
constructor(e) {
|
|
972
|
-
if (this.items = new
|
|
973
|
+
if (this.items = new Wt(), e) for (const [t, i] of e) this.set(t, i);
|
|
973
974
|
}
|
|
974
975
|
get size() {
|
|
975
976
|
return this.items.size;
|
|
@@ -998,29 +999,29 @@ var hr = [
|
|
|
998
999
|
return this.items.indexOf(e.toBigInt());
|
|
999
1000
|
}
|
|
1000
1001
|
*entries() {
|
|
1001
|
-
for (const [e, t] of this.items.entries()) yield [
|
|
1002
|
+
for (const [e, t] of this.items.entries()) yield [z.fromBigInt(e), t];
|
|
1002
1003
|
}
|
|
1003
1004
|
*keys() {
|
|
1004
|
-
for (const e of this.items.keys()) yield
|
|
1005
|
+
for (const e of this.items.keys()) yield z.fromBigInt(e);
|
|
1005
1006
|
}
|
|
1006
1007
|
*values() {
|
|
1007
1008
|
for (const e of this.items.values()) yield e;
|
|
1008
1009
|
}
|
|
1009
1010
|
forEach(e, t) {
|
|
1010
1011
|
for (const [i, r] of this.items.entries()) {
|
|
1011
|
-
const s =
|
|
1012
|
+
const s = z.fromBigInt(i);
|
|
1012
1013
|
e.call(t, r, s, this);
|
|
1013
1014
|
}
|
|
1014
1015
|
}
|
|
1015
1016
|
*[Symbol.iterator]() {
|
|
1016
1017
|
yield* this.entries();
|
|
1017
1018
|
}
|
|
1018
|
-
},
|
|
1019
|
+
}, We = class {
|
|
1019
1020
|
indexMap;
|
|
1020
1021
|
_keys = [];
|
|
1021
1022
|
_values = [];
|
|
1022
1023
|
constructor(e) {
|
|
1023
|
-
if (this.indexMap = new
|
|
1024
|
+
if (this.indexMap = new Wt(), e) for (const [t, i] of e) this.set(t, i);
|
|
1024
1025
|
}
|
|
1025
1026
|
get size() {
|
|
1026
1027
|
return this._keys.length;
|
|
@@ -1074,7 +1075,7 @@ var hr = [
|
|
|
1074
1075
|
*[Symbol.iterator]() {
|
|
1075
1076
|
yield* this.entries();
|
|
1076
1077
|
}
|
|
1077
|
-
},
|
|
1078
|
+
}, _t = class {
|
|
1078
1079
|
static EXPECTED_BUFFER_LENGTH = 32;
|
|
1079
1080
|
static bufferToUint8Array(e) {
|
|
1080
1081
|
const t = new Uint8Array(e.byteLength);
|
|
@@ -1105,7 +1106,7 @@ var hr = [
|
|
|
1105
1106
|
static uint8ArrayToValue(e) {
|
|
1106
1107
|
return e.length === 0 ? 0n : BigInt("0x" + f(e));
|
|
1107
1108
|
}
|
|
1108
|
-
},
|
|
1109
|
+
}, Ht = class {
|
|
1109
1110
|
buffer;
|
|
1110
1111
|
currentOffset = 0;
|
|
1111
1112
|
constructor(e) {
|
|
@@ -1221,7 +1222,7 @@ var hr = [
|
|
|
1221
1222
|
return this.readString(t);
|
|
1222
1223
|
}
|
|
1223
1224
|
readAddress() {
|
|
1224
|
-
return new
|
|
1225
|
+
return new z(Array.from(this.readBytes(32)));
|
|
1225
1226
|
}
|
|
1226
1227
|
readTweakedPublicKey() {
|
|
1227
1228
|
return this.verifyEnd(this.currentOffset + 32), this.readBytes(32);
|
|
@@ -1229,7 +1230,7 @@ var hr = [
|
|
|
1229
1230
|
readExtendedAddress() {
|
|
1230
1231
|
this.verifyEnd(this.currentOffset + 64);
|
|
1231
1232
|
const e = Array.from(this.readBytes(32));
|
|
1232
|
-
return new
|
|
1233
|
+
return new z(Array.from(this.readBytes(32)), e);
|
|
1233
1234
|
}
|
|
1234
1235
|
readSchnorrSignature() {
|
|
1235
1236
|
return this.verifyEnd(this.currentOffset + 64 + 64), {
|
|
@@ -1293,7 +1294,7 @@ var hr = [
|
|
|
1293
1294
|
return i;
|
|
1294
1295
|
}
|
|
1295
1296
|
readAddressValueTuple(e = !0) {
|
|
1296
|
-
const t = this.readU16(e), i = new
|
|
1297
|
+
const t = this.readU16(e), i = new Fe();
|
|
1297
1298
|
for (let r = 0; r < t; r++) {
|
|
1298
1299
|
const s = this.readAddress(), n = this.readU256(e);
|
|
1299
1300
|
if (i.has(s)) throw new Error("Duplicate address found in map");
|
|
@@ -1307,7 +1308,7 @@ var hr = [
|
|
|
1307
1308
|
return i;
|
|
1308
1309
|
}
|
|
1309
1310
|
readExtendedAddressMapU256(e = !0) {
|
|
1310
|
-
const t = this.readU16(e), i = new
|
|
1311
|
+
const t = this.readU16(e), i = new We();
|
|
1311
1312
|
for (let r = 0; r < t; r++) {
|
|
1312
1313
|
const s = this.readExtendedAddress(), n = this.readU256(e);
|
|
1313
1314
|
if (i.has(s)) throw new Error("Duplicate tweaked address found in map");
|
|
@@ -1332,7 +1333,7 @@ var hr = [
|
|
|
1332
1333
|
toHexString(e) {
|
|
1333
1334
|
return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
1334
1335
|
}
|
|
1335
|
-
},
|
|
1336
|
+
}, V = class He {
|
|
1336
1337
|
currentOffset = 0;
|
|
1337
1338
|
buffer;
|
|
1338
1339
|
constructor(t = 0) {
|
|
@@ -1385,7 +1386,7 @@ var hr = [
|
|
|
1385
1386
|
writeI128(t, i = !0) {
|
|
1386
1387
|
if (t > 170141183460469231731687303715884105727n || t < -170141183460469231731687303715884105728n) throw new Error("i128 value is too large.");
|
|
1387
1388
|
this.allocSafe(16);
|
|
1388
|
-
const r =
|
|
1389
|
+
const r = _t.valueToUint8Array(t, 16);
|
|
1389
1390
|
if (r.byteLength !== 16) throw new Error(`Invalid i128 value: ${t}`);
|
|
1390
1391
|
if (i) for (let s = 0; s < r.byteLength; s++) this.writeU8(r[s]);
|
|
1391
1392
|
else for (let s = r.byteLength - 1; s >= 0; s--) this.writeU8(r[s]);
|
|
@@ -1393,7 +1394,7 @@ var hr = [
|
|
|
1393
1394
|
writeU256(t, i = !0) {
|
|
1394
1395
|
if (t > 115792089237316195423570985008687907853269984665640564039457584007913129639935n && t < 0n) throw new Error("u256 value is too large or negative.");
|
|
1395
1396
|
this.allocSafe(32);
|
|
1396
|
-
const r =
|
|
1397
|
+
const r = _t.valueToUint8Array(t);
|
|
1397
1398
|
if (r.byteLength !== 32) throw new Error(`Invalid u256 value: ${t}`);
|
|
1398
1399
|
if (i) for (let s = 0; s < r.byteLength; s++) this.writeU8(r[s]);
|
|
1399
1400
|
else for (let s = r.byteLength - 1; s >= 0; s--) this.writeU8(r[s]);
|
|
@@ -1401,7 +1402,7 @@ var hr = [
|
|
|
1401
1402
|
writeU128(t, i = !0) {
|
|
1402
1403
|
if (t > 340282366920938463463374607431768211455n && t < 0n) throw new Error("u128 value is too large or negative.");
|
|
1403
1404
|
this.allocSafe(16);
|
|
1404
|
-
const r =
|
|
1405
|
+
const r = _t.valueToUint8Array(t, 16);
|
|
1405
1406
|
if (r.byteLength !== 16) throw new Error(`Invalid u128 value: ${t}`);
|
|
1406
1407
|
if (i) for (let s = 0; s < r.byteLength; s++) this.writeU8(r[s]);
|
|
1407
1408
|
else for (let s = r.byteLength - 1; s >= 0; s--) this.writeU8(r[s]);
|
|
@@ -1441,7 +1442,7 @@ var hr = [
|
|
|
1441
1442
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(4);
|
|
1442
1443
|
}
|
|
1443
1444
|
toBytesReader() {
|
|
1444
|
-
return new
|
|
1445
|
+
return new Ht(this.getBuffer());
|
|
1445
1446
|
}
|
|
1446
1447
|
getOffset() {
|
|
1447
1448
|
return this.currentOffset;
|
|
@@ -1478,7 +1479,7 @@ var hr = [
|
|
|
1478
1479
|
this.writeU32(t.length), this.writeBytes(t);
|
|
1479
1480
|
}
|
|
1480
1481
|
writeArrayOfBuffer(t, i = !0) {
|
|
1481
|
-
const r =
|
|
1482
|
+
const r = He.estimateArrayOfBufferLength(t);
|
|
1482
1483
|
this.allocSafe(r), this.writeU16(t.length, i);
|
|
1483
1484
|
for (let s = 0; s < t.length; s++)
|
|
1484
1485
|
this.writeU32(t[s].length, i), this.writeBytes(t[s]);
|
|
@@ -1544,30 +1545,30 @@ var hr = [
|
|
|
1544
1545
|
getDefaultBuffer(t = 0) {
|
|
1545
1546
|
return new DataView(new ArrayBuffer(t));
|
|
1546
1547
|
}
|
|
1547
|
-
}, tt = class
|
|
1548
|
+
}, tt = class Ve {
|
|
1548
1549
|
static DATA_CHUNK_SIZE = 512;
|
|
1549
|
-
static MAGIC =
|
|
1550
|
+
static MAGIC = Oi("op");
|
|
1550
1551
|
senderPubKey;
|
|
1551
1552
|
xSenderPubKey;
|
|
1552
1553
|
contractSaltPubKey;
|
|
1553
1554
|
network = y.bitcoin;
|
|
1554
1555
|
constructor(t, i, r = y.bitcoin) {
|
|
1555
|
-
this.senderPubKey = t, this.contractSaltPubKey = i, this.network = r, this.xSenderPubKey =
|
|
1556
|
+
this.senderPubKey = t, this.contractSaltPubKey = i, this.network = r, this.xSenderPubKey = O(t);
|
|
1556
1557
|
}
|
|
1557
1558
|
buildHeader(t) {
|
|
1558
1559
|
let i = 0;
|
|
1559
1560
|
for (const s of t) i |= s;
|
|
1560
|
-
const r =
|
|
1561
|
+
const r = qt(3);
|
|
1561
1562
|
return r[0] = i >> 16 & 255, r[1] = i >> 8 & 255, r[2] = i & 255, Uint8Array.from([this.senderPubKey[0], ...r]);
|
|
1562
1563
|
}
|
|
1563
1564
|
getHeader(t, i = []) {
|
|
1564
|
-
const r = new
|
|
1565
|
+
const r = new V(12);
|
|
1565
1566
|
return r.writeBytes(this.buildHeader(i)), r.writeU64(t), new Uint8Array(r.getBuffer());
|
|
1566
1567
|
}
|
|
1567
|
-
splitBufferIntoChunks(t, i =
|
|
1568
|
+
splitBufferIntoChunks(t, i = Ve.DATA_CHUNK_SIZE) {
|
|
1568
1569
|
const r = [];
|
|
1569
1570
|
for (let s = 0; s < t.length; s += i) {
|
|
1570
|
-
const n = Math.min(i, t.length - s), o =
|
|
1571
|
+
const n = Math.min(i, t.length - s), o = qt(n);
|
|
1571
1572
|
for (let a = 0; a < n; a++) o[a] = t[s + a];
|
|
1572
1573
|
r.push([o]);
|
|
1573
1574
|
}
|
|
@@ -1575,21 +1576,21 @@ var hr = [
|
|
|
1575
1576
|
}
|
|
1576
1577
|
encodeFeature(t, i) {
|
|
1577
1578
|
switch (t.opcode) {
|
|
1578
|
-
case
|
|
1579
|
+
case q.ACCESS_LIST:
|
|
1579
1580
|
return this.encodeAccessListFeature(t, i);
|
|
1580
|
-
case
|
|
1581
|
+
case q.EPOCH_SUBMISSION:
|
|
1581
1582
|
return this.encodeChallengeSubmission(t, i);
|
|
1582
|
-
case
|
|
1583
|
+
case q.MLDSA_LINK_PUBKEY:
|
|
1583
1584
|
return this.encodeLinkRequest(t, i);
|
|
1584
1585
|
default:
|
|
1585
1586
|
throw new Error(`Unknown feature type: ${t.opcode}`);
|
|
1586
1587
|
}
|
|
1587
1588
|
}
|
|
1588
1589
|
encodeAccessListFeature(t, i) {
|
|
1589
|
-
const r = new
|
|
1590
|
+
const r = new V();
|
|
1590
1591
|
r.writeU16(Object.keys(t.data).length);
|
|
1591
1592
|
for (const s in t.data) {
|
|
1592
|
-
const n =
|
|
1593
|
+
const n = z.fromString(s), o = t.data[s];
|
|
1593
1594
|
r.writeAddress(n), r.writeU32(o.length);
|
|
1594
1595
|
for (const a of o) {
|
|
1595
1596
|
const c = Uint8Array.from(atob(a), (u) => u.charCodeAt(0));
|
|
@@ -1602,11 +1603,11 @@ var hr = [
|
|
|
1602
1603
|
encodeChallengeSubmission(t, i) {
|
|
1603
1604
|
if ("verifySignature" in t.data && !t.data.verifySignature()) throw new Error("Invalid signature in challenge submission feature");
|
|
1604
1605
|
if (t.data.graffiti && t.data.graffiti.length > 16) throw new Error("Invalid epoch submission graffiti length");
|
|
1605
|
-
const r = new
|
|
1606
|
+
const r = new V();
|
|
1606
1607
|
r.writeBytes(t.data.publicKey.toBuffer()), r.writeBytes(t.data.solution), t.data.graffiti && r.writeBytes(t.data.graffiti), i.writeBytesWithLength(r.getBuffer());
|
|
1607
1608
|
}
|
|
1608
1609
|
encodeLinkRequest(t, i) {
|
|
1609
|
-
const r = t.data, s = new
|
|
1610
|
+
const r = t.data, s = new V();
|
|
1610
1611
|
if (s.writeU8(r.level), s.writeBytes(r.hashedPublicKey), s.writeBoolean(r.verifyRequest), r.verifyRequest) {
|
|
1611
1612
|
if (!r.publicKey || !r.mldsaSignature) throw new Error("MLDSA public key and signature required when verifyRequest is true");
|
|
1612
1613
|
s.writeBytes(r.publicKey), s.writeBytes(r.mldsaSignature);
|
|
@@ -1614,16 +1615,16 @@ var hr = [
|
|
|
1614
1615
|
if (!r.legacySignature || r.legacySignature.length !== 64) throw new Error("Legacy signature must be exactly 64 bytes");
|
|
1615
1616
|
s.writeBytes(r.legacySignature), i.writeBytesWithLength(s.getBuffer());
|
|
1616
1617
|
}
|
|
1617
|
-
},
|
|
1618
|
+
}, le = class extends tt {
|
|
1618
1619
|
constructor(e, t, i = y.bitcoin) {
|
|
1619
1620
|
super(e, t, i);
|
|
1620
1621
|
}
|
|
1621
1622
|
static getPubKeyAsBuffer(e, t) {
|
|
1622
|
-
let i = new Uint8Array(0);
|
|
1623
|
+
let i = /* @__PURE__ */ new Uint8Array(0);
|
|
1623
1624
|
for (const s of e) {
|
|
1624
1625
|
if (!I.fromPublicKey(s, t).compressed) throw new Error("Public key must be compressed");
|
|
1625
1626
|
if (s.byteLength !== 33) throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
1626
|
-
i =
|
|
1627
|
+
i = ht([i, s]);
|
|
1627
1628
|
}
|
|
1628
1629
|
const r = Z.compress(i);
|
|
1629
1630
|
return r.byteLength >= i.byteLength ? i : r;
|
|
@@ -1634,7 +1635,7 @@ var hr = [
|
|
|
1634
1635
|
if (!n.length) throw new Error("No data chunks found");
|
|
1635
1636
|
const o = [], a = [];
|
|
1636
1637
|
if (s && s.length) {
|
|
1637
|
-
const h = s.sort((w, T) => w.priority - T.priority), p = new
|
|
1638
|
+
const h = s.sort((w, T) => w.priority - T.priority), p = new V();
|
|
1638
1639
|
for (let w = 0; w < h.length; w++) {
|
|
1639
1640
|
const T = h[w];
|
|
1640
1641
|
o.push(T.opcode), this.encodeFeature(T, p);
|
|
@@ -1666,33 +1667,33 @@ var hr = [
|
|
|
1666
1667
|
tt.MAGIC
|
|
1667
1668
|
];
|
|
1668
1669
|
c = c.concat(...a, d.OP_1NEGATE, ...n, d.OP_ELSE, d.OP_1, d.OP_ENDIF);
|
|
1669
|
-
const u = c.flat(), l =
|
|
1670
|
-
if (!
|
|
1670
|
+
const u = c.flat(), l = b.compile(u);
|
|
1671
|
+
if (!b.decompile(l)) throw new Error("Failed to decompile script??");
|
|
1671
1672
|
return l;
|
|
1672
1673
|
}
|
|
1673
|
-
},
|
|
1674
|
+
}, ze = class extends tt {
|
|
1674
1675
|
constructor(e, t = y.bitcoin) {
|
|
1675
1676
|
super(e, void 0, t);
|
|
1676
1677
|
}
|
|
1677
1678
|
compile(e) {
|
|
1678
|
-
const t = e.flat(), i =
|
|
1679
|
-
if (!
|
|
1679
|
+
const t = e.flat(), i = b.compile(t);
|
|
1680
|
+
if (!b.decompile(i)) throw new Error("Failed to decompile script??");
|
|
1680
1681
|
return i;
|
|
1681
1682
|
}
|
|
1682
|
-
}, fs = 0,
|
|
1683
|
+
}, fs = 0, qe = Uint8Array.from([0]), he = class extends tt {
|
|
1683
1684
|
constructor(e, t, i = y.bitcoin) {
|
|
1684
1685
|
super(e, t, i);
|
|
1685
1686
|
}
|
|
1686
1687
|
compile(e, t, i, r, s, n) {
|
|
1687
|
-
const o = this.getAsm(e, t, i, r, s, n), a =
|
|
1688
|
-
if (!
|
|
1688
|
+
const o = this.getAsm(e, t, i, r, s, n), a = b.compile(o);
|
|
1689
|
+
if (!b.decompile(a)) throw new Error("Failed to decompile script??");
|
|
1689
1690
|
return a;
|
|
1690
1691
|
}
|
|
1691
1692
|
getAsm(e, t, i, r, s, n) {
|
|
1692
1693
|
if (!this.contractSaltPubKey) throw new Error("Contract salt public key not set");
|
|
1693
1694
|
const o = this.splitBufferIntoChunks(e), a = s ? this.splitBufferIntoChunks(s) : [], c = [], u = [];
|
|
1694
1695
|
if (n && n.length) {
|
|
1695
|
-
const l = n.sort((p, w) => p.priority - w.priority), h = new
|
|
1696
|
+
const l = n.sort((p, w) => p.priority - w.priority), h = new V();
|
|
1696
1697
|
for (let p = 0; p < l.length; p++) {
|
|
1697
1698
|
const w = l[p];
|
|
1698
1699
|
c.push(w.opcode), this.encodeFeature(w, h);
|
|
@@ -1732,7 +1733,7 @@ var hr = [
|
|
|
1732
1733
|
d.OP_ENDIF
|
|
1733
1734
|
].flat();
|
|
1734
1735
|
}
|
|
1735
|
-
},
|
|
1736
|
+
}, St = class _ extends Le {
|
|
1736
1737
|
static MAX_CHUNK_SIZE = 80;
|
|
1737
1738
|
static MAX_STACK_ITEMS = 100;
|
|
1738
1739
|
static MAX_WITNESS_SIZE = 1650;
|
|
@@ -1740,11 +1741,11 @@ var hr = [
|
|
|
1740
1741
|
static MIN_OUTPUT_VALUE = 330n;
|
|
1741
1742
|
static BYTES_PER_COMMITMENT = 23;
|
|
1742
1743
|
static WITNESS_FIXED_OVERHEAD = 112;
|
|
1743
|
-
static WITNESS_PER_CHUNK_OVERHEAD =
|
|
1744
|
-
static MAX_CHUNKS_PER_OUTPUT = Math.floor((
|
|
1744
|
+
static WITNESS_PER_CHUNK_OVERHEAD = _.MAX_CHUNK_SIZE + 1 + _.BYTES_PER_COMMITMENT;
|
|
1745
|
+
static MAX_CHUNKS_PER_OUTPUT = Math.floor((_.MAX_WITNESS_SIZE - _.WITNESS_FIXED_OVERHEAD) / _.WITNESS_PER_CHUNK_OVERHEAD);
|
|
1745
1746
|
static INPUT_BASE_WEIGHT = 164;
|
|
1746
|
-
static INPUT_WITNESS_WEIGHT_MAX =
|
|
1747
|
-
static WEIGHT_PER_INPUT =
|
|
1747
|
+
static INPUT_WITNESS_WEIGHT_MAX = _.MAX_WITNESS_SIZE;
|
|
1748
|
+
static WEIGHT_PER_INPUT = _.INPUT_BASE_WEIGHT + _.INPUT_WITNESS_WEIGHT_MAX;
|
|
1748
1749
|
logColor = "#4a90d9";
|
|
1749
1750
|
publicKey;
|
|
1750
1751
|
network;
|
|
@@ -1753,21 +1754,21 @@ var hr = [
|
|
|
1753
1754
|
this.publicKey = t, this.network = i;
|
|
1754
1755
|
}
|
|
1755
1756
|
static calculateMaxInputsPerTx() {
|
|
1756
|
-
const t =
|
|
1757
|
-
return Math.floor(t /
|
|
1757
|
+
const t = _.MAX_STANDARD_WEIGHT - 40 - 200;
|
|
1758
|
+
return Math.floor(t / _.WEIGHT_PER_INPUT);
|
|
1758
1759
|
}
|
|
1759
1760
|
static calculateMaxDataPerTx() {
|
|
1760
|
-
return
|
|
1761
|
+
return _.calculateMaxInputsPerTx() * _.MAX_CHUNKS_PER_OUTPUT * _.MAX_CHUNK_SIZE;
|
|
1761
1762
|
}
|
|
1762
1763
|
static estimateOutputCount(t) {
|
|
1763
|
-
return Math.ceil(t / (
|
|
1764
|
+
return Math.ceil(t / (_.MAX_CHUNKS_PER_OUTPUT * _.MAX_CHUNK_SIZE));
|
|
1764
1765
|
}
|
|
1765
1766
|
static estimateChunkCount(t) {
|
|
1766
|
-
return Math.ceil(t /
|
|
1767
|
+
return Math.ceil(t / _.MAX_CHUNK_SIZE);
|
|
1767
1768
|
}
|
|
1768
1769
|
static validateHashCommittedScript(t) {
|
|
1769
1770
|
try {
|
|
1770
|
-
const i =
|
|
1771
|
+
const i = b.decompile(t);
|
|
1771
1772
|
if (!i || i.length < 5) return !1;
|
|
1772
1773
|
const r = i.length - 1;
|
|
1773
1774
|
if (i[r] !== d.OP_CHECKSIG) return !1;
|
|
@@ -1786,8 +1787,8 @@ var hr = [
|
|
|
1786
1787
|
}
|
|
1787
1788
|
static extractDataHashes(t) {
|
|
1788
1789
|
try {
|
|
1789
|
-
const i =
|
|
1790
|
-
if (!i || !
|
|
1790
|
+
const i = b.decompile(t);
|
|
1791
|
+
if (!i || !_.validateHashCommittedScript(t)) return null;
|
|
1791
1792
|
const r = i.slice(0, -2), s = [];
|
|
1792
1793
|
for (let n = 0; n < r.length; n += 3) s.push(r[n + 1]);
|
|
1793
1794
|
return s.reverse();
|
|
@@ -1797,14 +1798,14 @@ var hr = [
|
|
|
1797
1798
|
}
|
|
1798
1799
|
static extractPublicKey(t) {
|
|
1799
1800
|
try {
|
|
1800
|
-
const i =
|
|
1801
|
-
return !i || !
|
|
1801
|
+
const i = b.decompile(t);
|
|
1802
|
+
return !i || !_.validateHashCommittedScript(t) ? null : i[i.length - 2];
|
|
1802
1803
|
} catch {
|
|
1803
1804
|
return null;
|
|
1804
1805
|
}
|
|
1805
1806
|
}
|
|
1806
1807
|
static verifyChunkCommitments(t, i) {
|
|
1807
|
-
const r =
|
|
1808
|
+
const r = _.extractDataHashes(i);
|
|
1808
1809
|
if (!r || r.length !== t.length) return !1;
|
|
1809
1810
|
for (let s = 0; s < t.length; s++) {
|
|
1810
1811
|
const n = D.hash160(t[s]);
|
|
@@ -1813,18 +1814,18 @@ var hr = [
|
|
|
1813
1814
|
return !0;
|
|
1814
1815
|
}
|
|
1815
1816
|
static estimateFees(t, i, r = 0.7) {
|
|
1816
|
-
const s = Math.ceil(t * r), n =
|
|
1817
|
+
const s = Math.ceil(t * r), n = _.estimateOutputCount(s), o = _.estimateChunkCount(s), a = 127 + (n * 43 + 43), c = 40 + n * _.WEIGHT_PER_INPUT + 200, u = Math.ceil(c / 4), l = BigInt(Math.ceil(a * i)), h = BigInt(Math.ceil(u * i)), p = l + h, w = BigInt(n) * _.MIN_OUTPUT_VALUE;
|
|
1817
1818
|
return {
|
|
1818
1819
|
compressedSize: s,
|
|
1819
1820
|
outputCount: n,
|
|
1820
1821
|
chunkCount: o,
|
|
1821
|
-
setupVBytes:
|
|
1822
|
-
revealVBytes:
|
|
1823
|
-
setupFee:
|
|
1824
|
-
revealFee:
|
|
1825
|
-
totalFee:
|
|
1826
|
-
outputsValue:
|
|
1827
|
-
totalCost:
|
|
1822
|
+
setupVBytes: a,
|
|
1823
|
+
revealVBytes: u,
|
|
1824
|
+
setupFee: l,
|
|
1825
|
+
revealFee: h,
|
|
1826
|
+
totalFee: p,
|
|
1827
|
+
outputsValue: w,
|
|
1828
|
+
totalCost: p + w
|
|
1828
1829
|
};
|
|
1829
1830
|
}
|
|
1830
1831
|
hashChunk(t) {
|
|
@@ -1832,15 +1833,15 @@ var hr = [
|
|
|
1832
1833
|
}
|
|
1833
1834
|
generateWitnessScript(t) {
|
|
1834
1835
|
if (t.length === 0) throw new Error("At least one data hash is required");
|
|
1835
|
-
if (t.length >
|
|
1836
|
+
if (t.length > _.MAX_CHUNKS_PER_OUTPUT) throw new Error(`Too many chunks: ${t.length} exceeds limit of ${_.MAX_CHUNKS_PER_OUTPUT}`);
|
|
1836
1837
|
for (const r of t) if (r.length !== 20) throw new Error(`HASH160 requires 20-byte hash, got ${r.length}`);
|
|
1837
1838
|
const i = [];
|
|
1838
1839
|
for (let r = t.length - 1; r >= 0; r--)
|
|
1839
1840
|
i.push(d.OP_HASH160), i.push(t[r]), i.push(d.OP_EQUALVERIFY);
|
|
1840
|
-
return i.push(this.publicKey), i.push(d.OP_CHECKSIG),
|
|
1841
|
+
return i.push(this.publicKey), i.push(d.OP_CHECKSIG), b.compile(i);
|
|
1841
1842
|
}
|
|
1842
1843
|
generateP2WSHAddress(t) {
|
|
1843
|
-
const i =
|
|
1844
|
+
const i = U.p2wsh({
|
|
1844
1845
|
redeem: { output: t },
|
|
1845
1846
|
network: this.network
|
|
1846
1847
|
});
|
|
@@ -1851,8 +1852,8 @@ var hr = [
|
|
|
1851
1852
|
scriptPubKey: i.output
|
|
1852
1853
|
};
|
|
1853
1854
|
}
|
|
1854
|
-
prepareChunks(t, i =
|
|
1855
|
-
if (i >
|
|
1855
|
+
prepareChunks(t, i = _.MAX_CHUNK_SIZE) {
|
|
1856
|
+
if (i > _.MAX_CHUNK_SIZE) throw new Error(`Chunk size ${i} exceeds P2WSH stack item limit of ${_.MAX_CHUNK_SIZE}`);
|
|
1856
1857
|
if (t.length === 0) throw new Error("Data cannot be empty");
|
|
1857
1858
|
const r = [];
|
|
1858
1859
|
let s = 0;
|
|
@@ -1863,7 +1864,7 @@ var hr = [
|
|
|
1863
1864
|
const n = [];
|
|
1864
1865
|
let o = 0;
|
|
1865
1866
|
for (; o < r.length; ) {
|
|
1866
|
-
const c = r.slice(o, o +
|
|
1867
|
+
const c = r.slice(o, o + _.MAX_CHUNKS_PER_OUTPUT), u = c, l = u.map((w) => this.hashChunk(w)), h = this.generateWitnessScript(l), p = this.generateP2WSHAddress(h);
|
|
1867
1868
|
n.push({
|
|
1868
1869
|
address: p.address,
|
|
1869
1870
|
witnessScript: p.witnessScript,
|
|
@@ -1876,16 +1877,16 @@ var hr = [
|
|
|
1876
1877
|
const a = r.length;
|
|
1877
1878
|
return this.log(`Prepared ${n.length} P2WSH outputs with ${a} chunks (${t.length} bytes, ~${Math.ceil(t.length / n.length)} bytes/output)`), n;
|
|
1878
1879
|
}
|
|
1879
|
-
},
|
|
1880
|
+
}, ur = class extends tt {
|
|
1880
1881
|
constructor(e, t = y.bitcoin) {
|
|
1881
|
-
super(e, new Uint8Array(0), t);
|
|
1882
|
+
super(e, /* @__PURE__ */ new Uint8Array(0), t);
|
|
1882
1883
|
}
|
|
1883
1884
|
static getPubKeyAsBuffer(e, t) {
|
|
1884
|
-
let i = new Uint8Array(0);
|
|
1885
|
+
let i = /* @__PURE__ */ new Uint8Array(0);
|
|
1885
1886
|
for (const s of e) {
|
|
1886
1887
|
if (!I.fromPublicKey(s, t).compressed) throw new Error("Public key must be compressed");
|
|
1887
1888
|
if (s.byteLength !== 33) throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
1888
|
-
i =
|
|
1889
|
+
i = ht([i, s]);
|
|
1889
1890
|
}
|
|
1890
1891
|
const r = Z.compress(i);
|
|
1891
1892
|
return r.byteLength >= i.byteLength ? i : r;
|
|
@@ -1895,7 +1896,7 @@ var hr = [
|
|
|
1895
1896
|
if (!n.length) throw new Error("No data chunks found");
|
|
1896
1897
|
const o = [], a = [];
|
|
1897
1898
|
if (s && s.length) {
|
|
1898
|
-
const h = s.sort((w, T) => w.priority - T.priority), p = new
|
|
1899
|
+
const h = s.sort((w, T) => w.priority - T.priority), p = new V();
|
|
1899
1900
|
for (let w = 0; w < h.length; w++) {
|
|
1900
1901
|
const T = h[w];
|
|
1901
1902
|
o.push(T.opcode), this.encodeFeature(T, p);
|
|
@@ -1922,21 +1923,21 @@ var hr = [
|
|
|
1922
1923
|
tt.MAGIC
|
|
1923
1924
|
];
|
|
1924
1925
|
c = c.concat(...a, d.OP_1NEGATE, ...n, d.OP_ELSE, d.OP_1, d.OP_ENDIF);
|
|
1925
|
-
const u = c.flat(), l =
|
|
1926
|
-
if (!
|
|
1926
|
+
const u = c.flat(), l = b.compile(u);
|
|
1927
|
+
if (!b.decompile(l)) throw new Error("Failed to decompile script??");
|
|
1927
1928
|
return l;
|
|
1928
1929
|
}
|
|
1929
|
-
},
|
|
1930
|
+
}, Ge = class Zt {
|
|
1930
1931
|
static MAXIMUM_SUPPORTED_SIGNATURE = 255;
|
|
1931
1932
|
static compile(t, i = 0, r) {
|
|
1932
1933
|
if (i < 2) throw new Error("Minimum signatures must be greater than 1");
|
|
1933
1934
|
if (t.length < i) throw new Error("The amount of public keys is lower than the minimum required");
|
|
1934
|
-
if (i >
|
|
1935
|
-
const s =
|
|
1936
|
-
s[0] = i, t = t.filter((u, l, h) => l === h.findIndex((p) => C(u, p))), t = t.sort((u, l) =>
|
|
1935
|
+
if (i > Zt.MAXIMUM_SUPPORTED_SIGNATURE) throw new Error(`The maximum amount of signatures is ${Zt.MAXIMUM_SUPPORTED_SIGNATURE}`);
|
|
1936
|
+
const s = qt(1);
|
|
1937
|
+
s[0] = i, t = t.filter((u, l, h) => l === h.findIndex((p) => C(u, p))), t = t.sort((u, l) => Mi(u, l));
|
|
1937
1938
|
let n = !1;
|
|
1938
1939
|
const o = t.map((u) => {
|
|
1939
|
-
const l =
|
|
1940
|
+
const l = O(u);
|
|
1940
1941
|
return r && !n && (n = C(r, l)), l;
|
|
1941
1942
|
});
|
|
1942
1943
|
r && !n && o.push(r);
|
|
@@ -1945,11 +1946,11 @@ var hr = [
|
|
|
1945
1946
|
...o.flatMap((u) => [u, d.OP_CHECKSIGADD]),
|
|
1946
1947
|
s,
|
|
1947
1948
|
d.OP_NUMEQUAL
|
|
1948
|
-
].flat(), c =
|
|
1949
|
-
if (!
|
|
1949
|
+
].flat(), c = b.compile(a);
|
|
1950
|
+
if (!b.decompile(c)) throw new Error("Failed to decompile script.");
|
|
1950
1951
|
return c;
|
|
1951
1952
|
}
|
|
1952
|
-
},
|
|
1953
|
+
}, Jt = class Xe extends tt {
|
|
1953
1954
|
static P2WDA_VERSION = 1;
|
|
1954
1955
|
constructor(t, i, r = y.bitcoin) {
|
|
1955
1956
|
super(t, i, r);
|
|
@@ -1961,8 +1962,8 @@ var hr = [
|
|
|
1961
1962
|
compile(t, i, r, s, n = []) {
|
|
1962
1963
|
if (!this.contractSaltPubKey) throw new Error("Contract salt public key not set");
|
|
1963
1964
|
if (i.length !== 32) throw new Error("Contract secret must be exactly 32 bytes");
|
|
1964
|
-
const o = new
|
|
1965
|
-
o.writeU8(
|
|
1965
|
+
const o = new V();
|
|
1966
|
+
o.writeU8(Xe.P2WDA_VERSION);
|
|
1966
1967
|
const a = n.sort((c, u) => c.priority - u.priority);
|
|
1967
1968
|
return o.writeBytes(this.getHeader(s, a.map((c) => c.opcode))), o.writeBytes(i), o.writeBytes(r.publicKey.toBuffer()), o.writeBytes(r.solution), o.writeU32(t.length), o.writeBytes(t), this.writeFeatures(o, a), new Uint8Array(o.getBuffer());
|
|
1968
1969
|
}
|
|
@@ -1975,8 +1976,8 @@ var hr = [
|
|
|
1975
1976
|
t.writeU8(r.opcode), this.encodeFeature(r, t);
|
|
1976
1977
|
}
|
|
1977
1978
|
};
|
|
1978
|
-
function
|
|
1979
|
-
let t = new Uint8Array(0);
|
|
1979
|
+
function It(e) {
|
|
1980
|
+
let t = /* @__PURE__ */ new Uint8Array(0);
|
|
1980
1981
|
function i(a, c) {
|
|
1981
1982
|
const u = new Uint8Array(a.length + c.length);
|
|
1982
1983
|
return u.set(a, 0), u.set(c, a.length), u;
|
|
@@ -1985,8 +1986,8 @@ function Pt(e) {
|
|
|
1985
1986
|
t = i(t, a);
|
|
1986
1987
|
}
|
|
1987
1988
|
function s(a) {
|
|
1988
|
-
const c = t.length, u =
|
|
1989
|
-
l.set(t, 0), t = l,
|
|
1989
|
+
const c = t.length, u = Gt.encodingLength(a), l = new Uint8Array(c + u);
|
|
1990
|
+
l.set(t, 0), t = l, Gt.encode(a, t, c);
|
|
1990
1991
|
}
|
|
1991
1992
|
function n(a) {
|
|
1992
1993
|
s(a.length), r(a);
|
|
@@ -1996,8 +1997,8 @@ function Pt(e) {
|
|
|
1996
1997
|
}
|
|
1997
1998
|
return o(e), t;
|
|
1998
1999
|
}
|
|
1999
|
-
var
|
|
2000
|
-
static NUMS_INTERNAL_KEY =
|
|
2000
|
+
var Ut = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"), gs = 192, rt = class {
|
|
2001
|
+
static NUMS_INTERNAL_KEY = Ut;
|
|
2001
2002
|
static LEAF_VERSION = 192;
|
|
2002
2003
|
static buildTapscript(e) {
|
|
2003
2004
|
if (e.csvBlocks < 1 || e.csvBlocks > 65535) throw new Error("csvBlocks must be between 1 and 65535");
|
|
@@ -2005,9 +2006,9 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2005
2006
|
if (e.threshold < 1 || e.threshold > e.pubkeys.length) throw new Error("Invalid threshold");
|
|
2006
2007
|
for (const i of e.pubkeys) if (i.length !== 32) throw new Error("Tapscript pubkeys must be 32 bytes (x,only)");
|
|
2007
2008
|
const t = [];
|
|
2008
|
-
t.push(
|
|
2009
|
+
t.push(b.number.encode(e.csvBlocks)), t.push(d.OP_CHECKSEQUENCEVERIFY), t.push(d.OP_DROP), t.push(e.pubkeys[0], d.OP_CHECKSIG);
|
|
2009
2010
|
for (let i = 1; i < e.pubkeys.length; i++) t.push(e.pubkeys[i], d.OP_CHECKSIGADD);
|
|
2010
|
-
return e.threshold >= 1 && e.threshold <= 16 ? t.push(d.OP_1 + e.threshold - 1) : t.push(
|
|
2011
|
+
return e.threshold >= 1 && e.threshold <= 16 ? t.push(d.OP_1 + e.threshold - 1) : t.push(b.number.encode(e.threshold)), t.push(d.OP_NUMEQUAL), b.compile(t);
|
|
2011
2012
|
}
|
|
2012
2013
|
static buildCSV2MultisigTapscript(e, t) {
|
|
2013
2014
|
return this.buildTapscript({
|
|
@@ -2017,8 +2018,8 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2017
2018
|
});
|
|
2018
2019
|
}
|
|
2019
2020
|
static generateAddress(e, t) {
|
|
2020
|
-
const i = this.buildTapscript(e), r =
|
|
2021
|
-
internalPubkey:
|
|
2021
|
+
const i = this.buildTapscript(e), r = U.p2tr({
|
|
2022
|
+
internalPubkey: Ut,
|
|
2022
2023
|
scriptTree: { output: i },
|
|
2023
2024
|
redeem: {
|
|
2024
2025
|
output: i,
|
|
@@ -2034,7 +2035,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2034
2035
|
tapscript: i,
|
|
2035
2036
|
scriptPubKey: r.output,
|
|
2036
2037
|
controlBlock: s,
|
|
2037
|
-
internalPubkey:
|
|
2038
|
+
internalPubkey: Ut,
|
|
2038
2039
|
leafVersion: 192,
|
|
2039
2040
|
config: e
|
|
2040
2041
|
};
|
|
@@ -2057,7 +2058,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2057
2058
|
};
|
|
2058
2059
|
}
|
|
2059
2060
|
static isP2TRScriptPubKey(e) {
|
|
2060
|
-
return
|
|
2061
|
+
return Rt(e);
|
|
2061
2062
|
}
|
|
2062
2063
|
static deriveAddressFromTapscript(e, t) {
|
|
2063
2064
|
const i = this.parseTapscript(e);
|
|
@@ -2065,21 +2066,21 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2065
2066
|
}
|
|
2066
2067
|
static buildDummyWitness(e) {
|
|
2067
2068
|
const { config: t, tapscript: i, controlBlock: r } = e, s = [];
|
|
2068
|
-
for (let n = 0; n < t.pubkeys.length; n++) t.pubkeys.length - 1 - n < t.threshold ? s.push(new Uint8Array(64)) : s.push(new Uint8Array(0));
|
|
2069
|
+
for (let n = 0; n < t.pubkeys.length; n++) t.pubkeys.length - 1 - n < t.threshold ? s.push(/* @__PURE__ */ new Uint8Array(64)) : s.push(/* @__PURE__ */ new Uint8Array(0));
|
|
2069
2070
|
return s.push(i), s.push(r), s;
|
|
2070
2071
|
}
|
|
2071
2072
|
static buildFinalWitnessFromTapScriptSigs(e, t) {
|
|
2072
2073
|
const { config: i, tapscript: r, controlBlock: s } = t, n = /* @__PURE__ */ new Map();
|
|
2073
2074
|
for (const u of e)
|
|
2074
|
-
!u.pubkey || u.pubkey.length !== 32 || n.set(
|
|
2075
|
+
!u.pubkey || u.pubkey.length !== 32 || n.set(Ue(u.pubkey), u.signature);
|
|
2075
2076
|
const o = [];
|
|
2076
2077
|
let a = 0;
|
|
2077
2078
|
for (const u of i.pubkeys) {
|
|
2078
|
-
const l = n.get(
|
|
2079
|
+
const l = n.get(Ue(u));
|
|
2079
2080
|
if (l) {
|
|
2080
2081
|
if (l.length !== 64 && l.length !== 65) throw new Error(`Invalid Schnorr signature length ${l.length} for CSV multisig spend`);
|
|
2081
2082
|
o.push(l), a++;
|
|
2082
|
-
} else o.push(new Uint8Array(0));
|
|
2083
|
+
} else o.push(/* @__PURE__ */ new Uint8Array(0));
|
|
2083
2084
|
}
|
|
2084
2085
|
if (a < i.threshold) throw new Error(`CSV multisig spend needs ${i.threshold} signatures, got ${a}`);
|
|
2085
2086
|
const c = [];
|
|
@@ -2089,17 +2090,17 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2089
2090
|
static isSpendableUTXO(e, t) {
|
|
2090
2091
|
if (!e.witnessScript) return !1;
|
|
2091
2092
|
const i = g(e.scriptPubKey.hex);
|
|
2092
|
-
if (!
|
|
2093
|
+
if (!Rt(i)) return !1;
|
|
2093
2094
|
const r = e.witnessScript instanceof Uint8Array ? e.witnessScript : g(e.witnessScript), s = this.deriveAddressFromTapscript(r, t);
|
|
2094
2095
|
return s ? C(s.scriptPubKey, i) : !1;
|
|
2095
2096
|
}
|
|
2096
2097
|
static parseTapscript(e) {
|
|
2097
|
-
const t =
|
|
2098
|
+
const t = b.decompile(e);
|
|
2098
2099
|
if (!t || t.length < 6) return null;
|
|
2099
2100
|
const i = t[0];
|
|
2100
2101
|
let r;
|
|
2101
2102
|
if (i instanceof Uint8Array) try {
|
|
2102
|
-
r =
|
|
2103
|
+
r = b.number.decode(i);
|
|
2103
2104
|
} catch {
|
|
2104
2105
|
return null;
|
|
2105
2106
|
}
|
|
@@ -2115,7 +2116,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2115
2116
|
const o = t[s];
|
|
2116
2117
|
let a;
|
|
2117
2118
|
if (typeof o == "number" && o >= d.OP_1 && o <= d.OP_16) a = o - d.OP_1 + 1;
|
|
2118
|
-
else if (o instanceof Uint8Array) a =
|
|
2119
|
+
else if (o instanceof Uint8Array) a = b.number.decode(o);
|
|
2119
2120
|
else return null;
|
|
2120
2121
|
return t[s + 1] !== d.OP_NUMEQUAL || a < 1 || a > n.length ? null : {
|
|
2121
2122
|
pubkeys: n,
|
|
@@ -2137,7 +2138,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2137
2138
|
const o = s.tapScriptSig ?? [], a = this.buildFinalWitnessFromTapScriptSigs(o, n);
|
|
2138
2139
|
e.finalizeInput(t, () => ({
|
|
2139
2140
|
finalScriptSig: void 0,
|
|
2140
|
-
finalScriptWitness:
|
|
2141
|
+
finalScriptWitness: It(a)
|
|
2141
2142
|
}));
|
|
2142
2143
|
}
|
|
2143
2144
|
static isCSVMultisigUTXO(e) {
|
|
@@ -2146,40 +2147,40 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2146
2147
|
return this.parseTapscript(t) !== null;
|
|
2147
2148
|
}
|
|
2148
2149
|
};
|
|
2149
|
-
function
|
|
2150
|
+
function Ue(e) {
|
|
2150
2151
|
let t = "";
|
|
2151
2152
|
for (let i = 0; i < e.length; i++) t += e[i].toString(16).padStart(2, "0");
|
|
2152
2153
|
return t;
|
|
2153
2154
|
}
|
|
2154
|
-
var
|
|
2155
|
+
var Ot = Pi(), de = class {
|
|
2155
2156
|
static generatePKSH(e, t) {
|
|
2156
2157
|
if (e.length !== 32) throw new Error("Invalid hash length");
|
|
2157
|
-
const i =
|
|
2158
|
+
const i = Bi(e);
|
|
2158
2159
|
return this.toSegwitAddress(i, t);
|
|
2159
2160
|
}
|
|
2160
2161
|
static generateTaprootAddress(e, t) {
|
|
2161
2162
|
if (e.length !== 32) throw new Error("Invalid public key length");
|
|
2162
|
-
const i =
|
|
2163
|
-
return i.unshift(1),
|
|
2163
|
+
const i = Ot.bech32m.toWords(e);
|
|
2164
|
+
return i.unshift(1), Ot.bech32m.encode(t.bech32, i);
|
|
2164
2165
|
}
|
|
2165
2166
|
static toSegwitAddress(e, t) {
|
|
2166
|
-
const i =
|
|
2167
|
-
return i.unshift(0),
|
|
2167
|
+
const i = Ot.bech32.toWords(e);
|
|
2168
|
+
return i.unshift(0), Ot.bech32.encode(t.bech32, i);
|
|
2168
2169
|
}
|
|
2169
|
-
},
|
|
2170
|
+
}, lr = class ut {
|
|
2170
2171
|
static TAP_SCRIPT_VERSION = 192;
|
|
2171
2172
|
static getContractAddress(t) {
|
|
2172
|
-
const { scriptTree: i } =
|
|
2173
|
-
return
|
|
2173
|
+
const { scriptTree: i } = ut.buildScriptTree(t);
|
|
2174
|
+
return ut.generateAddressFromScript(t, i);
|
|
2174
2175
|
}
|
|
2175
2176
|
static verifyControlBlock(t, i) {
|
|
2176
|
-
const { scriptTree: r, compiledTargetScript: s, network: n } =
|
|
2177
|
-
internalPubkey:
|
|
2177
|
+
const { scriptTree: r, compiledTargetScript: s, network: n } = ut.buildScriptTree(t), o = U.p2tr({
|
|
2178
|
+
internalPubkey: O(t.deployerPubKey),
|
|
2178
2179
|
network: n,
|
|
2179
2180
|
scriptTree: r,
|
|
2180
2181
|
redeem: {
|
|
2181
2182
|
output: s,
|
|
2182
|
-
redeemVersion:
|
|
2183
|
+
redeemVersion: ut.TAP_SCRIPT_VERSION
|
|
2183
2184
|
}
|
|
2184
2185
|
}).witness;
|
|
2185
2186
|
if (!o || o.length === 0) return !1;
|
|
@@ -2187,7 +2188,7 @@ var _t = _i(), ge = class {
|
|
|
2187
2188
|
return C(a, i);
|
|
2188
2189
|
}
|
|
2189
2190
|
static getContractSeed(t, i, r) {
|
|
2190
|
-
const s =
|
|
2191
|
+
const s = ht([
|
|
2191
2192
|
t,
|
|
2192
2193
|
r,
|
|
2193
2194
|
D.hash256(i)
|
|
@@ -2196,52 +2197,52 @@ var _t = _i(), ge = class {
|
|
|
2196
2197
|
}
|
|
2197
2198
|
static generateAddressFromScript(t, i) {
|
|
2198
2199
|
const r = t.network || y.bitcoin, s = {
|
|
2199
|
-
internalPubkey:
|
|
2200
|
+
internalPubkey: O(t.deployerPubKey),
|
|
2200
2201
|
network: r,
|
|
2201
2202
|
scriptTree: i
|
|
2202
2203
|
};
|
|
2203
|
-
return
|
|
2204
|
+
return U.p2tr(s).address;
|
|
2204
2205
|
}
|
|
2205
2206
|
static buildScriptTree(t) {
|
|
2206
|
-
const i = t.network || y.bitcoin, r = new
|
|
2207
|
+
const i = t.network || y.bitcoin, r = new he(t.deployerPubKey, O(t.contractSaltPubKey), i).compile(t.bytecode, t.originalSalt, t.challenge, t.priorityFee, t.calldata, t.features), s = b.compile([O(t.deployerPubKey), d.OP_CHECKSIG]);
|
|
2207
2208
|
return {
|
|
2208
2209
|
scriptTree: [{
|
|
2209
2210
|
output: r,
|
|
2210
|
-
version:
|
|
2211
|
+
version: ut.TAP_SCRIPT_VERSION
|
|
2211
2212
|
}, {
|
|
2212
2213
|
output: s,
|
|
2213
|
-
version:
|
|
2214
|
+
version: ut.TAP_SCRIPT_VERSION
|
|
2214
2215
|
}],
|
|
2215
2216
|
compiledTargetScript: r,
|
|
2216
2217
|
network: i
|
|
2217
2218
|
};
|
|
2218
2219
|
}
|
|
2219
2220
|
};
|
|
2220
|
-
function
|
|
2221
|
+
function dt(e) {
|
|
2221
2222
|
return "privateKey" in e && e.privateKey != null;
|
|
2222
2223
|
}
|
|
2223
|
-
var
|
|
2224
|
+
var pe = class {
|
|
2224
2225
|
static tweakSigner(e, t = {}) {
|
|
2225
2226
|
let i = e.privateKey;
|
|
2226
2227
|
if (!i) throw new Error("Private key is required for tweaking signer!");
|
|
2227
2228
|
e.publicKey[0] === 3 && (i = K.privateNegate(i));
|
|
2228
|
-
const r = K.privateAdd(i,
|
|
2229
|
+
const r = K.privateAdd(i, Li(O(e.publicKey), t.tweakHash));
|
|
2229
2230
|
if (!r) throw new Error("Invalid tweaked private key!");
|
|
2230
2231
|
return I.fromPrivateKey(r, t.network);
|
|
2231
2232
|
}
|
|
2232
2233
|
};
|
|
2233
|
-
function
|
|
2234
|
+
function $e(e) {
|
|
2234
2235
|
return typeof e == "object" && e !== null && "web3" in e && typeof e.web3 == "object" && "getMLDSAPublicKey" in e.web3 && "signMLDSAMessage" in e.web3;
|
|
2235
2236
|
}
|
|
2236
2237
|
var Tt = /* @__PURE__ */ (function(e) {
|
|
2237
2238
|
return e.Mainnet = "mainnet", e.Testnet = "testnet", e.OpnetTestnet = "opnetTestnet", e.Regtest = "regtest", e;
|
|
2238
|
-
})({}),
|
|
2239
|
+
})({}), hr = /* @__PURE__ */ (function(e) {
|
|
2239
2240
|
return e.BITCOIN_MAINNET = "BITCOIN_MAINNET", e.BITCOIN_TESTNET = "BITCOIN_TESTNET", e.BITCOIN_TESTNET4 = "BITCOIN_TESTNET4", e.BITCOIN_REGTEST = "BITCOIN_REGTEST", e.BITCOIN_SIGNET = "BITCOIN_SIGNET", e.OPNET_TESTNET = "OPNET_TESTNET", e.FRACTAL_BITCOIN_MAINNET = "FRACTAL_BITCOIN_MAINNET", e.FRACTAL_BITCOIN_TESTNET = "FRACTAL_BITCOIN_TESTNET", e.DOGECOIN_MAINNET = "DOGECOIN_MAINNET", e.DOGECOIN_TESTNET = "DOGECOIN_TESTNET", e.DOGECOIN_REGTEST = "DOGECOIN_REGTEST", e.LITECOIN_MAINNET = "LITECOIN_MAINNET", e.LITECOIN_TESTNET = "LITECOIN_TESTNET", e.LITECOIN_REGTEST = "LITECOIN_REGTEST", e.BITCOINCASH_MAINNET = "BITCOINCASH_MAINNET", e.BITCOINCASH_TESTNET = "BITCOINCASH_TESTNET", e.BITCOINCASH_REGTEST = "BITCOINCASH_REGTEST", e.DASH_MAINNET = "DASH_MAINNET", e.DASH_TESTNET = "DASH_TESTNET", e.DASH_REGTEST = "DASH_REGTEST", e;
|
|
2240
|
-
})({}),
|
|
2241
|
+
})({}), dr = /* @__PURE__ */ (function(e) {
|
|
2241
2242
|
return e.ecdsa = "ecdsa", e.bip322 = "bip322-simple", e;
|
|
2242
|
-
})({}),
|
|
2243
|
+
})({}), te = /* @__PURE__ */ (function(e) {
|
|
2243
2244
|
return e.ecdsa = "ecdsa", e.schnorr = "schnorr", e;
|
|
2244
|
-
})({}),
|
|
2245
|
+
})({}), pr = class {
|
|
2245
2246
|
sha256(e) {
|
|
2246
2247
|
return D.sha256(e);
|
|
2247
2248
|
}
|
|
@@ -2250,7 +2251,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2250
2251
|
if (!t) return null;
|
|
2251
2252
|
const i = typeof e == "string" ? new TextEncoder().encode(e) : e, r = this.sha256(i), s = f(r);
|
|
2252
2253
|
return {
|
|
2253
|
-
signature: g(await t.signData(s,
|
|
2254
|
+
signature: g(await t.signData(s, te.schnorr, typeof e == "string" ? e : void 0)),
|
|
2254
2255
|
message: r
|
|
2255
2256
|
};
|
|
2256
2257
|
}
|
|
@@ -2259,7 +2260,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2259
2260
|
if (!t) return null;
|
|
2260
2261
|
const i = typeof e == "string" ? new TextEncoder().encode(e) : e, r = this.sha256(i), s = f(r);
|
|
2261
2262
|
return {
|
|
2262
|
-
signature: g(await t.signData(s,
|
|
2263
|
+
signature: g(await t.signData(s, te.ecdsa, typeof e == "string" ? e : void 0)),
|
|
2263
2264
|
message: r
|
|
2264
2265
|
};
|
|
2265
2266
|
}
|
|
@@ -2323,7 +2324,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2323
2324
|
return e ? g(await e.web3.getMLDSAPublicKey()) : null;
|
|
2324
2325
|
}
|
|
2325
2326
|
tweakAndSignMessage(e, t, i) {
|
|
2326
|
-
const r =
|
|
2327
|
+
const r = pe.tweakSigner(e, { network: i });
|
|
2327
2328
|
return this.signMessage(r, t);
|
|
2328
2329
|
}
|
|
2329
2330
|
signMessage(e, t) {
|
|
@@ -2354,7 +2355,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2354
2355
|
if (typeof t == "string" && (t = new TextEncoder().encode(t)), i.length !== 64) throw new Error("Invalid signature length.");
|
|
2355
2356
|
const r = this.sha256(t);
|
|
2356
2357
|
if (!K.verifySchnorr) throw new Error("backend.verifySchnorr is not available.");
|
|
2357
|
-
return K.verifySchnorr(r,
|
|
2358
|
+
return K.verifySchnorr(r, O(e), i);
|
|
2358
2359
|
}
|
|
2359
2360
|
tweakAndVerifySignature(e, t, i) {
|
|
2360
2361
|
const r = I.tweakPublicKey(e);
|
|
@@ -2381,9 +2382,10 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2381
2382
|
getOPWallet() {
|
|
2382
2383
|
if (typeof window > "u") return null;
|
|
2383
2384
|
const e = window;
|
|
2384
|
-
return !e.opnet ||
|
|
2385
|
+
return !e.opnet || !$e(e.opnet) ? null : e.opnet;
|
|
2385
2386
|
}
|
|
2386
|
-
},
|
|
2387
|
+
}, st = new pr(), Bt = class At {
|
|
2388
|
+
network;
|
|
2387
2389
|
_keypair;
|
|
2388
2390
|
_mldsaKeypair;
|
|
2389
2391
|
_securityLevel;
|
|
@@ -2396,22 +2398,22 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2396
2398
|
_bufferPubKey;
|
|
2397
2399
|
_tweakedKey;
|
|
2398
2400
|
_address;
|
|
2399
|
-
constructor(t, i, r = y.bitcoin, s =
|
|
2401
|
+
constructor(t, i, r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2, n) {
|
|
2400
2402
|
this.network = r, this._securityLevel = s;
|
|
2401
2403
|
const o = t.startsWith("0x") ? t.slice(2) : t;
|
|
2402
2404
|
W.isValidHex(o) ? this._keypair = I.fromPrivateKey(g(o), this.network) : this._keypair = I.fromWIF(o, this.network);
|
|
2403
2405
|
const a = i.startsWith("0x") ? i.slice(2) : i;
|
|
2404
2406
|
if (W.isValidHex(a)) {
|
|
2405
|
-
const c = g(a), u = (0,
|
|
2407
|
+
const c = g(a), u = (0, v.getMLDSAConfig)(s, this.network), l = u.privateKeySize, h = l + u.publicKeySize;
|
|
2406
2408
|
let p;
|
|
2407
2409
|
if (c.length === l) p = c;
|
|
2408
2410
|
else if (c.length === h) p = c.subarray(0, l);
|
|
2409
2411
|
else throw new Error(`Invalid ML-DSA key length for security level ${s}. Expected ${l} bytes (private only) or ${h} bytes (private+public), got ${c.length} bytes.`);
|
|
2410
2412
|
if (n && n.length !== 32) throw new Error("Chain code must be 32 bytes");
|
|
2411
|
-
this._chainCode = n || new Uint8Array(32), this._mldsaKeypair =
|
|
2413
|
+
this._chainCode = n || /* @__PURE__ */ new Uint8Array(32), this._mldsaKeypair = v.QuantumBIP32Factory.fromPrivateKey(p, this._chainCode, this.network, s);
|
|
2412
2414
|
} else
|
|
2413
|
-
this._mldsaKeypair =
|
|
2414
|
-
this._bufferPubKey = this._keypair.publicKey, this._address = new
|
|
2415
|
+
this._mldsaKeypair = v.QuantumBIP32Factory.fromBase58(a), this._chainCode = new Uint8Array(this._mldsaKeypair.chainCode), this._securityLevel = this._mldsaKeypair.securityLevel;
|
|
2416
|
+
this._bufferPubKey = this._keypair.publicKey, this._address = new z(this._mldsaKeypair.publicKey, this._keypair.publicKey), this._p2tr = this._address.p2tr(this.network), this._p2wpkh = this._address.p2wpkh(this.network), this._legacy = this._address.p2pkh(this.network), this._segwitLegacy = this._address.p2shp2wpkh(this.network), this._p2wda = this._address.p2wda(this.network), this._tweakedKey = this._address.tweakedPublicKeyToBuffer();
|
|
2415
2417
|
}
|
|
2416
2418
|
get address() {
|
|
2417
2419
|
return this._address;
|
|
@@ -2475,17 +2477,17 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2475
2477
|
}
|
|
2476
2478
|
get xOnly() {
|
|
2477
2479
|
if (!this.keypair) throw new Error("Keypair not set");
|
|
2478
|
-
return
|
|
2480
|
+
return O(this._bufferPubKey);
|
|
2479
2481
|
}
|
|
2480
|
-
static fromWif(t, i, r = y.bitcoin, s =
|
|
2482
|
+
static fromWif(t, i, r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2, n) {
|
|
2481
2483
|
return new At(t, i, r, s, n);
|
|
2482
2484
|
}
|
|
2483
|
-
static generate(t = y.bitcoin, i =
|
|
2485
|
+
static generate(t = y.bitcoin, i = v.MLDSASecurityLevel.LEVEL2) {
|
|
2484
2486
|
const r = I.generateWallet(t, i);
|
|
2485
2487
|
if (!r.quantumPrivateKey) throw new Error("Failed to generate quantum keys");
|
|
2486
2488
|
return new At(r.privateKey, r.quantumPrivateKey, t, i);
|
|
2487
2489
|
}
|
|
2488
|
-
static fromPrivateKeys(t, i, r = y.bitcoin, s =
|
|
2490
|
+
static fromPrivateKeys(t, i, r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2, n) {
|
|
2489
2491
|
return new At(t, i, r, s, n);
|
|
2490
2492
|
}
|
|
2491
2493
|
toWIF() {
|
|
@@ -2515,29 +2517,29 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2515
2517
|
if (!r.chainCode) throw new Error("Failed to derive classical chain code");
|
|
2516
2518
|
return new At(f(new Uint8Array(r.privateKey)), i.toBase58(), this.network, this._securityLevel, new Uint8Array(r.chainCode));
|
|
2517
2519
|
}
|
|
2518
|
-
}, mt = /* @__PURE__ */
|
|
2520
|
+
}, mt = /* @__PURE__ */ ae(Ei(), 1), ee = /* @__PURE__ */ (function(e) {
|
|
2519
2521
|
return e[e.MINIMUM = 128] = "MINIMUM", e[e.LOW = 160] = "LOW", e[e.MEDIUM = 192] = "MEDIUM", e[e.HIGH = 224] = "HIGH", e[e.MAXIMUM = 256] = "MAXIMUM", e;
|
|
2520
|
-
})({}),
|
|
2522
|
+
})({}), kt = /* @__PURE__ */ (function(e) {
|
|
2521
2523
|
return e[e.BIP44 = 44] = "BIP44", e[e.BIP49 = 49] = "BIP49", e[e.BIP84 = 84] = "BIP84", e[e.BIP86 = 86] = "BIP86", e;
|
|
2522
2524
|
})({});
|
|
2523
|
-
function
|
|
2525
|
+
function fr(e) {
|
|
2524
2526
|
switch (e) {
|
|
2525
|
-
case
|
|
2527
|
+
case 44:
|
|
2526
2528
|
return "BIP44: Legacy addresses (P2PKH), widely used by Unisat and other wallets";
|
|
2527
|
-
case
|
|
2529
|
+
case 49:
|
|
2528
2530
|
return "BIP49: Wrapped SegWit addresses (P2SH-P2WPKH)";
|
|
2529
|
-
case
|
|
2531
|
+
case 84:
|
|
2530
2532
|
return "BIP84: Native SegWit addresses (P2WPKH) - DEFAULT";
|
|
2531
|
-
case
|
|
2533
|
+
case 86:
|
|
2532
2534
|
return "BIP86: Taproot addresses (P2TR)";
|
|
2533
2535
|
default:
|
|
2534
2536
|
return "Unknown BIP standard";
|
|
2535
2537
|
}
|
|
2536
2538
|
}
|
|
2537
|
-
function
|
|
2539
|
+
function Ye(e, t, i, r, s) {
|
|
2538
2540
|
return `m/${e}'/${t}'/${i}'/${r}/${s}`;
|
|
2539
2541
|
}
|
|
2540
|
-
var
|
|
2542
|
+
var gr = (0, v.BIP32Factory)(K), Sr = class je {
|
|
2541
2543
|
_phrase;
|
|
2542
2544
|
_passphrase;
|
|
2543
2545
|
_network;
|
|
@@ -2545,9 +2547,9 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2545
2547
|
_seed;
|
|
2546
2548
|
_classicalRoot;
|
|
2547
2549
|
_quantumRoot;
|
|
2548
|
-
constructor(t, i = "", r = y.bitcoin, s =
|
|
2550
|
+
constructor(t, i = "", r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2) {
|
|
2549
2551
|
if (!mt.validateMnemonic(t)) throw new Error("Invalid mnemonic phrase");
|
|
2550
|
-
this._phrase = t, this._passphrase = i, this._network = r, this._securityLevel = s, this._seed = mt.mnemonicToSeedSync(this._phrase, this._passphrase), this._classicalRoot =
|
|
2552
|
+
this._phrase = t, this._passphrase = i, this._network = r, this._securityLevel = s, this._seed = mt.mnemonicToSeedSync(this._phrase, this._passphrase), this._classicalRoot = gr.fromSeed(this._seed, this._network), this._quantumRoot = v.QuantumBIP32Factory.fromSeed(this._seed, this._network, this._securityLevel);
|
|
2551
2553
|
}
|
|
2552
2554
|
get phrase() {
|
|
2553
2555
|
return this._phrase;
|
|
@@ -2561,11 +2563,12 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2561
2563
|
get seed() {
|
|
2562
2564
|
return new Uint8Array(this._seed);
|
|
2563
2565
|
}
|
|
2564
|
-
static generatePhrase(t =
|
|
2566
|
+
static generatePhrase(t = ee.MAXIMUM) {
|
|
2565
2567
|
return mt.generateMnemonic(t);
|
|
2566
2568
|
}
|
|
2567
|
-
static generate(t =
|
|
2568
|
-
|
|
2569
|
+
static generate(t = ee.MAXIMUM, i = "", r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2) {
|
|
2570
|
+
const n = mt.generateMnemonic(t);
|
|
2571
|
+
return new je(n, i, r, s);
|
|
2569
2572
|
}
|
|
2570
2573
|
static validate(t) {
|
|
2571
2574
|
return mt.validateMnemonic(t);
|
|
@@ -2576,26 +2579,26 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2576
2579
|
[Symbol.dispose]() {
|
|
2577
2580
|
this.zeroize();
|
|
2578
2581
|
}
|
|
2579
|
-
derive(t = 0, i = 0, r = !1, s =
|
|
2582
|
+
derive(t = 0, i = 0, r = !1, s = kt.BIP84) {
|
|
2580
2583
|
const n = this.buildClassicalPath(i, t, r, s), o = this._classicalRoot.derivePath(n);
|
|
2581
2584
|
if (!o.privateKey) throw new Error(`Failed to derive classical private key at index ${t}`);
|
|
2582
2585
|
const a = this.buildQuantumPath(i, t, r), c = this._quantumRoot.derivePath(a);
|
|
2583
2586
|
if (!c.privateKey) throw new Error(`Failed to derive quantum private key at index ${t}`);
|
|
2584
|
-
return new
|
|
2587
|
+
return new Bt(f(new Uint8Array(o.privateKey)), f(new Uint8Array(c.privateKey)), this._network, this._securityLevel, new Uint8Array(this._quantumRoot.chainCode));
|
|
2585
2588
|
}
|
|
2586
|
-
deriveOPWallet(t =
|
|
2589
|
+
deriveOPWallet(t = ct.P2TR, i = 0, r = 0, s = !1) {
|
|
2587
2590
|
let n;
|
|
2588
2591
|
switch (t) {
|
|
2589
|
-
case
|
|
2592
|
+
case ct.P2PKH:
|
|
2590
2593
|
n = 44;
|
|
2591
2594
|
break;
|
|
2592
|
-
case
|
|
2595
|
+
case ct.P2SH_OR_P2SH_P2WPKH:
|
|
2593
2596
|
n = 49;
|
|
2594
2597
|
break;
|
|
2595
|
-
case
|
|
2598
|
+
case ct.P2WPKH:
|
|
2596
2599
|
n = 84;
|
|
2597
2600
|
break;
|
|
2598
|
-
case
|
|
2601
|
+
case ct.P2TR:
|
|
2599
2602
|
n = 86;
|
|
2600
2603
|
break;
|
|
2601
2604
|
default:
|
|
@@ -2605,14 +2608,14 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2605
2608
|
if (!u.privateKey) throw new Error(`Failed to derive classical private key at path ${c}`);
|
|
2606
2609
|
const l = `m/360'/${o}'/${r}'/${a}/${i}`, h = this._quantumRoot.derivePath(l);
|
|
2607
2610
|
if (!h.privateKey) throw new Error(`Failed to derive quantum private key at path ${l}`);
|
|
2608
|
-
return new
|
|
2611
|
+
return new Bt(f(new Uint8Array(u.privateKey)), f(new Uint8Array(h.privateKey)), this._network, this._securityLevel, new Uint8Array(this._quantumRoot.chainCode));
|
|
2609
2612
|
}
|
|
2610
|
-
deriveMultipleOPWallet(t =
|
|
2613
|
+
deriveMultipleOPWallet(t = ct.P2TR, i = 5, r = 0, s = 0, n = !1) {
|
|
2611
2614
|
const o = [];
|
|
2612
2615
|
for (let a = 0; a < i; a++) o.push(this.deriveOPWallet(t, r + a, s, n));
|
|
2613
2616
|
return o;
|
|
2614
2617
|
}
|
|
2615
|
-
deriveMultiple(t, i = 0, r = 0, s = !1, n =
|
|
2618
|
+
deriveMultiple(t, i = 0, r = 0, s = !1, n = kt.BIP84) {
|
|
2616
2619
|
const o = [];
|
|
2617
2620
|
for (let a = 0; a < t; a++) o.push(this.derive(i + a, r, s, n));
|
|
2618
2621
|
return o;
|
|
@@ -2621,7 +2624,7 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2621
2624
|
const r = this._classicalRoot.derivePath(t), s = this._quantumRoot.derivePath(i);
|
|
2622
2625
|
if (!r.privateKey) throw new Error(`Failed to derive classical private key at path ${t}`);
|
|
2623
2626
|
if (!s.privateKey) throw new Error(`Failed to derive quantum private key at path ${i}`);
|
|
2624
|
-
return new
|
|
2627
|
+
return new Bt(f(new Uint8Array(r.privateKey)), f(new Uint8Array(s.privateKey)), this._network, this._securityLevel, new Uint8Array(this._quantumRoot.chainCode));
|
|
2625
2628
|
}
|
|
2626
2629
|
getClassicalRoot() {
|
|
2627
2630
|
return this._classicalRoot;
|
|
@@ -2629,8 +2632,8 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2629
2632
|
getQuantumRoot() {
|
|
2630
2633
|
return this._quantumRoot;
|
|
2631
2634
|
}
|
|
2632
|
-
buildClassicalPath(t, i, r, s =
|
|
2633
|
-
return
|
|
2635
|
+
buildClassicalPath(t, i, r, s = kt.BIP84) {
|
|
2636
|
+
return Ye(s, this.getCoinType(), t, r ? 1 : 0, i);
|
|
2634
2637
|
}
|
|
2635
2638
|
buildQuantumPath(t, i, r) {
|
|
2636
2639
|
return `m/360'/${this.getCoinType()}'/${t}'/${r ? 1 : 0}/${i}`;
|
|
@@ -2638,22 +2641,23 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2638
2641
|
getCoinType() {
|
|
2639
2642
|
return this._network.bech32 === y.testnet.bech32 || this._network.bech32 === y.opnetTestnet.bech32 || this._network.bech32 === y.regtest.bech32 ? 1 : 0;
|
|
2640
2643
|
}
|
|
2641
|
-
},
|
|
2644
|
+
}, wr = /* @__PURE__ */ (function(e) {
|
|
2642
2645
|
return e[e.MLDSA44 = 1312] = "MLDSA44", e[e.MLDSA65 = 1952] = "MLDSA65", e[e.MLDSA87 = 2592] = "MLDSA87", e;
|
|
2643
2646
|
})({});
|
|
2644
|
-
function
|
|
2647
|
+
function ie(e) {
|
|
2645
2648
|
switch (e) {
|
|
2646
|
-
case
|
|
2647
|
-
return
|
|
2648
|
-
case
|
|
2649
|
-
return
|
|
2650
|
-
case
|
|
2651
|
-
return
|
|
2649
|
+
case 1312:
|
|
2650
|
+
return v.MLDSASecurityLevel.LEVEL2;
|
|
2651
|
+
case 1952:
|
|
2652
|
+
return v.MLDSASecurityLevel.LEVEL3;
|
|
2653
|
+
case 2592:
|
|
2654
|
+
return v.MLDSASecurityLevel.LEVEL5;
|
|
2652
2655
|
default:
|
|
2653
2656
|
throw new Error(`Invalid MLDSA public key length: ${e}`);
|
|
2654
2657
|
}
|
|
2655
2658
|
}
|
|
2656
|
-
var
|
|
2659
|
+
var yr = class {
|
|
2660
|
+
network;
|
|
2657
2661
|
constructor(e = y.bitcoin) {
|
|
2658
2662
|
this.network = e;
|
|
2659
2663
|
}
|
|
@@ -2663,29 +2667,29 @@ var Tr = class {
|
|
|
2663
2667
|
getAddress() {
|
|
2664
2668
|
return this.address;
|
|
2665
2669
|
}
|
|
2666
|
-
},
|
|
2670
|
+
}, Qe = /* @__PURE__ */ (function(e) {
|
|
2667
2671
|
return e[e.Bitcoin = 0] = "Bitcoin", e[e.Fractal = 1] = "Fractal", e;
|
|
2668
2672
|
})({});
|
|
2669
|
-
function
|
|
2670
|
-
return e && !!(e.tapInternalKey || e.tapMerkleRoot || e.tapLeafScript && e.tapLeafScript.length || e.tapBip32Derivation && e.tapBip32Derivation.length || e.witnessUtxo && (
|
|
2673
|
+
function fe(e) {
|
|
2674
|
+
return e && !!(e.tapInternalKey || e.tapMerkleRoot || e.tapLeafScript && e.tapLeafScript.length || e.tapBip32Derivation && e.tapBip32Derivation.length || e.witnessUtxo && (Rt(e.witnessUtxo.script) || Ce(e.witnessUtxo.script)));
|
|
2671
2675
|
}
|
|
2672
|
-
function
|
|
2676
|
+
function mr(e) {
|
|
2673
2677
|
return e.redeemScript ? e.redeemScript : e.witnessScript ? e.witnessScript : e.witnessUtxo ? e.witnessUtxo.script : (e.nonWitnessUtxo, null);
|
|
2674
2678
|
}
|
|
2675
|
-
function
|
|
2679
|
+
function ge(e, t) {
|
|
2676
2680
|
if (e.nonWitnessUtxo && !e.redeemScript && !e.witnessScript && !e.witnessUtxo || e.redeemScript) return !0;
|
|
2677
|
-
const i =
|
|
2678
|
-
return i ?
|
|
2681
|
+
const i = mr(e);
|
|
2682
|
+
return i ? Se(t, i) : !1;
|
|
2679
2683
|
}
|
|
2680
|
-
function
|
|
2681
|
-
return
|
|
2684
|
+
function Se(e, t) {
|
|
2685
|
+
return _i(e, t) !== -1;
|
|
2682
2686
|
}
|
|
2683
|
-
var
|
|
2687
|
+
var we = class {
|
|
2684
2688
|
constructor() {
|
|
2685
2689
|
}
|
|
2686
2690
|
};
|
|
2687
|
-
|
|
2688
|
-
var
|
|
2691
|
+
vt();
|
|
2692
|
+
var Tr = class extends we {
|
|
2689
2693
|
isInitialized = !1;
|
|
2690
2694
|
constructor() {
|
|
2691
2695
|
if (super(), !window) throw new Error("UnisatSigner can only be used in a browser environment");
|
|
@@ -2746,7 +2750,7 @@ var Er = class extends Te {
|
|
|
2746
2750
|
}
|
|
2747
2751
|
const t = await this.unisat.getPublicKey();
|
|
2748
2752
|
if (t === "") throw new Error("Unlock your wallet first");
|
|
2749
|
-
this._publicKey =
|
|
2753
|
+
this._publicKey = ce(g(t)), this._p2wpkh = I.getP2WPKHAddress(this, this.network), this._p2tr = I.getTaprootAddress(this, this.network), this._addresses = [this._p2wpkh, this._p2tr], this.isInitialized = !0;
|
|
2750
2754
|
}
|
|
2751
2755
|
getPublicKey() {
|
|
2752
2756
|
if (!this.isInitialized) throw new Error("UnisatSigner not initialized");
|
|
@@ -2780,18 +2784,18 @@ var Er = class extends Te {
|
|
|
2780
2784
|
t.push(o);
|
|
2781
2785
|
const a = n.data.inputs.map((c, u) => {
|
|
2782
2786
|
let l = !1, h = !1;
|
|
2783
|
-
if (
|
|
2787
|
+
if (fe(c)) {
|
|
2784
2788
|
if (c.tapLeafScript && c.tapLeafScript.length > 0) {
|
|
2785
|
-
for (const p of c.tapLeafScript) if (
|
|
2789
|
+
for (const p of c.tapLeafScript) if (Ar(this.publicKey, p.script)) {
|
|
2786
2790
|
l = !0, h = !1;
|
|
2787
2791
|
break;
|
|
2788
2792
|
}
|
|
2789
2793
|
}
|
|
2790
2794
|
if (!l && c.tapInternalKey) {
|
|
2791
2795
|
const p = c.tapInternalKey;
|
|
2792
|
-
C(p,
|
|
2796
|
+
C(p, O(this.publicKey)) && (l = !0, h = !0);
|
|
2793
2797
|
}
|
|
2794
|
-
} else
|
|
2798
|
+
} else ge(c, this.publicKey) && (l = !0, h = !1);
|
|
2795
2799
|
return l ? {
|
|
2796
2800
|
index: u,
|
|
2797
2801
|
publicKey: f(this.publicKey),
|
|
@@ -2803,7 +2807,7 @@ var Er = class extends Te {
|
|
|
2803
2807
|
toSignInputs: a
|
|
2804
2808
|
});
|
|
2805
2809
|
}
|
|
2806
|
-
const r = await this.unisat.signPsbt(t[0], i[0]), s =
|
|
2810
|
+
const r = await this.unisat.signPsbt(t[0], i[0]), s = N.fromHex(r);
|
|
2807
2811
|
e[0].combine(s);
|
|
2808
2812
|
}
|
|
2809
2813
|
hasAlreadySignedTapScriptSig(e) {
|
|
@@ -2840,7 +2844,7 @@ var Er = class extends Te {
|
|
|
2840
2844
|
disableTweakSigner: i
|
|
2841
2845
|
}]).flat()
|
|
2842
2846
|
}, n = e.toHex(), o = await this.unisat.signPsbt(n, s);
|
|
2843
|
-
return
|
|
2847
|
+
return N.fromHex(o);
|
|
2844
2848
|
}
|
|
2845
2849
|
getNonDuplicateScriptSig(e, t) {
|
|
2846
2850
|
const i = [];
|
|
@@ -2851,36 +2855,36 @@ var Er = class extends Te {
|
|
|
2851
2855
|
return i;
|
|
2852
2856
|
}
|
|
2853
2857
|
};
|
|
2854
|
-
function
|
|
2855
|
-
return
|
|
2858
|
+
function Ar(e, t) {
|
|
2859
|
+
return br(e, t) !== -1;
|
|
2856
2860
|
}
|
|
2857
|
-
function
|
|
2858
|
-
const i = D.hash160(e), r =
|
|
2861
|
+
function br(e, t) {
|
|
2862
|
+
const i = D.hash160(e), r = O(e), s = b.decompile(t);
|
|
2859
2863
|
if (s === null) throw new Error("Unknown script error");
|
|
2860
2864
|
return s.findIndex((n) => typeof n == "number" ? !1 : n instanceof Uint8Array && (C(n, e) || C(n, i) || C(n, r)));
|
|
2861
2865
|
}
|
|
2862
|
-
function
|
|
2866
|
+
function Ze(e) {
|
|
2863
2867
|
return new Map(e);
|
|
2864
2868
|
}
|
|
2865
|
-
function
|
|
2869
|
+
function Er(e) {
|
|
2866
2870
|
return {
|
|
2867
2871
|
enabled: !0,
|
|
2868
|
-
signerMap: e instanceof Map ? e :
|
|
2872
|
+
signerMap: e instanceof Map ? e : Ze(e)
|
|
2869
2873
|
};
|
|
2870
2874
|
}
|
|
2871
|
-
function
|
|
2875
|
+
function Ir() {
|
|
2872
2876
|
return {
|
|
2873
2877
|
enabled: !1,
|
|
2874
2878
|
signerMap: /* @__PURE__ */ new Map()
|
|
2875
2879
|
};
|
|
2876
2880
|
}
|
|
2877
|
-
|
|
2878
|
-
function
|
|
2881
|
+
vt();
|
|
2882
|
+
function Pr(e) {
|
|
2879
2883
|
return {
|
|
2880
2884
|
publicKey: e.publicKey,
|
|
2881
2885
|
getPrivateKey() {
|
|
2882
2886
|
if (!e.privateKey) throw new Error("Signer does not have a private key");
|
|
2883
|
-
return
|
|
2887
|
+
return Re(e.privateKey);
|
|
2884
2888
|
},
|
|
2885
2889
|
sign(t, i) {
|
|
2886
2890
|
return e.sign(t, i);
|
|
@@ -2891,12 +2895,12 @@ function Or(e) {
|
|
|
2891
2895
|
}
|
|
2892
2896
|
};
|
|
2893
2897
|
}
|
|
2894
|
-
function
|
|
2898
|
+
function Je(e, t) {
|
|
2895
2899
|
return {
|
|
2896
|
-
publicKey:
|
|
2900
|
+
publicKey: ce(e.publicKey),
|
|
2897
2901
|
getPrivateKey() {
|
|
2898
2902
|
if (!t.privateKey) throw new Error("Tweaked signer does not have a private key");
|
|
2899
|
-
return
|
|
2903
|
+
return Re(t.privateKey);
|
|
2900
2904
|
},
|
|
2901
2905
|
sign(i, r) {
|
|
2902
2906
|
return t.sign(i, r);
|
|
@@ -2909,11 +2913,11 @@ function ii(e, t) {
|
|
|
2909
2913
|
}
|
|
2910
2914
|
var m = /* @__PURE__ */ (function(e) {
|
|
2911
2915
|
return e[e.GENERIC = 0] = "GENERIC", e[e.FUNDING = 1] = "FUNDING", e[e.DEPLOYMENT = 2] = "DEPLOYMENT", e[e.INTERACTION = 3] = "INTERACTION", e[e.MULTI_SIG = 4] = "MULTI_SIG", e[e.CUSTOM_CODE = 5] = "CUSTOM_CODE", e[e.CANCEL = 6] = "CANCEL", e[e.CONSOLIDATED_SETUP = 7] = "CONSOLIDATED_SETUP", e[e.CONSOLIDATED_REVEAL = 8] = "CONSOLIDATED_REVEAL", e;
|
|
2912
|
-
})({}),
|
|
2916
|
+
})({}), vr = /* @__PURE__ */ (function(e) {
|
|
2913
2917
|
return e[e.REPLACE_BY_FEE = 4294967293] = "REPLACE_BY_FEE", e[e.FINAL = 4294967295] = "FINAL", e;
|
|
2914
|
-
})({}),
|
|
2918
|
+
})({}), Or = /* @__PURE__ */ (function(e) {
|
|
2915
2919
|
return e[e.BLOCKS = 0] = "BLOCKS", e[e.TIMESTAMPS = 1] = "TIMESTAMPS", e;
|
|
2916
|
-
})({}),
|
|
2920
|
+
})({}), ti = class re extends Le {
|
|
2917
2921
|
logColor = "#00ffe1";
|
|
2918
2922
|
finalized = !1;
|
|
2919
2923
|
signer;
|
|
@@ -2924,7 +2928,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
2924
2928
|
scriptData = null;
|
|
2925
2929
|
tapData = null;
|
|
2926
2930
|
inputs = [];
|
|
2927
|
-
sequence =
|
|
2931
|
+
sequence = 4294967293;
|
|
2928
2932
|
tapLeafScript = null;
|
|
2929
2933
|
nonWitnessUtxo;
|
|
2930
2934
|
isBrowser = !1;
|
|
@@ -2945,7 +2949,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
2945
2949
|
parallelSigningConfig;
|
|
2946
2950
|
useP2MR = !1;
|
|
2947
2951
|
constructor(t) {
|
|
2948
|
-
super(), this.signer = t.signer, this.network = t.network, this.noSignatures = t.noSignatures || !1, t.nonWitnessUtxo !== void 0 && (this.nonWitnessUtxo = t.nonWitnessUtxo), t.unlockScript !== void 0 && (this.unlockScript = t.unlockScript), this.isBrowser = typeof window < "u", t.txVersion && (this.txVersion = t.txVersion), t.mldsaSigner && (this._mldsaSigner = t.mldsaSigner, this._hashedPublicKey =
|
|
2952
|
+
super(), this.signer = t.signer, this.network = t.network, this.noSignatures = t.noSignatures || !1, t.nonWitnessUtxo !== void 0 && (this.nonWitnessUtxo = t.nonWitnessUtxo), t.unlockScript !== void 0 && (this.unlockScript = t.unlockScript), this.isBrowser = typeof window < "u", t.txVersion && (this.txVersion = t.txVersion), t.mldsaSigner && (this._mldsaSigner = t.mldsaSigner, this._hashedPublicKey = st.sha256(this._mldsaSigner.publicKey)), t.addressRotation?.enabled && (this.addressRotationEnabled = !0, this.signerMap = t.addressRotation.signerMap), t.parallelSigning && (this.parallelSigningConfig = t.parallelSigning), t.useP2MR && (this.useP2MR = !0);
|
|
2949
2953
|
}
|
|
2950
2954
|
get mldsaSigner() {
|
|
2951
2955
|
if (!this._mldsaSigner) throw new Error("MLDSA Signer is not set");
|
|
@@ -2965,7 +2969,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
2965
2969
|
return i += a, c;
|
|
2966
2970
|
}
|
|
2967
2971
|
function s() {
|
|
2968
|
-
const a =
|
|
2972
|
+
const a = Gt.decode(t, i);
|
|
2969
2973
|
return i += a.bytes, a.numberValue || 0;
|
|
2970
2974
|
}
|
|
2971
2975
|
function n() {
|
|
@@ -3013,17 +3017,17 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3013
3017
|
}
|
|
3014
3018
|
disableRBF() {
|
|
3015
3019
|
if (this.signed) throw new Error("Transaction is already signed");
|
|
3016
|
-
this.sequence =
|
|
3020
|
+
this.sequence = 4294967295;
|
|
3017
3021
|
for (const t of this.inputs) {
|
|
3018
3022
|
const i = this.inputs.indexOf(t);
|
|
3019
|
-
this.csvInputIndices.has(i) || this.csvMultisigInputs.has(i) || (t.sequence =
|
|
3023
|
+
this.csvInputIndices.has(i) || this.csvMultisigInputs.has(i) || (t.sequence = 4294967295);
|
|
3020
3024
|
}
|
|
3021
3025
|
}
|
|
3022
3026
|
getTweakerHash() {
|
|
3023
3027
|
return this.tapData?.hash;
|
|
3024
3028
|
}
|
|
3025
3029
|
preEstimateTransactionFees(t, i, r, s, n) {
|
|
3026
|
-
const o = 10n, a = 41n, c = 68n, u = 144n, l = 34n, h = o + a * i + c * r, p = 1n + n *
|
|
3030
|
+
const o = 10n, a = 41n, c = 68n, u = 144n, l = 34n, h = o + a * i + c * r, p = 1n + n * 35n + 1n + s, w = s * u + n * l + p;
|
|
3027
3031
|
return (h * 3n + (h + w)) / 4n * t;
|
|
3028
3032
|
}
|
|
3029
3033
|
getSignerForInput(t) {
|
|
@@ -3049,7 +3053,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3049
3053
|
}
|
|
3050
3054
|
}
|
|
3051
3055
|
internalPubKeyToXOnlyForInput(t) {
|
|
3052
|
-
return
|
|
3056
|
+
return O(this.getSignerForInput(t).publicKey);
|
|
3053
3057
|
}
|
|
3054
3058
|
getTweakedSignerForInput(t, i = !1) {
|
|
3055
3059
|
if (!this.addressRotationEnabled)
|
|
@@ -3062,21 +3066,21 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3062
3066
|
generateTapData() {
|
|
3063
3067
|
return this.useP2MR ? {
|
|
3064
3068
|
network: this.network,
|
|
3065
|
-
name:
|
|
3069
|
+
name: E.P2MR
|
|
3066
3070
|
} : {
|
|
3067
3071
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
3068
3072
|
network: this.network,
|
|
3069
|
-
name:
|
|
3073
|
+
name: E.P2TR
|
|
3070
3074
|
};
|
|
3071
3075
|
}
|
|
3072
3076
|
generateScriptAddress() {
|
|
3073
3077
|
return this.useP2MR ? {
|
|
3074
3078
|
network: this.network,
|
|
3075
|
-
name:
|
|
3079
|
+
name: E.P2MR
|
|
3076
3080
|
} : {
|
|
3077
3081
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
3078
3082
|
network: this.network,
|
|
3079
|
-
name:
|
|
3083
|
+
name: E.P2TR
|
|
3080
3084
|
};
|
|
3081
3085
|
}
|
|
3082
3086
|
getSignerKey() {
|
|
@@ -3085,7 +3089,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3085
3089
|
async signInput(t, i, r, s, n = !1, o = !1) {
|
|
3086
3090
|
if (this.anchorInputIndices.has(r)) return;
|
|
3087
3091
|
const a = s.publicKey;
|
|
3088
|
-
let c =
|
|
3092
|
+
let c = fe(i);
|
|
3089
3093
|
n && (c = !c);
|
|
3090
3094
|
let u = !1, l = !1;
|
|
3091
3095
|
if (c) try {
|
|
@@ -3093,7 +3097,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3093
3097
|
} catch (h) {
|
|
3094
3098
|
this.error(`Failed to sign Taproot script path input ${r} (reverse: ${n}): ${h.message}`), l = !0;
|
|
3095
3099
|
}
|
|
3096
|
-
else if (n ||
|
|
3100
|
+
else if (n || ge(i, a)) try {
|
|
3097
3101
|
await this.signNonTaprootInput(s, t, r), u = !0;
|
|
3098
3102
|
} catch (h) {
|
|
3099
3103
|
this.error(`Failed to sign non-Taproot input ${r}: ${h.stack}`), l = !0;
|
|
@@ -3121,18 +3125,27 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3121
3125
|
await this.signInputsNonWalletBased(t);
|
|
3122
3126
|
}
|
|
3123
3127
|
async signInputsNonWalletBased(t) {
|
|
3124
|
-
if (!this.noSignatures) if (this.canUseParallelSigning &&
|
|
3125
|
-
let
|
|
3128
|
+
if (!this.noSignatures) if (this.canUseParallelSigning && dt(this.signer)) {
|
|
3129
|
+
let r = /* @__PURE__ */ new Set();
|
|
3126
3130
|
try {
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3129
|
-
} catch (
|
|
3130
|
-
this.error(`Parallel signing failed, falling back to sequential: ${
|
|
3131
|
+
const s = await this.signKeyPathInputsParallel(t);
|
|
3132
|
+
s.success && (r = new Set(s.signatures.keys()));
|
|
3133
|
+
} catch (s) {
|
|
3134
|
+
this.error(`Parallel signing failed, falling back to sequential: ${s.message}`);
|
|
3131
3135
|
}
|
|
3132
|
-
await this.signRemainingInputsSequential(t,
|
|
3136
|
+
await this.signRemainingInputsSequential(t, r);
|
|
3133
3137
|
} else await this.signInputsSequential(t);
|
|
3134
|
-
|
|
3135
|
-
|
|
3138
|
+
let i = !0;
|
|
3139
|
+
for (let r = 0; r < t.data.inputs.length; r++) try {
|
|
3140
|
+
t.finalizeInput(r, this.customFinalizerP2SH.bind(this));
|
|
3141
|
+
} catch (s) {
|
|
3142
|
+
if (this.csvMultisigInputs.has(r)) {
|
|
3143
|
+
i = !1;
|
|
3144
|
+
continue;
|
|
3145
|
+
}
|
|
3146
|
+
throw s;
|
|
3147
|
+
}
|
|
3148
|
+
this.finalized = i;
|
|
3136
3149
|
}
|
|
3137
3150
|
async signInputsSequential(t) {
|
|
3138
3151
|
const i = t.data.inputs, r = 20, s = this.splitArray(i, r);
|
|
@@ -3170,11 +3183,11 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3170
3183
|
}
|
|
3171
3184
|
}
|
|
3172
3185
|
internalPubKeyToXOnly() {
|
|
3173
|
-
return
|
|
3186
|
+
return O(this.signer.publicKey);
|
|
3174
3187
|
}
|
|
3175
3188
|
internalInit() {
|
|
3176
3189
|
const t = this.generateScriptAddress(), i = this.generateTapData();
|
|
3177
|
-
t.name ===
|
|
3190
|
+
t.name === E.P2MR ? this.scriptData = U.p2mr(t) : this.scriptData = U.p2tr(t), i.name === E.P2MR ? this.tapData = U.p2mr(i) : this.tapData = U.p2tr(i);
|
|
3178
3191
|
}
|
|
3179
3192
|
tweakSigner() {
|
|
3180
3193
|
if (this.tweakedSigner) return;
|
|
@@ -3187,13 +3200,13 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3187
3200
|
const s = this.getTweakerHash();
|
|
3188
3201
|
s !== void 0 && (r.tweakHash = s);
|
|
3189
3202
|
}
|
|
3190
|
-
if (
|
|
3191
|
-
return
|
|
3203
|
+
if (dt(i))
|
|
3204
|
+
return pe.tweakSigner(i, r);
|
|
3192
3205
|
}
|
|
3193
3206
|
async signKeyPathInputsParallel(t, i) {
|
|
3194
3207
|
const r = this.signer, s = this.getTweakedSigner(!0);
|
|
3195
3208
|
if (!s) throw new Error("Cannot create tweaked signer for parallel signing");
|
|
3196
|
-
const n =
|
|
3209
|
+
const n = Je(r, s), o = Ui(t, n), a = i ? o.filter((l) => !i.has(l.inputIndex)) : o;
|
|
3197
3210
|
if (a.length === 0) return {
|
|
3198
3211
|
success: !0,
|
|
3199
3212
|
signatures: /* @__PURE__ */ new Map(),
|
|
@@ -3201,11 +3214,11 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3201
3214
|
durationMs: 0
|
|
3202
3215
|
};
|
|
3203
3216
|
let c, u = !1;
|
|
3204
|
-
this.parallelSigningConfig && "signBatch" in this.parallelSigningConfig ? c = this.parallelSigningConfig : (c =
|
|
3217
|
+
this.parallelSigningConfig && "signBatch" in this.parallelSigningConfig ? c = this.parallelSigningConfig : (c = Ki.getInstance(this.parallelSigningConfig), c.isPreservingWorkers || (u = !0));
|
|
3205
3218
|
try {
|
|
3206
3219
|
await c.initialize();
|
|
3207
3220
|
const l = await c.signBatch(a, n);
|
|
3208
|
-
if (l.success)
|
|
3221
|
+
if (l.success) Vi(t, l, n);
|
|
3209
3222
|
else {
|
|
3210
3223
|
const h = [...l.errors.entries()].map(([p, w]) => `Input ${p}: ${w}`).join(", ");
|
|
3211
3224
|
this.error(`Parallel signing had errors: ${h}`);
|
|
@@ -3216,30 +3229,30 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3216
3229
|
}
|
|
3217
3230
|
}
|
|
3218
3231
|
generateP2SHRedeemScript(t) {
|
|
3219
|
-
const i =
|
|
3232
|
+
const i = U.p2wsh({
|
|
3220
3233
|
redeem: { output: t },
|
|
3221
3234
|
network: this.network
|
|
3222
3235
|
});
|
|
3223
|
-
return
|
|
3236
|
+
return U.p2sh({
|
|
3224
3237
|
redeem: i,
|
|
3225
3238
|
network: this.network
|
|
3226
3239
|
}).output;
|
|
3227
3240
|
}
|
|
3228
3241
|
generateP2SHRedeemScriptLegacy(t) {
|
|
3229
|
-
const i = D.hash160(this.signer.publicKey), r =
|
|
3242
|
+
const i = D.hash160(this.signer.publicKey), r = b.compile([
|
|
3230
3243
|
d.OP_DUP,
|
|
3231
3244
|
d.OP_HASH160,
|
|
3232
3245
|
i,
|
|
3233
3246
|
d.OP_EQUALVERIFY,
|
|
3234
3247
|
d.OP_CHECKSIG
|
|
3235
|
-
]), s = D.hash160(r), n =
|
|
3248
|
+
]), s = D.hash160(r), n = b.compile([
|
|
3236
3249
|
d.OP_HASH160,
|
|
3237
3250
|
s,
|
|
3238
3251
|
d.OP_EQUAL
|
|
3239
|
-
]), o =
|
|
3252
|
+
]), o = U.p2wsh({
|
|
3240
3253
|
redeem: { output: r },
|
|
3241
3254
|
network: this.network
|
|
3242
|
-
}), a =
|
|
3255
|
+
}), a = U.p2sh({
|
|
3243
3256
|
redeem: o,
|
|
3244
3257
|
network: this.network
|
|
3245
3258
|
});
|
|
@@ -3249,10 +3262,10 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3249
3262
|
};
|
|
3250
3263
|
}
|
|
3251
3264
|
generateP2SHP2PKHRedeemScript(t, i) {
|
|
3252
|
-
const r = (this.addressRotationEnabled && i !== void 0 ? this.getSignerForInput(i) : this.signer).publicKey, s =
|
|
3265
|
+
const r = (this.addressRotationEnabled && i !== void 0 ? this.getSignerForInput(i) : this.signer).publicKey, s = U.p2wpkh({
|
|
3253
3266
|
pubkey: r,
|
|
3254
3267
|
network: this.network
|
|
3255
|
-
}), n =
|
|
3268
|
+
}), n = U.p2sh({
|
|
3256
3269
|
redeem: s,
|
|
3257
3270
|
network: this.network
|
|
3258
3271
|
}), o = n.address;
|
|
@@ -3272,11 +3285,11 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3272
3285
|
script: s
|
|
3273
3286
|
}
|
|
3274
3287
|
};
|
|
3275
|
-
if (
|
|
3288
|
+
if (Ci(s)) if (t.nonWitnessUtxo) n.nonWitnessUtxo = t.nonWitnessUtxo instanceof Uint8Array ? t.nonWitnessUtxo : g(t.nonWitnessUtxo);
|
|
3276
3289
|
else throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");
|
|
3277
|
-
else if (!(
|
|
3278
|
-
if (
|
|
3279
|
-
else if (
|
|
3290
|
+
else if (!(Ie(s) || Ri(s)))
|
|
3291
|
+
if (Pe(s)) this.processP2WSHInput(t, n, i);
|
|
3292
|
+
else if (Hi(s)) {
|
|
3280
3293
|
let o;
|
|
3281
3294
|
if (t.redeemScript) o = t.redeemScript instanceof Uint8Array ? t.redeemScript : g(t.redeemScript);
|
|
3282
3295
|
else {
|
|
@@ -3286,33 +3299,33 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3286
3299
|
o = u.redeemScript;
|
|
3287
3300
|
}
|
|
3288
3301
|
n.redeemScript = o;
|
|
3289
|
-
const a =
|
|
3302
|
+
const a = U.p2sh({ redeem: { output: n.redeemScript } });
|
|
3290
3303
|
if (!a.redeem) throw new Error("Failed to extract redeem script from P2SH UTXO");
|
|
3291
3304
|
const c = a.redeem.output;
|
|
3292
3305
|
if (!c) throw new Error("Failed to extract redeem output from P2SH UTXO");
|
|
3293
|
-
t.nonWitnessUtxo && (n.nonWitnessUtxo = t.nonWitnessUtxo instanceof Uint8Array ? t.nonWitnessUtxo : g(t.nonWitnessUtxo)),
|
|
3294
|
-
} else if (
|
|
3306
|
+
t.nonWitnessUtxo && (n.nonWitnessUtxo = t.nonWitnessUtxo instanceof Uint8Array ? t.nonWitnessUtxo : g(t.nonWitnessUtxo)), Ie(c) ? Reflect.deleteProperty(n, "nonWitnessUtxo") : Pe(c) ? (Reflect.deleteProperty(n, "nonWitnessUtxo"), this.processP2WSHInput(t, n, i)) : Reflect.deleteProperty(n, "witnessUtxo");
|
|
3307
|
+
} else if (Rt(s)) {
|
|
3295
3308
|
if (this.sighashTypes) {
|
|
3296
|
-
const o =
|
|
3309
|
+
const o = re.calculateSignHash(this.sighashTypes);
|
|
3297
3310
|
o && (n.sighashType = o);
|
|
3298
3311
|
}
|
|
3299
3312
|
this.processCSVMultisigP2TRInput(t, n, i, s) || (this.addressRotationEnabled ? n.tapInternalKey = this.internalPubKeyToXOnlyForInput(i) : (this.tweakSigner(), n.tapInternalKey = this.internalPubKeyToXOnly()));
|
|
3300
|
-
} else if (
|
|
3313
|
+
} else if (Ce(s)) {
|
|
3301
3314
|
if (this.sighashTypes) {
|
|
3302
|
-
const o =
|
|
3315
|
+
const o = re.calculateSignHash(this.sighashTypes);
|
|
3303
3316
|
o && (n.sighashType = o);
|
|
3304
3317
|
}
|
|
3305
3318
|
i === 0 && this.tapData?.hash && (n.tapMerkleRoot = this.tapData.hash);
|
|
3306
|
-
} else if (
|
|
3319
|
+
} else if (zi(s))
|
|
3307
3320
|
this.anchorInputIndices.add(i), n.isPayToAnchor = !0;
|
|
3308
|
-
else if (
|
|
3321
|
+
else if (Di(s) || Wi(s)) if (t.nonWitnessUtxo) n.nonWitnessUtxo = t.nonWitnessUtxo instanceof Uint8Array ? t.nonWitnessUtxo : g(t.nonWitnessUtxo);
|
|
3309
3322
|
else throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");
|
|
3310
3323
|
else this.error(`Unknown or unsupported script type for output: ${t.scriptPubKey.hex}`);
|
|
3311
3324
|
return i === 0 && (this.tapLeafScript && !this.csvMultisigInputs.has(i) && (n.tapLeafScript = [this.tapLeafScript]), this.nonWitnessUtxo && (n.nonWitnessUtxo = this.nonWitnessUtxo)), n;
|
|
3312
3325
|
}
|
|
3313
3326
|
processCSVMultisigP2TRInput(t, i, r, s) {
|
|
3314
3327
|
if (!t.witnessScript) return !1;
|
|
3315
|
-
const n = t.witnessScript instanceof Uint8Array ? t.witnessScript : g(t.witnessScript), o =
|
|
3328
|
+
const n = t.witnessScript instanceof Uint8Array ? t.witnessScript : g(t.witnessScript), o = rt.deriveAddressFromTapscript(n, this.network);
|
|
3316
3329
|
return !o || !C(o.scriptPubKey, s) ? !1 : (i.tapLeafScript = [{
|
|
3317
3330
|
leafVersion: o.leafVersion,
|
|
3318
3331
|
script: o.tapscript,
|
|
@@ -3322,9 +3335,9 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3322
3335
|
processP2WSHInput(t, i, r) {
|
|
3323
3336
|
if (!t.witnessScript) throw new Error("Missing witnessScript for P2WSH UTXO");
|
|
3324
3337
|
i.witnessScript = t.witnessScript instanceof Uint8Array ? t.witnessScript : g(t.witnessScript);
|
|
3325
|
-
const s =
|
|
3338
|
+
const s = b.decompile(i.witnessScript);
|
|
3326
3339
|
if (s && this.isCSVScript(s)) {
|
|
3327
|
-
const n =
|
|
3340
|
+
const n = b.decompile(i.witnessScript);
|
|
3328
3341
|
if (n && this.isCSVScript(n)) {
|
|
3329
3342
|
this.csvInputIndices.add(r);
|
|
3330
3343
|
const o = this.extractCSVBlocks(n);
|
|
@@ -3351,7 +3364,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3351
3364
|
if (n && i.partialSig && c && c.redeemScript) {
|
|
3352
3365
|
const l = i.partialSig.map((h) => h.signature) || [];
|
|
3353
3366
|
return {
|
|
3354
|
-
finalScriptSig:
|
|
3367
|
+
finalScriptSig: b.compile([...l, c.redeemScript]),
|
|
3355
3368
|
finalScriptWitness: void 0
|
|
3356
3369
|
};
|
|
3357
3370
|
}
|
|
@@ -3364,31 +3377,40 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3364
3377
|
const l = i.tapScriptSig ?? [];
|
|
3365
3378
|
return {
|
|
3366
3379
|
finalScriptSig: void 0,
|
|
3367
|
-
finalScriptWitness:
|
|
3380
|
+
finalScriptWitness: It(rt.buildFinalWitnessFromTapScriptSigs(l, u))
|
|
3368
3381
|
};
|
|
3369
3382
|
}
|
|
3370
3383
|
if (o && s && i.witnessScript) {
|
|
3371
3384
|
if (!i.partialSig || i.partialSig.length === 0) throw new Error(`No signatures for P2WSH input #${t}`);
|
|
3372
|
-
if (
|
|
3385
|
+
if (X.isP2WDAWitnessScript(i.witnessScript)) return this.finalizeSecondaryP2WDA(t, i);
|
|
3373
3386
|
if (this.csvInputIndices.has(t)) return {
|
|
3374
3387
|
finalScriptSig: void 0,
|
|
3375
|
-
finalScriptWitness:
|
|
3388
|
+
finalScriptWitness: It([i.partialSig[0].signature, i.witnessScript])
|
|
3376
3389
|
};
|
|
3377
3390
|
}
|
|
3378
|
-
return
|
|
3391
|
+
return Ke(t, i, r, s, n, o, !0, this.unlockScript);
|
|
3379
3392
|
};
|
|
3380
3393
|
finalizeSecondaryP2WDA(t, i) {
|
|
3381
3394
|
if (!i.partialSig || i.partialSig.length === 0) throw new Error(`No signature for P2WDA input #${t}`);
|
|
3382
3395
|
if (!i.witnessScript) throw new Error(`No witness script for P2WDA input #${t}`);
|
|
3383
3396
|
return {
|
|
3384
3397
|
finalScriptSig: void 0,
|
|
3385
|
-
finalScriptWitness:
|
|
3398
|
+
finalScriptWitness: It(X.createSimpleP2WDAWitness(i.partialSig[0].signature, i.witnessScript))
|
|
3386
3399
|
};
|
|
3387
3400
|
}
|
|
3388
3401
|
async signInputsWalletBased(t) {
|
|
3389
3402
|
await this.signer.multiSignPsbt([t]);
|
|
3390
|
-
|
|
3391
|
-
|
|
3403
|
+
let i = !0;
|
|
3404
|
+
for (let r = 0; r < t.data.inputs.length; r++) try {
|
|
3405
|
+
t.finalizeInput(r, this.customFinalizerP2SH.bind(this));
|
|
3406
|
+
} catch (s) {
|
|
3407
|
+
if (this.csvMultisigInputs.has(r)) {
|
|
3408
|
+
i = !1;
|
|
3409
|
+
continue;
|
|
3410
|
+
}
|
|
3411
|
+
throw s;
|
|
3412
|
+
}
|
|
3413
|
+
this.finalized = i;
|
|
3392
3414
|
}
|
|
3393
3415
|
isCSVScript(t) {
|
|
3394
3416
|
return t.some((i) => i === d.OP_CHECKSEQUENCEVERIFY);
|
|
@@ -3398,15 +3420,15 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3398
3420
|
if (t > 65535) throw new Error(`CSV blocks ${t} exceeds maximum of 65,535`);
|
|
3399
3421
|
const r = (t & 1 << 22) !== 0;
|
|
3400
3422
|
let s = t & 65535;
|
|
3401
|
-
return r && (s |= 1 << 22), i ===
|
|
3423
|
+
return r && (s |= 1 << 22), i === 4294967293 && (s |= 1 << 25), s = s & 2147483647, s;
|
|
3402
3424
|
}
|
|
3403
3425
|
getCSVType(t) {
|
|
3404
|
-
return t & 1 << 22 ?
|
|
3426
|
+
return t & 1 << 22 ? 1 : 0;
|
|
3405
3427
|
}
|
|
3406
3428
|
extractCSVBlocks(t) {
|
|
3407
3429
|
for (let i = 0; i < t.length; i++) if (t[i] === d.OP_CHECKSEQUENCEVERIFY && i > 0) {
|
|
3408
3430
|
const r = t[i - 1];
|
|
3409
|
-
if (r instanceof Uint8Array) return
|
|
3431
|
+
if (r instanceof Uint8Array) return b.number.decode(r);
|
|
3410
3432
|
if (typeof r == "number") {
|
|
3411
3433
|
if (r === d.OP_0 || r === d.OP_FALSE) return 0;
|
|
3412
3434
|
if (r === d.OP_1NEGATE) return -1;
|
|
@@ -3431,7 +3453,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3431
3453
|
}
|
|
3432
3454
|
isTaprootScriptSpend(t, i) {
|
|
3433
3455
|
if (t.tapLeafScript && t.tapLeafScript.length > 0) {
|
|
3434
|
-
for (const r of t.tapLeafScript) if (
|
|
3456
|
+
for (const r of t.tapLeafScript) if (Se(i, r.script)) return !0;
|
|
3435
3457
|
}
|
|
3436
3458
|
return !1;
|
|
3437
3459
|
}
|
|
@@ -3588,12 +3610,12 @@ var _r = /* @__PURE__ */ new Map([
|
|
|
3588
3610
|
6
|
|
3589
3611
|
])]
|
|
3590
3612
|
]);
|
|
3591
|
-
function
|
|
3613
|
+
function Be(e) {
|
|
3592
3614
|
const t = _r.get(bt(e));
|
|
3593
3615
|
if (!t) throw new Error("Unsupported network for chain ID retrieval");
|
|
3594
3616
|
return t.slice();
|
|
3595
3617
|
}
|
|
3596
|
-
var
|
|
3618
|
+
var ke = new Uint8Array([
|
|
3597
3619
|
231,
|
|
3598
3620
|
132,
|
|
3599
3621
|
153,
|
|
@@ -3626,7 +3648,7 @@ var Ce = new Uint8Array([
|
|
|
3626
3648
|
64,
|
|
3627
3649
|
121,
|
|
3628
3650
|
57
|
|
3629
|
-
]),
|
|
3651
|
+
]), Pt = 330n, ei = 297n, se = g("51024e73"), Ss = 1, B = class R extends ti {
|
|
3630
3652
|
static MINIMUM_DUST = 330n;
|
|
3631
3653
|
logColor = "#785def";
|
|
3632
3654
|
debugFees = !1;
|
|
@@ -3655,8 +3677,8 @@ var Ce = new Uint8Array([
|
|
|
3655
3677
|
note;
|
|
3656
3678
|
optionalOutputsAdded = !1;
|
|
3657
3679
|
constructor(t) {
|
|
3658
|
-
if (super(t), t.estimatedFees && (this.estimatedFees = t.estimatedFees), this.signer = t.signer, this.network = t.network, this.feeRate = t.feeRate, this.priorityFee = t.priorityFee ?? 0n, this.gasSatFee = t.gasSatFee ?? 0n, this.utxos = t.utxos, this.optionalInputs = t.optionalInputs || [], this.to = t.to || void 0, this.debugFees = t.debugFees || !1, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), t.note && (typeof t.note == "string" ? this.note = new TextEncoder().encode(t.note) : this.note = t.note), this.anchor = t.anchor ?? !1, this.isPubKeyDestination = this.to ?
|
|
3659
|
-
this.transaction = new
|
|
3680
|
+
if (super(t), t.estimatedFees && (this.estimatedFees = t.estimatedFees), this.signer = t.signer, this.network = t.network, this.feeRate = t.feeRate, this.priorityFee = t.priorityFee ?? 0n, this.gasSatFee = t.gasSatFee ?? 0n, this.utxos = t.utxos, this.optionalInputs = t.optionalInputs || [], this.to = t.to || void 0, this.debugFees = t.debugFees || !1, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), t.note && (typeof t.note == "string" ? this.note = new TextEncoder().encode(t.note) : this.note = t.note), this.anchor = t.anchor ?? !1, this.isPubKeyDestination = this.to ? Et.isValidPublicKey(this.to, this.network) : !1, this.optionalOutputs = t.optionalOutputs, this.from = R.getFrom(t.from, this.signer, this.network), this.totalInputAmount = this.calculateTotalUTXOAmount(), this.calculateTotalVOutAmount() < this.totalInputAmount) throw new Error("Vout value is less than the value to send");
|
|
3681
|
+
this.transaction = new N({
|
|
3660
3682
|
network: this.network,
|
|
3661
3683
|
version: this.txVersion
|
|
3662
3684
|
});
|
|
@@ -3665,13 +3687,13 @@ var Ce = new Uint8Array([
|
|
|
3665
3687
|
return t || I.getTaprootAddress(i, r);
|
|
3666
3688
|
}
|
|
3667
3689
|
static witnessStackToScriptWitness(t) {
|
|
3668
|
-
return
|
|
3690
|
+
return It(t);
|
|
3669
3691
|
}
|
|
3670
3692
|
[Symbol.dispose]() {
|
|
3671
3693
|
super[Symbol.dispose](), this.updateInputs.length = 0, this.outputs.length = 0, this.feeOutput = null, this.optionalOutputs = void 0, this.utxos = [], this.optionalInputs = [];
|
|
3672
3694
|
}
|
|
3673
3695
|
addOPReturn(t) {
|
|
3674
|
-
const i =
|
|
3696
|
+
const i = b.compile([d.OP_RETURN, t]);
|
|
3675
3697
|
this.addOutput({
|
|
3676
3698
|
value: L(0n),
|
|
3677
3699
|
script: i
|
|
@@ -3680,7 +3702,7 @@ var Ce = new Uint8Array([
|
|
|
3680
3702
|
addAnchor() {
|
|
3681
3703
|
this.addOutput({
|
|
3682
3704
|
value: L(0n),
|
|
3683
|
-
script:
|
|
3705
|
+
script: se
|
|
3684
3706
|
});
|
|
3685
3707
|
}
|
|
3686
3708
|
async getFundingTransactionParameters() {
|
|
@@ -3725,8 +3747,12 @@ var Ce = new Uint8Array([
|
|
|
3725
3747
|
}
|
|
3726
3748
|
}
|
|
3727
3749
|
async signPSBT() {
|
|
3728
|
-
if (
|
|
3729
|
-
throw new Error("
|
|
3750
|
+
if (!this.utxos.length) throw new Error("No UTXOs specified");
|
|
3751
|
+
if (this.to && !this.isPubKeyDestination && !I.verifyContractAddress(this.to, this.network)) throw new Error("Invalid contract address. The contract address must be a taproot address.");
|
|
3752
|
+
if (this.signed) throw new Error("Transaction is already signed");
|
|
3753
|
+
if (this.signed = !0, await this.buildTransaction(), !await this.internalBuildTransaction(this.transaction)) throw new Error("Could not sign transaction");
|
|
3754
|
+
if (this.regenerated) throw new Error("Transaction was regenerated");
|
|
3755
|
+
return this.transaction;
|
|
3730
3756
|
}
|
|
3731
3757
|
addInput(t) {
|
|
3732
3758
|
this.inputs.push(t);
|
|
@@ -3736,7 +3762,7 @@ var Ce = new Uint8Array([
|
|
|
3736
3762
|
const r = t;
|
|
3737
3763
|
if (!r.script || r.script.length === 0) throw new Error("Output value is 0 and no script provided");
|
|
3738
3764
|
if (r.script.length < 2) throw new Error("Output script is too short");
|
|
3739
|
-
if (r.script[0] !== d.OP_RETURN && !C(r.script,
|
|
3765
|
+
if (r.script[0] !== d.OP_RETURN && !C(r.script, se)) throw new Error("Output script must start with OP_RETURN or be an ANCHOR when value is 0");
|
|
3740
3766
|
} else if (!i && BigInt(t.value) < R.MINIMUM_DUST) throw new Error(`Output value is less than the minimum dust ${t.value} < ${R.MINIMUM_DUST}`);
|
|
3741
3767
|
this.outputs.push(t);
|
|
3742
3768
|
}
|
|
@@ -3751,19 +3777,19 @@ var Ce = new Uint8Array([
|
|
|
3751
3777
|
}
|
|
3752
3778
|
async estimateTransactionFees() {
|
|
3753
3779
|
await Promise.resolve();
|
|
3754
|
-
const t = new
|
|
3780
|
+
const t = new N({ network: this.network }), i = this.getInputs(), r = this.getOutputs();
|
|
3755
3781
|
t.addInputs(i), t.addOutputs(r);
|
|
3756
|
-
const s = new Uint8Array(64), n = new Uint8Array(72), o = new Uint8Array(33).fill(2), a = (h, p) => {
|
|
3782
|
+
const s = /* @__PURE__ */ new Uint8Array(64), n = /* @__PURE__ */ new Uint8Array(72), o = (/* @__PURE__ */ new Uint8Array(33)).fill(2), a = (h, p) => {
|
|
3757
3783
|
if (p.isPayToAnchor || this.anchorInputIndices.has(h)) return {
|
|
3758
3784
|
finalScriptSig: void 0,
|
|
3759
3785
|
finalScriptWitness: Uint8Array.from([0])
|
|
3760
3786
|
};
|
|
3761
3787
|
const w = this.csvMultisigInputs.get(h);
|
|
3762
|
-
if (w) return { finalScriptWitness: R.witnessStackToScriptWitness(
|
|
3763
|
-
if (p.witnessScript &&
|
|
3788
|
+
if (w) return { finalScriptWitness: R.witnessStackToScriptWitness(rt.buildDummyWitness(w)) };
|
|
3789
|
+
if (p.witnessScript && X.isP2WDAWitnessScript(p.witnessScript)) {
|
|
3764
3790
|
const A = [];
|
|
3765
|
-
for (let x = 0; x < 10; x++) A.push(new Uint8Array(0));
|
|
3766
|
-
const k = new Uint8Array(72);
|
|
3791
|
+
for (let x = 0; x < 10; x++) A.push(/* @__PURE__ */ new Uint8Array(0));
|
|
3792
|
+
const k = /* @__PURE__ */ new Uint8Array(72);
|
|
3767
3793
|
return { finalScriptWitness: R.witnessStackToScriptWitness([
|
|
3768
3794
|
...A,
|
|
3769
3795
|
k,
|
|
@@ -3771,7 +3797,7 @@ var Ce = new Uint8Array([
|
|
|
3771
3797
|
]) };
|
|
3772
3798
|
}
|
|
3773
3799
|
if (h === 0 && this.tapLeafScript) {
|
|
3774
|
-
const A = new Uint8Array(32), k = this.tapLeafScript.script, x = this.useP2MR ? 33 : 65, yt = new Uint8Array(x);
|
|
3800
|
+
const A = /* @__PURE__ */ new Uint8Array(32), k = this.tapLeafScript.script, x = this.useP2MR ? 33 : 65, yt = new Uint8Array(x);
|
|
3775
3801
|
return { finalScriptWitness: R.witnessStackToScriptWitness([
|
|
3776
3802
|
A,
|
|
3777
3803
|
s,
|
|
@@ -3800,11 +3826,11 @@ var Ce = new Uint8Array([
|
|
|
3800
3826
|
if (A && A.length >= 4) {
|
|
3801
3827
|
const k = A[0], x = A[A.length - 1];
|
|
3802
3828
|
if (typeof k == "number" && k >= d.OP_1 && x === d.OP_CHECKMULTISIG) {
|
|
3803
|
-
const yt = k - d.OP_1 + 1,
|
|
3804
|
-
for (let
|
|
3829
|
+
const yt = k - d.OP_1 + 1, be = [];
|
|
3830
|
+
for (let Ee = 0; Ee < yt; Ee++) be.push(n);
|
|
3805
3831
|
return { finalScriptWitness: R.witnessStackToScriptWitness([
|
|
3806
|
-
new Uint8Array(0),
|
|
3807
|
-
...
|
|
3832
|
+
/* @__PURE__ */ new Uint8Array(0),
|
|
3833
|
+
...be,
|
|
3808
3834
|
p.witnessScript
|
|
3809
3835
|
]) };
|
|
3810
3836
|
}
|
|
@@ -3822,7 +3848,7 @@ var Ce = new Uint8Array([
|
|
|
3822
3848
|
finalScriptWitness: void 0
|
|
3823
3849
|
};
|
|
3824
3850
|
const T = p.witnessUtxo?.script;
|
|
3825
|
-
return T ? p.tapInternalKey ? { finalScriptWitness: R.witnessStackToScriptWitness([s]) } : T.length === 22 && T[0] === d.OP_0 ? { finalScriptWitness: R.witnessStackToScriptWitness([n, o]) } : p.redeemScript?.length === 22 && p.redeemScript[0] === d.OP_0 ? { finalScriptWitness: R.witnessStackToScriptWitness([n, o]) } :
|
|
3851
|
+
return T ? p.tapInternalKey ? { finalScriptWitness: R.witnessStackToScriptWitness([s]) } : T.length === 22 && T[0] === d.OP_0 ? { finalScriptWitness: R.witnessStackToScriptWitness([n, o]) } : p.redeemScript?.length === 22 && p.redeemScript[0] === d.OP_0 ? { finalScriptWitness: R.witnessStackToScriptWitness([n, o]) } : Ke(h, p, T, !0, !!p.redeemScript, !!p.witnessScript) : {
|
|
3826
3852
|
finalScriptSig: void 0,
|
|
3827
3853
|
finalScriptWitness: void 0
|
|
3828
3854
|
};
|
|
@@ -3839,10 +3865,10 @@ var Ce = new Uint8Array([
|
|
|
3839
3865
|
return this.debugFees && this.log(`Estimating fees: feeRate=${this.feeRate}, accurate_vSize=${c}, fee=${l}n`), l;
|
|
3840
3866
|
}
|
|
3841
3867
|
async rebuildFromBase64(t) {
|
|
3842
|
-
return this.transaction =
|
|
3868
|
+
return this.transaction = N.fromBase64(t, {
|
|
3843
3869
|
network: this.network,
|
|
3844
3870
|
version: this.txVersion
|
|
3845
|
-
}), this.signed = !1, this.sighashTypes = [
|
|
3871
|
+
}), this.signed = !1, this.sighashTypes = [Xt.SIGHASH_ANYONECANPAY, Xt.SIGHASH_ALL], await this.signPSBT();
|
|
3846
3872
|
}
|
|
3847
3873
|
setPSBT(t) {
|
|
3848
3874
|
this.transaction = t;
|
|
@@ -3867,14 +3893,19 @@ var Ce = new Uint8Array([
|
|
|
3867
3893
|
this.feeOutput = this.createChangeOutput(s), this.overflowFees = s, this.transactionFee = r;
|
|
3868
3894
|
else {
|
|
3869
3895
|
this.feeOutput = null, this.overflowFees = 0n;
|
|
3870
|
-
const
|
|
3871
|
-
if (this.transactionFee =
|
|
3872
|
-
|
|
3896
|
+
const a = await this.estimateTransactionFees();
|
|
3897
|
+
if (this.transactionFee = a, this.debugFees && this.warn(`Amount to send back (${s} sat) is less than minimum dust. Fee without change: ${a} sats`), i && s < 0n) throw new Error(`Insufficient funds for fee: need at least ${-s} more sats to cover fees.`);
|
|
3898
|
+
}
|
|
3899
|
+
const n = t + this.transactionFee, o = BigInt(Math.ceil(1));
|
|
3900
|
+
if (this.totalInputAmount < t) throw new Error(`Insufficient funds: need ${n} sats but only have ${this.totalInputAmount} sats`);
|
|
3901
|
+
if (this.totalInputAmount < n - o) {
|
|
3902
|
+
const a = n - this.totalInputAmount - o;
|
|
3903
|
+
throw new Error(`Insufficient funds for fee: need at least ${a} more sats to cover fees.`);
|
|
3873
3904
|
}
|
|
3874
3905
|
this.debugFees && this.log(`Final fee: ${this.transactionFee} sats, Change output: ${this.feeOutput ? `${this.feeOutput.value} sats` : "none"}`);
|
|
3875
3906
|
}
|
|
3876
3907
|
defineLockScript() {
|
|
3877
|
-
return
|
|
3908
|
+
return b.compile([O(this.signer.publicKey), d.OP_CHECKSIG]);
|
|
3878
3909
|
}
|
|
3879
3910
|
addValueToToOutput(t) {
|
|
3880
3911
|
if (BigInt(t) < R.MINIMUM_DUST) throw new Error(`Value to send is less than the minimum dust ${t} < ${R.MINIMUM_DUST}`);
|
|
@@ -3892,25 +3923,25 @@ var Ce = new Uint8Array([
|
|
|
3892
3923
|
}
|
|
3893
3924
|
generateLegacySignature() {
|
|
3894
3925
|
if (this.tweakSigner(), !this.tweakedSigner) throw new Error("Tweaked signer is not defined");
|
|
3895
|
-
const t =
|
|
3926
|
+
const t = O(this.tweakedSigner.publicKey), i = this.signer.publicKey;
|
|
3896
3927
|
if (i.length !== 33) throw new Error("Original public key must be compressed (33 bytes)");
|
|
3897
|
-
const r =
|
|
3898
|
-
s.writeU8(
|
|
3899
|
-
const n = s.getBuffer(), o =
|
|
3900
|
-
if (!
|
|
3928
|
+
const r = Be(this.network), s = new V();
|
|
3929
|
+
s.writeU8(v.MLDSASecurityLevel.LEVEL2), s.writeBytes(this.hashedPublicKey), s.writeBytes(t), s.writeBytes(i), s.writeBytes(ke), s.writeBytes(r);
|
|
3930
|
+
const n = s.getBuffer(), o = st.signMessage(this.tweakedSigner, n);
|
|
3931
|
+
if (!st.verifySignature(t, n, o.signature)) throw new Error("Could not verify generated legacy signature for MLDSA link request");
|
|
3901
3932
|
return new Uint8Array(o.signature);
|
|
3902
3933
|
}
|
|
3903
3934
|
generateMLDSASignature() {
|
|
3904
3935
|
if (!this.mldsaSigner) throw new Error("MLDSA signer is not defined");
|
|
3905
3936
|
if (this.tweakSigner(), !this.tweakedSigner) throw new Error("Tweaked signer is not defined");
|
|
3906
|
-
const t =
|
|
3937
|
+
const t = O(this.tweakedSigner.publicKey), i = this.signer.publicKey;
|
|
3907
3938
|
if (i.length !== 33) throw new Error("Original public key must be compressed (33 bytes)");
|
|
3908
|
-
const r =
|
|
3909
|
-
if (s !==
|
|
3910
|
-
const n = new
|
|
3911
|
-
n.writeU8(s), n.writeBytes(this.hashedPublicKey), n.writeBytes(this.mldsaSigner.publicKey), n.writeBytes(t), n.writeBytes(i), n.writeBytes(
|
|
3912
|
-
const o = n.getBuffer(), a =
|
|
3913
|
-
if (!
|
|
3939
|
+
const r = Be(this.network), s = ie(this.mldsaSigner.publicKey.length);
|
|
3940
|
+
if (s !== v.MLDSASecurityLevel.LEVEL2) throw new Error("Only MLDSA level 2 is supported for link requests");
|
|
3941
|
+
const n = new V();
|
|
3942
|
+
n.writeU8(s), n.writeBytes(this.hashedPublicKey), n.writeBytes(this.mldsaSigner.publicKey), n.writeBytes(t), n.writeBytes(i), n.writeBytes(ke), n.writeBytes(r);
|
|
3943
|
+
const o = n.getBuffer(), a = st.signMLDSAMessage(this.mldsaSigner, o);
|
|
3944
|
+
if (!st.verifyMLDSASignature(this.mldsaSigner, o, a.signature)) throw new Error("Could not verify generated MLDSA signature for link request");
|
|
3914
3945
|
return new Uint8Array(a.signature);
|
|
3915
3946
|
}
|
|
3916
3947
|
generateMLDSALinkRequest(t, i) {
|
|
@@ -3919,12 +3950,12 @@ var Ce = new Uint8Array([
|
|
|
3919
3950
|
t.revealMLDSAPublicKey && (n = this.generateMLDSASignature());
|
|
3920
3951
|
const o = {
|
|
3921
3952
|
priority: J.MLDSA_LINK_PUBKEY,
|
|
3922
|
-
opcode:
|
|
3953
|
+
opcode: q.MLDSA_LINK_PUBKEY,
|
|
3923
3954
|
data: {
|
|
3924
3955
|
verifyRequest: !!t.revealMLDSAPublicKey,
|
|
3925
3956
|
publicKey: r.publicKey,
|
|
3926
3957
|
hashedPublicKey: this.hashedPublicKey,
|
|
3927
|
-
level:
|
|
3958
|
+
level: ie(r.publicKey.length),
|
|
3928
3959
|
legacySignature: s,
|
|
3929
3960
|
mldsaSignature: n
|
|
3930
3961
|
}
|
|
@@ -3980,7 +4011,7 @@ var Ce = new Uint8Array([
|
|
|
3980
4011
|
addFeeToOutput(t, i, r, s) {
|
|
3981
4012
|
if (s) {
|
|
3982
4013
|
let n;
|
|
3983
|
-
t >
|
|
4014
|
+
t > 627n ? n = ei : n = t, this.addOutput({
|
|
3984
4015
|
value: L(n),
|
|
3985
4016
|
address: i
|
|
3986
4017
|
}, !0), n === 297n && t - 297n > 330n && this.addOutput({
|
|
@@ -3988,7 +4019,7 @@ var Ce = new Uint8Array([
|
|
|
3988
4019
|
address: r.address
|
|
3989
4020
|
}, !0);
|
|
3990
4021
|
} else {
|
|
3991
|
-
const n = t < 330n ?
|
|
4022
|
+
const n = t < 330n ? Pt : t;
|
|
3992
4023
|
this.addOutput({
|
|
3993
4024
|
value: L(n),
|
|
3994
4025
|
address: r.address
|
|
@@ -4024,13 +4055,13 @@ var Ce = new Uint8Array([
|
|
|
4024
4055
|
return !1;
|
|
4025
4056
|
}
|
|
4026
4057
|
createChangeOutput(t) {
|
|
4027
|
-
if (
|
|
4058
|
+
if (Et.isValidP2TRAddress(this.from, this.network)) return {
|
|
4028
4059
|
value: L(t),
|
|
4029
4060
|
address: this.from,
|
|
4030
4061
|
tapInternalKey: this.internalPubKeyToXOnly()
|
|
4031
4062
|
};
|
|
4032
|
-
if (
|
|
4033
|
-
const i =
|
|
4063
|
+
if (Et.isValidPublicKey(this.from, this.network)) {
|
|
4064
|
+
const i = b.compile([g(this.from.startsWith("0x") ? this.from.slice(2) : this.from), d.OP_CHECKSIG]);
|
|
4034
4065
|
return {
|
|
4035
4066
|
value: L(t),
|
|
4036
4067
|
script: i
|
|
@@ -4040,7 +4071,7 @@ var Ce = new Uint8Array([
|
|
|
4040
4071
|
address: this.from
|
|
4041
4072
|
};
|
|
4042
4073
|
}
|
|
4043
|
-
},
|
|
4074
|
+
}, Kt = class extends B {
|
|
4044
4075
|
type = m.CUSTOM_CODE;
|
|
4045
4076
|
_scriptAddress;
|
|
4046
4077
|
tapLeafScript = null;
|
|
@@ -4057,7 +4088,7 @@ var Ce = new Uint8Array([
|
|
|
4057
4088
|
constructor(e) {
|
|
4058
4089
|
if (super(e), !e.script) throw new Error("Bitcoin script is required");
|
|
4059
4090
|
if (!e.witnesses) throw new Error("Witness(es) are required");
|
|
4060
|
-
this.witnesses = e.witnesses, this.randomBytes = e.randomBytes || W.rndBytes(), this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.scriptSeed = this.getContractSeed(), this.contractSigner = I.fromSeedKeyPair(this.scriptSeed, this.network), this.generator = new
|
|
4091
|
+
this.witnesses = e.witnesses, this.randomBytes = e.randomBytes || W.rndBytes(), this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.scriptSeed = this.getContractSeed(), this.contractSigner = I.fromSeedKeyPair(this.scriptSeed, this.network), this.generator = new ze(this.internalPubKeyToXOnly(), this.network), this.compiledTargetScript = this.generator.compile(e.script), this.scriptTree = this.getScriptTree(), this.internalInit(), this._scriptAddress = de.generatePKSH(this.scriptSeed, this.network);
|
|
4061
4092
|
}
|
|
4062
4093
|
get scriptAddress() {
|
|
4063
4094
|
return this._scriptAddress;
|
|
@@ -4072,7 +4103,7 @@ var Ce = new Uint8Array([
|
|
|
4072
4103
|
return this.randomBytes;
|
|
4073
4104
|
}
|
|
4074
4105
|
contractSignerXOnlyPubKey() {
|
|
4075
|
-
return
|
|
4106
|
+
return O(this.contractSigner.publicKey);
|
|
4076
4107
|
}
|
|
4077
4108
|
async buildTransaction() {
|
|
4078
4109
|
this.to || (this.to = this.getScriptAddress());
|
|
@@ -4102,7 +4133,7 @@ var Ce = new Uint8Array([
|
|
|
4102
4133
|
}
|
|
4103
4134
|
e.signInput(0, this.getSignerKey()), e.finalizeInput(0, this.customFinalizer);
|
|
4104
4135
|
const t = /* @__PURE__ */ new Set([0]);
|
|
4105
|
-
if (this.canUseParallelSigning &&
|
|
4136
|
+
if (this.canUseParallelSigning && dt(this.signer)) try {
|
|
4106
4137
|
const i = await this.signKeyPathInputsParallel(e, /* @__PURE__ */ new Set([0]));
|
|
4107
4138
|
if (i.success) for (const r of i.signatures.keys()) t.add(r);
|
|
4108
4139
|
} catch (i) {
|
|
@@ -4119,12 +4150,12 @@ var Ce = new Uint8Array([
|
|
|
4119
4150
|
return this.useP2MR ? {
|
|
4120
4151
|
network: this.network,
|
|
4121
4152
|
scriptTree: this.scriptTree,
|
|
4122
|
-
name:
|
|
4153
|
+
name: E.P2MR
|
|
4123
4154
|
} : {
|
|
4124
4155
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4125
4156
|
network: this.network,
|
|
4126
4157
|
scriptTree: this.scriptTree,
|
|
4127
|
-
name:
|
|
4158
|
+
name: E.P2TR
|
|
4128
4159
|
};
|
|
4129
4160
|
}
|
|
4130
4161
|
generateTapData() {
|
|
@@ -4135,13 +4166,13 @@ var Ce = new Uint8Array([
|
|
|
4135
4166
|
network: this.network,
|
|
4136
4167
|
scriptTree: this.scriptTree,
|
|
4137
4168
|
redeem: e,
|
|
4138
|
-
name:
|
|
4169
|
+
name: E.P2MR
|
|
4139
4170
|
} : {
|
|
4140
4171
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4141
4172
|
network: this.network,
|
|
4142
4173
|
scriptTree: this.scriptTree,
|
|
4143
4174
|
redeem: e,
|
|
4144
|
-
name:
|
|
4175
|
+
name: E.P2TR
|
|
4145
4176
|
};
|
|
4146
4177
|
}
|
|
4147
4178
|
getScriptSolution(e) {
|
|
@@ -4169,11 +4200,11 @@ var Ce = new Uint8Array([
|
|
|
4169
4200
|
};
|
|
4170
4201
|
generateRedeemScripts() {
|
|
4171
4202
|
this.targetScriptRedeem = {
|
|
4172
|
-
name:
|
|
4203
|
+
name: E.P2TR,
|
|
4173
4204
|
output: this.compiledTargetScript,
|
|
4174
4205
|
redeemVersion: 192
|
|
4175
4206
|
}, this.leftOverFundsScriptRedeem = {
|
|
4176
|
-
name:
|
|
4207
|
+
name: E.P2TR,
|
|
4177
4208
|
output: this.getLeafScript(),
|
|
4178
4209
|
redeemVersion: 192
|
|
4179
4210
|
};
|
|
@@ -4190,7 +4221,7 @@ var Ce = new Uint8Array([
|
|
|
4190
4221
|
version: 192
|
|
4191
4222
|
}];
|
|
4192
4223
|
}
|
|
4193
|
-
},
|
|
4224
|
+
}, ye = class extends B {
|
|
4194
4225
|
static MAXIMUM_CALLDATA_SIZE = 380 * 1024;
|
|
4195
4226
|
randomBytes;
|
|
4196
4227
|
targetScriptRedeem = null;
|
|
@@ -4204,7 +4235,7 @@ var Ce = new Uint8Array([
|
|
|
4204
4235
|
constructor(e) {
|
|
4205
4236
|
if (super(e), !e.calldata) throw new Error("Calldata is required");
|
|
4206
4237
|
if (!e.challenge) throw new Error("Challenge solution is required");
|
|
4207
|
-
this.challenge = e.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.disableAutoRefund = e.disableAutoRefund || !1, this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.calldata = Z.compress(e.calldata), this.randomBytes = e.randomBytes || W.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.calldataGenerator = new
|
|
4238
|
+
this.challenge = e.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.disableAutoRefund = e.disableAutoRefund || !1, this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.calldata = Z.compress(e.calldata), this.randomBytes = e.randomBytes || W.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.calldataGenerator = new le(this.signer.publicKey, this.scriptSignerXOnlyPubKey(), this.network);
|
|
4208
4239
|
}
|
|
4209
4240
|
exportCompiledTargetScript() {
|
|
4210
4241
|
return this.compiledTargetScript;
|
|
@@ -4219,7 +4250,7 @@ var Ce = new Uint8Array([
|
|
|
4219
4250
|
return this.challenge;
|
|
4220
4251
|
}
|
|
4221
4252
|
scriptSignerXOnlyPubKey() {
|
|
4222
|
-
return
|
|
4253
|
+
return O(this.scriptSigner.publicKey);
|
|
4223
4254
|
}
|
|
4224
4255
|
generateKeyPairFromSeed() {
|
|
4225
4256
|
return I.fromSeedKeyPair(this.randomBytes, this.network);
|
|
@@ -4246,12 +4277,12 @@ var Ce = new Uint8Array([
|
|
|
4246
4277
|
return this.useP2MR ? {
|
|
4247
4278
|
network: this.network,
|
|
4248
4279
|
scriptTree: this.scriptTree,
|
|
4249
|
-
name:
|
|
4280
|
+
name: E.P2MR
|
|
4250
4281
|
} : {
|
|
4251
4282
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4252
4283
|
network: this.network,
|
|
4253
4284
|
scriptTree: this.scriptTree,
|
|
4254
|
-
name:
|
|
4285
|
+
name: E.P2TR
|
|
4255
4286
|
};
|
|
4256
4287
|
}
|
|
4257
4288
|
generateTapData() {
|
|
@@ -4262,13 +4293,13 @@ var Ce = new Uint8Array([
|
|
|
4262
4293
|
network: this.network,
|
|
4263
4294
|
scriptTree: this.scriptTree,
|
|
4264
4295
|
redeem: e,
|
|
4265
|
-
name:
|
|
4296
|
+
name: E.P2MR
|
|
4266
4297
|
} : {
|
|
4267
4298
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4268
4299
|
network: this.network,
|
|
4269
4300
|
scriptTree: this.scriptTree,
|
|
4270
4301
|
redeem: e,
|
|
4271
|
-
name:
|
|
4302
|
+
name: E.P2TR
|
|
4272
4303
|
};
|
|
4273
4304
|
}
|
|
4274
4305
|
getScriptSolution(e) {
|
|
@@ -4306,7 +4337,7 @@ var Ce = new Uint8Array([
|
|
|
4306
4337
|
}
|
|
4307
4338
|
}
|
|
4308
4339
|
async signInputsNonWalletBased(e) {
|
|
4309
|
-
if (await this.signInput(e, e.data.inputs[0], 0, this.scriptSigner), await this.signInput(e, e.data.inputs[0], 0, this.getSignerKey()), e.finalizeInput(0, this.customFinalizer.bind(this)), this.canUseParallelSigning &&
|
|
4340
|
+
if (await this.signInput(e, e.data.inputs[0], 0, this.scriptSigner), await this.signInput(e, e.data.inputs[0], 0, this.getSignerKey()), e.finalizeInput(0, this.customFinalizer.bind(this)), this.canUseParallelSigning && dt(this.signer)) {
|
|
4310
4341
|
let t = /* @__PURE__ */ new Set();
|
|
4311
4342
|
try {
|
|
4312
4343
|
const i = await this.signKeyPathInputsParallel(e, /* @__PURE__ */ new Set([0]));
|
|
@@ -4327,21 +4358,21 @@ var Ce = new Uint8Array([
|
|
|
4327
4358
|
if (!this.to) throw new Error("To address is required");
|
|
4328
4359
|
const e = this.getTransactionOPNetFee();
|
|
4329
4360
|
this.addFeeToOutput(e, this.to, this.epochChallenge, !1);
|
|
4330
|
-
const t = e < 330n ?
|
|
4361
|
+
const t = e < 330n ? Pt : e, i = this.addOptionalOutputsAndGetAmount();
|
|
4331
4362
|
this.disableAutoRefund || await this.addRefundOutput(t + i);
|
|
4332
4363
|
}
|
|
4333
4364
|
generateRedeemScripts() {
|
|
4334
4365
|
this.targetScriptRedeem = {
|
|
4335
|
-
name:
|
|
4366
|
+
name: E.P2TR,
|
|
4336
4367
|
output: this.compiledTargetScript,
|
|
4337
4368
|
redeemVersion: 192
|
|
4338
4369
|
}, this.leftOverFundsScriptRedeem = {
|
|
4339
|
-
name:
|
|
4370
|
+
name: E.P2TR,
|
|
4340
4371
|
output: this.LOCK_LEAF_SCRIPT,
|
|
4341
4372
|
redeemVersion: 192
|
|
4342
4373
|
};
|
|
4343
4374
|
}
|
|
4344
|
-
},
|
|
4375
|
+
}, Dt = class ii extends B {
|
|
4345
4376
|
static MAXIMUM_CONTRACT_SIZE = 1536 * 1024;
|
|
4346
4377
|
type = m.DEPLOYMENT;
|
|
4347
4378
|
challenge;
|
|
@@ -4363,12 +4394,12 @@ var Ce = new Uint8Array([
|
|
|
4363
4394
|
_computedAddress;
|
|
4364
4395
|
constructor(t) {
|
|
4365
4396
|
if (super(t), !this.hashedPublicKey) throw new Error("MLDSA signer must be defined to deploy a contract.");
|
|
4366
|
-
if (this.bytecode = Z.compress(new Uint8Array([
|
|
4367
|
-
if (this.randomBytes = t.randomBytes || W.rndBytes(), this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.contractSeed = this.getContractSeed(), this.contractSigner = I.fromSeedKeyPair(this.contractSeed, this.network), this.deploymentGenerator = new
|
|
4397
|
+
if (this.bytecode = Z.compress(new Uint8Array([...qe, ...t.bytecode])), this.verifyBytecode(), t.calldata && (this.calldata = t.calldata, this.verifyCalldata()), !t.challenge) throw new Error("Challenge solution is required");
|
|
4398
|
+
if (this.randomBytes = t.randomBytes || W.rndBytes(), this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.contractSeed = this.getContractSeed(), this.contractSigner = I.fromSeedKeyPair(this.contractSeed, this.network), this.deploymentGenerator = new he(this.signer.publicKey, this.contractSignerXOnlyPubKey(), this.network), t.compiledTargetScript) if (t.compiledTargetScript instanceof Uint8Array) this.compiledTargetScript = t.compiledTargetScript;
|
|
4368
4399
|
else if (typeof t.compiledTargetScript == "string") this.compiledTargetScript = g(t.compiledTargetScript);
|
|
4369
4400
|
else throw new Error("Invalid compiled target script format.");
|
|
4370
4401
|
else this.compiledTargetScript = this.deploymentGenerator.compile(this.bytecode, this.randomBytes, this.challenge, this.priorityFee, this.calldata, this.generateFeatures(t));
|
|
4371
|
-
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + f(this.contractSeed), this._contractAddress = new
|
|
4402
|
+
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + f(this.contractSeed), this._contractAddress = new z(this.contractSeed);
|
|
4372
4403
|
}
|
|
4373
4404
|
get contractPubKey() {
|
|
4374
4405
|
return this._contractPubKey;
|
|
@@ -4392,7 +4423,7 @@ var Ce = new Uint8Array([
|
|
|
4392
4423
|
return this._computedAddress ? this._computedAddress : (this._computedAddress = I.p2op(this.contractSeed, this.network, this.deploymentVersion), this._computedAddress);
|
|
4393
4424
|
}
|
|
4394
4425
|
contractSignerXOnlyPubKey() {
|
|
4395
|
-
return
|
|
4426
|
+
return O(this.contractSigner.publicKey);
|
|
4396
4427
|
}
|
|
4397
4428
|
async buildTransaction() {
|
|
4398
4429
|
this.to || (this.to = this.getScriptAddress());
|
|
@@ -4429,7 +4460,7 @@ var Ce = new Uint8Array([
|
|
|
4429
4460
|
}
|
|
4430
4461
|
t.signInput(0, this.contractSigner), t.signInput(0, this.getSignerKey()), t.finalizeInput(0, this.customFinalizer.bind(this));
|
|
4431
4462
|
const i = /* @__PURE__ */ new Set([0]);
|
|
4432
|
-
if (this.canUseParallelSigning &&
|
|
4463
|
+
if (this.canUseParallelSigning && dt(this.signer)) try {
|
|
4433
4464
|
const r = await this.signKeyPathInputsParallel(t, /* @__PURE__ */ new Set([0]));
|
|
4434
4465
|
if (r.success) for (const s of r.signatures.keys()) i.add(s);
|
|
4435
4466
|
} catch (r) {
|
|
@@ -4444,11 +4475,11 @@ var Ce = new Uint8Array([
|
|
|
4444
4475
|
}
|
|
4445
4476
|
generateScriptAddress() {
|
|
4446
4477
|
return this.useP2MR ? {
|
|
4447
|
-
name:
|
|
4478
|
+
name: E.P2MR,
|
|
4448
4479
|
network: this.network,
|
|
4449
4480
|
scriptTree: this.scriptTree
|
|
4450
4481
|
} : {
|
|
4451
|
-
name:
|
|
4482
|
+
name: E.P2TR,
|
|
4452
4483
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4453
4484
|
network: this.network,
|
|
4454
4485
|
scriptTree: this.scriptTree
|
|
@@ -4459,12 +4490,12 @@ var Ce = new Uint8Array([
|
|
|
4459
4490
|
if (!t) throw new Error("Left over funds script redeem is required");
|
|
4460
4491
|
if (!this.scriptTree) throw new Error("Script tree is required");
|
|
4461
4492
|
return this.useP2MR ? {
|
|
4462
|
-
name:
|
|
4493
|
+
name: E.P2MR,
|
|
4463
4494
|
network: this.network,
|
|
4464
4495
|
scriptTree: this.scriptTree,
|
|
4465
4496
|
redeem: t
|
|
4466
4497
|
} : {
|
|
4467
|
-
name:
|
|
4498
|
+
name: E.P2TR,
|
|
4468
4499
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4469
4500
|
network: this.network,
|
|
4470
4501
|
scriptTree: this.scriptTree,
|
|
@@ -4475,21 +4506,21 @@ var Ce = new Uint8Array([
|
|
|
4475
4506
|
const i = [], r = t.challenge.getSubmission();
|
|
4476
4507
|
if (r && i.push({
|
|
4477
4508
|
priority: J.MLDSA_LINK_PUBKEY,
|
|
4478
|
-
opcode:
|
|
4509
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
4479
4510
|
data: r
|
|
4480
4511
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress) throw new Error("To reveal the MLDSA public key, you must set linkMLDSAPublicKeyToAddress to true.");
|
|
4481
4512
|
return t.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(t, i), i;
|
|
4482
4513
|
}
|
|
4483
4514
|
verifyCalldata() {
|
|
4484
|
-
if (this.calldata && this.calldata.length >
|
|
4515
|
+
if (this.calldata && this.calldata.length > ye.MAXIMUM_CALLDATA_SIZE) throw new Error("Calldata size overflow.");
|
|
4485
4516
|
}
|
|
4486
4517
|
verifyBytecode() {
|
|
4487
4518
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
4488
|
-
if (this.bytecode.length >
|
|
4519
|
+
if (this.bytecode.length > ii.MAXIMUM_CONTRACT_SIZE) throw new Error("Contract size overflow.");
|
|
4489
4520
|
}
|
|
4490
4521
|
getContractSeed() {
|
|
4491
4522
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
4492
|
-
const t =
|
|
4523
|
+
const t = ht([
|
|
4493
4524
|
this.internalPubKeyToXOnly(),
|
|
4494
4525
|
D.hash256(this.randomBytes),
|
|
4495
4526
|
D.hash256(this.bytecode)
|
|
@@ -4508,11 +4539,11 @@ var Ce = new Uint8Array([
|
|
|
4508
4539
|
};
|
|
4509
4540
|
generateRedeemScripts() {
|
|
4510
4541
|
this.targetScriptRedeem = {
|
|
4511
|
-
name:
|
|
4542
|
+
name: E.P2TR,
|
|
4512
4543
|
output: this.compiledTargetScript,
|
|
4513
4544
|
redeemVersion: 192
|
|
4514
4545
|
}, this.leftOverFundsScriptRedeem = {
|
|
4515
|
-
name:
|
|
4546
|
+
name: E.P2TR,
|
|
4516
4547
|
output: this.getLeafScript(),
|
|
4517
4548
|
redeemVersion: 192
|
|
4518
4549
|
};
|
|
@@ -4530,7 +4561,7 @@ var Ce = new Uint8Array([
|
|
|
4530
4561
|
version: 192
|
|
4531
4562
|
}];
|
|
4532
4563
|
}
|
|
4533
|
-
},
|
|
4564
|
+
}, Mt = class extends B {
|
|
4534
4565
|
type = m.FUNDING;
|
|
4535
4566
|
amount;
|
|
4536
4567
|
splitInputsInto;
|
|
@@ -4544,28 +4575,30 @@ var Ce = new Uint8Array([
|
|
|
4544
4575
|
}
|
|
4545
4576
|
async buildTransaction() {
|
|
4546
4577
|
if (!this.to) throw new Error("Recipient address is required");
|
|
4547
|
-
if (this.addInputsFromUTXO(), this.autoAdjustAmount
|
|
4578
|
+
if (this.addInputsFromUTXO(), this.autoAdjustAmount) {
|
|
4548
4579
|
const t = this.splitInputsInto > 1 ? this.splitInputsInto : 1, i = this.amount / BigInt(t);
|
|
4549
|
-
for (let
|
|
4550
|
-
const
|
|
4580
|
+
for (let n = 0; n < t; n++) if (this.isPubKeyDestination) {
|
|
4581
|
+
const o = this.to.startsWith("0x") ? this.to.slice(2) : this.to, a = b.compile([g(o), d.OP_CHECKSIG]);
|
|
4551
4582
|
this.addOutput({
|
|
4552
4583
|
value: L(i),
|
|
4553
|
-
script:
|
|
4584
|
+
script: a
|
|
4554
4585
|
});
|
|
4555
4586
|
} else this.addOutput({
|
|
4556
4587
|
value: L(i),
|
|
4557
4588
|
address: this.to
|
|
4558
4589
|
});
|
|
4559
|
-
this.note && this.addOPReturn(this.note);
|
|
4560
|
-
const r = await this.estimateTransactionFees(), s = t + (this.note ? 1 : 0);
|
|
4561
|
-
for (let
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4590
|
+
this.note && this.addOPReturn(this.note), this.anchor && this.addAnchor();
|
|
4591
|
+
const r = await this.estimateTransactionFees(), s = t + (this.note ? 1 : 0) + (this.anchor ? 1 : 0);
|
|
4592
|
+
for (let n = 0; n < s; n++) this.outputs.pop();
|
|
4593
|
+
if (this.amount + r > this.totalInputAmount) {
|
|
4594
|
+
const n = this.totalInputAmount - r;
|
|
4595
|
+
if (n < B.MINIMUM_DUST) throw new Error(`Insufficient funds: after deducting fee of ${r} sats, remaining amount ${n} sats is below minimum dust`);
|
|
4596
|
+
this.amount = n;
|
|
4597
|
+
}
|
|
4565
4598
|
}
|
|
4566
4599
|
if (this.splitInputsInto > 1) this.splitInputs(this.amount);
|
|
4567
4600
|
else if (this.isPubKeyDestination) {
|
|
4568
|
-
const t = this.to.startsWith("0x") ? this.to.slice(2) : this.to, i =
|
|
4601
|
+
const t = this.to.startsWith("0x") ? this.to.slice(2) : this.to, i = b.compile([g(t), d.OP_CHECKSIG]);
|
|
4569
4602
|
this.addOutput({
|
|
4570
4603
|
value: L(this.amount),
|
|
4571
4604
|
script: i
|
|
@@ -4591,7 +4624,7 @@ var Ce = new Uint8Array([
|
|
|
4591
4624
|
getSignerKey() {
|
|
4592
4625
|
return this.signer;
|
|
4593
4626
|
}
|
|
4594
|
-
},
|
|
4627
|
+
}, Nt = class extends ye {
|
|
4595
4628
|
type = m.INTERACTION;
|
|
4596
4629
|
compiledTargetScript;
|
|
4597
4630
|
scriptTree;
|
|
@@ -4610,18 +4643,18 @@ var Ce = new Uint8Array([
|
|
|
4610
4643
|
const t = [];
|
|
4611
4644
|
e.loadedStorage && t.push({
|
|
4612
4645
|
priority: J.ACCESS_LIST,
|
|
4613
|
-
opcode:
|
|
4646
|
+
opcode: q.ACCESS_LIST,
|
|
4614
4647
|
data: e.loadedStorage
|
|
4615
4648
|
});
|
|
4616
4649
|
const i = e.challenge.getSubmission();
|
|
4617
4650
|
if (i && t.push({
|
|
4618
4651
|
priority: J.EPOCH_SUBMISSION,
|
|
4619
|
-
opcode:
|
|
4652
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
4620
4653
|
data: i
|
|
4621
4654
|
}), e.revealMLDSAPublicKey && !e.linkMLDSAPublicKeyToAddress) throw new Error("To reveal the MLDSA public key, you must set linkMLDSAPublicKeyToAddress to true.");
|
|
4622
4655
|
return e.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(e, t), t;
|
|
4623
4656
|
}
|
|
4624
|
-
},
|
|
4657
|
+
}, ri = class lt extends B {
|
|
4625
4658
|
static MAX_WITNESS_FIELDS = 10;
|
|
4626
4659
|
static MAX_BYTES_PER_WITNESS = 80;
|
|
4627
4660
|
type = m.INTERACTION;
|
|
@@ -4640,7 +4673,7 @@ var Ce = new Uint8Array([
|
|
|
4640
4673
|
if (!t.contract) throw new Error("Contract secret is required");
|
|
4641
4674
|
if (!t.calldata) throw new Error("Calldata is required");
|
|
4642
4675
|
if (!t.challenge) throw new Error("Challenge solution is required");
|
|
4643
|
-
if (this.disableAutoRefund = t.disableAutoRefund || !1, this.contractSecret = g(t.contract.startsWith("0x") ? t.contract.slice(2) : t.contract), this.calldata = Z.compress(t.calldata), this.challenge = t.challenge, this.randomBytes = t.randomBytes || W.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.p2wdaGenerator = new
|
|
4676
|
+
if (this.disableAutoRefund = t.disableAutoRefund || !1, this.contractSecret = g(t.contract.startsWith("0x") ? t.contract.slice(2) : t.contract), this.calldata = Z.compress(t.calldata), this.challenge = t.challenge, this.randomBytes = t.randomBytes || W.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.p2wdaGenerator = new Jt(this.signer.publicKey, this.scriptSignerXOnlyPubKey(), this.network), this.contractSecret.length !== 32) throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
4644
4677
|
if (this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.validateP2WDAInputs(), t.compiledTargetScript) if (t.compiledTargetScript instanceof Uint8Array) this.compiledOperationData = t.compiledTargetScript;
|
|
4645
4678
|
else if (typeof t.compiledTargetScript == "string") this.compiledOperationData = g(t.compiledTargetScript);
|
|
4646
4679
|
else throw new Error("Invalid compiled target script format.");
|
|
@@ -4675,13 +4708,13 @@ var Ce = new Uint8Array([
|
|
|
4675
4708
|
const i = [];
|
|
4676
4709
|
t.loadedStorage && i.push({
|
|
4677
4710
|
priority: J.ACCESS_LIST,
|
|
4678
|
-
opcode:
|
|
4711
|
+
opcode: q.ACCESS_LIST,
|
|
4679
4712
|
data: t.loadedStorage
|
|
4680
4713
|
});
|
|
4681
4714
|
const r = t.challenge.getSubmission();
|
|
4682
4715
|
return r && i.push({
|
|
4683
4716
|
priority: J.EPOCH_SUBMISSION,
|
|
4684
|
-
opcode:
|
|
4717
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
4685
4718
|
data: r
|
|
4686
4719
|
}), i;
|
|
4687
4720
|
}
|
|
@@ -4689,32 +4722,32 @@ var Ce = new Uint8Array([
|
|
|
4689
4722
|
return I.fromSeedKeyPair(this.randomBytes, this.network);
|
|
4690
4723
|
}
|
|
4691
4724
|
scriptSignerXOnlyPubKey() {
|
|
4692
|
-
return
|
|
4725
|
+
return O(this.scriptSigner.publicKey);
|
|
4693
4726
|
}
|
|
4694
4727
|
validateP2WDAInputs() {
|
|
4695
|
-
if (this.utxos.length === 0 ||
|
|
4696
|
-
for (let t = 0; t < this.utxos.length; t++)
|
|
4728
|
+
if (this.utxos.length === 0 || !X.isP2WDAUTXO(this.utxos[0])) throw new Error("Input 0 must be a P2WDA UTXO");
|
|
4729
|
+
for (let t = 0; t < this.utxos.length; t++) X.isP2WDAUTXO(this.utxos[t]) && this.p2wdaInputIndices.add(t);
|
|
4697
4730
|
for (let t = 0; t < this.optionalInputs.length; t++) {
|
|
4698
4731
|
const i = this.utxos.length + t;
|
|
4699
|
-
|
|
4732
|
+
X.isP2WDAUTXO(this.optionalInputs[t]) && this.p2wdaInputIndices.add(i);
|
|
4700
4733
|
}
|
|
4701
4734
|
}
|
|
4702
4735
|
validateOperationDataSize() {
|
|
4703
4736
|
if (!this.compiledOperationData) throw new Error("Operation data not compiled");
|
|
4704
4737
|
const t = this.compiledOperationData.length;
|
|
4705
|
-
if (!
|
|
4706
|
-
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(r /
|
|
4707
|
-
throw new Error(`Please dont use P2WDA for this operation. Data too large. Raw size: ${t} bytes, estimated compressed: ${r} bytes, needs ${s} witness fields, max is ${
|
|
4738
|
+
if (!Jt.validateWitnessSize(t)) {
|
|
4739
|
+
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(r / lt.MAX_BYTES_PER_WITNESS);
|
|
4740
|
+
throw new Error(`Please dont use P2WDA for this operation. Data too large. Raw size: ${t} bytes, estimated compressed: ${r} bytes, needs ${s} witness fields, max is ${lt.MAX_WITNESS_FIELDS}`);
|
|
4708
4741
|
}
|
|
4709
4742
|
}
|
|
4710
4743
|
finalizePrimaryP2WDA(t, i) {
|
|
4711
4744
|
if (!i.partialSig || i.partialSig.length === 0) throw new Error(`No signature for P2WDA input #${t}`);
|
|
4712
4745
|
if (!i.witnessScript) throw new Error(`No witness script for P2WDA input #${t}`);
|
|
4713
4746
|
if (!this.compiledOperationData) throw new Error("Operation data not compiled");
|
|
4714
|
-
const r = i.partialSig[0].signature, s =
|
|
4715
|
-
if (c.length >
|
|
4747
|
+
const r = i.partialSig[0].signature, s = ht([r, this.compiledOperationData]), n = st.signMessage(this.signer, s).signature, o = ht([n, this.compiledOperationData]), a = Z.compress(o), c = this.splitIntoWitnessChunks(a);
|
|
4748
|
+
if (c.length > lt.MAX_WITNESS_FIELDS) throw new Error(`Compressed data needs ${c.length} witness fields, max is ${lt.MAX_WITNESS_FIELDS}`);
|
|
4716
4749
|
const u = [r];
|
|
4717
|
-
for (let l = 0; l <
|
|
4750
|
+
for (let l = 0; l < lt.MAX_WITNESS_FIELDS; l++) u.push(l < c.length ? c[l] : /* @__PURE__ */ new Uint8Array(0));
|
|
4718
4751
|
return u.push(i.witnessScript), {
|
|
4719
4752
|
finalScriptSig: void 0,
|
|
4720
4753
|
finalScriptWitness: B.witnessStackToScriptWitness(u)
|
|
@@ -4724,12 +4757,12 @@ var Ce = new Uint8Array([
|
|
|
4724
4757
|
const i = [];
|
|
4725
4758
|
let r = 0;
|
|
4726
4759
|
for (; r < t.length; ) {
|
|
4727
|
-
const s = Math.min(
|
|
4760
|
+
const s = Math.min(lt.MAX_BYTES_PER_WITNESS, t.length - r);
|
|
4728
4761
|
i.push(t.slice(r, r + s)), r += s;
|
|
4729
4762
|
}
|
|
4730
4763
|
return i;
|
|
4731
4764
|
}
|
|
4732
|
-
},
|
|
4765
|
+
}, me = class extends B {
|
|
4733
4766
|
type = m.CANCEL;
|
|
4734
4767
|
tapLeafScript = null;
|
|
4735
4768
|
compiledTargetScript;
|
|
@@ -4742,8 +4775,8 @@ var Ce = new Uint8Array([
|
|
|
4742
4775
|
gasSatFee: 1n,
|
|
4743
4776
|
isCancellation: !0,
|
|
4744
4777
|
priorityFee: 1n,
|
|
4745
|
-
calldata: new Uint8Array(0)
|
|
4746
|
-
}), this.contractSecret = new Uint8Array(0), e.compiledTargetScript instanceof Uint8Array ? this.compiledTargetScript = e.compiledTargetScript : this.compiledTargetScript = g(e.compiledTargetScript), this.scriptTree = this.getMinimalScriptTree(), this.internalInit();
|
|
4778
|
+
calldata: /* @__PURE__ */ new Uint8Array(0)
|
|
4779
|
+
}), this.contractSecret = /* @__PURE__ */ new Uint8Array(0), e.compiledTargetScript instanceof Uint8Array ? this.compiledTargetScript = e.compiledTargetScript : this.compiledTargetScript = g(e.compiledTargetScript), this.scriptTree = this.getMinimalScriptTree(), this.internalInit();
|
|
4747
4780
|
}
|
|
4748
4781
|
async buildTransaction() {
|
|
4749
4782
|
if (!this.from) throw new Error("From address is required");
|
|
@@ -4760,12 +4793,12 @@ var Ce = new Uint8Array([
|
|
|
4760
4793
|
return this.useP2MR ? {
|
|
4761
4794
|
network: this.network,
|
|
4762
4795
|
scriptTree: this.scriptTree,
|
|
4763
|
-
name:
|
|
4796
|
+
name: E.P2MR
|
|
4764
4797
|
} : {
|
|
4765
4798
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4766
4799
|
network: this.network,
|
|
4767
4800
|
scriptTree: this.scriptTree,
|
|
4768
|
-
name:
|
|
4801
|
+
name: E.P2TR
|
|
4769
4802
|
};
|
|
4770
4803
|
}
|
|
4771
4804
|
generateTapData() {
|
|
@@ -4776,13 +4809,13 @@ var Ce = new Uint8Array([
|
|
|
4776
4809
|
network: this.network,
|
|
4777
4810
|
scriptTree: this.scriptTree,
|
|
4778
4811
|
redeem: e,
|
|
4779
|
-
name:
|
|
4812
|
+
name: E.P2MR
|
|
4780
4813
|
} : {
|
|
4781
4814
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4782
4815
|
network: this.network,
|
|
4783
4816
|
scriptTree: this.scriptTree,
|
|
4784
4817
|
redeem: e,
|
|
4785
|
-
name:
|
|
4818
|
+
name: E.P2TR
|
|
4786
4819
|
};
|
|
4787
4820
|
}
|
|
4788
4821
|
customFinalizer = (e, t) => {
|
|
@@ -4806,7 +4839,7 @@ var Ce = new Uint8Array([
|
|
|
4806
4839
|
async signInputsNonWalletBased(e) {
|
|
4807
4840
|
await this.signInput(e, e.data.inputs[0], 0, this.getSignerKey()), e.finalizeInput(0, this.customFinalizer.bind(this));
|
|
4808
4841
|
let t = /* @__PURE__ */ new Set();
|
|
4809
|
-
if (this.canUseParallelSigning &&
|
|
4842
|
+
if (this.canUseParallelSigning && dt(this.signer)) try {
|
|
4810
4843
|
const i = await this.signKeyPathInputsParallel(e, /* @__PURE__ */ new Set([0]));
|
|
4811
4844
|
i.success && (t = new Set(i.signatures.keys()));
|
|
4812
4845
|
} catch (i) {
|
|
@@ -4831,12 +4864,12 @@ var Ce = new Uint8Array([
|
|
|
4831
4864
|
}
|
|
4832
4865
|
generateLeftoverFundsRedeem() {
|
|
4833
4866
|
this.leftOverFundsScriptRedeem = {
|
|
4834
|
-
name:
|
|
4867
|
+
name: E.P2TR,
|
|
4835
4868
|
output: this.LOCK_LEAF_SCRIPT,
|
|
4836
4869
|
redeemVersion: 192
|
|
4837
4870
|
};
|
|
4838
4871
|
}
|
|
4839
|
-
},
|
|
4872
|
+
}, si = class extends B {
|
|
4840
4873
|
type = m.INTERACTION;
|
|
4841
4874
|
randomBytes;
|
|
4842
4875
|
contractAddress;
|
|
@@ -4857,12 +4890,12 @@ var Ce = new Uint8Array([
|
|
|
4857
4890
|
if (!e.contract) throw new Error("Contract secret (contract) is required");
|
|
4858
4891
|
if (!e.calldata) throw new Error("Calldata is required");
|
|
4859
4892
|
if (!e.challenge) throw new Error("Challenge solution is required");
|
|
4860
|
-
if (this.contractAddress = e.to, this.contractSecret = g(e.contract.startsWith("0x") ? e.contract.slice(2) : e.contract), this.disableAutoRefund = e.disableAutoRefund || !1, this.maxChunkSize = e.maxChunkSize ??
|
|
4861
|
-
if (this.calldata = Z.compress(e.calldata), this.randomBytes = e.randomBytes || W.rndBytes(), this.scriptSigner = I.fromSeedKeyPair(this.randomBytes, this.network), this.challenge = e.challenge, this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.calldataGenerator = new
|
|
4893
|
+
if (this.contractAddress = e.to, this.contractSecret = g(e.contract.startsWith("0x") ? e.contract.slice(2) : e.contract), this.disableAutoRefund = e.disableAutoRefund || !1, this.maxChunkSize = e.maxChunkSize ?? St.MAX_CHUNK_SIZE, this.contractSecret.length !== 32) throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
4894
|
+
if (this.calldata = Z.compress(e.calldata), this.randomBytes = e.randomBytes || W.rndBytes(), this.scriptSigner = I.fromSeedKeyPair(this.randomBytes, this.network), this.challenge = e.challenge, this.epochChallenge = nt.generateTimeLockAddress(this.challenge.publicKey.originalPublicKeyBuffer(), this.network), this.calldataGenerator = new le(this.signer.publicKey, O(this.scriptSigner.publicKey), this.network), e.compiledTargetScript) if (e.compiledTargetScript instanceof Uint8Array) this.compiledTargetScript = e.compiledTargetScript;
|
|
4862
4895
|
else if (typeof e.compiledTargetScript == "string") this.compiledTargetScript = g(e.compiledTargetScript);
|
|
4863
4896
|
else throw new Error("Invalid compiled target script format.");
|
|
4864
4897
|
else this.compiledTargetScript = this.calldataGenerator.compile(this.calldata, this.contractSecret, this.challenge, this.priorityFee, this.generateFeatures(e));
|
|
4865
|
-
this.hashCommitmentGenerator = new
|
|
4898
|
+
this.hashCommitmentGenerator = new St(this.signer.publicKey, this.network), this.commitmentOutputs = this.hashCommitmentGenerator.prepareChunks(this.compiledTargetScript, this.maxChunkSize), this.validateOutputCount();
|
|
4866
4899
|
const t = this.commitmentOutputs.reduce((i, r) => i + r.dataChunks.length, 0);
|
|
4867
4900
|
this.log(`ConsolidatedInteractionTransaction: ${this.commitmentOutputs.length} outputs, ${t} chunks from ${this.compiledTargetScript.length} bytes compiled data`), this.internalInit();
|
|
4868
4901
|
}
|
|
@@ -4905,7 +4938,7 @@ var Ce = new Uint8Array([
|
|
|
4905
4938
|
};
|
|
4906
4939
|
}
|
|
4907
4940
|
buildRevealTransaction(e) {
|
|
4908
|
-
const t = new
|
|
4941
|
+
const t = new N({ network: this.network }), i = this.calculateValuePerOutput();
|
|
4909
4942
|
for (let h = 0; h < this.commitmentOutputs.length; h++) {
|
|
4910
4943
|
const p = this.commitmentOutputs[h];
|
|
4911
4944
|
t.addInput({
|
|
@@ -4918,7 +4951,7 @@ var Ce = new Uint8Array([
|
|
|
4918
4951
|
witnessScript: p.witnessScript
|
|
4919
4952
|
});
|
|
4920
4953
|
}
|
|
4921
|
-
const r = BigInt(this.commitmentOutputs.length) * i, s = this.getTransactionOPNetFee(), n = s < 330n ?
|
|
4954
|
+
const r = BigInt(this.commitmentOutputs.length) * i, s = this.getTransactionOPNetFee(), n = s < 330n ? Pt : s;
|
|
4922
4955
|
t.addOutput({
|
|
4923
4956
|
address: this.epochChallenge.address,
|
|
4924
4957
|
value: L(n)
|
|
@@ -4982,37 +5015,37 @@ var Ce = new Uint8Array([
|
|
|
4982
5015
|
}
|
|
4983
5016
|
calculateValuePerOutput() {
|
|
4984
5017
|
if (this.cachedValuePerOutput !== null) return this.cachedValuePerOutput;
|
|
4985
|
-
const e = this.commitmentOutputs.length, t = this.getTransactionOPNetFee(), i = t < 330n ?
|
|
5018
|
+
const e = this.commitmentOutputs.length, t = this.getTransactionOPNetFee(), i = t < 330n ? Pt : t, r = this.estimateRevealVBytes(), s = i + BigInt(Math.ceil(r * this.feeRate)) + B.MINIMUM_DUST, n = BigInt(Math.ceil(Number(s) / e)), o = St.MIN_OUTPUT_VALUE;
|
|
4986
5019
|
return this.cachedValuePerOutput = n > o ? n : o, this.cachedValuePerOutput;
|
|
4987
5020
|
}
|
|
4988
5021
|
getRefundAddress() {
|
|
4989
|
-
return this.from ? this.from :
|
|
5022
|
+
return this.from ? this.from : de.generatePKSH(this.signer.publicKey, this.network);
|
|
4990
5023
|
}
|
|
4991
5024
|
generateFeatures(e) {
|
|
4992
5025
|
const t = [];
|
|
4993
5026
|
e.loadedStorage && t.push({
|
|
4994
5027
|
priority: J.ACCESS_LIST,
|
|
4995
|
-
opcode:
|
|
5028
|
+
opcode: q.ACCESS_LIST,
|
|
4996
5029
|
data: e.loadedStorage
|
|
4997
5030
|
});
|
|
4998
5031
|
const i = e.challenge.getSubmission();
|
|
4999
5032
|
if (i && t.push({
|
|
5000
5033
|
priority: J.EPOCH_SUBMISSION,
|
|
5001
|
-
opcode:
|
|
5034
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
5002
5035
|
data: i
|
|
5003
5036
|
}), e.revealMLDSAPublicKey && !e.linkMLDSAPublicKeyToAddress) throw new Error("To reveal the MLDSA public key, you must set linkMLDSAPublicKeyToAddress to true.");
|
|
5004
5037
|
return e.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(e, t), t;
|
|
5005
5038
|
}
|
|
5006
5039
|
validateOutputCount() {
|
|
5007
|
-
const e =
|
|
5040
|
+
const e = St.calculateMaxInputsPerTx();
|
|
5008
5041
|
if (this.commitmentOutputs.length > e) {
|
|
5009
|
-
const t =
|
|
5042
|
+
const t = St.calculateMaxDataPerTx();
|
|
5010
5043
|
throw new Error(`Data too large: ${this.commitmentOutputs.length} P2WSH outputs needed, max ${e} per standard transaction (~${Math.floor(t / 1024)}KB). Compiled data: ${this.compiledTargetScript.length} bytes.`);
|
|
5011
5044
|
}
|
|
5012
5045
|
}
|
|
5013
|
-
},
|
|
5046
|
+
}, ni = class {
|
|
5014
5047
|
debug = !1;
|
|
5015
|
-
DUMMY_PUBKEY = new Uint8Array(32).fill(1);
|
|
5048
|
+
DUMMY_PUBKEY = (/* @__PURE__ */ new Uint8Array(32)).fill(1);
|
|
5016
5049
|
P2TR_SCRIPT = Uint8Array.from([
|
|
5017
5050
|
81,
|
|
5018
5051
|
32,
|
|
@@ -5027,7 +5060,7 @@ var Ce = new Uint8Array([
|
|
|
5027
5060
|
const t = await this.detectCancelOPWallet(e);
|
|
5028
5061
|
if (t) return t;
|
|
5029
5062
|
if (!("signer" in e)) throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
5030
|
-
const i = await new
|
|
5063
|
+
const i = await new me(e).signTransaction();
|
|
5031
5064
|
return {
|
|
5032
5065
|
transaction: i.toHex(),
|
|
5033
5066
|
nextUTXOs: this.getUTXOAsTransaction(i, e.from, 0),
|
|
@@ -5042,7 +5075,7 @@ var Ce = new Uint8Array([
|
|
|
5042
5075
|
const t = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: i, estimatedAmount: r } = await this.iterateFundingAmount({
|
|
5043
5076
|
...e,
|
|
5044
5077
|
optionalInputs: t
|
|
5045
|
-
},
|
|
5078
|
+
}, Kt, async (c) => {
|
|
5046
5079
|
const u = await c.estimateTransactionFees(), l = this.getPriorityFee(e), h = c.getOptionalOutputValue();
|
|
5047
5080
|
return u + l + h;
|
|
5048
5081
|
}, "CustomScript"), s = await i.getFundingTransactionParameters();
|
|
@@ -5060,7 +5093,7 @@ var Ce = new Uint8Array([
|
|
|
5060
5093
|
optionalInputs: []
|
|
5061
5094
|
});
|
|
5062
5095
|
if (!o) throw new Error("Could not sign funding transaction.");
|
|
5063
|
-
const a = await new
|
|
5096
|
+
const a = await new Kt({
|
|
5064
5097
|
...e,
|
|
5065
5098
|
utxos: this.getUTXOAsTransaction(o.tx, e.to, 0),
|
|
5066
5099
|
randomBytes: i.getRndBytes(),
|
|
@@ -5087,7 +5120,7 @@ var Ce = new Uint8Array([
|
|
|
5087
5120
|
const i = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: n } = await this.iterateFundingAmount({
|
|
5088
5121
|
...e,
|
|
5089
5122
|
optionalInputs: i
|
|
5090
|
-
},
|
|
5123
|
+
}, Nt, async (p) => {
|
|
5091
5124
|
const w = await p.estimateTransactionFees() + p.getTotalOutputValue();
|
|
5092
5125
|
if (e.subtractExtraUTXOFromAmountRequired && e.optionalInputs && e.optionalInputs.length > 0) {
|
|
5093
5126
|
const T = e.optionalInputs.reduce((k, x) => k + x.value, 0n), A = w > T ? w - T : 0n;
|
|
@@ -5111,7 +5144,7 @@ var Ce = new Uint8Array([
|
|
|
5111
5144
|
optionalInputs: []
|
|
5112
5145
|
});
|
|
5113
5146
|
if (!c) throw new Error("Could not sign funding transaction.");
|
|
5114
|
-
const u = this.getUTXOAsTransaction(c.tx, r.getScriptAddress(), 0), l = new
|
|
5147
|
+
const u = this.getUTXOAsTransaction(c.tx, r.getScriptAddress(), 0), l = new Nt({
|
|
5115
5148
|
...e,
|
|
5116
5149
|
utxos: u,
|
|
5117
5150
|
randomBytes: r.getRndBytes(),
|
|
@@ -5139,7 +5172,7 @@ var Ce = new Uint8Array([
|
|
|
5139
5172
|
if (!e.utxos[0]) throw new Error("Missing at least one UTXO.");
|
|
5140
5173
|
if (!("signer" in e)) throw new Error('Field "signer" not provided.');
|
|
5141
5174
|
if (!e.challenge) throw new Error('Field "challenge" not provided.');
|
|
5142
|
-
const t = this.parseOptionalInputs(e.optionalInputs), i = new
|
|
5175
|
+
const t = this.parseOptionalInputs(e.optionalInputs), i = new si({
|
|
5143
5176
|
...e,
|
|
5144
5177
|
optionalInputs: t
|
|
5145
5178
|
}), r = await i.build();
|
|
@@ -5163,7 +5196,7 @@ var Ce = new Uint8Array([
|
|
|
5163
5196
|
const i = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: n } = await this.iterateFundingAmount({
|
|
5164
5197
|
...e,
|
|
5165
5198
|
optionalInputs: i
|
|
5166
|
-
},
|
|
5199
|
+
}, Dt, async (A) => {
|
|
5167
5200
|
const k = await A.estimateTransactionFees(), x = this.getPriorityFee(e), yt = A.getOptionalOutputValue();
|
|
5168
5201
|
return k + x + yt;
|
|
5169
5202
|
}, "Deployment");
|
|
@@ -5177,7 +5210,7 @@ var Ce = new Uint8Array([
|
|
|
5177
5210
|
});
|
|
5178
5211
|
if (!a) throw new Error("Could not sign funding transaction.");
|
|
5179
5212
|
o.estimatedFees = a.estimatedFees;
|
|
5180
|
-
const c = await new
|
|
5213
|
+
const c = await new Mt({
|
|
5181
5214
|
...o,
|
|
5182
5215
|
optionalInputs: [],
|
|
5183
5216
|
optionalOutputs: []
|
|
@@ -5191,7 +5224,7 @@ var Ce = new Uint8Array([
|
|
|
5191
5224
|
address: r.getScriptAddress()
|
|
5192
5225
|
},
|
|
5193
5226
|
value: BigInt(u.value)
|
|
5194
|
-
}, h = new
|
|
5227
|
+
}, h = new Dt({
|
|
5195
5228
|
...e,
|
|
5196
5229
|
utxos: [l],
|
|
5197
5230
|
randomBytes: r.getRndBytes(),
|
|
@@ -5229,7 +5262,7 @@ var Ce = new Uint8Array([
|
|
|
5229
5262
|
estimatedFees: i.estimatedFees,
|
|
5230
5263
|
tx: i.tx.toHex(),
|
|
5231
5264
|
nextUTXOs: this.getAllNewUTXOs(i.original, i.tx, e.from),
|
|
5232
|
-
inputUtxos: e.utxos
|
|
5265
|
+
inputUtxos: [...e.utxos, ...e.feeUtxos ?? []]
|
|
5233
5266
|
};
|
|
5234
5267
|
}
|
|
5235
5268
|
getAllNewUTXOs(e, t, i) {
|
|
@@ -5310,7 +5343,7 @@ var Ce = new Uint8Array([
|
|
|
5310
5343
|
}
|
|
5311
5344
|
async createFundTransaction(e) {
|
|
5312
5345
|
if (!e.to) throw new Error('Field "to" not provided.');
|
|
5313
|
-
const t = new
|
|
5346
|
+
const t = new Mt(e), i = await t.signTransaction();
|
|
5314
5347
|
if (!i) throw new Error("Could not sign funding transaction.");
|
|
5315
5348
|
return {
|
|
5316
5349
|
tx: i,
|
|
@@ -5321,12 +5354,12 @@ var Ce = new Uint8Array([
|
|
|
5321
5354
|
};
|
|
5322
5355
|
}
|
|
5323
5356
|
hasP2WDAInputs(e) {
|
|
5324
|
-
return e.some((t) =>
|
|
5357
|
+
return e.some((t) => X.isP2WDAUTXO(t));
|
|
5325
5358
|
}
|
|
5326
5359
|
async signP2WDAInteraction(e) {
|
|
5327
5360
|
if (!e.from) throw new Error('Field "from" not provided.');
|
|
5328
5361
|
if (!("signer" in e)) throw new Error("P2WDA interactions require a signer. OP_WALLET is not supported for P2WDA.");
|
|
5329
|
-
const t = this.parseOptionalInputs(e.optionalInputs), i = new
|
|
5362
|
+
const t = this.parseOptionalInputs(e.optionalInputs), i = new ri({
|
|
5330
5363
|
...e,
|
|
5331
5364
|
optionalInputs: t
|
|
5332
5365
|
}), r = await i.signTransaction();
|
|
@@ -5347,14 +5380,14 @@ var Ce = new Uint8Array([
|
|
|
5347
5380
|
return t < B.MINIMUM_DUST ? B.MINIMUM_DUST : t;
|
|
5348
5381
|
}
|
|
5349
5382
|
async iterateFundingAmount(e, t, i, r) {
|
|
5350
|
-
const s = "randomBytes" in e ? e.randomBytes ?? W.rndBytes() : W.rndBytes(), n =
|
|
5383
|
+
const s = "randomBytes" in e ? e.randomBytes ?? W.rndBytes() : W.rndBytes(), n = z.dead().p2tr(e.network);
|
|
5351
5384
|
let o = this.INITIAL_FUNDING_ESTIMATE, a = 0n, c = 0, u = null, l = null;
|
|
5352
5385
|
for (; c < this.MAX_ITERATIONS && o !== a; ) {
|
|
5353
5386
|
a = o;
|
|
5354
|
-
const h = new
|
|
5387
|
+
const h = new Xt();
|
|
5355
5388
|
h.addOutput(this.P2TR_SCRIPT, L(o));
|
|
5356
5389
|
const p = {
|
|
5357
|
-
transactionId: f(new Uint8Array(32)),
|
|
5390
|
+
transactionId: f(/* @__PURE__ */ new Uint8Array(32)),
|
|
5358
5391
|
outputIndex: 0,
|
|
5359
5392
|
scriptPubKey: {
|
|
5360
5393
|
hex: f(this.P2TR_SCRIPT),
|
|
@@ -5409,7 +5442,7 @@ var Ce = new Uint8Array([
|
|
|
5409
5442
|
}];
|
|
5410
5443
|
}
|
|
5411
5444
|
}, Q = class F extends B {
|
|
5412
|
-
static LOCK_LEAF_SCRIPT =
|
|
5445
|
+
static LOCK_LEAF_SCRIPT = b.compile([
|
|
5413
5446
|
d.OP_XOR,
|
|
5414
5447
|
d.OP_NOP,
|
|
5415
5448
|
d.OP_CODESEPARATOR
|
|
@@ -5438,10 +5471,10 @@ var Ce = new Uint8Array([
|
|
|
5438
5471
|
priorityFee: 0n,
|
|
5439
5472
|
gasSatFee: 0n
|
|
5440
5473
|
}), !t.pubkeys) throw new Error("Pubkeys are required");
|
|
5441
|
-
t.psbt && (this.log("Using provided PSBT."), this.transaction = t.psbt, this.originalInputCount = this.transaction.data.inputs.length), this.refundVault = t.refundVault, this.requestedAmount = t.requestedAmount, this.receiver = t.receiver, this.publicKeys = t.pubkeys, this.minimumSignatures = t.minimumSignatures, this.compiledTargetScript =
|
|
5474
|
+
t.psbt && (this.log("Using provided PSBT."), this.transaction = t.psbt, this.originalInputCount = this.transaction.data.inputs.length), this.refundVault = t.refundVault, this.requestedAmount = t.requestedAmount, this.receiver = t.receiver, this.publicKeys = t.pubkeys, this.minimumSignatures = t.minimumSignatures, this.compiledTargetScript = Ge.compile(t.pubkeys, this.minimumSignatures), this.scriptTree = this.getScriptTree(), this.internalInit();
|
|
5442
5475
|
}
|
|
5443
5476
|
static fromBase64(t) {
|
|
5444
|
-
const i =
|
|
5477
|
+
const i = N.fromBase64(t.psbt, { network: t.network });
|
|
5445
5478
|
return new F({
|
|
5446
5479
|
...t,
|
|
5447
5480
|
psbt: i
|
|
@@ -5468,7 +5501,7 @@ var Ce = new Uint8Array([
|
|
|
5468
5501
|
let n = !1, o = !0;
|
|
5469
5502
|
for (let a = r; a < t.data.inputs.length; a++) {
|
|
5470
5503
|
const c = t.data.inputs[a];
|
|
5471
|
-
c.tapInternalKey || (c.tapInternalKey =
|
|
5504
|
+
c.tapInternalKey || (c.tapInternalKey = O(F.numsPoint));
|
|
5472
5505
|
const u = [];
|
|
5473
5506
|
if (c.finalScriptWitness) {
|
|
5474
5507
|
const h = B.readScriptWitnessToWitnessStack(c.finalScriptWitness);
|
|
@@ -5513,8 +5546,8 @@ var Ce = new Uint8Array([
|
|
|
5513
5546
|
else {
|
|
5514
5547
|
for (const u of s) {
|
|
5515
5548
|
let l = !1;
|
|
5516
|
-
for (const h of i.tapScriptSig) C(h.pubkey,
|
|
5517
|
-
l || o.push(new Uint8Array(0));
|
|
5549
|
+
for (const h of i.tapScriptSig) C(h.pubkey, O(u)) && (o.push(h.signature), l = !0);
|
|
5550
|
+
l || o.push(/* @__PURE__ */ new Uint8Array(0));
|
|
5518
5551
|
}
|
|
5519
5552
|
o = o.reverse();
|
|
5520
5553
|
}
|
|
@@ -5532,7 +5565,7 @@ var Ce = new Uint8Array([
|
|
|
5532
5565
|
let n = 0;
|
|
5533
5566
|
for (let o = i; o < t.data.inputs.length; o++) try {
|
|
5534
5567
|
const a = t.data.inputs[o];
|
|
5535
|
-
a.tapInternalKey || (a.tapInternalKey =
|
|
5568
|
+
a.tapInternalKey || (a.tapInternalKey = O(F.numsPoint));
|
|
5536
5569
|
const c = [];
|
|
5537
5570
|
if (a.finalScriptWitness) {
|
|
5538
5571
|
const u = B.readScriptWitnessToWitnessStack(a.finalScriptWitness);
|
|
@@ -5605,12 +5638,12 @@ var Ce = new Uint8Array([
|
|
|
5605
5638
|
return this.useP2MR ? {
|
|
5606
5639
|
network: this.network,
|
|
5607
5640
|
scriptTree: this.scriptTree,
|
|
5608
|
-
name:
|
|
5641
|
+
name: E.P2MR
|
|
5609
5642
|
} : {
|
|
5610
|
-
internalPubkey:
|
|
5643
|
+
internalPubkey: O(F.numsPoint),
|
|
5611
5644
|
network: this.network,
|
|
5612
5645
|
scriptTree: this.scriptTree,
|
|
5613
|
-
name:
|
|
5646
|
+
name: E.P2TR
|
|
5614
5647
|
};
|
|
5615
5648
|
}
|
|
5616
5649
|
generateTapData() {
|
|
@@ -5621,13 +5654,13 @@ var Ce = new Uint8Array([
|
|
|
5621
5654
|
network: this.network,
|
|
5622
5655
|
scriptTree: this.scriptTree,
|
|
5623
5656
|
redeem: t,
|
|
5624
|
-
name:
|
|
5657
|
+
name: E.P2MR
|
|
5625
5658
|
} : {
|
|
5626
|
-
internalPubkey:
|
|
5659
|
+
internalPubkey: O(F.numsPoint),
|
|
5627
5660
|
network: this.network,
|
|
5628
5661
|
scriptTree: this.scriptTree,
|
|
5629
5662
|
redeem: t,
|
|
5630
|
-
name:
|
|
5663
|
+
name: E.P2TR
|
|
5631
5664
|
};
|
|
5632
5665
|
}
|
|
5633
5666
|
getScriptSolution(t) {
|
|
@@ -5657,41 +5690,41 @@ var Ce = new Uint8Array([
|
|
|
5657
5690
|
};
|
|
5658
5691
|
generateRedeemScripts() {
|
|
5659
5692
|
this.targetScriptRedeem = {
|
|
5660
|
-
name:
|
|
5693
|
+
name: E.P2TR,
|
|
5661
5694
|
output: this.compiledTargetScript,
|
|
5662
5695
|
redeemVersion: 192
|
|
5663
5696
|
}, this.leftOverFundsScriptRedeem = {
|
|
5664
|
-
name:
|
|
5697
|
+
name: E.P2TR,
|
|
5665
5698
|
output: F.LOCK_LEAF_SCRIPT,
|
|
5666
5699
|
redeemVersion: 192
|
|
5667
5700
|
};
|
|
5668
5701
|
}
|
|
5669
|
-
},
|
|
5670
|
-
function
|
|
5702
|
+
}, ws = 2, ys = 66;
|
|
5703
|
+
function oi(e) {
|
|
5671
5704
|
return e.type === m.FUNDING;
|
|
5672
5705
|
}
|
|
5673
|
-
function
|
|
5706
|
+
function ai(e) {
|
|
5674
5707
|
return e.type === m.DEPLOYMENT;
|
|
5675
5708
|
}
|
|
5676
|
-
function
|
|
5709
|
+
function ci(e) {
|
|
5677
5710
|
return e.type === m.INTERACTION;
|
|
5678
5711
|
}
|
|
5679
5712
|
function et(e) {
|
|
5680
5713
|
return e.type === m.MULTI_SIG;
|
|
5681
5714
|
}
|
|
5682
|
-
function
|
|
5715
|
+
function ui(e) {
|
|
5683
5716
|
return e.type === m.CUSTOM_CODE;
|
|
5684
5717
|
}
|
|
5685
|
-
function
|
|
5718
|
+
function li(e) {
|
|
5686
5719
|
return e.type === m.CANCEL;
|
|
5687
5720
|
}
|
|
5688
|
-
function
|
|
5721
|
+
function G(e) {
|
|
5689
5722
|
return e.startsWith("0x") ? e.slice(2) : e;
|
|
5690
5723
|
}
|
|
5691
|
-
var
|
|
5724
|
+
var P = class {
|
|
5692
5725
|
static serialize(e) {
|
|
5693
|
-
const t = new
|
|
5694
|
-
this.writeHeader(t, e.header), this.writeBaseParams(t, e.baseParams), this.writeUTXOArray(t, e.utxos), this.writeUTXOArray(t, e.optionalInputs), this.writeOutputArray(t, e.optionalOutputs), t.writeBoolean(e.addressRotationEnabled), this.writeSignerMappings(t, e.signerMappings), this.writeTypeSpecificData(t, e.typeSpecificData), this.writePrecomputedData(t, e.precomputedData);
|
|
5726
|
+
const t = new V();
|
|
5727
|
+
this.writeHeader(t, e.header), this.writeBaseParams(t, e.baseParams), this.writeUTXOArray(t, e.utxos), this.writeUTXOArray(t, e.optionalInputs), this.writeOutputArray(t, e.optionalOutputs), t.writeBoolean(e.addressRotationEnabled), this.writeSignerMappings(t, e.signerMappings), this.writeTypeSpecificData(t, e.typeSpecificData), this.writePrecomputedData(t, e.precomputedData), t.writeStringWithLength(e.partialPsbtBase64 ?? "");
|
|
5695
5728
|
const i = t.getBuffer(), r = this.calculateChecksum(i), s = new Uint8Array(i.length + r.length);
|
|
5696
5729
|
return s.set(i, 0), s.set(r, i.length), s;
|
|
5697
5730
|
}
|
|
@@ -5699,18 +5732,25 @@ var U = class {
|
|
|
5699
5732
|
if (e.length < 32) throw new Error("Invalid serialized data: too short");
|
|
5700
5733
|
const t = e.subarray(-32), i = e.subarray(0, -32), r = this.calculateChecksum(i);
|
|
5701
5734
|
if (!this.bytesEqual(t, r)) throw new Error("Invalid checksum - data may be corrupted");
|
|
5702
|
-
const s = new
|
|
5703
|
-
if (n.formatVersion >
|
|
5735
|
+
const s = new Ht(i), n = this.readHeader(s);
|
|
5736
|
+
if (n.formatVersion > 2) throw new Error(`Unsupported format version: ${n.formatVersion}`);
|
|
5737
|
+
const o = this.readBaseParams(s), a = this.readUTXOArray(s), c = this.readUTXOArray(s), u = this.readOutputArray(s), l = s.readBoolean(), h = this.readSignerMappings(s), p = this.readTypeSpecificData(s, n.transactionType), w = this.readPrecomputedData(s);
|
|
5738
|
+
let T;
|
|
5739
|
+
if (n.formatVersion >= 2) {
|
|
5740
|
+
const A = s.readStringWithLength();
|
|
5741
|
+
T = A.length > 0 ? A : void 0;
|
|
5742
|
+
}
|
|
5704
5743
|
return {
|
|
5705
5744
|
header: n,
|
|
5706
|
-
baseParams:
|
|
5707
|
-
utxos:
|
|
5708
|
-
optionalInputs:
|
|
5709
|
-
optionalOutputs:
|
|
5710
|
-
addressRotationEnabled:
|
|
5711
|
-
signerMappings:
|
|
5712
|
-
typeSpecificData:
|
|
5713
|
-
precomputedData:
|
|
5745
|
+
baseParams: o,
|
|
5746
|
+
utxos: a,
|
|
5747
|
+
optionalInputs: c,
|
|
5748
|
+
optionalOutputs: u,
|
|
5749
|
+
addressRotationEnabled: l,
|
|
5750
|
+
signerMappings: h,
|
|
5751
|
+
typeSpecificData: p,
|
|
5752
|
+
precomputedData: w,
|
|
5753
|
+
...T !== void 0 ? { partialPsbtBase64: T } : {}
|
|
5714
5754
|
};
|
|
5715
5755
|
}
|
|
5716
5756
|
static toBase64(e) {
|
|
@@ -5970,11 +6010,11 @@ var U = class {
|
|
|
5970
6010
|
};
|
|
5971
6011
|
}
|
|
5972
6012
|
static writeChallenge(e, t) {
|
|
5973
|
-
e.writeU64(BigInt(t.epochNumber)), e.writeStringWithLength(t.mldsaPublicKey), e.writeStringWithLength(t.legacyPublicKey), e.writeBytesWithLength(g(
|
|
6013
|
+
e.writeU64(BigInt(t.epochNumber)), e.writeStringWithLength(t.mldsaPublicKey), e.writeStringWithLength(t.legacyPublicKey), e.writeBytesWithLength(g(G(t.solution))), e.writeBytesWithLength(g(G(t.salt))), e.writeBytesWithLength(g(G(t.graffiti))), e.writeU8(t.difficulty), this.writeChallengeVerification(e, t.verification), e.writeBoolean(t.submission !== void 0), t.submission !== void 0 && (e.writeStringWithLength(t.submission.mldsaPublicKey), e.writeStringWithLength(t.submission.legacyPublicKey), e.writeBytesWithLength(g(G(t.submission.solution))), e.writeBoolean(t.submission.graffiti !== void 0), t.submission.graffiti !== void 0 && e.writeBytesWithLength(g(G(t.submission.graffiti))), e.writeBytesWithLength(g(G(t.submission.signature))));
|
|
5974
6014
|
}
|
|
5975
6015
|
static writeChallengeVerification(e, t) {
|
|
5976
|
-
e.writeBytesWithLength(g(
|
|
5977
|
-
for (const i of t.proofs) e.writeBytesWithLength(g(
|
|
6016
|
+
e.writeBytesWithLength(g(G(t.epochHash))), e.writeBytesWithLength(g(G(t.epochRoot))), e.writeBytesWithLength(g(G(t.targetHash))), e.writeBytesWithLength(g(G(t.targetChecksum))), e.writeU64(BigInt(t.startBlock)), e.writeU64(BigInt(t.endBlock)), e.writeU16(t.proofs.length);
|
|
6017
|
+
for (const i of t.proofs) e.writeBytesWithLength(g(G(i)));
|
|
5978
6018
|
}
|
|
5979
6019
|
static readChallenge(e) {
|
|
5980
6020
|
const t = e.readU64().toString(), i = e.readStringWithLength(), r = e.readStringWithLength(), s = "0x" + f(e.readBytesWithLength()), n = "0x" + f(e.readBytesWithLength()), o = "0x" + f(e.readBytesWithLength()), a = e.readU8(), c = this.readChallengeVerification(e), u = e.readBoolean();
|
|
@@ -6042,8 +6082,8 @@ var U = class {
|
|
|
6042
6082
|
};
|
|
6043
6083
|
}
|
|
6044
6084
|
static calculateChecksum(e) {
|
|
6045
|
-
const t =
|
|
6046
|
-
return new Uint8Array(
|
|
6085
|
+
const t = jt("sha256").update(e).digest();
|
|
6086
|
+
return new Uint8Array(jt("sha256").update(t).digest());
|
|
6047
6087
|
}
|
|
6048
6088
|
static bytesEqual(e, t) {
|
|
6049
6089
|
if (e.length !== t.length) return !1;
|
|
@@ -6088,13 +6128,13 @@ var U = class {
|
|
|
6088
6128
|
throw new Error(`Unknown network value: ${e}`);
|
|
6089
6129
|
}
|
|
6090
6130
|
}
|
|
6091
|
-
},
|
|
6131
|
+
}, Vt = /* @__PURE__ */ (function(e) {
|
|
6092
6132
|
return e[e.Roswell = 0] = "Roswell", e[e.Rachel = 1] = "Rachel", e[e.Kecksburg = 2] = "Kecksburg", e[e.Phoenix = 3] = "Phoenix", e[e.Aurora = 4] = "Aurora", e[e.Rendlesham = 5] = "Rendlesham", e[e.Lazar = 6] = "Lazar", e[e.ShagHarbor = 7] = "ShagHarbor", e[e.Exeter = 8] = "Exeter", e[e.Stephenville = 9] = "Stephenville", e[e.Valensole = 10] = "Valensole", e[e.Socorro = 11] = "Socorro", e[e.Pascagoula = 12] = "Pascagoula", e[e.Tehran = 13] = "Tehran", e[e.Westall = 14] = "Westall", e[e.Hopkinsville = 15] = "Hopkinsville", e[e.Belgium = 16] = "Belgium", e[e.Breeze = 17] = "Breeze", e[e.Flatwoods = 18] = "Flatwoods", e[e.Maury = 20] = "Maury", e[e.Varginha = 21] = "Varginha", e[e.Trindade = 22] = "Trindade", e[e.Levelland = 23] = "Levelland", e[e.Wanaque = 24] = "Wanaque", e[e.Coyame = 25] = "Coyame", e[e.Delphos = 26] = "Delphos", e;
|
|
6093
|
-
})({}),
|
|
6094
|
-
CONSENSUS:
|
|
6133
|
+
})({}), hi = {
|
|
6134
|
+
CONSENSUS: Vt.Roswell,
|
|
6095
6135
|
CONSENSUS_NAME: "Roswell",
|
|
6096
6136
|
ENABLED_AT_BLOCK: 0n
|
|
6097
|
-
},
|
|
6137
|
+
}, di = { [Vt.Roswell]: hi }, Te = Vt.Roswell, Ur = di[Te], $ = class {
|
|
6098
6138
|
static fromFunding(e, t) {
|
|
6099
6139
|
return this.captureState({
|
|
6100
6140
|
params: e,
|
|
@@ -6153,8 +6193,8 @@ var U = class {
|
|
|
6153
6193
|
}
|
|
6154
6194
|
static createHeader(e, t, i) {
|
|
6155
6195
|
return {
|
|
6156
|
-
formatVersion:
|
|
6157
|
-
consensusVersion:
|
|
6196
|
+
formatVersion: 2,
|
|
6197
|
+
consensusVersion: Te,
|
|
6158
6198
|
transactionType: e,
|
|
6159
6199
|
chainId: i ?? this.networkToChainId(t),
|
|
6160
6200
|
timestamp: Date.now()
|
|
@@ -6320,22 +6360,28 @@ var U = class {
|
|
|
6320
6360
|
return e.bech32 === "bc" ? "mainnet" : e.bech32 === "tb" ? "testnet" : e.bech32 === "opt" ? "opnetTestnet" : "regtest";
|
|
6321
6361
|
}
|
|
6322
6362
|
static networkToChainId(e) {
|
|
6323
|
-
return
|
|
6363
|
+
return Qe.Bitcoin;
|
|
6324
6364
|
}
|
|
6325
6365
|
};
|
|
6326
|
-
function
|
|
6366
|
+
function M(e) {
|
|
6327
6367
|
return g(e.startsWith("0x") ? e.slice(2) : e);
|
|
6328
6368
|
}
|
|
6329
|
-
var
|
|
6369
|
+
var wt = class {
|
|
6330
6370
|
static BLOCKS_PER_EPOCH = 5n;
|
|
6331
6371
|
static sha1(e) {
|
|
6332
6372
|
return D.sha1(e);
|
|
6333
6373
|
}
|
|
6334
|
-
static calculatePreimage(e, t, i) {
|
|
6374
|
+
static calculatePreimage(e, t, i, r = !1) {
|
|
6335
6375
|
if (e.length !== 32 || t.length !== 32 || i.length !== 32) throw new Error("All inputs must be 32 bytes");
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6376
|
+
if (r) return this.concatenatePreimage(e, t, i);
|
|
6377
|
+
const s = /* @__PURE__ */ new Uint8Array(32);
|
|
6378
|
+
for (let n = 0; n < 32; n++) s[n] = e[n] ^ t[n] ^ i[n];
|
|
6379
|
+
return s;
|
|
6380
|
+
}
|
|
6381
|
+
static concatenatePreimage(e, t, i) {
|
|
6382
|
+
if (e.length !== 32 || t.length !== 32 || i.length !== 32) throw new Error("All inputs must be 32 bytes");
|
|
6383
|
+
const r = /* @__PURE__ */ new Uint8Array(96);
|
|
6384
|
+
return r.set(e, 0), r.set(t, 32), r.set(i, 64), r;
|
|
6339
6385
|
}
|
|
6340
6386
|
static countMatchingBits(e, t) {
|
|
6341
6387
|
let i = 0;
|
|
@@ -6349,43 +6395,43 @@ var St = class {
|
|
|
6349
6395
|
}
|
|
6350
6396
|
return i;
|
|
6351
6397
|
}
|
|
6352
|
-
static verifySolution(e, t = !1) {
|
|
6398
|
+
static verifySolution(e, t = !1, i = !1) {
|
|
6353
6399
|
try {
|
|
6354
|
-
const
|
|
6355
|
-
if (!C(
|
|
6356
|
-
const
|
|
6357
|
-
return !(
|
|
6358
|
-
} catch (
|
|
6359
|
-
return t && console.error("Verification error:",
|
|
6400
|
+
const r = e.verification, s = this.calculatePreimage(r.targetChecksum, e.publicKey.toBuffer(), e.salt, i), n = this.sha1(s);
|
|
6401
|
+
if (!C(n, e.solution) || this.countMatchingBits(n, r.targetHash) !== e.difficulty) return !1;
|
|
6402
|
+
const o = e.epochNumber * this.BLOCKS_PER_EPOCH, a = o + this.BLOCKS_PER_EPOCH - 1n;
|
|
6403
|
+
return !(r.startBlock !== o || r.endBlock !== a);
|
|
6404
|
+
} catch (r) {
|
|
6405
|
+
return t && console.error("Verification error:", r), !1;
|
|
6360
6406
|
}
|
|
6361
6407
|
}
|
|
6362
6408
|
static getMiningTargetBlock(e) {
|
|
6363
6409
|
return e === 0n ? null : e * this.BLOCKS_PER_EPOCH - 1n;
|
|
6364
6410
|
}
|
|
6365
|
-
static validateEpochWinner(e) {
|
|
6411
|
+
static validateEpochWinner(e, t = !1) {
|
|
6366
6412
|
try {
|
|
6367
|
-
const
|
|
6368
|
-
epochHash:
|
|
6369
|
-
epochRoot:
|
|
6370
|
-
targetHash:
|
|
6371
|
-
targetChecksum:
|
|
6413
|
+
const i = BigInt(e.epochNumber), r = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), s = M(e.solution), n = M(e.salt), o = e.difficulty, a = {
|
|
6414
|
+
epochHash: M(e.verification.epochHash),
|
|
6415
|
+
epochRoot: M(e.verification.epochRoot),
|
|
6416
|
+
targetHash: M(e.verification.targetHash),
|
|
6417
|
+
targetChecksum: M(e.verification.targetChecksum),
|
|
6372
6418
|
startBlock: BigInt(e.verification.startBlock),
|
|
6373
6419
|
endBlock: BigInt(e.verification.endBlock),
|
|
6374
|
-
proofs: Object.freeze(e.verification.proofs.map((
|
|
6375
|
-
},
|
|
6376
|
-
if (!C(
|
|
6377
|
-
const
|
|
6378
|
-
return !(
|
|
6420
|
+
proofs: Object.freeze(e.verification.proofs.map((p) => M(p)))
|
|
6421
|
+
}, c = this.calculatePreimage(a.targetChecksum, r.toBuffer(), n, t), u = this.sha1(c);
|
|
6422
|
+
if (!C(u, s) || this.countMatchingBits(u, a.targetHash) !== o) return !1;
|
|
6423
|
+
const l = i * this.BLOCKS_PER_EPOCH, h = l + this.BLOCKS_PER_EPOCH - 1n;
|
|
6424
|
+
return !(a.startBlock !== l || a.endBlock !== h);
|
|
6379
6425
|
} catch {
|
|
6380
6426
|
return !1;
|
|
6381
6427
|
}
|
|
6382
6428
|
}
|
|
6383
|
-
static validateChallengeSolution(e) {
|
|
6384
|
-
return this.verifySolution(e);
|
|
6429
|
+
static validateChallengeSolution(e, t = !1) {
|
|
6430
|
+
return this.verifySolution(e, !1, t);
|
|
6385
6431
|
}
|
|
6386
|
-
static calculateSolution(e, t, i) {
|
|
6387
|
-
const
|
|
6388
|
-
return this.sha1(
|
|
6432
|
+
static calculateSolution(e, t, i, r = !1) {
|
|
6433
|
+
const s = this.calculatePreimage(e, t, i, r);
|
|
6434
|
+
return this.sha1(s);
|
|
6389
6435
|
}
|
|
6390
6436
|
static checkDifficulty(e, t, i) {
|
|
6391
6437
|
const r = this.countMatchingBits(e, t);
|
|
@@ -6394,7 +6440,7 @@ var St = class {
|
|
|
6394
6440
|
difficulty: r
|
|
6395
6441
|
};
|
|
6396
6442
|
}
|
|
6397
|
-
},
|
|
6443
|
+
}, pi = class {
|
|
6398
6444
|
epochHash;
|
|
6399
6445
|
epochRoot;
|
|
6400
6446
|
targetHash;
|
|
@@ -6403,23 +6449,24 @@ var St = class {
|
|
|
6403
6449
|
endBlock;
|
|
6404
6450
|
proofs;
|
|
6405
6451
|
constructor(e) {
|
|
6406
|
-
this.epochHash =
|
|
6452
|
+
this.epochHash = M(e.epochHash), this.epochRoot = M(e.epochRoot), this.targetHash = M(e.targetHash), this.targetChecksum = M(e.targetChecksum), this.startBlock = BigInt(e.startBlock), this.endBlock = BigInt(e.endBlock), this.proofs = Object.freeze(e.proofs.map((t) => M(t)));
|
|
6407
6453
|
}
|
|
6408
|
-
},
|
|
6454
|
+
}, fi = class {
|
|
6455
|
+
epochNumber;
|
|
6409
6456
|
publicKey;
|
|
6410
6457
|
solution;
|
|
6411
6458
|
graffiti;
|
|
6412
6459
|
signature;
|
|
6413
6460
|
constructor(e, t) {
|
|
6414
|
-
this.epochNumber = t, this.publicKey =
|
|
6461
|
+
this.epochNumber = t, this.publicKey = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), this.solution = M(e.solution), this.graffiti = e.graffiti ? M(e.graffiti) : void 0, this.signature = M(e.signature);
|
|
6415
6462
|
}
|
|
6416
6463
|
verifySignature() {
|
|
6417
|
-
const e = new
|
|
6464
|
+
const e = new V();
|
|
6418
6465
|
e.writeAddress(this.publicKey), e.writeU64(this.epochNumber), e.writeBytes(this.solution), this.graffiti && e.writeBytes(this.graffiti);
|
|
6419
6466
|
const t = e.getBuffer();
|
|
6420
|
-
return
|
|
6467
|
+
return st.verifySignature(this.publicKey.tweakedPublicKeyToBuffer(), t, this.signature);
|
|
6421
6468
|
}
|
|
6422
|
-
},
|
|
6469
|
+
}, ne = class {
|
|
6423
6470
|
epochNumber;
|
|
6424
6471
|
publicKey;
|
|
6425
6472
|
solution;
|
|
@@ -6429,10 +6476,10 @@ var St = class {
|
|
|
6429
6476
|
verification;
|
|
6430
6477
|
submission;
|
|
6431
6478
|
constructor(e) {
|
|
6432
|
-
this.epochNumber = BigInt(e.epochNumber), this.publicKey =
|
|
6479
|
+
this.epochNumber = BigInt(e.epochNumber), this.publicKey = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), this.solution = M(e.solution), this.salt = M(e.salt), this.graffiti = M(e.graffiti), this.difficulty = e.difficulty, this.verification = new pi(e.verification), this.submission = e.submission ? new fi(e.submission, this.epochNumber + 2n) : e.submission;
|
|
6433
6480
|
}
|
|
6434
6481
|
static validateRaw(e) {
|
|
6435
|
-
return
|
|
6482
|
+
return wt.validateEpochWinner(e);
|
|
6436
6483
|
}
|
|
6437
6484
|
verifySubmissionSignature() {
|
|
6438
6485
|
if (!this.submission) throw new Error("No submission provided in request.");
|
|
@@ -6445,7 +6492,7 @@ var St = class {
|
|
|
6445
6492
|
}
|
|
6446
6493
|
}
|
|
6447
6494
|
verify() {
|
|
6448
|
-
return
|
|
6495
|
+
return wt.validateChallengeSolution(this);
|
|
6449
6496
|
}
|
|
6450
6497
|
toBuffer() {
|
|
6451
6498
|
return this.solution;
|
|
@@ -6474,15 +6521,15 @@ var St = class {
|
|
|
6474
6521
|
};
|
|
6475
6522
|
}
|
|
6476
6523
|
calculateSolution() {
|
|
6477
|
-
return
|
|
6524
|
+
return wt.calculateSolution(this.verification.targetChecksum, this.publicKey.toBuffer(), this.salt);
|
|
6478
6525
|
}
|
|
6479
6526
|
checkDifficulty(e) {
|
|
6480
|
-
return
|
|
6527
|
+
return wt.checkDifficulty(this.solution, this.verification.targetHash, e);
|
|
6481
6528
|
}
|
|
6482
6529
|
getMiningTargetBlock() {
|
|
6483
|
-
return
|
|
6530
|
+
return wt.getMiningTargetBlock(this.epochNumber);
|
|
6484
6531
|
}
|
|
6485
|
-
},
|
|
6532
|
+
}, j = class {
|
|
6486
6533
|
static reconstruct(e, t) {
|
|
6487
6534
|
const i = this.nameToNetwork(e.baseParams.networkName), r = this.deserializeUTXOs(e.utxos), s = this.deserializeUTXOs(e.optionalInputs), n = this.deserializeOutputs(e.optionalOutputs), o = this.buildAddressRotationConfig(e.addressRotationEnabled, t.signerMap), a = t.newFeeRate ?? e.baseParams.feeRate, c = t.newPriorityFee ?? BigInt(e.baseParams.priorityFee), u = t.newGasSatFee ?? BigInt(e.baseParams.gasSatFee), l = {
|
|
6488
6535
|
signer: t.signer,
|
|
@@ -6505,24 +6552,24 @@ var St = class {
|
|
|
6505
6552
|
...e.precomputedData.estimatedFees !== void 0 ? { estimatedFees: BigInt(e.precomputedData.estimatedFees) } : {},
|
|
6506
6553
|
...e.precomputedData.compiledTargetScript !== void 0 ? { compiledTargetScript: g(e.precomputedData.compiledTargetScript) } : {}
|
|
6507
6554
|
}, h = e.typeSpecificData;
|
|
6508
|
-
if (
|
|
6509
|
-
if (
|
|
6510
|
-
if (
|
|
6555
|
+
if (oi(h)) return this.reconstructFunding(l, h);
|
|
6556
|
+
if (ai(h)) return this.reconstructDeployment(l, h, e);
|
|
6557
|
+
if (ci(h)) return this.reconstructInteraction(l, h, e);
|
|
6511
6558
|
if (et(h)) return this.reconstructMultiSig(l, h);
|
|
6512
|
-
if (
|
|
6513
|
-
if (
|
|
6559
|
+
if (ui(h)) return this.reconstructCustomScript(l, h, e);
|
|
6560
|
+
if (li(h)) return this.reconstructCancel(l, h);
|
|
6514
6561
|
throw new Error(`Unsupported transaction type: ${e.header.transactionType}`);
|
|
6515
6562
|
}
|
|
6516
6563
|
static reconstructFunding(e, t) {
|
|
6517
|
-
return new
|
|
6564
|
+
return new Mt({
|
|
6518
6565
|
...e,
|
|
6519
6566
|
amount: BigInt(t.amount),
|
|
6520
6567
|
splitInputsInto: t.splitInputsInto
|
|
6521
6568
|
});
|
|
6522
6569
|
}
|
|
6523
6570
|
static reconstructDeployment(e, t, i) {
|
|
6524
|
-
const r = new
|
|
6525
|
-
return new
|
|
6571
|
+
const r = new ne(t.challenge);
|
|
6572
|
+
return new Dt({
|
|
6526
6573
|
...e,
|
|
6527
6574
|
bytecode: g(t.bytecode),
|
|
6528
6575
|
challenge: r,
|
|
@@ -6533,9 +6580,9 @@ var St = class {
|
|
|
6533
6580
|
});
|
|
6534
6581
|
}
|
|
6535
6582
|
static reconstructInteraction(e, t, i) {
|
|
6536
|
-
const r = new
|
|
6583
|
+
const r = new ne(t.challenge);
|
|
6537
6584
|
if (!e.to) throw new Error('InteractionTransaction requires a "to" address');
|
|
6538
|
-
return new
|
|
6585
|
+
return new Nt({
|
|
6539
6586
|
...e,
|
|
6540
6587
|
to: e.to,
|
|
6541
6588
|
calldata: g(t.calldata),
|
|
@@ -6583,7 +6630,7 @@ var St = class {
|
|
|
6583
6630
|
static reconstructCustomScript(e, t, i) {
|
|
6584
6631
|
const r = t.scriptElements.map((n) => n.elementType === "buffer" ? g(n.value) : [n.value]), s = t.witnesses.map((n) => g(n));
|
|
6585
6632
|
if (!e.to) throw new Error('CustomScriptTransaction requires a "to" address');
|
|
6586
|
-
return new
|
|
6633
|
+
return new Kt({
|
|
6587
6634
|
...e,
|
|
6588
6635
|
to: e.to,
|
|
6589
6636
|
script: r,
|
|
@@ -6593,7 +6640,7 @@ var St = class {
|
|
|
6593
6640
|
});
|
|
6594
6641
|
}
|
|
6595
6642
|
static reconstructCancel(e, t) {
|
|
6596
|
-
return new
|
|
6643
|
+
return new me({
|
|
6597
6644
|
...e,
|
|
6598
6645
|
compiledTargetScript: g(t.compiledTargetScript)
|
|
6599
6646
|
});
|
|
@@ -6655,50 +6702,50 @@ var St = class {
|
|
|
6655
6702
|
}
|
|
6656
6703
|
}, Br = class {
|
|
6657
6704
|
static exportFunding(e, t) {
|
|
6658
|
-
const i =
|
|
6659
|
-
return
|
|
6705
|
+
const i = $.fromFunding(e, t);
|
|
6706
|
+
return P.toBase64(i);
|
|
6660
6707
|
}
|
|
6661
6708
|
static exportDeployment(e, t) {
|
|
6662
|
-
const i =
|
|
6663
|
-
return
|
|
6709
|
+
const i = $.fromDeployment(e, t);
|
|
6710
|
+
return P.toBase64(i);
|
|
6664
6711
|
}
|
|
6665
6712
|
static exportInteraction(e, t) {
|
|
6666
|
-
const i =
|
|
6667
|
-
return
|
|
6713
|
+
const i = $.fromInteraction(e, t);
|
|
6714
|
+
return P.toBase64(i);
|
|
6668
6715
|
}
|
|
6669
6716
|
static exportMultiSig(e, t) {
|
|
6670
|
-
const i =
|
|
6671
|
-
return
|
|
6717
|
+
const i = $.fromMultiSig(e, t);
|
|
6718
|
+
return P.toBase64(i);
|
|
6672
6719
|
}
|
|
6673
6720
|
static exportCustomScript(e, t) {
|
|
6674
|
-
const i =
|
|
6675
|
-
return
|
|
6721
|
+
const i = $.fromCustomScript(e, t);
|
|
6722
|
+
return P.toBase64(i);
|
|
6676
6723
|
}
|
|
6677
6724
|
static exportCancel(e, t) {
|
|
6678
|
-
const i =
|
|
6679
|
-
return
|
|
6725
|
+
const i = $.fromCancel(e, t);
|
|
6726
|
+
return P.toBase64(i);
|
|
6680
6727
|
}
|
|
6681
6728
|
static exportFromBuilder(e, t, i) {
|
|
6682
6729
|
const r = e.type;
|
|
6683
6730
|
let s;
|
|
6684
6731
|
switch (r) {
|
|
6685
6732
|
case m.FUNDING:
|
|
6686
|
-
s =
|
|
6733
|
+
s = $.fromFunding(t, i);
|
|
6687
6734
|
break;
|
|
6688
6735
|
case m.DEPLOYMENT:
|
|
6689
|
-
s =
|
|
6736
|
+
s = $.fromDeployment(t, i);
|
|
6690
6737
|
break;
|
|
6691
6738
|
case m.INTERACTION:
|
|
6692
|
-
s =
|
|
6739
|
+
s = $.fromInteraction(t, i);
|
|
6693
6740
|
break;
|
|
6694
6741
|
default:
|
|
6695
6742
|
throw new Error(`Unsupported transaction type for export: ${r}`);
|
|
6696
6743
|
}
|
|
6697
|
-
return
|
|
6744
|
+
return P.toBase64(s);
|
|
6698
6745
|
}
|
|
6699
6746
|
static importForSigning(e, t) {
|
|
6700
|
-
const i =
|
|
6701
|
-
return
|
|
6747
|
+
const i = P.fromBase64(e);
|
|
6748
|
+
return j.reconstruct(i, t);
|
|
6702
6749
|
}
|
|
6703
6750
|
static async signAndExport(e) {
|
|
6704
6751
|
return (await e.signTransaction()).toHex();
|
|
@@ -6708,14 +6755,14 @@ var St = class {
|
|
|
6708
6755
|
return this.signAndExport(i);
|
|
6709
6756
|
}
|
|
6710
6757
|
static rebuildWithNewFees(e, t) {
|
|
6711
|
-
const i =
|
|
6758
|
+
const i = P.fromBase64(e), r = {
|
|
6712
6759
|
...i,
|
|
6713
6760
|
baseParams: {
|
|
6714
6761
|
...i.baseParams,
|
|
6715
6762
|
feeRate: t
|
|
6716
6763
|
}
|
|
6717
6764
|
};
|
|
6718
|
-
return
|
|
6765
|
+
return P.toBase64(r);
|
|
6719
6766
|
}
|
|
6720
6767
|
static async rebuildSignAndExport(e, t, i) {
|
|
6721
6768
|
const r = this.importForSigning(e, {
|
|
@@ -6725,39 +6772,39 @@ var St = class {
|
|
|
6725
6772
|
return this.signAndExport(r);
|
|
6726
6773
|
}
|
|
6727
6774
|
static inspect(e) {
|
|
6728
|
-
return
|
|
6775
|
+
return P.fromBase64(e);
|
|
6729
6776
|
}
|
|
6730
6777
|
static validate(e) {
|
|
6731
6778
|
try {
|
|
6732
|
-
return
|
|
6779
|
+
return P.fromBase64(e), !0;
|
|
6733
6780
|
} catch {
|
|
6734
6781
|
return !1;
|
|
6735
6782
|
}
|
|
6736
6783
|
}
|
|
6737
6784
|
static getType(e) {
|
|
6738
|
-
return
|
|
6785
|
+
return P.fromBase64(e).header.transactionType;
|
|
6739
6786
|
}
|
|
6740
6787
|
static fromBase64(e) {
|
|
6741
|
-
return
|
|
6788
|
+
return P.fromBase64(e);
|
|
6742
6789
|
}
|
|
6743
6790
|
static toBase64(e) {
|
|
6744
|
-
return
|
|
6791
|
+
return P.toBase64(e);
|
|
6745
6792
|
}
|
|
6746
6793
|
static toHex(e) {
|
|
6747
|
-
const t =
|
|
6748
|
-
return
|
|
6794
|
+
const t = P.fromBase64(e);
|
|
6795
|
+
return P.toHex(t);
|
|
6749
6796
|
}
|
|
6750
6797
|
static fromHex(e) {
|
|
6751
|
-
const t =
|
|
6752
|
-
return
|
|
6798
|
+
const t = P.fromHex(e);
|
|
6799
|
+
return P.toBase64(t);
|
|
6753
6800
|
}
|
|
6754
6801
|
static async multiSigAddSignature(e, t) {
|
|
6755
|
-
const i =
|
|
6802
|
+
const i = P.fromBase64(e);
|
|
6756
6803
|
if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6757
6804
|
const r = i.typeSpecificData, s = r.pubkeys.map((p) => g(p));
|
|
6758
6805
|
let n;
|
|
6759
|
-
const o =
|
|
6760
|
-
r.existingPsbtBase64 ? n =
|
|
6806
|
+
const o = j.nameToNetwork(i.baseParams.networkName);
|
|
6807
|
+
r.existingPsbtBase64 ? n = N.fromBase64(r.existingPsbtBase64, { network: o }) : n = await this.importForSigning(e, { signer: t }).signPSBT();
|
|
6761
6808
|
const a = [];
|
|
6762
6809
|
for (let p = r.originalInputCount; p < n.data.inputs.length; p++) a.push(r.minimumSignatures);
|
|
6763
6810
|
const c = Q.signPartial(n, t, r.originalInputCount, a), u = [];
|
|
@@ -6771,22 +6818,22 @@ var St = class {
|
|
|
6771
6818
|
}
|
|
6772
6819
|
};
|
|
6773
6820
|
return {
|
|
6774
|
-
state:
|
|
6821
|
+
state: P.toBase64(h),
|
|
6775
6822
|
signed: c.signed,
|
|
6776
6823
|
final: c.final,
|
|
6777
6824
|
psbtBase64: l
|
|
6778
6825
|
};
|
|
6779
6826
|
}
|
|
6780
6827
|
static multiSigHasSigned(e, t) {
|
|
6781
|
-
const i =
|
|
6828
|
+
const i = P.fromBase64(e);
|
|
6782
6829
|
if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6783
6830
|
const r = i.typeSpecificData;
|
|
6784
6831
|
if (!r.existingPsbtBase64) return !1;
|
|
6785
|
-
const s =
|
|
6832
|
+
const s = j.nameToNetwork(i.baseParams.networkName), n = N.fromBase64(r.existingPsbtBase64, { network: s }), o = t instanceof Uint8Array ? t : g(t);
|
|
6786
6833
|
return Q.verifyIfSigned(n, o);
|
|
6787
6834
|
}
|
|
6788
6835
|
static multiSigGetSignatureStatus(e) {
|
|
6789
|
-
const t =
|
|
6836
|
+
const t = P.fromBase64(e);
|
|
6790
6837
|
if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6791
6838
|
const i = t.typeSpecificData, r = i.minimumSignatures;
|
|
6792
6839
|
if (!i.existingPsbtBase64) return {
|
|
@@ -6795,7 +6842,7 @@ var St = class {
|
|
|
6795
6842
|
isComplete: !1,
|
|
6796
6843
|
signers: []
|
|
6797
6844
|
};
|
|
6798
|
-
const s =
|
|
6845
|
+
const s = j.nameToNetwork(t.baseParams.networkName), n = N.fromBase64(i.existingPsbtBase64, { network: s }), o = /* @__PURE__ */ new Set();
|
|
6799
6846
|
for (let c = i.originalInputCount; c < n.data.inputs.length; c++) {
|
|
6800
6847
|
const u = n.data.inputs[c];
|
|
6801
6848
|
if (u.tapScriptSig) for (const l of u.tapScriptSig) o.add(f(l.pubkey));
|
|
@@ -6816,22 +6863,22 @@ var St = class {
|
|
|
6816
6863
|
};
|
|
6817
6864
|
}
|
|
6818
6865
|
static multiSigFinalize(e) {
|
|
6819
|
-
const t =
|
|
6866
|
+
const t = P.fromBase64(e);
|
|
6820
6867
|
if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6821
6868
|
const i = t.typeSpecificData;
|
|
6822
6869
|
if (!i.existingPsbtBase64) throw new Error("No PSBT found in state - transaction has not been signed");
|
|
6823
|
-
const r =
|
|
6870
|
+
const r = j.nameToNetwork(t.baseParams.networkName), s = N.fromBase64(i.existingPsbtBase64, { network: r }), n = i.pubkeys.map((a) => g(a)), o = [];
|
|
6824
6871
|
for (let a = i.originalInputCount; a < s.data.inputs.length; a++) o.push(n);
|
|
6825
6872
|
if (!Q.attemptFinalizeInputs(s, i.originalInputCount, o, !0)) throw new Error("Failed to finalize multisig transaction - not enough signatures");
|
|
6826
6873
|
return s.extractTransaction(!0, !0).toHex();
|
|
6827
6874
|
}
|
|
6828
6875
|
static multiSigGetPsbt(e) {
|
|
6829
|
-
const t =
|
|
6876
|
+
const t = P.fromBase64(e);
|
|
6830
6877
|
if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6831
6878
|
return t.typeSpecificData.existingPsbtBase64 || null;
|
|
6832
6879
|
}
|
|
6833
6880
|
static multiSigUpdatePsbt(e, t) {
|
|
6834
|
-
const i =
|
|
6881
|
+
const i = P.fromBase64(e);
|
|
6835
6882
|
if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6836
6883
|
const r = {
|
|
6837
6884
|
...i,
|
|
@@ -6840,9 +6887,83 @@ var St = class {
|
|
|
6840
6887
|
existingPsbtBase64: t
|
|
6841
6888
|
}
|
|
6842
6889
|
};
|
|
6843
|
-
return
|
|
6890
|
+
return P.toBase64(r);
|
|
6891
|
+
}
|
|
6892
|
+
static csvMultisigGetStatus(e) {
|
|
6893
|
+
const t = P.fromBase64(e);
|
|
6894
|
+
if (!t.partialPsbtBase64) return [];
|
|
6895
|
+
const i = j.nameToNetwork(t.baseParams.networkName), r = N.fromBase64(t.partialPsbtBase64, { network: i });
|
|
6896
|
+
return this.computeCSVMultisigStatus(t, r, i);
|
|
6897
|
+
}
|
|
6898
|
+
static async addCSVMultisigSignature(e, t) {
|
|
6899
|
+
const i = P.fromBase64(e), r = j.nameToNetwork(i.baseParams.networkName);
|
|
6900
|
+
let s;
|
|
6901
|
+
i.partialPsbtBase64 ? (s = N.fromBase64(i.partialPsbtBase64, { network: r }), this.addSignerToCSVInputs(s, t, r)) : (s = await this.importForSigning(e, { signer: t }).signPSBT(), this.addSignerToCSVInputs(s, t, r));
|
|
6902
|
+
const n = this.computeCSVMultisigStatus(i, s, r), o = n.length > 0 && n.every((c) => c.collected >= c.required), a = {
|
|
6903
|
+
...i,
|
|
6904
|
+
partialPsbtBase64: s.toBase64()
|
|
6905
|
+
};
|
|
6906
|
+
return {
|
|
6907
|
+
state: P.toBase64(a),
|
|
6908
|
+
final: o,
|
|
6909
|
+
perInput: n
|
|
6910
|
+
};
|
|
6911
|
+
}
|
|
6912
|
+
static csvMultisigFinalize(e) {
|
|
6913
|
+
const t = P.fromBase64(e);
|
|
6914
|
+
if (!t.partialPsbtBase64) throw new Error("No partial PSBT in state — call addCSVMultisigSignature first");
|
|
6915
|
+
const i = j.nameToNetwork(t.baseParams.networkName), r = N.fromBase64(t.partialPsbtBase64, { network: i });
|
|
6916
|
+
for (let s = 0; s < r.data.inputs.length; s++) {
|
|
6917
|
+
const n = r.data.inputs[s];
|
|
6918
|
+
if (!n.tapLeafScript || n.tapLeafScript.length === 0) continue;
|
|
6919
|
+
const o = n.tapLeafScript[0];
|
|
6920
|
+
if (!o) continue;
|
|
6921
|
+
const a = rt.deriveAddressFromTapscript(o.script, i);
|
|
6922
|
+
a && rt.finalizePsbtInput(r, s, i, a);
|
|
6923
|
+
}
|
|
6924
|
+
return r.extractTransaction(!0, !0).toHex();
|
|
6925
|
+
}
|
|
6926
|
+
static addSignerToCSVInputs(e, t, i) {
|
|
6927
|
+
const r = f(O(t.publicKey));
|
|
6928
|
+
for (let s = 0; s < e.data.inputs.length; s++) {
|
|
6929
|
+
const n = e.data.inputs[s];
|
|
6930
|
+
if (!n.tapLeafScript || n.tapLeafScript.length === 0) continue;
|
|
6931
|
+
const o = n.tapLeafScript[0];
|
|
6932
|
+
if (!o) continue;
|
|
6933
|
+
const a = rt.deriveAddressFromTapscript(o.script, i);
|
|
6934
|
+
a && a.config.pubkeys.some((c) => f(c) === r) && ((n.tapScriptSig ?? []).some((c) => f(c.pubkey) === r) || e.signTaprootInput(s, t));
|
|
6935
|
+
}
|
|
6936
|
+
}
|
|
6937
|
+
static computeCSVMultisigStatus(e, t, i) {
|
|
6938
|
+
const r = [];
|
|
6939
|
+
for (let s = 0; s < e.utxos.length; s++) {
|
|
6940
|
+
const n = e.utxos[s];
|
|
6941
|
+
if (!n?.witnessScript) continue;
|
|
6942
|
+
const o = g(n.witnessScript), a = rt.deriveAddressFromTapscript(o, i);
|
|
6943
|
+
if (!a) continue;
|
|
6944
|
+
const c = t.data.inputs[s];
|
|
6945
|
+
if (!c) continue;
|
|
6946
|
+
if (c.finalScriptWitness) {
|
|
6947
|
+
r.push({
|
|
6948
|
+
inputIndex: s,
|
|
6949
|
+
required: a.config.threshold,
|
|
6950
|
+
collected: a.config.threshold,
|
|
6951
|
+
signers: []
|
|
6952
|
+
});
|
|
6953
|
+
continue;
|
|
6954
|
+
}
|
|
6955
|
+
const u = c.tapScriptSig ?? [];
|
|
6956
|
+
r.push({
|
|
6957
|
+
inputIndex: s,
|
|
6958
|
+
required: a.config.threshold,
|
|
6959
|
+
collected: u.length,
|
|
6960
|
+
signers: u.map((l) => f(l.pubkey))
|
|
6961
|
+
});
|
|
6962
|
+
}
|
|
6963
|
+
return r;
|
|
6844
6964
|
}
|
|
6845
6965
|
}, kr = class {
|
|
6966
|
+
opnetAPIUrl;
|
|
6846
6967
|
utxoPath = "address/utxos";
|
|
6847
6968
|
rpc = "json-rpc";
|
|
6848
6969
|
constructor(e) {
|
|
@@ -6872,7 +6993,7 @@ var St = class {
|
|
|
6872
6993
|
const k = n[A];
|
|
6873
6994
|
if (!k) throw new Error(`Invalid raw index ${A} - not found in raw transactions array`);
|
|
6874
6995
|
let x = p.get(A);
|
|
6875
|
-
if (x === void 0 && (x =
|
|
6996
|
+
if (x === void 0 && (x = Ni(k), p.set(A, x)), l += T, u.push({
|
|
6876
6997
|
transactionId: w.transactionId,
|
|
6877
6998
|
outputIndex: w.outputIndex,
|
|
6878
6999
|
value: T,
|
|
@@ -6927,7 +7048,7 @@ var St = class {
|
|
|
6927
7048
|
priorityFee: 0n,
|
|
6928
7049
|
gasSatFee: 330n,
|
|
6929
7050
|
mldsaSigner: null
|
|
6930
|
-
}, a = await new
|
|
7051
|
+
}, a = await new ni().createBTCTransfer(o), c = await this.broadcastTransaction(a.tx, !1);
|
|
6931
7052
|
return c || { error: "Could not broadcast transaction" };
|
|
6932
7053
|
}
|
|
6933
7054
|
async rpcMethod(e, t) {
|
|
@@ -6987,7 +7108,7 @@ var St = class {
|
|
|
6987
7108
|
if (!s) throw new Error("Failed to generate address");
|
|
6988
7109
|
return s;
|
|
6989
7110
|
}
|
|
6990
|
-
}, Kr = /* @__PURE__ */
|
|
7111
|
+
}, Kr = /* @__PURE__ */ ae(vi(), 1), S = /* @__PURE__ */ (function(e) {
|
|
6991
7112
|
return e.UINT8 = "UINT8", e.UINT16 = "UINT16", e.UINT32 = "UINT32", e.UINT64 = "UINT64", e.UINT128 = "UINT128", e.UINT256 = "UINT256", e.INT8 = "INT8", e.INT16 = "INT16", e.INT32 = "INT32", e.INT64 = "INT64", e.INT128 = "INT128", e.BOOL = "BOOL", e.ADDRESS = "ADDRESS", e.EXTENDED_ADDRESS = "EXTENDED_ADDRESS", e.STRING = "STRING", e.BYTES4 = "BYTES4", e.BYTES32 = "BYTES32", e.BYTES = "BYTES", e.ADDRESS_UINT256_TUPLE = "ADDRESS_UINT256_TUPLE", e.EXTENDED_ADDRESS_UINT256_TUPLE = "EXTENDED_ADDRESS_UINT256_TUPLE", e.SCHNORR_SIGNATURE = "SCHNORR_SIGNATURE", e.ARRAY_OF_ADDRESSES = "ARRAY_OF_ADDRESSES", e.ARRAY_OF_EXTENDED_ADDRESSES = "ARRAY_OF_EXTENDED_ADDRESSES", e.ARRAY_OF_UINT256 = "ARRAY_OF_UINT256", e.ARRAY_OF_UINT128 = "ARRAY_OF_UINT128", e.ARRAY_OF_UINT64 = "ARRAY_OF_UINT64", e.ARRAY_OF_UINT32 = "ARRAY_OF_UINT32", e.ARRAY_OF_UINT16 = "ARRAY_OF_UINT16", e.ARRAY_OF_UINT8 = "ARRAY_OF_UINT8", e.ARRAY_OF_STRING = "ARRAY_OF_STRING", e.ARRAY_OF_BYTES = "ARRAY_OF_BYTES", e.ARRAY_OF_BUFFERS = "ARRAY_OF_BUFFERS", e;
|
|
6992
7113
|
})({}), Dr = {
|
|
6993
7114
|
address: S.ADDRESS,
|
|
@@ -7023,7 +7144,7 @@ var St = class {
|
|
|
7023
7144
|
"buffer[]": S.ARRAY_OF_BUFFERS,
|
|
7024
7145
|
"string[]": S.ARRAY_OF_STRING,
|
|
7025
7146
|
boolean: S.BOOL
|
|
7026
|
-
},
|
|
7147
|
+
}, gi = {
|
|
7027
7148
|
[S.ADDRESS]: "address",
|
|
7028
7149
|
[S.EXTENDED_ADDRESS]: "extendedAddress",
|
|
7029
7150
|
[S.BOOL]: "bool",
|
|
@@ -7057,28 +7178,28 @@ var St = class {
|
|
|
7057
7178
|
[S.ARRAY_OF_STRING]: "string[]",
|
|
7058
7179
|
[S.ARRAY_OF_BUFFERS]: "buffer[]"
|
|
7059
7180
|
};
|
|
7060
|
-
function
|
|
7181
|
+
function Si(e) {
|
|
7061
7182
|
return Array.isArray(e);
|
|
7062
7183
|
}
|
|
7063
|
-
function
|
|
7184
|
+
function Ae(e) {
|
|
7064
7185
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
7065
7186
|
}
|
|
7066
|
-
function
|
|
7187
|
+
function wi(e) {
|
|
7067
7188
|
return typeof e == "string";
|
|
7068
7189
|
}
|
|
7069
|
-
function
|
|
7070
|
-
if (
|
|
7071
|
-
const i =
|
|
7190
|
+
function Lt(e) {
|
|
7191
|
+
if (wi(e)) {
|
|
7192
|
+
const i = gi[e];
|
|
7072
7193
|
if (!i) throw new Error(`Unknown ABI type: ${e}`);
|
|
7073
7194
|
return i;
|
|
7074
7195
|
}
|
|
7075
|
-
if (
|
|
7196
|
+
if (Ae(e)) return `tuple(${Object.values(e).map((i) => Lt(i)).join(",")})`;
|
|
7076
7197
|
const t = e[0];
|
|
7077
|
-
return e.length === 1 && t !== void 0 ? `${
|
|
7198
|
+
return e.length === 1 && t !== void 0 ? `${Lt(t)}[]` : `tuple(${e.map((i) => Lt(i)).join(",")})[]`;
|
|
7078
7199
|
}
|
|
7079
7200
|
var Mr = class {
|
|
7080
7201
|
decodeData(e, t) {
|
|
7081
|
-
const i = new
|
|
7202
|
+
const i = new Ht(e), r = [];
|
|
7082
7203
|
for (const s of t) r.push(this.decodeSingleValue(i, s));
|
|
7083
7204
|
return r;
|
|
7084
7205
|
}
|
|
@@ -7090,11 +7211,11 @@ var Mr = class {
|
|
|
7090
7211
|
return e.toString(16);
|
|
7091
7212
|
}
|
|
7092
7213
|
decodeSingleValue(e, t) {
|
|
7093
|
-
if (
|
|
7214
|
+
if (Si(t)) {
|
|
7094
7215
|
const i = t[0];
|
|
7095
7216
|
return t.length === 1 && i !== void 0 ? this.decodeArray(e, i) : this.decodeTuple(e, t);
|
|
7096
7217
|
}
|
|
7097
|
-
if (
|
|
7218
|
+
if (Ae(t)) return this.decodeStruct(e, t);
|
|
7098
7219
|
switch (t) {
|
|
7099
7220
|
case S.UINT8:
|
|
7100
7221
|
return e.readU8();
|
|
@@ -7186,7 +7307,7 @@ var Mr = class {
|
|
|
7186
7307
|
sha256(e) {
|
|
7187
7308
|
return new Uint8Array(new Kr.default.sha256().update(e).digest());
|
|
7188
7309
|
}
|
|
7189
|
-
}, Nr = class
|
|
7310
|
+
}, Nr = class yi {
|
|
7190
7311
|
items;
|
|
7191
7312
|
keys;
|
|
7192
7313
|
constructor(t = []) {
|
|
@@ -7208,7 +7329,7 @@ var Mr = class {
|
|
|
7208
7329
|
this.items.delete(i) && (this.keys = this.keys.filter((r) => r.toBigInt() !== i));
|
|
7209
7330
|
}
|
|
7210
7331
|
clone() {
|
|
7211
|
-
return new
|
|
7332
|
+
return new yi(this.keys);
|
|
7212
7333
|
}
|
|
7213
7334
|
clear() {
|
|
7214
7335
|
this.items.clear(), this.keys = [];
|
|
@@ -7224,17 +7345,18 @@ var Mr = class {
|
|
|
7224
7345
|
*[Symbol.iterator]() {
|
|
7225
7346
|
yield* this.keys;
|
|
7226
7347
|
}
|
|
7227
|
-
}, xr = class
|
|
7348
|
+
}, xr = class mi {
|
|
7349
|
+
compareFn;
|
|
7228
7350
|
map;
|
|
7229
7351
|
#t;
|
|
7230
7352
|
constructor(t) {
|
|
7231
|
-
this.compareFn = t, this.map = new
|
|
7353
|
+
this.compareFn = t, this.map = new Wt(), this.#t = [];
|
|
7232
7354
|
}
|
|
7233
7355
|
get size() {
|
|
7234
7356
|
return this.map.size;
|
|
7235
7357
|
}
|
|
7236
7358
|
static fromMap(t, i) {
|
|
7237
|
-
const r = new
|
|
7359
|
+
const r = new mi(i);
|
|
7238
7360
|
for (const [s, n] of t) r.set(s, n);
|
|
7239
7361
|
return r;
|
|
7240
7362
|
}
|
|
@@ -7293,7 +7415,8 @@ var Mr = class {
|
|
|
7293
7415
|
*[Symbol.iterator]() {
|
|
7294
7416
|
for (const t of this.#t) yield [t, this.map.get(t)];
|
|
7295
7417
|
}
|
|
7296
|
-
}, Fr = class
|
|
7418
|
+
}, Fr = class Ti {
|
|
7419
|
+
compareFn;
|
|
7297
7420
|
elements;
|
|
7298
7421
|
constructor(t) {
|
|
7299
7422
|
this.compareFn = t, this.elements = [];
|
|
@@ -7302,7 +7425,7 @@ var Mr = class {
|
|
|
7302
7425
|
return this.elements.length;
|
|
7303
7426
|
}
|
|
7304
7427
|
static fromSet(t, i) {
|
|
7305
|
-
const r = new
|
|
7428
|
+
const r = new Ti(i);
|
|
7306
7429
|
for (const s of t) r.add(s);
|
|
7307
7430
|
return r;
|
|
7308
7431
|
}
|
|
@@ -7348,6 +7471,8 @@ var Mr = class {
|
|
|
7348
7471
|
};
|
|
7349
7472
|
}
|
|
7350
7473
|
}, Wr = class {
|
|
7474
|
+
type;
|
|
7475
|
+
data;
|
|
7351
7476
|
constructor(e, t) {
|
|
7352
7477
|
this.type = e, this.data = t;
|
|
7353
7478
|
}
|
|
@@ -7356,8 +7481,8 @@ var Mr = class {
|
|
|
7356
7481
|
})({}), Vr = /* @__PURE__ */ (function(e) {
|
|
7357
7482
|
return e.ECDSA = "ECDSA", e.BIP322 = "BIP322", e;
|
|
7358
7483
|
})({});
|
|
7359
|
-
|
|
7360
|
-
var zr = class extends
|
|
7484
|
+
vt();
|
|
7485
|
+
var zr = class extends we {
|
|
7361
7486
|
isInitialized = !1;
|
|
7362
7487
|
constructor() {
|
|
7363
7488
|
if (super(), !window) throw new Error("XverseSigner can only be used in a browser environment");
|
|
@@ -7400,7 +7525,7 @@ var zr = class extends Te {
|
|
|
7400
7525
|
if (!t) throw new Error("Payment address not found");
|
|
7401
7526
|
const i = t.address.startsWith("opt") ? y.opnetTestnet : t.address.startsWith("tb") ? y.testnet : t.address.startsWith("bc") ? y.bitcoin : null;
|
|
7402
7527
|
if (!i) throw new Error("Network not supported");
|
|
7403
|
-
this._network = i, this._publicKey =
|
|
7528
|
+
this._network = i, this._publicKey = ce(g(t.publicKey)), this._p2wpkh = I.getP2WPKHAddress(this, this.network), this._p2tr = I.getTaprootAddress(this, this.network), this._addresses = [this._p2wpkh, this._p2tr], this.isInitialized = !0;
|
|
7404
7529
|
}
|
|
7405
7530
|
async signData(e, t, i) {
|
|
7406
7531
|
if (!this.isInitialized) throw new Error("UnisatSigner not initialized");
|
|
@@ -7446,18 +7571,18 @@ var zr = class extends Te {
|
|
|
7446
7571
|
t.push(a);
|
|
7447
7572
|
const c = o.data.inputs.map((u, l) => {
|
|
7448
7573
|
let h = !1, p = !1;
|
|
7449
|
-
if (
|
|
7574
|
+
if (fe(u)) {
|
|
7450
7575
|
if (u.tapLeafScript && u.tapLeafScript.length > 0) {
|
|
7451
|
-
for (const w of u.tapLeafScript) if (
|
|
7576
|
+
for (const w of u.tapLeafScript) if (Se(this.publicKey, w.script)) {
|
|
7452
7577
|
h = !0, p = !1;
|
|
7453
7578
|
break;
|
|
7454
7579
|
}
|
|
7455
7580
|
}
|
|
7456
7581
|
if (!h && u.tapInternalKey) {
|
|
7457
7582
|
const w = u.tapInternalKey;
|
|
7458
|
-
C(w,
|
|
7583
|
+
C(w, O(this.publicKey)) && (h = !0, p = !0);
|
|
7459
7584
|
}
|
|
7460
|
-
} else
|
|
7585
|
+
} else ge(u, this.publicKey) && (h = !0, p = !1);
|
|
7461
7586
|
return h ? {
|
|
7462
7587
|
index: l,
|
|
7463
7588
|
publicKey: f(this.publicKey),
|
|
@@ -7474,7 +7599,7 @@ var zr = class extends Te {
|
|
|
7474
7599
|
signInputs: r
|
|
7475
7600
|
});
|
|
7476
7601
|
if ("error" in s) throw new Error(s.error.message);
|
|
7477
|
-
const n =
|
|
7602
|
+
const n = N.fromBase64(s.result.psbt);
|
|
7478
7603
|
e[0].combine(n);
|
|
7479
7604
|
}
|
|
7480
7605
|
hasAlreadySignedTapScriptSig(e) {
|
|
@@ -7515,7 +7640,7 @@ var zr = class extends Te {
|
|
|
7515
7640
|
signInputs: o
|
|
7516
7641
|
});
|
|
7517
7642
|
if ("error" in a) throw new Error(a.error.message);
|
|
7518
|
-
return
|
|
7643
|
+
return N.fromBase64(a.result.psbt);
|
|
7519
7644
|
}
|
|
7520
7645
|
getNonDuplicateScriptSig(e, t) {
|
|
7521
7646
|
const i = [];
|
|
@@ -7525,7 +7650,7 @@ var zr = class extends Te {
|
|
|
7525
7650
|
}
|
|
7526
7651
|
return i;
|
|
7527
7652
|
}
|
|
7528
|
-
}, qr = class
|
|
7653
|
+
}, qr = class oe {
|
|
7529
7654
|
static INITIAL_CAPACITY = 16;
|
|
7530
7655
|
static LOAD_FACTOR = 0.75;
|
|
7531
7656
|
#t;
|
|
@@ -7533,7 +7658,7 @@ var zr = class extends Te {
|
|
|
7533
7658
|
deleted;
|
|
7534
7659
|
capacity;
|
|
7535
7660
|
constructor() {
|
|
7536
|
-
this.capacity =
|
|
7661
|
+
this.capacity = oe.INITIAL_CAPACITY, this.#t = new Array(this.capacity), this.#e = new Array(this.capacity), this.deleted = new Array(this.capacity).fill(!1);
|
|
7537
7662
|
}
|
|
7538
7663
|
_size = 0;
|
|
7539
7664
|
get size() {
|
|
@@ -7542,7 +7667,7 @@ var zr = class extends Te {
|
|
|
7542
7667
|
set(t, i) {
|
|
7543
7668
|
let r = !0;
|
|
7544
7669
|
const s = this.findInsertIndex(t);
|
|
7545
|
-
return (this.#t[s] === void 0 || this.deleted[s]) && (this._size++, r = !1), this.#t[s] = t, this.#e[s] = i, this.deleted[s] = !1, this._size > this.capacity *
|
|
7670
|
+
return (this.#t[s] === void 0 || this.deleted[s]) && (this._size++, r = !1), this.#t[s] = t, this.#e[s] = i, this.deleted[s] = !1, this._size > this.capacity * oe.LOAD_FACTOR && this.resize(), r;
|
|
7546
7671
|
}
|
|
7547
7672
|
get(t) {
|
|
7548
7673
|
const i = this.findIndex(t);
|
|
@@ -7647,7 +7772,7 @@ var zr = class extends Te {
|
|
|
7647
7772
|
return !0;
|
|
7648
7773
|
}
|
|
7649
7774
|
getBytes(t) {
|
|
7650
|
-
return t instanceof ArrayBuffer ? new Uint8Array(t) : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(0);
|
|
7775
|
+
return t instanceof ArrayBuffer ? new Uint8Array(t) : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : /* @__PURE__ */ new Uint8Array(0);
|
|
7651
7776
|
}
|
|
7652
7777
|
findIndex(t) {
|
|
7653
7778
|
let i = this.hash(t);
|
|
@@ -7670,284 +7795,286 @@ var zr = class extends Te {
|
|
|
7670
7795
|
this.capacity *= 2, this.#t = new Array(this.capacity), this.#e = new Array(this.capacity), this.deleted = new Array(this.capacity).fill(!1), this._size = 0;
|
|
7671
7796
|
for (let r = 0; r < t.length; r++) t[r] !== void 0 && !this.deleted[r] && this.set(t[r], i[r]);
|
|
7672
7797
|
}
|
|
7673
|
-
},
|
|
7798
|
+
}, ms = /* @__PURE__ */ Ai({
|
|
7674
7799
|
ABICoder: () => Mr,
|
|
7675
7800
|
ABIDataTypes: () => S,
|
|
7676
7801
|
ADDRESS_BYTE_LENGTH: () => 32,
|
|
7677
|
-
ANCHOR_SCRIPT: () =>
|
|
7678
|
-
AbiTypeToStr: () =>
|
|
7679
|
-
Address: () =>
|
|
7680
|
-
AddressGenerator: () =>
|
|
7681
|
-
AddressMap: () =>
|
|
7802
|
+
ANCHOR_SCRIPT: () => se,
|
|
7803
|
+
AbiTypeToStr: () => gi,
|
|
7804
|
+
Address: () => z,
|
|
7805
|
+
AddressGenerator: () => de,
|
|
7806
|
+
AddressMap: () => Fe,
|
|
7682
7807
|
AddressSet: () => Nr,
|
|
7683
|
-
AddressTypes: () =>
|
|
7684
|
-
AddressVerificator: () =>
|
|
7685
|
-
BIPStandard: () =>
|
|
7808
|
+
AddressTypes: () => ct,
|
|
7809
|
+
AddressVerificator: () => Et,
|
|
7810
|
+
BIPStandard: () => kt,
|
|
7686
7811
|
BOOLEAN_BYTE_LENGTH: () => 1,
|
|
7687
|
-
BinaryReader: () =>
|
|
7688
|
-
BinaryWriter: () =>
|
|
7812
|
+
BinaryReader: () => Ht,
|
|
7813
|
+
BinaryWriter: () => V,
|
|
7689
7814
|
BitcoinUtils: () => W,
|
|
7690
|
-
BufferHelper: () =>
|
|
7691
|
-
CSVModes: () =>
|
|
7692
|
-
CSVMultisigProvider: () =>
|
|
7693
|
-
CalldataGenerator: () =>
|
|
7694
|
-
CancelTransaction: () =>
|
|
7695
|
-
ChainId: () =>
|
|
7696
|
-
ChallengeSolution: () =>
|
|
7697
|
-
ChallengeSubmission: () =>
|
|
7698
|
-
ChallengeVerification: () =>
|
|
7815
|
+
BufferHelper: () => _t,
|
|
7816
|
+
CSVModes: () => Or,
|
|
7817
|
+
CSVMultisigProvider: () => rt,
|
|
7818
|
+
CalldataGenerator: () => le,
|
|
7819
|
+
CancelTransaction: () => me,
|
|
7820
|
+
ChainId: () => Qe,
|
|
7821
|
+
ChallengeSolution: () => ne,
|
|
7822
|
+
ChallengeSubmission: () => fi,
|
|
7823
|
+
ChallengeVerification: () => pi,
|
|
7699
7824
|
Compressor: () => Z,
|
|
7700
|
-
Consensus: () =>
|
|
7701
|
-
ConsolidatedInteractionTransaction: () =>
|
|
7702
|
-
ContractAddress: () =>
|
|
7703
|
-
ContractBaseMetadata: () =>
|
|
7704
|
-
CustomGenerator: () =>
|
|
7705
|
-
CustomKeypair: () =>
|
|
7825
|
+
Consensus: () => Vt,
|
|
7826
|
+
ConsolidatedInteractionTransaction: () => si,
|
|
7827
|
+
ContractAddress: () => Qt,
|
|
7828
|
+
ContractBaseMetadata: () => yr,
|
|
7829
|
+
CustomGenerator: () => ze,
|
|
7830
|
+
CustomKeypair: () => we,
|
|
7706
7831
|
CustomMap: () => qr,
|
|
7707
|
-
CustomScriptTransaction: () =>
|
|
7708
|
-
DeploymentGenerator: () =>
|
|
7709
|
-
DeploymentTransaction: () =>
|
|
7832
|
+
CustomScriptTransaction: () => Kt,
|
|
7833
|
+
DeploymentGenerator: () => he,
|
|
7834
|
+
DeploymentTransaction: () => Dt,
|
|
7710
7835
|
DeterministicMap: () => xr,
|
|
7711
7836
|
DeterministicSet: () => Fr,
|
|
7712
7837
|
EXTENDED_ADDRESS_BYTE_LENGTH: () => 64,
|
|
7713
7838
|
EcKeyPair: () => I,
|
|
7714
|
-
EpochValidator: () =>
|
|
7715
|
-
ExtendedAddressMap: () =>
|
|
7716
|
-
FastMap: () =>
|
|
7839
|
+
EpochValidator: () => wt,
|
|
7840
|
+
ExtendedAddressMap: () => We,
|
|
7841
|
+
FastMap: () => Wt,
|
|
7717
7842
|
FeaturePriority: () => J,
|
|
7718
|
-
Features: () =>
|
|
7719
|
-
FundingTransaction: () =>
|
|
7843
|
+
Features: () => q,
|
|
7844
|
+
FundingTransaction: () => Mt,
|
|
7720
7845
|
Generator: () => tt,
|
|
7721
|
-
HashCommitmentGenerator: () =>
|
|
7846
|
+
HashCommitmentGenerator: () => St,
|
|
7722
7847
|
I128_BYTE_LENGTH: () => 16,
|
|
7723
7848
|
I16_BYTE_LENGTH: () => 2,
|
|
7724
7849
|
I256_BYTE_LENGTH: () => 32,
|
|
7725
7850
|
I32_BYTE_LENGTH: () => 4,
|
|
7726
7851
|
I64_BYTE_LENGTH: () => 8,
|
|
7727
7852
|
I8_BYTE_LENGTH: () => 1,
|
|
7728
|
-
InteractionTransaction: () =>
|
|
7729
|
-
InteractionTransactionP2WDA: () =>
|
|
7853
|
+
InteractionTransaction: () => Nt,
|
|
7854
|
+
InteractionTransactionP2WDA: () => ri,
|
|
7730
7855
|
LEAF_VERSION_TAPSCRIPT: () => 192,
|
|
7731
|
-
LegacyCalldataGenerator: () =>
|
|
7732
|
-
MINIMUM_AMOUNT_CA: () =>
|
|
7733
|
-
MINIMUM_AMOUNT_REWARD: () =>
|
|
7734
|
-
MLDSAPublicKeyMetadata: () =>
|
|
7735
|
-
MLDSASecurityLevel: () =>
|
|
7736
|
-
MessageSigner: () =>
|
|
7737
|
-
MessageType: () =>
|
|
7738
|
-
Mnemonic: () =>
|
|
7739
|
-
MnemonicStrength: () =>
|
|
7740
|
-
MultiSignGenerator: () =>
|
|
7856
|
+
LegacyCalldataGenerator: () => ur,
|
|
7857
|
+
MINIMUM_AMOUNT_CA: () => ei,
|
|
7858
|
+
MINIMUM_AMOUNT_REWARD: () => Pt,
|
|
7859
|
+
MLDSAPublicKeyMetadata: () => wr,
|
|
7860
|
+
MLDSASecurityLevel: () => v.MLDSASecurityLevel,
|
|
7861
|
+
MessageSigner: () => st,
|
|
7862
|
+
MessageType: () => dr,
|
|
7863
|
+
Mnemonic: () => Sr,
|
|
7864
|
+
MnemonicStrength: () => ee,
|
|
7865
|
+
MultiSignGenerator: () => Ge,
|
|
7741
7866
|
MultiSignTransaction: () => Q,
|
|
7742
|
-
NUMS_INTERNAL_KEY: () =>
|
|
7867
|
+
NUMS_INTERNAL_KEY: () => Ut,
|
|
7743
7868
|
NetEvent: () => Wr,
|
|
7744
7869
|
OPNET_DEPLOYMENT_VERSION: () => 0,
|
|
7745
|
-
OPNetConsensusConfig: () =>
|
|
7870
|
+
OPNetConsensusConfig: () => di,
|
|
7746
7871
|
OPNetLimitedProvider: () => kr,
|
|
7747
7872
|
OfflineTransactionManager: () => Br,
|
|
7748
7873
|
P2MR_MS: () => Cr,
|
|
7749
7874
|
P2TR_MS: () => Rr,
|
|
7750
|
-
P2WDADetector: () =>
|
|
7751
|
-
P2WDAGenerator: () =>
|
|
7875
|
+
P2WDADetector: () => X,
|
|
7876
|
+
P2WDAGenerator: () => Jt,
|
|
7752
7877
|
PSBTTypes: () => Lr,
|
|
7753
|
-
QuantumBIP32Factory: () =>
|
|
7754
|
-
QuantumDerivationPath: () =>
|
|
7755
|
-
RoswellConsensus: () =>
|
|
7878
|
+
QuantumBIP32Factory: () => v.QuantumBIP32Factory,
|
|
7879
|
+
QuantumDerivationPath: () => v.QuantumDerivationPath,
|
|
7880
|
+
RoswellConsensus: () => hi,
|
|
7756
7881
|
SCHNORR_SIGNATURE_BYTE_LENGTH: () => 64,
|
|
7757
7882
|
SELECTOR_BYTE_LENGTH: () => 4,
|
|
7758
|
-
SERIALIZATION_FORMAT_VERSION: () =>
|
|
7883
|
+
SERIALIZATION_FORMAT_VERSION: () => 2,
|
|
7759
7884
|
SERIALIZATION_MAGIC_BYTE: () => 66,
|
|
7760
|
-
Secp256k1PointDeriver: () =>
|
|
7761
|
-
SharedInteractionTransaction: () =>
|
|
7762
|
-
SignatureType: () =>
|
|
7885
|
+
Secp256k1PointDeriver: () => Ne,
|
|
7886
|
+
SharedInteractionTransaction: () => ye,
|
|
7887
|
+
SignatureType: () => te,
|
|
7763
7888
|
SigningProtocol: () => Vr,
|
|
7764
7889
|
StrToAbiType: () => Dr,
|
|
7765
|
-
|
|
7890
|
+
TOLERANCE: () => 1,
|
|
7891
|
+
TapscriptVerificator: () => lr,
|
|
7766
7892
|
TimeLockGenerator: () => nt,
|
|
7767
7893
|
TransactionBuilder: () => B,
|
|
7768
|
-
TransactionFactory: () =>
|
|
7769
|
-
TransactionReconstructor: () =>
|
|
7770
|
-
TransactionSequence: () =>
|
|
7771
|
-
TransactionSerializer: () =>
|
|
7772
|
-
TransactionStateCapture: () =>
|
|
7894
|
+
TransactionFactory: () => ni,
|
|
7895
|
+
TransactionReconstructor: () => j,
|
|
7896
|
+
TransactionSequence: () => vr,
|
|
7897
|
+
TransactionSerializer: () => P,
|
|
7898
|
+
TransactionStateCapture: () => $,
|
|
7773
7899
|
TransactionType: () => m,
|
|
7774
|
-
TweakedSigner: () =>
|
|
7775
|
-
TweakedTransaction: () =>
|
|
7900
|
+
TweakedSigner: () => pe,
|
|
7901
|
+
TweakedTransaction: () => ti,
|
|
7776
7902
|
U128_BYTE_LENGTH: () => 16,
|
|
7777
7903
|
U16_BYTE_LENGTH: () => 2,
|
|
7778
7904
|
U256_BYTE_LENGTH: () => 32,
|
|
7779
7905
|
U32_BYTE_LENGTH: () => 4,
|
|
7780
7906
|
U64_BYTE_LENGTH: () => 8,
|
|
7781
7907
|
U8_BYTE_LENGTH: () => 1,
|
|
7782
|
-
UnisatChainType: () =>
|
|
7783
|
-
UnisatSigner: () =>
|
|
7784
|
-
Wallet: () =>
|
|
7908
|
+
UnisatChainType: () => hr,
|
|
7909
|
+
UnisatSigner: () => Tr,
|
|
7910
|
+
Wallet: () => Bt,
|
|
7785
7911
|
WalletNetworks: () => Tt,
|
|
7786
7912
|
XverseNetwork: () => Hr,
|
|
7787
7913
|
XverseSigner: () => zr,
|
|
7788
|
-
abiTypeToSelectorString: () =>
|
|
7789
|
-
buildBIPPath: () =>
|
|
7790
|
-
createAddressRotation: () =>
|
|
7791
|
-
createSignerMap: () =>
|
|
7792
|
-
currentConsensus: () =>
|
|
7914
|
+
abiTypeToSelectorString: () => Lt,
|
|
7915
|
+
buildBIPPath: () => Ye,
|
|
7916
|
+
createAddressRotation: () => Er,
|
|
7917
|
+
createSignerMap: () => Ze,
|
|
7918
|
+
currentConsensus: () => Te,
|
|
7793
7919
|
currentConsensusConfig: () => Ur,
|
|
7794
|
-
disabledAddressRotation: () =>
|
|
7795
|
-
getBIPDescription: () =>
|
|
7796
|
-
getLevelFromPublicKeyLength: () =>
|
|
7797
|
-
isAbiStruct: () =>
|
|
7798
|
-
isAbiTuple: () =>
|
|
7799
|
-
isCancelSpecificData: () =>
|
|
7800
|
-
isCustomScriptSpecificData: () =>
|
|
7801
|
-
isDeploymentSpecificData: () =>
|
|
7802
|
-
isFundingSpecificData: () =>
|
|
7803
|
-
isInteractionSpecificData: () =>
|
|
7920
|
+
disabledAddressRotation: () => Ir,
|
|
7921
|
+
getBIPDescription: () => fr,
|
|
7922
|
+
getLevelFromPublicKeyLength: () => ie,
|
|
7923
|
+
isAbiStruct: () => Ae,
|
|
7924
|
+
isAbiTuple: () => Si,
|
|
7925
|
+
isCancelSpecificData: () => li,
|
|
7926
|
+
isCustomScriptSpecificData: () => ui,
|
|
7927
|
+
isDeploymentSpecificData: () => ai,
|
|
7928
|
+
isFundingSpecificData: () => oi,
|
|
7929
|
+
isInteractionSpecificData: () => ci,
|
|
7804
7930
|
isMultiSigSpecificData: () => et,
|
|
7805
|
-
isOPWallet: () =>
|
|
7806
|
-
isSimpleAbiType: () =>
|
|
7807
|
-
isUniversalSigner: () =>
|
|
7808
|
-
toParallelKeyPair: () =>
|
|
7809
|
-
toTweakedParallelKeyPair: () =>
|
|
7810
|
-
version: () =>
|
|
7811
|
-
versionBuffer: () =>
|
|
7812
|
-
}),
|
|
7931
|
+
isOPWallet: () => $e,
|
|
7932
|
+
isSimpleAbiType: () => wi,
|
|
7933
|
+
isUniversalSigner: () => dt,
|
|
7934
|
+
toParallelKeyPair: () => Pr,
|
|
7935
|
+
toTweakedParallelKeyPair: () => Je,
|
|
7936
|
+
version: () => ji,
|
|
7937
|
+
versionBuffer: () => qe
|
|
7938
|
+
}), Ts = v.MLDSASecurityLevel, As = v.QuantumBIP32Factory, bs = v.QuantumDerivationPath;
|
|
7813
7939
|
export {
|
|
7814
7940
|
Mr as ABICoder,
|
|
7815
7941
|
S as ABIDataTypes,
|
|
7816
7942
|
jr as ADDRESS_BYTE_LENGTH,
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7943
|
+
se as ANCHOR_SCRIPT,
|
|
7944
|
+
gi as AbiTypeToStr,
|
|
7945
|
+
z as Address,
|
|
7946
|
+
de as AddressGenerator,
|
|
7947
|
+
Fe as AddressMap,
|
|
7822
7948
|
Nr as AddressSet,
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7949
|
+
ct as AddressTypes,
|
|
7950
|
+
Et as AddressVerificator,
|
|
7951
|
+
kt as BIPStandard,
|
|
7826
7952
|
ds as BOOLEAN_BYTE_LENGTH,
|
|
7827
|
-
|
|
7828
|
-
|
|
7953
|
+
Ht as BinaryReader,
|
|
7954
|
+
V as BinaryWriter,
|
|
7829
7955
|
W as BitcoinUtils,
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7956
|
+
_t as BufferHelper,
|
|
7957
|
+
Or as CSVModes,
|
|
7958
|
+
rt as CSVMultisigProvider,
|
|
7959
|
+
le as CalldataGenerator,
|
|
7960
|
+
me as CancelTransaction,
|
|
7961
|
+
Qe as ChainId,
|
|
7962
|
+
ne as ChallengeSolution,
|
|
7963
|
+
fi as ChallengeSubmission,
|
|
7964
|
+
pi as ChallengeVerification,
|
|
7839
7965
|
Z as Compressor,
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7966
|
+
Vt as Consensus,
|
|
7967
|
+
si as ConsolidatedInteractionTransaction,
|
|
7968
|
+
Qt as ContractAddress,
|
|
7969
|
+
yr as ContractBaseMetadata,
|
|
7970
|
+
ze as CustomGenerator,
|
|
7971
|
+
we as CustomKeypair,
|
|
7846
7972
|
qr as CustomMap,
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7973
|
+
Kt as CustomScriptTransaction,
|
|
7974
|
+
he as DeploymentGenerator,
|
|
7975
|
+
Dt as DeploymentTransaction,
|
|
7850
7976
|
xr as DeterministicMap,
|
|
7851
7977
|
Fr as DeterministicSet,
|
|
7852
7978
|
Qr as EXTENDED_ADDRESS_BYTE_LENGTH,
|
|
7853
7979
|
I as EcKeyPair,
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7980
|
+
wt as EpochValidator,
|
|
7981
|
+
We as ExtendedAddressMap,
|
|
7982
|
+
Wt as FastMap,
|
|
7857
7983
|
J as FeaturePriority,
|
|
7858
|
-
|
|
7859
|
-
|
|
7984
|
+
q as Features,
|
|
7985
|
+
Mt as FundingTransaction,
|
|
7860
7986
|
tt as Generator,
|
|
7861
|
-
|
|
7987
|
+
St as HashCommitmentGenerator,
|
|
7862
7988
|
as as I128_BYTE_LENGTH,
|
|
7863
7989
|
ls as I16_BYTE_LENGTH,
|
|
7864
7990
|
os as I256_BYTE_LENGTH,
|
|
7865
7991
|
us as I32_BYTE_LENGTH,
|
|
7866
7992
|
cs as I64_BYTE_LENGTH,
|
|
7867
7993
|
hs as I8_BYTE_LENGTH,
|
|
7868
|
-
|
|
7869
|
-
|
|
7994
|
+
Nt as InteractionTransaction,
|
|
7995
|
+
ri as InteractionTransactionP2WDA,
|
|
7870
7996
|
gs as LEAF_VERSION_TAPSCRIPT,
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7997
|
+
ur as LegacyCalldataGenerator,
|
|
7998
|
+
ei as MINIMUM_AMOUNT_CA,
|
|
7999
|
+
Pt as MINIMUM_AMOUNT_REWARD,
|
|
8000
|
+
wr as MLDSAPublicKeyMetadata,
|
|
8001
|
+
Ts as MLDSASecurityLevel,
|
|
8002
|
+
st as MessageSigner,
|
|
8003
|
+
dr as MessageType,
|
|
8004
|
+
Sr as Mnemonic,
|
|
8005
|
+
ee as MnemonicStrength,
|
|
8006
|
+
Ge as MultiSignGenerator,
|
|
7881
8007
|
Q as MultiSignTransaction,
|
|
7882
|
-
|
|
8008
|
+
Ut as NUMS_INTERNAL_KEY,
|
|
7883
8009
|
Wr as NetEvent,
|
|
7884
8010
|
fs as OPNET_DEPLOYMENT_VERSION,
|
|
7885
|
-
|
|
8011
|
+
di as OPNetConsensusConfig,
|
|
7886
8012
|
kr as OPNetLimitedProvider,
|
|
7887
8013
|
Br as OfflineTransactionManager,
|
|
7888
8014
|
Cr as P2MR_MS,
|
|
7889
8015
|
Rr as P2TR_MS,
|
|
7890
|
-
|
|
7891
|
-
|
|
8016
|
+
X as P2WDADetector,
|
|
8017
|
+
Jt as P2WDAGenerator,
|
|
7892
8018
|
Lr as PSBTTypes,
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
8019
|
+
As as QuantumBIP32Factory,
|
|
8020
|
+
bs as QuantumDerivationPath,
|
|
8021
|
+
hi as RoswellConsensus,
|
|
7896
8022
|
Zr as SCHNORR_SIGNATURE_BYTE_LENGTH,
|
|
7897
8023
|
Jr as SELECTOR_BYTE_LENGTH,
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
8024
|
+
ws as SERIALIZATION_FORMAT_VERSION,
|
|
8025
|
+
ys as SERIALIZATION_MAGIC_BYTE,
|
|
8026
|
+
Ne as Secp256k1PointDeriver,
|
|
8027
|
+
ye as SharedInteractionTransaction,
|
|
8028
|
+
te as SignatureType,
|
|
7903
8029
|
Vr as SigningProtocol,
|
|
7904
8030
|
Dr as StrToAbiType,
|
|
7905
|
-
|
|
8031
|
+
Ss as TOLERANCE,
|
|
8032
|
+
lr as TapscriptVerificator,
|
|
7906
8033
|
nt as TimeLockGenerator,
|
|
7907
8034
|
B as TransactionBuilder,
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
8035
|
+
ni as TransactionFactory,
|
|
8036
|
+
j as TransactionReconstructor,
|
|
8037
|
+
vr as TransactionSequence,
|
|
8038
|
+
P as TransactionSerializer,
|
|
8039
|
+
$ as TransactionStateCapture,
|
|
7913
8040
|
m as TransactionType,
|
|
7914
|
-
|
|
7915
|
-
|
|
8041
|
+
pe as TweakedSigner,
|
|
8042
|
+
ti as TweakedTransaction,
|
|
7916
8043
|
es as U128_BYTE_LENGTH,
|
|
7917
8044
|
ss as U16_BYTE_LENGTH,
|
|
7918
8045
|
ts as U256_BYTE_LENGTH,
|
|
7919
8046
|
rs as U32_BYTE_LENGTH,
|
|
7920
8047
|
is as U64_BYTE_LENGTH,
|
|
7921
8048
|
ns as U8_BYTE_LENGTH,
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
8049
|
+
hr as UnisatChainType,
|
|
8050
|
+
Tr as UnisatSigner,
|
|
8051
|
+
Bt as Wallet,
|
|
7925
8052
|
Tt as WalletNetworks,
|
|
7926
8053
|
Hr as XverseNetwork,
|
|
7927
8054
|
zr as XverseSigner,
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
8055
|
+
Lt as abiTypeToSelectorString,
|
|
8056
|
+
Ye as buildBIPPath,
|
|
8057
|
+
Er as createAddressRotation,
|
|
8058
|
+
Ze as createSignerMap,
|
|
8059
|
+
Te as currentConsensus,
|
|
7933
8060
|
Ur as currentConsensusConfig,
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
8061
|
+
Ir as disabledAddressRotation,
|
|
8062
|
+
fr as getBIPDescription,
|
|
8063
|
+
ie as getLevelFromPublicKeyLength,
|
|
8064
|
+
Ae as isAbiStruct,
|
|
8065
|
+
Si as isAbiTuple,
|
|
8066
|
+
li as isCancelSpecificData,
|
|
8067
|
+
ui as isCustomScriptSpecificData,
|
|
8068
|
+
ai as isDeploymentSpecificData,
|
|
8069
|
+
oi as isFundingSpecificData,
|
|
8070
|
+
ci as isInteractionSpecificData,
|
|
7944
8071
|
et as isMultiSigSpecificData,
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
8072
|
+
$e as isOPWallet,
|
|
8073
|
+
wi as isSimpleAbiType,
|
|
8074
|
+
dt as isUniversalSigner,
|
|
8075
|
+
ms as opnet,
|
|
8076
|
+
Pr as toParallelKeyPair,
|
|
8077
|
+
Je as toTweakedParallelKeyPair,
|
|
8078
|
+
ji as version,
|
|
8079
|
+
qe as versionBuffer
|
|
7953
8080
|
};
|