@btc-vision/transaction 1.8.7-beta.0 → 1.8.7
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 +364 -364
- package/browser/index.js +1022 -903
- package/browser/noble-curves.js +1183 -2156
- 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 +1395 -1395
- 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/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;
|
|
@@ -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;
|
|
@@ -559,16 +559,16 @@ var ur = /^[0-9a-fA-F]+$/, W = class Fe {
|
|
|
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,21 +686,21 @@ 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
695
|
const i = Uint8Array.from(t), r = i.slice(1, 33), s = i.slice(33), n = 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
|
-
return new
|
|
699
|
+
return new Y(Y.bigintToUint8Array(t), i !== void 0 ? Y.bigintToUint8Array(i) : void 0);
|
|
700
700
|
}
|
|
701
701
|
static fromUint64Array(t, i, r, s) {
|
|
702
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
|
+
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
704
|
}
|
|
705
705
|
static bigintToUint8Array(t) {
|
|
706
706
|
const i = new Uint8Array(32), r = new DataView(i.buffer);
|
|
@@ -800,7 +800,7 @@ var hr = [
|
|
|
800
800
|
isValidLegacyPublicKey(t) {
|
|
801
801
|
const i = this.legacyPublicKey;
|
|
802
802
|
if (!i) throw new Error("Legacy key not set.");
|
|
803
|
-
return
|
|
803
|
+
return Et.isValidPublicKey(f(i), t);
|
|
804
804
|
}
|
|
805
805
|
p2pk() {
|
|
806
806
|
return this.toHex();
|
|
@@ -835,7 +835,7 @@ var hr = [
|
|
|
835
835
|
const i = new Uint8Array(this.#i);
|
|
836
836
|
if (i.length !== 33) throw new Error("P2WDA requires a compressed public key (33 bytes)");
|
|
837
837
|
try {
|
|
838
|
-
const r =
|
|
838
|
+
const r = X.generateP2WDAAddress(i, t);
|
|
839
839
|
return this.#n = t, this.#d = r, {
|
|
840
840
|
address: r.address,
|
|
841
841
|
witnessScript: r.witnessScript
|
|
@@ -883,7 +883,7 @@ var hr = [
|
|
|
883
883
|
const t = this.#o;
|
|
884
884
|
if (t && t.length === 32 && !this.#i)
|
|
885
885
|
try {
|
|
886
|
-
this.#s =
|
|
886
|
+
this.#s = Qt.generateHybridKeyFromHash(t);
|
|
887
887
|
} catch {
|
|
888
888
|
}
|
|
889
889
|
}
|
|
@@ -892,9 +892,9 @@ var hr = [
|
|
|
892
892
|
const i = new Uint8Array(32);
|
|
893
893
|
i.set(t), super.set(i);
|
|
894
894
|
} else {
|
|
895
|
-
if (!
|
|
895
|
+
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
896
|
this.#a = new Uint8Array(t.length), this.#a.set(t);
|
|
897
|
-
const i =
|
|
897
|
+
const i = Ft(new Uint8Array(t)), r = new Uint8Array(32);
|
|
898
898
|
r.set(i), super.set(r);
|
|
899
899
|
}
|
|
900
900
|
}
|
|
@@ -906,15 +906,15 @@ var hr = [
|
|
|
906
906
|
}
|
|
907
907
|
autoFormat(t) {
|
|
908
908
|
const i = t[0];
|
|
909
|
-
i === 3 || i === 2 || (i === 4 || i === 6 || i === 7) && (t =
|
|
910
|
-
const r =
|
|
911
|
-
this.#s =
|
|
909
|
+
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);
|
|
910
|
+
const r = O(I.tweakPublicKey(this.#i));
|
|
911
|
+
this.#s = Qt.generateHybridKeyFromHash(r), this.#o = new Uint8Array(32), this.#o.set(r);
|
|
912
912
|
}
|
|
913
|
-
},
|
|
913
|
+
}, Wt = class xe {
|
|
914
914
|
_keys = [];
|
|
915
915
|
_values = {};
|
|
916
916
|
constructor(t) {
|
|
917
|
-
if (t instanceof
|
|
917
|
+
if (t instanceof xe) this.setAll(t);
|
|
918
918
|
else if (t) for (const [i, r] of t) this.set(i, r);
|
|
919
919
|
}
|
|
920
920
|
get size() {
|
|
@@ -966,10 +966,10 @@ var hr = [
|
|
|
966
966
|
*[Symbol.iterator]() {
|
|
967
967
|
for (const t of this._keys) yield [t, this._values[t]];
|
|
968
968
|
}
|
|
969
|
-
},
|
|
969
|
+
}, Fe = class {
|
|
970
970
|
items;
|
|
971
971
|
constructor(e) {
|
|
972
|
-
if (this.items = new
|
|
972
|
+
if (this.items = new Wt(), e) for (const [t, i] of e) this.set(t, i);
|
|
973
973
|
}
|
|
974
974
|
get size() {
|
|
975
975
|
return this.items.size;
|
|
@@ -998,29 +998,29 @@ var hr = [
|
|
|
998
998
|
return this.items.indexOf(e.toBigInt());
|
|
999
999
|
}
|
|
1000
1000
|
*entries() {
|
|
1001
|
-
for (const [e, t] of this.items.entries()) yield [
|
|
1001
|
+
for (const [e, t] of this.items.entries()) yield [z.fromBigInt(e), t];
|
|
1002
1002
|
}
|
|
1003
1003
|
*keys() {
|
|
1004
|
-
for (const e of this.items.keys()) yield
|
|
1004
|
+
for (const e of this.items.keys()) yield z.fromBigInt(e);
|
|
1005
1005
|
}
|
|
1006
1006
|
*values() {
|
|
1007
1007
|
for (const e of this.items.values()) yield e;
|
|
1008
1008
|
}
|
|
1009
1009
|
forEach(e, t) {
|
|
1010
1010
|
for (const [i, r] of this.items.entries()) {
|
|
1011
|
-
const s =
|
|
1011
|
+
const s = z.fromBigInt(i);
|
|
1012
1012
|
e.call(t, r, s, this);
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
1015
|
*[Symbol.iterator]() {
|
|
1016
1016
|
yield* this.entries();
|
|
1017
1017
|
}
|
|
1018
|
-
},
|
|
1018
|
+
}, We = class {
|
|
1019
1019
|
indexMap;
|
|
1020
1020
|
_keys = [];
|
|
1021
1021
|
_values = [];
|
|
1022
1022
|
constructor(e) {
|
|
1023
|
-
if (this.indexMap = new
|
|
1023
|
+
if (this.indexMap = new Wt(), e) for (const [t, i] of e) this.set(t, i);
|
|
1024
1024
|
}
|
|
1025
1025
|
get size() {
|
|
1026
1026
|
return this._keys.length;
|
|
@@ -1074,7 +1074,7 @@ var hr = [
|
|
|
1074
1074
|
*[Symbol.iterator]() {
|
|
1075
1075
|
yield* this.entries();
|
|
1076
1076
|
}
|
|
1077
|
-
},
|
|
1077
|
+
}, _t = class {
|
|
1078
1078
|
static EXPECTED_BUFFER_LENGTH = 32;
|
|
1079
1079
|
static bufferToUint8Array(e) {
|
|
1080
1080
|
const t = new Uint8Array(e.byteLength);
|
|
@@ -1105,7 +1105,7 @@ var hr = [
|
|
|
1105
1105
|
static uint8ArrayToValue(e) {
|
|
1106
1106
|
return e.length === 0 ? 0n : BigInt("0x" + f(e));
|
|
1107
1107
|
}
|
|
1108
|
-
},
|
|
1108
|
+
}, Ht = class {
|
|
1109
1109
|
buffer;
|
|
1110
1110
|
currentOffset = 0;
|
|
1111
1111
|
constructor(e) {
|
|
@@ -1221,7 +1221,7 @@ var hr = [
|
|
|
1221
1221
|
return this.readString(t);
|
|
1222
1222
|
}
|
|
1223
1223
|
readAddress() {
|
|
1224
|
-
return new
|
|
1224
|
+
return new z(Array.from(this.readBytes(32)));
|
|
1225
1225
|
}
|
|
1226
1226
|
readTweakedPublicKey() {
|
|
1227
1227
|
return this.verifyEnd(this.currentOffset + 32), this.readBytes(32);
|
|
@@ -1229,7 +1229,7 @@ var hr = [
|
|
|
1229
1229
|
readExtendedAddress() {
|
|
1230
1230
|
this.verifyEnd(this.currentOffset + 64);
|
|
1231
1231
|
const e = Array.from(this.readBytes(32));
|
|
1232
|
-
return new
|
|
1232
|
+
return new z(Array.from(this.readBytes(32)), e);
|
|
1233
1233
|
}
|
|
1234
1234
|
readSchnorrSignature() {
|
|
1235
1235
|
return this.verifyEnd(this.currentOffset + 64 + 64), {
|
|
@@ -1293,7 +1293,7 @@ var hr = [
|
|
|
1293
1293
|
return i;
|
|
1294
1294
|
}
|
|
1295
1295
|
readAddressValueTuple(e = !0) {
|
|
1296
|
-
const t = this.readU16(e), i = new
|
|
1296
|
+
const t = this.readU16(e), i = new Fe();
|
|
1297
1297
|
for (let r = 0; r < t; r++) {
|
|
1298
1298
|
const s = this.readAddress(), n = this.readU256(e);
|
|
1299
1299
|
if (i.has(s)) throw new Error("Duplicate address found in map");
|
|
@@ -1307,7 +1307,7 @@ var hr = [
|
|
|
1307
1307
|
return i;
|
|
1308
1308
|
}
|
|
1309
1309
|
readExtendedAddressMapU256(e = !0) {
|
|
1310
|
-
const t = this.readU16(e), i = new
|
|
1310
|
+
const t = this.readU16(e), i = new We();
|
|
1311
1311
|
for (let r = 0; r < t; r++) {
|
|
1312
1312
|
const s = this.readExtendedAddress(), n = this.readU256(e);
|
|
1313
1313
|
if (i.has(s)) throw new Error("Duplicate tweaked address found in map");
|
|
@@ -1332,7 +1332,7 @@ var hr = [
|
|
|
1332
1332
|
toHexString(e) {
|
|
1333
1333
|
return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
|
|
1334
1334
|
}
|
|
1335
|
-
},
|
|
1335
|
+
}, V = class He {
|
|
1336
1336
|
currentOffset = 0;
|
|
1337
1337
|
buffer;
|
|
1338
1338
|
constructor(t = 0) {
|
|
@@ -1385,7 +1385,7 @@ var hr = [
|
|
|
1385
1385
|
writeI128(t, i = !0) {
|
|
1386
1386
|
if (t > 170141183460469231731687303715884105727n || t < -170141183460469231731687303715884105728n) throw new Error("i128 value is too large.");
|
|
1387
1387
|
this.allocSafe(16);
|
|
1388
|
-
const r =
|
|
1388
|
+
const r = _t.valueToUint8Array(t, 16);
|
|
1389
1389
|
if (r.byteLength !== 16) throw new Error(`Invalid i128 value: ${t}`);
|
|
1390
1390
|
if (i) for (let s = 0; s < r.byteLength; s++) this.writeU8(r[s]);
|
|
1391
1391
|
else for (let s = r.byteLength - 1; s >= 0; s--) this.writeU8(r[s]);
|
|
@@ -1393,7 +1393,7 @@ var hr = [
|
|
|
1393
1393
|
writeU256(t, i = !0) {
|
|
1394
1394
|
if (t > 115792089237316195423570985008687907853269984665640564039457584007913129639935n && t < 0n) throw new Error("u256 value is too large or negative.");
|
|
1395
1395
|
this.allocSafe(32);
|
|
1396
|
-
const r =
|
|
1396
|
+
const r = _t.valueToUint8Array(t);
|
|
1397
1397
|
if (r.byteLength !== 32) throw new Error(`Invalid u256 value: ${t}`);
|
|
1398
1398
|
if (i) for (let s = 0; s < r.byteLength; s++) this.writeU8(r[s]);
|
|
1399
1399
|
else for (let s = r.byteLength - 1; s >= 0; s--) this.writeU8(r[s]);
|
|
@@ -1401,7 +1401,7 @@ var hr = [
|
|
|
1401
1401
|
writeU128(t, i = !0) {
|
|
1402
1402
|
if (t > 340282366920938463463374607431768211455n && t < 0n) throw new Error("u128 value is too large or negative.");
|
|
1403
1403
|
this.allocSafe(16);
|
|
1404
|
-
const r =
|
|
1404
|
+
const r = _t.valueToUint8Array(t, 16);
|
|
1405
1405
|
if (r.byteLength !== 16) throw new Error(`Invalid u128 value: ${t}`);
|
|
1406
1406
|
if (i) for (let s = 0; s < r.byteLength; s++) this.writeU8(r[s]);
|
|
1407
1407
|
else for (let s = r.byteLength - 1; s >= 0; s--) this.writeU8(r[s]);
|
|
@@ -1441,7 +1441,7 @@ var hr = [
|
|
|
1441
1441
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(4);
|
|
1442
1442
|
}
|
|
1443
1443
|
toBytesReader() {
|
|
1444
|
-
return new
|
|
1444
|
+
return new Ht(this.getBuffer());
|
|
1445
1445
|
}
|
|
1446
1446
|
getOffset() {
|
|
1447
1447
|
return this.currentOffset;
|
|
@@ -1478,7 +1478,7 @@ var hr = [
|
|
|
1478
1478
|
this.writeU32(t.length), this.writeBytes(t);
|
|
1479
1479
|
}
|
|
1480
1480
|
writeArrayOfBuffer(t, i = !0) {
|
|
1481
|
-
const r =
|
|
1481
|
+
const r = He.estimateArrayOfBufferLength(t);
|
|
1482
1482
|
this.allocSafe(r), this.writeU16(t.length, i);
|
|
1483
1483
|
for (let s = 0; s < t.length; s++)
|
|
1484
1484
|
this.writeU32(t[s].length, i), this.writeBytes(t[s]);
|
|
@@ -1544,30 +1544,30 @@ var hr = [
|
|
|
1544
1544
|
getDefaultBuffer(t = 0) {
|
|
1545
1545
|
return new DataView(new ArrayBuffer(t));
|
|
1546
1546
|
}
|
|
1547
|
-
}, tt = class
|
|
1547
|
+
}, tt = class Ve {
|
|
1548
1548
|
static DATA_CHUNK_SIZE = 512;
|
|
1549
|
-
static MAGIC =
|
|
1549
|
+
static MAGIC = Oi("op");
|
|
1550
1550
|
senderPubKey;
|
|
1551
1551
|
xSenderPubKey;
|
|
1552
1552
|
contractSaltPubKey;
|
|
1553
1553
|
network = y.bitcoin;
|
|
1554
1554
|
constructor(t, i, r = y.bitcoin) {
|
|
1555
|
-
this.senderPubKey = t, this.contractSaltPubKey = i, this.network = r, this.xSenderPubKey =
|
|
1555
|
+
this.senderPubKey = t, this.contractSaltPubKey = i, this.network = r, this.xSenderPubKey = O(t);
|
|
1556
1556
|
}
|
|
1557
1557
|
buildHeader(t) {
|
|
1558
1558
|
let i = 0;
|
|
1559
1559
|
for (const s of t) i |= s;
|
|
1560
|
-
const r =
|
|
1560
|
+
const r = qt(3);
|
|
1561
1561
|
return r[0] = i >> 16 & 255, r[1] = i >> 8 & 255, r[2] = i & 255, Uint8Array.from([this.senderPubKey[0], ...r]);
|
|
1562
1562
|
}
|
|
1563
1563
|
getHeader(t, i = []) {
|
|
1564
|
-
const r = new
|
|
1564
|
+
const r = new V(12);
|
|
1565
1565
|
return r.writeBytes(this.buildHeader(i)), r.writeU64(t), new Uint8Array(r.getBuffer());
|
|
1566
1566
|
}
|
|
1567
|
-
splitBufferIntoChunks(t, i =
|
|
1567
|
+
splitBufferIntoChunks(t, i = Ve.DATA_CHUNK_SIZE) {
|
|
1568
1568
|
const r = [];
|
|
1569
1569
|
for (let s = 0; s < t.length; s += i) {
|
|
1570
|
-
const n = Math.min(i, t.length - s), o =
|
|
1570
|
+
const n = Math.min(i, t.length - s), o = qt(n);
|
|
1571
1571
|
for (let a = 0; a < n; a++) o[a] = t[s + a];
|
|
1572
1572
|
r.push([o]);
|
|
1573
1573
|
}
|
|
@@ -1575,21 +1575,21 @@ var hr = [
|
|
|
1575
1575
|
}
|
|
1576
1576
|
encodeFeature(t, i) {
|
|
1577
1577
|
switch (t.opcode) {
|
|
1578
|
-
case
|
|
1578
|
+
case q.ACCESS_LIST:
|
|
1579
1579
|
return this.encodeAccessListFeature(t, i);
|
|
1580
|
-
case
|
|
1580
|
+
case q.EPOCH_SUBMISSION:
|
|
1581
1581
|
return this.encodeChallengeSubmission(t, i);
|
|
1582
|
-
case
|
|
1582
|
+
case q.MLDSA_LINK_PUBKEY:
|
|
1583
1583
|
return this.encodeLinkRequest(t, i);
|
|
1584
1584
|
default:
|
|
1585
1585
|
throw new Error(`Unknown feature type: ${t.opcode}`);
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
1588
|
encodeAccessListFeature(t, i) {
|
|
1589
|
-
const r = new
|
|
1589
|
+
const r = new V();
|
|
1590
1590
|
r.writeU16(Object.keys(t.data).length);
|
|
1591
1591
|
for (const s in t.data) {
|
|
1592
|
-
const n =
|
|
1592
|
+
const n = z.fromString(s), o = t.data[s];
|
|
1593
1593
|
r.writeAddress(n), r.writeU32(o.length);
|
|
1594
1594
|
for (const a of o) {
|
|
1595
1595
|
const c = Uint8Array.from(atob(a), (u) => u.charCodeAt(0));
|
|
@@ -1602,11 +1602,11 @@ var hr = [
|
|
|
1602
1602
|
encodeChallengeSubmission(t, i) {
|
|
1603
1603
|
if ("verifySignature" in t.data && !t.data.verifySignature()) throw new Error("Invalid signature in challenge submission feature");
|
|
1604
1604
|
if (t.data.graffiti && t.data.graffiti.length > 16) throw new Error("Invalid epoch submission graffiti length");
|
|
1605
|
-
const r = new
|
|
1605
|
+
const r = new V();
|
|
1606
1606
|
r.writeBytes(t.data.publicKey.toBuffer()), r.writeBytes(t.data.solution), t.data.graffiti && r.writeBytes(t.data.graffiti), i.writeBytesWithLength(r.getBuffer());
|
|
1607
1607
|
}
|
|
1608
1608
|
encodeLinkRequest(t, i) {
|
|
1609
|
-
const r = t.data, s = new
|
|
1609
|
+
const r = t.data, s = new V();
|
|
1610
1610
|
if (s.writeU8(r.level), s.writeBytes(r.hashedPublicKey), s.writeBoolean(r.verifyRequest), r.verifyRequest) {
|
|
1611
1611
|
if (!r.publicKey || !r.mldsaSignature) throw new Error("MLDSA public key and signature required when verifyRequest is true");
|
|
1612
1612
|
s.writeBytes(r.publicKey), s.writeBytes(r.mldsaSignature);
|
|
@@ -1614,7 +1614,7 @@ var hr = [
|
|
|
1614
1614
|
if (!r.legacySignature || r.legacySignature.length !== 64) throw new Error("Legacy signature must be exactly 64 bytes");
|
|
1615
1615
|
s.writeBytes(r.legacySignature), i.writeBytesWithLength(s.getBuffer());
|
|
1616
1616
|
}
|
|
1617
|
-
},
|
|
1617
|
+
}, le = class extends tt {
|
|
1618
1618
|
constructor(e, t, i = y.bitcoin) {
|
|
1619
1619
|
super(e, t, i);
|
|
1620
1620
|
}
|
|
@@ -1623,7 +1623,7 @@ var hr = [
|
|
|
1623
1623
|
for (const s of e) {
|
|
1624
1624
|
if (!I.fromPublicKey(s, t).compressed) throw new Error("Public key must be compressed");
|
|
1625
1625
|
if (s.byteLength !== 33) throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
1626
|
-
i =
|
|
1626
|
+
i = ht([i, s]);
|
|
1627
1627
|
}
|
|
1628
1628
|
const r = Z.compress(i);
|
|
1629
1629
|
return r.byteLength >= i.byteLength ? i : r;
|
|
@@ -1634,7 +1634,7 @@ var hr = [
|
|
|
1634
1634
|
if (!n.length) throw new Error("No data chunks found");
|
|
1635
1635
|
const o = [], a = [];
|
|
1636
1636
|
if (s && s.length) {
|
|
1637
|
-
const h = s.sort((w, T) => w.priority - T.priority), p = new
|
|
1637
|
+
const h = s.sort((w, T) => w.priority - T.priority), p = new V();
|
|
1638
1638
|
for (let w = 0; w < h.length; w++) {
|
|
1639
1639
|
const T = h[w];
|
|
1640
1640
|
o.push(T.opcode), this.encodeFeature(T, p);
|
|
@@ -1666,33 +1666,33 @@ var hr = [
|
|
|
1666
1666
|
tt.MAGIC
|
|
1667
1667
|
];
|
|
1668
1668
|
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 (!
|
|
1669
|
+
const u = c.flat(), l = b.compile(u);
|
|
1670
|
+
if (!b.decompile(l)) throw new Error("Failed to decompile script??");
|
|
1671
1671
|
return l;
|
|
1672
1672
|
}
|
|
1673
|
-
},
|
|
1673
|
+
}, ze = class extends tt {
|
|
1674
1674
|
constructor(e, t = y.bitcoin) {
|
|
1675
1675
|
super(e, void 0, t);
|
|
1676
1676
|
}
|
|
1677
1677
|
compile(e) {
|
|
1678
|
-
const t = e.flat(), i =
|
|
1679
|
-
if (!
|
|
1678
|
+
const t = e.flat(), i = b.compile(t);
|
|
1679
|
+
if (!b.decompile(i)) throw new Error("Failed to decompile script??");
|
|
1680
1680
|
return i;
|
|
1681
1681
|
}
|
|
1682
|
-
}, fs = 0,
|
|
1682
|
+
}, fs = 0, qe = Uint8Array.from([0]), he = class extends tt {
|
|
1683
1683
|
constructor(e, t, i = y.bitcoin) {
|
|
1684
1684
|
super(e, t, i);
|
|
1685
1685
|
}
|
|
1686
1686
|
compile(e, t, i, r, s, n) {
|
|
1687
|
-
const o = this.getAsm(e, t, i, r, s, n), a =
|
|
1688
|
-
if (!
|
|
1687
|
+
const o = this.getAsm(e, t, i, r, s, n), a = b.compile(o);
|
|
1688
|
+
if (!b.decompile(a)) throw new Error("Failed to decompile script??");
|
|
1689
1689
|
return a;
|
|
1690
1690
|
}
|
|
1691
1691
|
getAsm(e, t, i, r, s, n) {
|
|
1692
1692
|
if (!this.contractSaltPubKey) throw new Error("Contract salt public key not set");
|
|
1693
1693
|
const o = this.splitBufferIntoChunks(e), a = s ? this.splitBufferIntoChunks(s) : [], c = [], u = [];
|
|
1694
1694
|
if (n && n.length) {
|
|
1695
|
-
const l = n.sort((p, w) => p.priority - w.priority), h = new
|
|
1695
|
+
const l = n.sort((p, w) => p.priority - w.priority), h = new V();
|
|
1696
1696
|
for (let p = 0; p < l.length; p++) {
|
|
1697
1697
|
const w = l[p];
|
|
1698
1698
|
c.push(w.opcode), this.encodeFeature(w, h);
|
|
@@ -1732,7 +1732,7 @@ var hr = [
|
|
|
1732
1732
|
d.OP_ENDIF
|
|
1733
1733
|
].flat();
|
|
1734
1734
|
}
|
|
1735
|
-
},
|
|
1735
|
+
}, St = class _ extends Le {
|
|
1736
1736
|
static MAX_CHUNK_SIZE = 80;
|
|
1737
1737
|
static MAX_STACK_ITEMS = 100;
|
|
1738
1738
|
static MAX_WITNESS_SIZE = 1650;
|
|
@@ -1740,11 +1740,11 @@ var hr = [
|
|
|
1740
1740
|
static MIN_OUTPUT_VALUE = 330n;
|
|
1741
1741
|
static BYTES_PER_COMMITMENT = 23;
|
|
1742
1742
|
static WITNESS_FIXED_OVERHEAD = 112;
|
|
1743
|
-
static WITNESS_PER_CHUNK_OVERHEAD =
|
|
1744
|
-
static MAX_CHUNKS_PER_OUTPUT = Math.floor((
|
|
1743
|
+
static WITNESS_PER_CHUNK_OVERHEAD = _.MAX_CHUNK_SIZE + 1 + _.BYTES_PER_COMMITMENT;
|
|
1744
|
+
static MAX_CHUNKS_PER_OUTPUT = Math.floor((_.MAX_WITNESS_SIZE - _.WITNESS_FIXED_OVERHEAD) / _.WITNESS_PER_CHUNK_OVERHEAD);
|
|
1745
1745
|
static INPUT_BASE_WEIGHT = 164;
|
|
1746
|
-
static INPUT_WITNESS_WEIGHT_MAX =
|
|
1747
|
-
static WEIGHT_PER_INPUT =
|
|
1746
|
+
static INPUT_WITNESS_WEIGHT_MAX = _.MAX_WITNESS_SIZE;
|
|
1747
|
+
static WEIGHT_PER_INPUT = _.INPUT_BASE_WEIGHT + _.INPUT_WITNESS_WEIGHT_MAX;
|
|
1748
1748
|
logColor = "#4a90d9";
|
|
1749
1749
|
publicKey;
|
|
1750
1750
|
network;
|
|
@@ -1753,21 +1753,21 @@ var hr = [
|
|
|
1753
1753
|
this.publicKey = t, this.network = i;
|
|
1754
1754
|
}
|
|
1755
1755
|
static calculateMaxInputsPerTx() {
|
|
1756
|
-
const t =
|
|
1757
|
-
return Math.floor(t /
|
|
1756
|
+
const t = _.MAX_STANDARD_WEIGHT - 40 - 200;
|
|
1757
|
+
return Math.floor(t / _.WEIGHT_PER_INPUT);
|
|
1758
1758
|
}
|
|
1759
1759
|
static calculateMaxDataPerTx() {
|
|
1760
|
-
return
|
|
1760
|
+
return _.calculateMaxInputsPerTx() * _.MAX_CHUNKS_PER_OUTPUT * _.MAX_CHUNK_SIZE;
|
|
1761
1761
|
}
|
|
1762
1762
|
static estimateOutputCount(t) {
|
|
1763
|
-
return Math.ceil(t / (
|
|
1763
|
+
return Math.ceil(t / (_.MAX_CHUNKS_PER_OUTPUT * _.MAX_CHUNK_SIZE));
|
|
1764
1764
|
}
|
|
1765
1765
|
static estimateChunkCount(t) {
|
|
1766
|
-
return Math.ceil(t /
|
|
1766
|
+
return Math.ceil(t / _.MAX_CHUNK_SIZE);
|
|
1767
1767
|
}
|
|
1768
1768
|
static validateHashCommittedScript(t) {
|
|
1769
1769
|
try {
|
|
1770
|
-
const i =
|
|
1770
|
+
const i = b.decompile(t);
|
|
1771
1771
|
if (!i || i.length < 5) return !1;
|
|
1772
1772
|
const r = i.length - 1;
|
|
1773
1773
|
if (i[r] !== d.OP_CHECKSIG) return !1;
|
|
@@ -1786,8 +1786,8 @@ var hr = [
|
|
|
1786
1786
|
}
|
|
1787
1787
|
static extractDataHashes(t) {
|
|
1788
1788
|
try {
|
|
1789
|
-
const i =
|
|
1790
|
-
if (!i || !
|
|
1789
|
+
const i = b.decompile(t);
|
|
1790
|
+
if (!i || !_.validateHashCommittedScript(t)) return null;
|
|
1791
1791
|
const r = i.slice(0, -2), s = [];
|
|
1792
1792
|
for (let n = 0; n < r.length; n += 3) s.push(r[n + 1]);
|
|
1793
1793
|
return s.reverse();
|
|
@@ -1797,14 +1797,14 @@ var hr = [
|
|
|
1797
1797
|
}
|
|
1798
1798
|
static extractPublicKey(t) {
|
|
1799
1799
|
try {
|
|
1800
|
-
const i =
|
|
1801
|
-
return !i || !
|
|
1800
|
+
const i = b.decompile(t);
|
|
1801
|
+
return !i || !_.validateHashCommittedScript(t) ? null : i[i.length - 2];
|
|
1802
1802
|
} catch {
|
|
1803
1803
|
return null;
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
1806
|
static verifyChunkCommitments(t, i) {
|
|
1807
|
-
const r =
|
|
1807
|
+
const r = _.extractDataHashes(i);
|
|
1808
1808
|
if (!r || r.length !== t.length) return !1;
|
|
1809
1809
|
for (let s = 0; s < t.length; s++) {
|
|
1810
1810
|
const n = D.hash160(t[s]);
|
|
@@ -1813,18 +1813,18 @@ var hr = [
|
|
|
1813
1813
|
return !0;
|
|
1814
1814
|
}
|
|
1815
1815
|
static estimateFees(t, i, r = 0.7) {
|
|
1816
|
-
const s = Math.ceil(t * r), n =
|
|
1816
|
+
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
1817
|
return {
|
|
1818
1818
|
compressedSize: s,
|
|
1819
1819
|
outputCount: n,
|
|
1820
1820
|
chunkCount: o,
|
|
1821
|
-
setupVBytes:
|
|
1822
|
-
revealVBytes:
|
|
1823
|
-
setupFee:
|
|
1824
|
-
revealFee:
|
|
1825
|
-
totalFee:
|
|
1826
|
-
outputsValue:
|
|
1827
|
-
totalCost:
|
|
1821
|
+
setupVBytes: a,
|
|
1822
|
+
revealVBytes: u,
|
|
1823
|
+
setupFee: l,
|
|
1824
|
+
revealFee: h,
|
|
1825
|
+
totalFee: p,
|
|
1826
|
+
outputsValue: w,
|
|
1827
|
+
totalCost: p + w
|
|
1828
1828
|
};
|
|
1829
1829
|
}
|
|
1830
1830
|
hashChunk(t) {
|
|
@@ -1832,15 +1832,15 @@ var hr = [
|
|
|
1832
1832
|
}
|
|
1833
1833
|
generateWitnessScript(t) {
|
|
1834
1834
|
if (t.length === 0) throw new Error("At least one data hash is required");
|
|
1835
|
-
if (t.length >
|
|
1835
|
+
if (t.length > _.MAX_CHUNKS_PER_OUTPUT) throw new Error(`Too many chunks: ${t.length} exceeds limit of ${_.MAX_CHUNKS_PER_OUTPUT}`);
|
|
1836
1836
|
for (const r of t) if (r.length !== 20) throw new Error(`HASH160 requires 20-byte hash, got ${r.length}`);
|
|
1837
1837
|
const i = [];
|
|
1838
1838
|
for (let r = t.length - 1; r >= 0; r--)
|
|
1839
1839
|
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),
|
|
1840
|
+
return i.push(this.publicKey), i.push(d.OP_CHECKSIG), b.compile(i);
|
|
1841
1841
|
}
|
|
1842
1842
|
generateP2WSHAddress(t) {
|
|
1843
|
-
const i =
|
|
1843
|
+
const i = U.p2wsh({
|
|
1844
1844
|
redeem: { output: t },
|
|
1845
1845
|
network: this.network
|
|
1846
1846
|
});
|
|
@@ -1851,8 +1851,8 @@ var hr = [
|
|
|
1851
1851
|
scriptPubKey: i.output
|
|
1852
1852
|
};
|
|
1853
1853
|
}
|
|
1854
|
-
prepareChunks(t, i =
|
|
1855
|
-
if (i >
|
|
1854
|
+
prepareChunks(t, i = _.MAX_CHUNK_SIZE) {
|
|
1855
|
+
if (i > _.MAX_CHUNK_SIZE) throw new Error(`Chunk size ${i} exceeds P2WSH stack item limit of ${_.MAX_CHUNK_SIZE}`);
|
|
1856
1856
|
if (t.length === 0) throw new Error("Data cannot be empty");
|
|
1857
1857
|
const r = [];
|
|
1858
1858
|
let s = 0;
|
|
@@ -1863,7 +1863,7 @@ var hr = [
|
|
|
1863
1863
|
const n = [];
|
|
1864
1864
|
let o = 0;
|
|
1865
1865
|
for (; o < r.length; ) {
|
|
1866
|
-
const c = r.slice(o, o +
|
|
1866
|
+
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
1867
|
n.push({
|
|
1868
1868
|
address: p.address,
|
|
1869
1869
|
witnessScript: p.witnessScript,
|
|
@@ -1876,7 +1876,7 @@ var hr = [
|
|
|
1876
1876
|
const a = r.length;
|
|
1877
1877
|
return this.log(`Prepared ${n.length} P2WSH outputs with ${a} chunks (${t.length} bytes, ~${Math.ceil(t.length / n.length)} bytes/output)`), n;
|
|
1878
1878
|
}
|
|
1879
|
-
},
|
|
1879
|
+
}, ur = class extends tt {
|
|
1880
1880
|
constructor(e, t = y.bitcoin) {
|
|
1881
1881
|
super(e, new Uint8Array(0), t);
|
|
1882
1882
|
}
|
|
@@ -1885,7 +1885,7 @@ var hr = [
|
|
|
1885
1885
|
for (const s of e) {
|
|
1886
1886
|
if (!I.fromPublicKey(s, t).compressed) throw new Error("Public key must be compressed");
|
|
1887
1887
|
if (s.byteLength !== 33) throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
1888
|
-
i =
|
|
1888
|
+
i = ht([i, s]);
|
|
1889
1889
|
}
|
|
1890
1890
|
const r = Z.compress(i);
|
|
1891
1891
|
return r.byteLength >= i.byteLength ? i : r;
|
|
@@ -1895,7 +1895,7 @@ var hr = [
|
|
|
1895
1895
|
if (!n.length) throw new Error("No data chunks found");
|
|
1896
1896
|
const o = [], a = [];
|
|
1897
1897
|
if (s && s.length) {
|
|
1898
|
-
const h = s.sort((w, T) => w.priority - T.priority), p = new
|
|
1898
|
+
const h = s.sort((w, T) => w.priority - T.priority), p = new V();
|
|
1899
1899
|
for (let w = 0; w < h.length; w++) {
|
|
1900
1900
|
const T = h[w];
|
|
1901
1901
|
o.push(T.opcode), this.encodeFeature(T, p);
|
|
@@ -1922,21 +1922,21 @@ var hr = [
|
|
|
1922
1922
|
tt.MAGIC
|
|
1923
1923
|
];
|
|
1924
1924
|
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 (!
|
|
1925
|
+
const u = c.flat(), l = b.compile(u);
|
|
1926
|
+
if (!b.decompile(l)) throw new Error("Failed to decompile script??");
|
|
1927
1927
|
return l;
|
|
1928
1928
|
}
|
|
1929
|
-
},
|
|
1929
|
+
}, Ge = class Zt {
|
|
1930
1930
|
static MAXIMUM_SUPPORTED_SIGNATURE = 255;
|
|
1931
1931
|
static compile(t, i = 0, r) {
|
|
1932
1932
|
if (i < 2) throw new Error("Minimum signatures must be greater than 1");
|
|
1933
1933
|
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) =>
|
|
1934
|
+
if (i > Zt.MAXIMUM_SUPPORTED_SIGNATURE) throw new Error(`The maximum amount of signatures is ${Zt.MAXIMUM_SUPPORTED_SIGNATURE}`);
|
|
1935
|
+
const s = qt(1);
|
|
1936
|
+
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
1937
|
let n = !1;
|
|
1938
1938
|
const o = t.map((u) => {
|
|
1939
|
-
const l =
|
|
1939
|
+
const l = O(u);
|
|
1940
1940
|
return r && !n && (n = C(r, l)), l;
|
|
1941
1941
|
});
|
|
1942
1942
|
r && !n && o.push(r);
|
|
@@ -1945,11 +1945,11 @@ var hr = [
|
|
|
1945
1945
|
...o.flatMap((u) => [u, d.OP_CHECKSIGADD]),
|
|
1946
1946
|
s,
|
|
1947
1947
|
d.OP_NUMEQUAL
|
|
1948
|
-
].flat(), c =
|
|
1949
|
-
if (!
|
|
1948
|
+
].flat(), c = b.compile(a);
|
|
1949
|
+
if (!b.decompile(c)) throw new Error("Failed to decompile script.");
|
|
1950
1950
|
return c;
|
|
1951
1951
|
}
|
|
1952
|
-
},
|
|
1952
|
+
}, Jt = class Xe extends tt {
|
|
1953
1953
|
static P2WDA_VERSION = 1;
|
|
1954
1954
|
constructor(t, i, r = y.bitcoin) {
|
|
1955
1955
|
super(t, i, r);
|
|
@@ -1961,8 +1961,8 @@ var hr = [
|
|
|
1961
1961
|
compile(t, i, r, s, n = []) {
|
|
1962
1962
|
if (!this.contractSaltPubKey) throw new Error("Contract salt public key not set");
|
|
1963
1963
|
if (i.length !== 32) throw new Error("Contract secret must be exactly 32 bytes");
|
|
1964
|
-
const o = new
|
|
1965
|
-
o.writeU8(
|
|
1964
|
+
const o = new V();
|
|
1965
|
+
o.writeU8(Xe.P2WDA_VERSION);
|
|
1966
1966
|
const a = n.sort((c, u) => c.priority - u.priority);
|
|
1967
1967
|
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
1968
|
}
|
|
@@ -1975,7 +1975,7 @@ var hr = [
|
|
|
1975
1975
|
t.writeU8(r.opcode), this.encodeFeature(r, t);
|
|
1976
1976
|
}
|
|
1977
1977
|
};
|
|
1978
|
-
function
|
|
1978
|
+
function It(e) {
|
|
1979
1979
|
let t = new Uint8Array(0);
|
|
1980
1980
|
function i(a, c) {
|
|
1981
1981
|
const u = new Uint8Array(a.length + c.length);
|
|
@@ -1985,8 +1985,8 @@ function Pt(e) {
|
|
|
1985
1985
|
t = i(t, a);
|
|
1986
1986
|
}
|
|
1987
1987
|
function s(a) {
|
|
1988
|
-
const c = t.length, u =
|
|
1989
|
-
l.set(t, 0), t = l,
|
|
1988
|
+
const c = t.length, u = Gt.encodingLength(a), l = new Uint8Array(c + u);
|
|
1989
|
+
l.set(t, 0), t = l, Gt.encode(a, t, c);
|
|
1990
1990
|
}
|
|
1991
1991
|
function n(a) {
|
|
1992
1992
|
s(a.length), r(a);
|
|
@@ -1996,8 +1996,8 @@ function Pt(e) {
|
|
|
1996
1996
|
}
|
|
1997
1997
|
return o(e), t;
|
|
1998
1998
|
}
|
|
1999
|
-
var
|
|
2000
|
-
static NUMS_INTERNAL_KEY =
|
|
1999
|
+
var Ut = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"), gs = 192, rt = class {
|
|
2000
|
+
static NUMS_INTERNAL_KEY = Ut;
|
|
2001
2001
|
static LEAF_VERSION = 192;
|
|
2002
2002
|
static buildTapscript(e) {
|
|
2003
2003
|
if (e.csvBlocks < 1 || e.csvBlocks > 65535) throw new Error("csvBlocks must be between 1 and 65535");
|
|
@@ -2005,9 +2005,9 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2005
2005
|
if (e.threshold < 1 || e.threshold > e.pubkeys.length) throw new Error("Invalid threshold");
|
|
2006
2006
|
for (const i of e.pubkeys) if (i.length !== 32) throw new Error("Tapscript pubkeys must be 32 bytes (x,only)");
|
|
2007
2007
|
const t = [];
|
|
2008
|
-
t.push(
|
|
2008
|
+
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
2009
|
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(
|
|
2010
|
+
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
2011
|
}
|
|
2012
2012
|
static buildCSV2MultisigTapscript(e, t) {
|
|
2013
2013
|
return this.buildTapscript({
|
|
@@ -2017,8 +2017,8 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2017
2017
|
});
|
|
2018
2018
|
}
|
|
2019
2019
|
static generateAddress(e, t) {
|
|
2020
|
-
const i = this.buildTapscript(e), r =
|
|
2021
|
-
internalPubkey:
|
|
2020
|
+
const i = this.buildTapscript(e), r = U.p2tr({
|
|
2021
|
+
internalPubkey: Ut,
|
|
2022
2022
|
scriptTree: { output: i },
|
|
2023
2023
|
redeem: {
|
|
2024
2024
|
output: i,
|
|
@@ -2034,7 +2034,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2034
2034
|
tapscript: i,
|
|
2035
2035
|
scriptPubKey: r.output,
|
|
2036
2036
|
controlBlock: s,
|
|
2037
|
-
internalPubkey:
|
|
2037
|
+
internalPubkey: Ut,
|
|
2038
2038
|
leafVersion: 192,
|
|
2039
2039
|
config: e
|
|
2040
2040
|
};
|
|
@@ -2057,7 +2057,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2057
2057
|
};
|
|
2058
2058
|
}
|
|
2059
2059
|
static isP2TRScriptPubKey(e) {
|
|
2060
|
-
return
|
|
2060
|
+
return Rt(e);
|
|
2061
2061
|
}
|
|
2062
2062
|
static deriveAddressFromTapscript(e, t) {
|
|
2063
2063
|
const i = this.parseTapscript(e);
|
|
@@ -2071,11 +2071,11 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2071
2071
|
static buildFinalWitnessFromTapScriptSigs(e, t) {
|
|
2072
2072
|
const { config: i, tapscript: r, controlBlock: s } = t, n = /* @__PURE__ */ new Map();
|
|
2073
2073
|
for (const u of e)
|
|
2074
|
-
!u.pubkey || u.pubkey.length !== 32 || n.set(
|
|
2074
|
+
!u.pubkey || u.pubkey.length !== 32 || n.set(Ue(u.pubkey), u.signature);
|
|
2075
2075
|
const o = [];
|
|
2076
2076
|
let a = 0;
|
|
2077
2077
|
for (const u of i.pubkeys) {
|
|
2078
|
-
const l = n.get(
|
|
2078
|
+
const l = n.get(Ue(u));
|
|
2079
2079
|
if (l) {
|
|
2080
2080
|
if (l.length !== 64 && l.length !== 65) throw new Error(`Invalid Schnorr signature length ${l.length} for CSV multisig spend`);
|
|
2081
2081
|
o.push(l), a++;
|
|
@@ -2089,17 +2089,17 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2089
2089
|
static isSpendableUTXO(e, t) {
|
|
2090
2090
|
if (!e.witnessScript) return !1;
|
|
2091
2091
|
const i = g(e.scriptPubKey.hex);
|
|
2092
|
-
if (!
|
|
2092
|
+
if (!Rt(i)) return !1;
|
|
2093
2093
|
const r = e.witnessScript instanceof Uint8Array ? e.witnessScript : g(e.witnessScript), s = this.deriveAddressFromTapscript(r, t);
|
|
2094
2094
|
return s ? C(s.scriptPubKey, i) : !1;
|
|
2095
2095
|
}
|
|
2096
2096
|
static parseTapscript(e) {
|
|
2097
|
-
const t =
|
|
2097
|
+
const t = b.decompile(e);
|
|
2098
2098
|
if (!t || t.length < 6) return null;
|
|
2099
2099
|
const i = t[0];
|
|
2100
2100
|
let r;
|
|
2101
2101
|
if (i instanceof Uint8Array) try {
|
|
2102
|
-
r =
|
|
2102
|
+
r = b.number.decode(i);
|
|
2103
2103
|
} catch {
|
|
2104
2104
|
return null;
|
|
2105
2105
|
}
|
|
@@ -2115,7 +2115,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2115
2115
|
const o = t[s];
|
|
2116
2116
|
let a;
|
|
2117
2117
|
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 =
|
|
2118
|
+
else if (o instanceof Uint8Array) a = b.number.decode(o);
|
|
2119
2119
|
else return null;
|
|
2120
2120
|
return t[s + 1] !== d.OP_NUMEQUAL || a < 1 || a > n.length ? null : {
|
|
2121
2121
|
pubkeys: n,
|
|
@@ -2137,7 +2137,7 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2137
2137
|
const o = s.tapScriptSig ?? [], a = this.buildFinalWitnessFromTapScriptSigs(o, n);
|
|
2138
2138
|
e.finalizeInput(t, () => ({
|
|
2139
2139
|
finalScriptSig: void 0,
|
|
2140
|
-
finalScriptWitness:
|
|
2140
|
+
finalScriptWitness: It(a)
|
|
2141
2141
|
}));
|
|
2142
2142
|
}
|
|
2143
2143
|
static isCSVMultisigUTXO(e) {
|
|
@@ -2146,40 +2146,40 @@ var Bt = g("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0"),
|
|
|
2146
2146
|
return this.parseTapscript(t) !== null;
|
|
2147
2147
|
}
|
|
2148
2148
|
};
|
|
2149
|
-
function
|
|
2149
|
+
function Ue(e) {
|
|
2150
2150
|
let t = "";
|
|
2151
2151
|
for (let i = 0; i < e.length; i++) t += e[i].toString(16).padStart(2, "0");
|
|
2152
2152
|
return t;
|
|
2153
2153
|
}
|
|
2154
|
-
var
|
|
2154
|
+
var Ot = Pi(), de = class {
|
|
2155
2155
|
static generatePKSH(e, t) {
|
|
2156
2156
|
if (e.length !== 32) throw new Error("Invalid hash length");
|
|
2157
|
-
const i =
|
|
2157
|
+
const i = Bi(e);
|
|
2158
2158
|
return this.toSegwitAddress(i, t);
|
|
2159
2159
|
}
|
|
2160
2160
|
static generateTaprootAddress(e, t) {
|
|
2161
2161
|
if (e.length !== 32) throw new Error("Invalid public key length");
|
|
2162
|
-
const i =
|
|
2163
|
-
return i.unshift(1),
|
|
2162
|
+
const i = Ot.bech32m.toWords(e);
|
|
2163
|
+
return i.unshift(1), Ot.bech32m.encode(t.bech32, i);
|
|
2164
2164
|
}
|
|
2165
2165
|
static toSegwitAddress(e, t) {
|
|
2166
|
-
const i =
|
|
2167
|
-
return i.unshift(0),
|
|
2166
|
+
const i = Ot.bech32.toWords(e);
|
|
2167
|
+
return i.unshift(0), Ot.bech32.encode(t.bech32, i);
|
|
2168
2168
|
}
|
|
2169
|
-
},
|
|
2169
|
+
}, lr = class ut {
|
|
2170
2170
|
static TAP_SCRIPT_VERSION = 192;
|
|
2171
2171
|
static getContractAddress(t) {
|
|
2172
|
-
const { scriptTree: i } =
|
|
2173
|
-
return
|
|
2172
|
+
const { scriptTree: i } = ut.buildScriptTree(t);
|
|
2173
|
+
return ut.generateAddressFromScript(t, i);
|
|
2174
2174
|
}
|
|
2175
2175
|
static verifyControlBlock(t, i) {
|
|
2176
|
-
const { scriptTree: r, compiledTargetScript: s, network: n } =
|
|
2177
|
-
internalPubkey:
|
|
2176
|
+
const { scriptTree: r, compiledTargetScript: s, network: n } = ut.buildScriptTree(t), o = U.p2tr({
|
|
2177
|
+
internalPubkey: O(t.deployerPubKey),
|
|
2178
2178
|
network: n,
|
|
2179
2179
|
scriptTree: r,
|
|
2180
2180
|
redeem: {
|
|
2181
2181
|
output: s,
|
|
2182
|
-
redeemVersion:
|
|
2182
|
+
redeemVersion: ut.TAP_SCRIPT_VERSION
|
|
2183
2183
|
}
|
|
2184
2184
|
}).witness;
|
|
2185
2185
|
if (!o || o.length === 0) return !1;
|
|
@@ -2187,7 +2187,7 @@ var _t = _i(), ge = class {
|
|
|
2187
2187
|
return C(a, i);
|
|
2188
2188
|
}
|
|
2189
2189
|
static getContractSeed(t, i, r) {
|
|
2190
|
-
const s =
|
|
2190
|
+
const s = ht([
|
|
2191
2191
|
t,
|
|
2192
2192
|
r,
|
|
2193
2193
|
D.hash256(i)
|
|
@@ -2196,52 +2196,52 @@ var _t = _i(), ge = class {
|
|
|
2196
2196
|
}
|
|
2197
2197
|
static generateAddressFromScript(t, i) {
|
|
2198
2198
|
const r = t.network || y.bitcoin, s = {
|
|
2199
|
-
internalPubkey:
|
|
2199
|
+
internalPubkey: O(t.deployerPubKey),
|
|
2200
2200
|
network: r,
|
|
2201
2201
|
scriptTree: i
|
|
2202
2202
|
};
|
|
2203
|
-
return
|
|
2203
|
+
return U.p2tr(s).address;
|
|
2204
2204
|
}
|
|
2205
2205
|
static buildScriptTree(t) {
|
|
2206
|
-
const i = t.network || y.bitcoin, r = new
|
|
2206
|
+
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
2207
|
return {
|
|
2208
2208
|
scriptTree: [{
|
|
2209
2209
|
output: r,
|
|
2210
|
-
version:
|
|
2210
|
+
version: ut.TAP_SCRIPT_VERSION
|
|
2211
2211
|
}, {
|
|
2212
2212
|
output: s,
|
|
2213
|
-
version:
|
|
2213
|
+
version: ut.TAP_SCRIPT_VERSION
|
|
2214
2214
|
}],
|
|
2215
2215
|
compiledTargetScript: r,
|
|
2216
2216
|
network: i
|
|
2217
2217
|
};
|
|
2218
2218
|
}
|
|
2219
2219
|
};
|
|
2220
|
-
function
|
|
2220
|
+
function dt(e) {
|
|
2221
2221
|
return "privateKey" in e && e.privateKey != null;
|
|
2222
2222
|
}
|
|
2223
|
-
var
|
|
2223
|
+
var pe = class {
|
|
2224
2224
|
static tweakSigner(e, t = {}) {
|
|
2225
2225
|
let i = e.privateKey;
|
|
2226
2226
|
if (!i) throw new Error("Private key is required for tweaking signer!");
|
|
2227
2227
|
e.publicKey[0] === 3 && (i = K.privateNegate(i));
|
|
2228
|
-
const r = K.privateAdd(i,
|
|
2228
|
+
const r = K.privateAdd(i, Li(O(e.publicKey), t.tweakHash));
|
|
2229
2229
|
if (!r) throw new Error("Invalid tweaked private key!");
|
|
2230
2230
|
return I.fromPrivateKey(r, t.network);
|
|
2231
2231
|
}
|
|
2232
2232
|
};
|
|
2233
|
-
function
|
|
2233
|
+
function $e(e) {
|
|
2234
2234
|
return typeof e == "object" && e !== null && "web3" in e && typeof e.web3 == "object" && "getMLDSAPublicKey" in e.web3 && "signMLDSAMessage" in e.web3;
|
|
2235
2235
|
}
|
|
2236
2236
|
var Tt = /* @__PURE__ */ (function(e) {
|
|
2237
2237
|
return e.Mainnet = "mainnet", e.Testnet = "testnet", e.OpnetTestnet = "opnetTestnet", e.Regtest = "regtest", e;
|
|
2238
|
-
})({}),
|
|
2238
|
+
})({}), hr = /* @__PURE__ */ (function(e) {
|
|
2239
2239
|
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
|
-
})({}),
|
|
2240
|
+
})({}), dr = /* @__PURE__ */ (function(e) {
|
|
2241
2241
|
return e.ecdsa = "ecdsa", e.bip322 = "bip322-simple", e;
|
|
2242
|
-
})({}),
|
|
2242
|
+
})({}), te = /* @__PURE__ */ (function(e) {
|
|
2243
2243
|
return e.ecdsa = "ecdsa", e.schnorr = "schnorr", e;
|
|
2244
|
-
})({}),
|
|
2244
|
+
})({}), pr = class {
|
|
2245
2245
|
sha256(e) {
|
|
2246
2246
|
return D.sha256(e);
|
|
2247
2247
|
}
|
|
@@ -2250,7 +2250,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2250
2250
|
if (!t) return null;
|
|
2251
2251
|
const i = typeof e == "string" ? new TextEncoder().encode(e) : e, r = this.sha256(i), s = f(r);
|
|
2252
2252
|
return {
|
|
2253
|
-
signature: g(await t.signData(s,
|
|
2253
|
+
signature: g(await t.signData(s, te.schnorr, typeof e == "string" ? e : void 0)),
|
|
2254
2254
|
message: r
|
|
2255
2255
|
};
|
|
2256
2256
|
}
|
|
@@ -2259,7 +2259,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2259
2259
|
if (!t) return null;
|
|
2260
2260
|
const i = typeof e == "string" ? new TextEncoder().encode(e) : e, r = this.sha256(i), s = f(r);
|
|
2261
2261
|
return {
|
|
2262
|
-
signature: g(await t.signData(s,
|
|
2262
|
+
signature: g(await t.signData(s, te.ecdsa, typeof e == "string" ? e : void 0)),
|
|
2263
2263
|
message: r
|
|
2264
2264
|
};
|
|
2265
2265
|
}
|
|
@@ -2323,7 +2323,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2323
2323
|
return e ? g(await e.web3.getMLDSAPublicKey()) : null;
|
|
2324
2324
|
}
|
|
2325
2325
|
tweakAndSignMessage(e, t, i) {
|
|
2326
|
-
const r =
|
|
2326
|
+
const r = pe.tweakSigner(e, { network: i });
|
|
2327
2327
|
return this.signMessage(r, t);
|
|
2328
2328
|
}
|
|
2329
2329
|
signMessage(e, t) {
|
|
@@ -2354,7 +2354,7 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2354
2354
|
if (typeof t == "string" && (t = new TextEncoder().encode(t)), i.length !== 64) throw new Error("Invalid signature length.");
|
|
2355
2355
|
const r = this.sha256(t);
|
|
2356
2356
|
if (!K.verifySchnorr) throw new Error("backend.verifySchnorr is not available.");
|
|
2357
|
-
return K.verifySchnorr(r,
|
|
2357
|
+
return K.verifySchnorr(r, O(e), i);
|
|
2358
2358
|
}
|
|
2359
2359
|
tweakAndVerifySignature(e, t, i) {
|
|
2360
2360
|
const r = I.tweakPublicKey(e);
|
|
@@ -2381,9 +2381,10 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2381
2381
|
getOPWallet() {
|
|
2382
2382
|
if (typeof window > "u") return null;
|
|
2383
2383
|
const e = window;
|
|
2384
|
-
return !e.opnet ||
|
|
2384
|
+
return !e.opnet || !$e(e.opnet) ? null : e.opnet;
|
|
2385
2385
|
}
|
|
2386
|
-
},
|
|
2386
|
+
}, st = new pr(), Bt = class At {
|
|
2387
|
+
network;
|
|
2387
2388
|
_keypair;
|
|
2388
2389
|
_mldsaKeypair;
|
|
2389
2390
|
_securityLevel;
|
|
@@ -2396,22 +2397,22 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2396
2397
|
_bufferPubKey;
|
|
2397
2398
|
_tweakedKey;
|
|
2398
2399
|
_address;
|
|
2399
|
-
constructor(t, i, r = y.bitcoin, s =
|
|
2400
|
+
constructor(t, i, r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2, n) {
|
|
2400
2401
|
this.network = r, this._securityLevel = s;
|
|
2401
2402
|
const o = t.startsWith("0x") ? t.slice(2) : t;
|
|
2402
2403
|
W.isValidHex(o) ? this._keypair = I.fromPrivateKey(g(o), this.network) : this._keypair = I.fromWIF(o, this.network);
|
|
2403
2404
|
const a = i.startsWith("0x") ? i.slice(2) : i;
|
|
2404
2405
|
if (W.isValidHex(a)) {
|
|
2405
|
-
const c = g(a), u = (0,
|
|
2406
|
+
const c = g(a), u = (0, v.getMLDSAConfig)(s, this.network), l = u.privateKeySize, h = l + u.publicKeySize;
|
|
2406
2407
|
let p;
|
|
2407
2408
|
if (c.length === l) p = c;
|
|
2408
2409
|
else if (c.length === h) p = c.subarray(0, l);
|
|
2409
2410
|
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
2411
|
if (n && n.length !== 32) throw new Error("Chain code must be 32 bytes");
|
|
2411
|
-
this._chainCode = n || new Uint8Array(32), this._mldsaKeypair =
|
|
2412
|
+
this._chainCode = n || new Uint8Array(32), this._mldsaKeypair = v.QuantumBIP32Factory.fromPrivateKey(p, this._chainCode, this.network, s);
|
|
2412
2413
|
} else
|
|
2413
|
-
this._mldsaKeypair =
|
|
2414
|
-
this._bufferPubKey = this._keypair.publicKey, this._address = new
|
|
2414
|
+
this._mldsaKeypair = v.QuantumBIP32Factory.fromBase58(a), this._chainCode = new Uint8Array(this._mldsaKeypair.chainCode), this._securityLevel = this._mldsaKeypair.securityLevel;
|
|
2415
|
+
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
2416
|
}
|
|
2416
2417
|
get address() {
|
|
2417
2418
|
return this._address;
|
|
@@ -2475,17 +2476,17 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2475
2476
|
}
|
|
2476
2477
|
get xOnly() {
|
|
2477
2478
|
if (!this.keypair) throw new Error("Keypair not set");
|
|
2478
|
-
return
|
|
2479
|
+
return O(this._bufferPubKey);
|
|
2479
2480
|
}
|
|
2480
|
-
static fromWif(t, i, r = y.bitcoin, s =
|
|
2481
|
+
static fromWif(t, i, r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2, n) {
|
|
2481
2482
|
return new At(t, i, r, s, n);
|
|
2482
2483
|
}
|
|
2483
|
-
static generate(t = y.bitcoin, i =
|
|
2484
|
+
static generate(t = y.bitcoin, i = v.MLDSASecurityLevel.LEVEL2) {
|
|
2484
2485
|
const r = I.generateWallet(t, i);
|
|
2485
2486
|
if (!r.quantumPrivateKey) throw new Error("Failed to generate quantum keys");
|
|
2486
2487
|
return new At(r.privateKey, r.quantumPrivateKey, t, i);
|
|
2487
2488
|
}
|
|
2488
|
-
static fromPrivateKeys(t, i, r = y.bitcoin, s =
|
|
2489
|
+
static fromPrivateKeys(t, i, r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2, n) {
|
|
2489
2490
|
return new At(t, i, r, s, n);
|
|
2490
2491
|
}
|
|
2491
2492
|
toWIF() {
|
|
@@ -2515,29 +2516,29 @@ var Tt = /* @__PURE__ */ (function(e) {
|
|
|
2515
2516
|
if (!r.chainCode) throw new Error("Failed to derive classical chain code");
|
|
2516
2517
|
return new At(f(new Uint8Array(r.privateKey)), i.toBase58(), this.network, this._securityLevel, new Uint8Array(r.chainCode));
|
|
2517
2518
|
}
|
|
2518
|
-
}, mt = /* @__PURE__ */
|
|
2519
|
+
}, mt = /* @__PURE__ */ ae(Ei(), 1), ee = /* @__PURE__ */ (function(e) {
|
|
2519
2520
|
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
|
-
})({}),
|
|
2521
|
+
})({}), kt = /* @__PURE__ */ (function(e) {
|
|
2521
2522
|
return e[e.BIP44 = 44] = "BIP44", e[e.BIP49 = 49] = "BIP49", e[e.BIP84 = 84] = "BIP84", e[e.BIP86 = 86] = "BIP86", e;
|
|
2522
2523
|
})({});
|
|
2523
|
-
function
|
|
2524
|
+
function fr(e) {
|
|
2524
2525
|
switch (e) {
|
|
2525
|
-
case
|
|
2526
|
+
case 44:
|
|
2526
2527
|
return "BIP44: Legacy addresses (P2PKH), widely used by Unisat and other wallets";
|
|
2527
|
-
case
|
|
2528
|
+
case 49:
|
|
2528
2529
|
return "BIP49: Wrapped SegWit addresses (P2SH-P2WPKH)";
|
|
2529
|
-
case
|
|
2530
|
+
case 84:
|
|
2530
2531
|
return "BIP84: Native SegWit addresses (P2WPKH) - DEFAULT";
|
|
2531
|
-
case
|
|
2532
|
+
case 86:
|
|
2532
2533
|
return "BIP86: Taproot addresses (P2TR)";
|
|
2533
2534
|
default:
|
|
2534
2535
|
return "Unknown BIP standard";
|
|
2535
2536
|
}
|
|
2536
2537
|
}
|
|
2537
|
-
function
|
|
2538
|
+
function Ye(e, t, i, r, s) {
|
|
2538
2539
|
return `m/${e}'/${t}'/${i}'/${r}/${s}`;
|
|
2539
2540
|
}
|
|
2540
|
-
var
|
|
2541
|
+
var gr = (0, v.BIP32Factory)(K), Sr = class je {
|
|
2541
2542
|
_phrase;
|
|
2542
2543
|
_passphrase;
|
|
2543
2544
|
_network;
|
|
@@ -2545,9 +2546,9 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2545
2546
|
_seed;
|
|
2546
2547
|
_classicalRoot;
|
|
2547
2548
|
_quantumRoot;
|
|
2548
|
-
constructor(t, i = "", r = y.bitcoin, s =
|
|
2549
|
+
constructor(t, i = "", r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2) {
|
|
2549
2550
|
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 =
|
|
2551
|
+
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
2552
|
}
|
|
2552
2553
|
get phrase() {
|
|
2553
2554
|
return this._phrase;
|
|
@@ -2561,11 +2562,11 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2561
2562
|
get seed() {
|
|
2562
2563
|
return new Uint8Array(this._seed);
|
|
2563
2564
|
}
|
|
2564
|
-
static generatePhrase(t =
|
|
2565
|
+
static generatePhrase(t = ee.MAXIMUM) {
|
|
2565
2566
|
return mt.generateMnemonic(t);
|
|
2566
2567
|
}
|
|
2567
|
-
static generate(t =
|
|
2568
|
-
return new
|
|
2568
|
+
static generate(t = ee.MAXIMUM, i = "", r = y.bitcoin, s = v.MLDSASecurityLevel.LEVEL2) {
|
|
2569
|
+
return new je(mt.generateMnemonic(t), i, r, s);
|
|
2569
2570
|
}
|
|
2570
2571
|
static validate(t) {
|
|
2571
2572
|
return mt.validateMnemonic(t);
|
|
@@ -2576,26 +2577,26 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2576
2577
|
[Symbol.dispose]() {
|
|
2577
2578
|
this.zeroize();
|
|
2578
2579
|
}
|
|
2579
|
-
derive(t = 0, i = 0, r = !1, s =
|
|
2580
|
+
derive(t = 0, i = 0, r = !1, s = kt.BIP84) {
|
|
2580
2581
|
const n = this.buildClassicalPath(i, t, r, s), o = this._classicalRoot.derivePath(n);
|
|
2581
2582
|
if (!o.privateKey) throw new Error(`Failed to derive classical private key at index ${t}`);
|
|
2582
2583
|
const a = this.buildQuantumPath(i, t, r), c = this._quantumRoot.derivePath(a);
|
|
2583
2584
|
if (!c.privateKey) throw new Error(`Failed to derive quantum private key at index ${t}`);
|
|
2584
|
-
return new
|
|
2585
|
+
return new Bt(f(new Uint8Array(o.privateKey)), f(new Uint8Array(c.privateKey)), this._network, this._securityLevel, new Uint8Array(this._quantumRoot.chainCode));
|
|
2585
2586
|
}
|
|
2586
|
-
deriveOPWallet(t =
|
|
2587
|
+
deriveOPWallet(t = ct.P2TR, i = 0, r = 0, s = !1) {
|
|
2587
2588
|
let n;
|
|
2588
2589
|
switch (t) {
|
|
2589
|
-
case
|
|
2590
|
+
case ct.P2PKH:
|
|
2590
2591
|
n = 44;
|
|
2591
2592
|
break;
|
|
2592
|
-
case
|
|
2593
|
+
case ct.P2SH_OR_P2SH_P2WPKH:
|
|
2593
2594
|
n = 49;
|
|
2594
2595
|
break;
|
|
2595
|
-
case
|
|
2596
|
+
case ct.P2WPKH:
|
|
2596
2597
|
n = 84;
|
|
2597
2598
|
break;
|
|
2598
|
-
case
|
|
2599
|
+
case ct.P2TR:
|
|
2599
2600
|
n = 86;
|
|
2600
2601
|
break;
|
|
2601
2602
|
default:
|
|
@@ -2605,14 +2606,14 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2605
2606
|
if (!u.privateKey) throw new Error(`Failed to derive classical private key at path ${c}`);
|
|
2606
2607
|
const l = `m/360'/${o}'/${r}'/${a}/${i}`, h = this._quantumRoot.derivePath(l);
|
|
2607
2608
|
if (!h.privateKey) throw new Error(`Failed to derive quantum private key at path ${l}`);
|
|
2608
|
-
return new
|
|
2609
|
+
return new Bt(f(new Uint8Array(u.privateKey)), f(new Uint8Array(h.privateKey)), this._network, this._securityLevel, new Uint8Array(this._quantumRoot.chainCode));
|
|
2609
2610
|
}
|
|
2610
|
-
deriveMultipleOPWallet(t =
|
|
2611
|
+
deriveMultipleOPWallet(t = ct.P2TR, i = 5, r = 0, s = 0, n = !1) {
|
|
2611
2612
|
const o = [];
|
|
2612
2613
|
for (let a = 0; a < i; a++) o.push(this.deriveOPWallet(t, r + a, s, n));
|
|
2613
2614
|
return o;
|
|
2614
2615
|
}
|
|
2615
|
-
deriveMultiple(t, i = 0, r = 0, s = !1, n =
|
|
2616
|
+
deriveMultiple(t, i = 0, r = 0, s = !1, n = kt.BIP84) {
|
|
2616
2617
|
const o = [];
|
|
2617
2618
|
for (let a = 0; a < t; a++) o.push(this.derive(i + a, r, s, n));
|
|
2618
2619
|
return o;
|
|
@@ -2621,7 +2622,7 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2621
2622
|
const r = this._classicalRoot.derivePath(t), s = this._quantumRoot.derivePath(i);
|
|
2622
2623
|
if (!r.privateKey) throw new Error(`Failed to derive classical private key at path ${t}`);
|
|
2623
2624
|
if (!s.privateKey) throw new Error(`Failed to derive quantum private key at path ${i}`);
|
|
2624
|
-
return new
|
|
2625
|
+
return new Bt(f(new Uint8Array(r.privateKey)), f(new Uint8Array(s.privateKey)), this._network, this._securityLevel, new Uint8Array(this._quantumRoot.chainCode));
|
|
2625
2626
|
}
|
|
2626
2627
|
getClassicalRoot() {
|
|
2627
2628
|
return this._classicalRoot;
|
|
@@ -2629,8 +2630,8 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2629
2630
|
getQuantumRoot() {
|
|
2630
2631
|
return this._quantumRoot;
|
|
2631
2632
|
}
|
|
2632
|
-
buildClassicalPath(t, i, r, s =
|
|
2633
|
-
return
|
|
2633
|
+
buildClassicalPath(t, i, r, s = kt.BIP84) {
|
|
2634
|
+
return Ye(s, this.getCoinType(), t, r ? 1 : 0, i);
|
|
2634
2635
|
}
|
|
2635
2636
|
buildQuantumPath(t, i, r) {
|
|
2636
2637
|
return `m/360'/${this.getCoinType()}'/${t}'/${r ? 1 : 0}/${i}`;
|
|
@@ -2638,22 +2639,23 @@ var yr = (0, P.BIP32Factory)(K), mr = class Je {
|
|
|
2638
2639
|
getCoinType() {
|
|
2639
2640
|
return this._network.bech32 === y.testnet.bech32 || this._network.bech32 === y.opnetTestnet.bech32 || this._network.bech32 === y.regtest.bech32 ? 1 : 0;
|
|
2640
2641
|
}
|
|
2641
|
-
},
|
|
2642
|
+
}, wr = /* @__PURE__ */ (function(e) {
|
|
2642
2643
|
return e[e.MLDSA44 = 1312] = "MLDSA44", e[e.MLDSA65 = 1952] = "MLDSA65", e[e.MLDSA87 = 2592] = "MLDSA87", e;
|
|
2643
2644
|
})({});
|
|
2644
|
-
function
|
|
2645
|
+
function ie(e) {
|
|
2645
2646
|
switch (e) {
|
|
2646
|
-
case
|
|
2647
|
-
return
|
|
2648
|
-
case
|
|
2649
|
-
return
|
|
2650
|
-
case
|
|
2651
|
-
return
|
|
2647
|
+
case 1312:
|
|
2648
|
+
return v.MLDSASecurityLevel.LEVEL2;
|
|
2649
|
+
case 1952:
|
|
2650
|
+
return v.MLDSASecurityLevel.LEVEL3;
|
|
2651
|
+
case 2592:
|
|
2652
|
+
return v.MLDSASecurityLevel.LEVEL5;
|
|
2652
2653
|
default:
|
|
2653
2654
|
throw new Error(`Invalid MLDSA public key length: ${e}`);
|
|
2654
2655
|
}
|
|
2655
2656
|
}
|
|
2656
|
-
var
|
|
2657
|
+
var yr = class {
|
|
2658
|
+
network;
|
|
2657
2659
|
constructor(e = y.bitcoin) {
|
|
2658
2660
|
this.network = e;
|
|
2659
2661
|
}
|
|
@@ -2663,29 +2665,29 @@ var Tr = class {
|
|
|
2663
2665
|
getAddress() {
|
|
2664
2666
|
return this.address;
|
|
2665
2667
|
}
|
|
2666
|
-
},
|
|
2668
|
+
}, Qe = /* @__PURE__ */ (function(e) {
|
|
2667
2669
|
return e[e.Bitcoin = 0] = "Bitcoin", e[e.Fractal = 1] = "Fractal", e;
|
|
2668
2670
|
})({});
|
|
2669
|
-
function
|
|
2670
|
-
return e && !!(e.tapInternalKey || e.tapMerkleRoot || e.tapLeafScript && e.tapLeafScript.length || e.tapBip32Derivation && e.tapBip32Derivation.length || e.witnessUtxo && (
|
|
2671
|
+
function fe(e) {
|
|
2672
|
+
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
2673
|
}
|
|
2672
|
-
function
|
|
2674
|
+
function mr(e) {
|
|
2673
2675
|
return e.redeemScript ? e.redeemScript : e.witnessScript ? e.witnessScript : e.witnessUtxo ? e.witnessUtxo.script : (e.nonWitnessUtxo, null);
|
|
2674
2676
|
}
|
|
2675
|
-
function
|
|
2677
|
+
function ge(e, t) {
|
|
2676
2678
|
if (e.nonWitnessUtxo && !e.redeemScript && !e.witnessScript && !e.witnessUtxo || e.redeemScript) return !0;
|
|
2677
|
-
const i =
|
|
2678
|
-
return i ?
|
|
2679
|
+
const i = mr(e);
|
|
2680
|
+
return i ? Se(t, i) : !1;
|
|
2679
2681
|
}
|
|
2680
|
-
function
|
|
2681
|
-
return
|
|
2682
|
+
function Se(e, t) {
|
|
2683
|
+
return _i(e, t) !== -1;
|
|
2682
2684
|
}
|
|
2683
|
-
var
|
|
2685
|
+
var we = class {
|
|
2684
2686
|
constructor() {
|
|
2685
2687
|
}
|
|
2686
2688
|
};
|
|
2687
|
-
|
|
2688
|
-
var
|
|
2689
|
+
vt();
|
|
2690
|
+
var Tr = class extends we {
|
|
2689
2691
|
isInitialized = !1;
|
|
2690
2692
|
constructor() {
|
|
2691
2693
|
if (super(), !window) throw new Error("UnisatSigner can only be used in a browser environment");
|
|
@@ -2746,7 +2748,7 @@ var Er = class extends Te {
|
|
|
2746
2748
|
}
|
|
2747
2749
|
const t = await this.unisat.getPublicKey();
|
|
2748
2750
|
if (t === "") throw new Error("Unlock your wallet first");
|
|
2749
|
-
this._publicKey =
|
|
2751
|
+
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
2752
|
}
|
|
2751
2753
|
getPublicKey() {
|
|
2752
2754
|
if (!this.isInitialized) throw new Error("UnisatSigner not initialized");
|
|
@@ -2780,18 +2782,18 @@ var Er = class extends Te {
|
|
|
2780
2782
|
t.push(o);
|
|
2781
2783
|
const a = n.data.inputs.map((c, u) => {
|
|
2782
2784
|
let l = !1, h = !1;
|
|
2783
|
-
if (
|
|
2785
|
+
if (fe(c)) {
|
|
2784
2786
|
if (c.tapLeafScript && c.tapLeafScript.length > 0) {
|
|
2785
|
-
for (const p of c.tapLeafScript) if (
|
|
2787
|
+
for (const p of c.tapLeafScript) if (Ar(this.publicKey, p.script)) {
|
|
2786
2788
|
l = !0, h = !1;
|
|
2787
2789
|
break;
|
|
2788
2790
|
}
|
|
2789
2791
|
}
|
|
2790
2792
|
if (!l && c.tapInternalKey) {
|
|
2791
2793
|
const p = c.tapInternalKey;
|
|
2792
|
-
C(p,
|
|
2794
|
+
C(p, O(this.publicKey)) && (l = !0, h = !0);
|
|
2793
2795
|
}
|
|
2794
|
-
} else
|
|
2796
|
+
} else ge(c, this.publicKey) && (l = !0, h = !1);
|
|
2795
2797
|
return l ? {
|
|
2796
2798
|
index: u,
|
|
2797
2799
|
publicKey: f(this.publicKey),
|
|
@@ -2803,7 +2805,7 @@ var Er = class extends Te {
|
|
|
2803
2805
|
toSignInputs: a
|
|
2804
2806
|
});
|
|
2805
2807
|
}
|
|
2806
|
-
const r = await this.unisat.signPsbt(t[0], i[0]), s =
|
|
2808
|
+
const r = await this.unisat.signPsbt(t[0], i[0]), s = N.fromHex(r);
|
|
2807
2809
|
e[0].combine(s);
|
|
2808
2810
|
}
|
|
2809
2811
|
hasAlreadySignedTapScriptSig(e) {
|
|
@@ -2840,7 +2842,7 @@ var Er = class extends Te {
|
|
|
2840
2842
|
disableTweakSigner: i
|
|
2841
2843
|
}]).flat()
|
|
2842
2844
|
}, n = e.toHex(), o = await this.unisat.signPsbt(n, s);
|
|
2843
|
-
return
|
|
2845
|
+
return N.fromHex(o);
|
|
2844
2846
|
}
|
|
2845
2847
|
getNonDuplicateScriptSig(e, t) {
|
|
2846
2848
|
const i = [];
|
|
@@ -2851,36 +2853,36 @@ var Er = class extends Te {
|
|
|
2851
2853
|
return i;
|
|
2852
2854
|
}
|
|
2853
2855
|
};
|
|
2854
|
-
function
|
|
2855
|
-
return
|
|
2856
|
+
function Ar(e, t) {
|
|
2857
|
+
return br(e, t) !== -1;
|
|
2856
2858
|
}
|
|
2857
|
-
function
|
|
2858
|
-
const i = D.hash160(e), r =
|
|
2859
|
+
function br(e, t) {
|
|
2860
|
+
const i = D.hash160(e), r = O(e), s = b.decompile(t);
|
|
2859
2861
|
if (s === null) throw new Error("Unknown script error");
|
|
2860
2862
|
return s.findIndex((n) => typeof n == "number" ? !1 : n instanceof Uint8Array && (C(n, e) || C(n, i) || C(n, r)));
|
|
2861
2863
|
}
|
|
2862
|
-
function
|
|
2864
|
+
function Ze(e) {
|
|
2863
2865
|
return new Map(e);
|
|
2864
2866
|
}
|
|
2865
|
-
function
|
|
2867
|
+
function Er(e) {
|
|
2866
2868
|
return {
|
|
2867
2869
|
enabled: !0,
|
|
2868
|
-
signerMap: e instanceof Map ? e :
|
|
2870
|
+
signerMap: e instanceof Map ? e : Ze(e)
|
|
2869
2871
|
};
|
|
2870
2872
|
}
|
|
2871
|
-
function
|
|
2873
|
+
function Ir() {
|
|
2872
2874
|
return {
|
|
2873
2875
|
enabled: !1,
|
|
2874
2876
|
signerMap: /* @__PURE__ */ new Map()
|
|
2875
2877
|
};
|
|
2876
2878
|
}
|
|
2877
|
-
|
|
2878
|
-
function
|
|
2879
|
+
vt();
|
|
2880
|
+
function Pr(e) {
|
|
2879
2881
|
return {
|
|
2880
2882
|
publicKey: e.publicKey,
|
|
2881
2883
|
getPrivateKey() {
|
|
2882
2884
|
if (!e.privateKey) throw new Error("Signer does not have a private key");
|
|
2883
|
-
return
|
|
2885
|
+
return Re(e.privateKey);
|
|
2884
2886
|
},
|
|
2885
2887
|
sign(t, i) {
|
|
2886
2888
|
return e.sign(t, i);
|
|
@@ -2891,12 +2893,12 @@ function Or(e) {
|
|
|
2891
2893
|
}
|
|
2892
2894
|
};
|
|
2893
2895
|
}
|
|
2894
|
-
function
|
|
2896
|
+
function Je(e, t) {
|
|
2895
2897
|
return {
|
|
2896
|
-
publicKey:
|
|
2898
|
+
publicKey: ce(e.publicKey),
|
|
2897
2899
|
getPrivateKey() {
|
|
2898
2900
|
if (!t.privateKey) throw new Error("Tweaked signer does not have a private key");
|
|
2899
|
-
return
|
|
2901
|
+
return Re(t.privateKey);
|
|
2900
2902
|
},
|
|
2901
2903
|
sign(i, r) {
|
|
2902
2904
|
return t.sign(i, r);
|
|
@@ -2909,11 +2911,11 @@ function ii(e, t) {
|
|
|
2909
2911
|
}
|
|
2910
2912
|
var m = /* @__PURE__ */ (function(e) {
|
|
2911
2913
|
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
|
-
})({}),
|
|
2914
|
+
})({}), vr = /* @__PURE__ */ (function(e) {
|
|
2913
2915
|
return e[e.REPLACE_BY_FEE = 4294967293] = "REPLACE_BY_FEE", e[e.FINAL = 4294967295] = "FINAL", e;
|
|
2914
|
-
})({}),
|
|
2916
|
+
})({}), Or = /* @__PURE__ */ (function(e) {
|
|
2915
2917
|
return e[e.BLOCKS = 0] = "BLOCKS", e[e.TIMESTAMPS = 1] = "TIMESTAMPS", e;
|
|
2916
|
-
})({}),
|
|
2918
|
+
})({}), ti = class re extends Le {
|
|
2917
2919
|
logColor = "#00ffe1";
|
|
2918
2920
|
finalized = !1;
|
|
2919
2921
|
signer;
|
|
@@ -2924,7 +2926,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
2924
2926
|
scriptData = null;
|
|
2925
2927
|
tapData = null;
|
|
2926
2928
|
inputs = [];
|
|
2927
|
-
sequence =
|
|
2929
|
+
sequence = 4294967293;
|
|
2928
2930
|
tapLeafScript = null;
|
|
2929
2931
|
nonWitnessUtxo;
|
|
2930
2932
|
isBrowser = !1;
|
|
@@ -2945,7 +2947,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
2945
2947
|
parallelSigningConfig;
|
|
2946
2948
|
useP2MR = !1;
|
|
2947
2949
|
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 =
|
|
2950
|
+
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
2951
|
}
|
|
2950
2952
|
get mldsaSigner() {
|
|
2951
2953
|
if (!this._mldsaSigner) throw new Error("MLDSA Signer is not set");
|
|
@@ -2965,7 +2967,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
2965
2967
|
return i += a, c;
|
|
2966
2968
|
}
|
|
2967
2969
|
function s() {
|
|
2968
|
-
const a =
|
|
2970
|
+
const a = Gt.decode(t, i);
|
|
2969
2971
|
return i += a.bytes, a.numberValue || 0;
|
|
2970
2972
|
}
|
|
2971
2973
|
function n() {
|
|
@@ -3013,17 +3015,17 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3013
3015
|
}
|
|
3014
3016
|
disableRBF() {
|
|
3015
3017
|
if (this.signed) throw new Error("Transaction is already signed");
|
|
3016
|
-
this.sequence =
|
|
3018
|
+
this.sequence = 4294967295;
|
|
3017
3019
|
for (const t of this.inputs) {
|
|
3018
3020
|
const i = this.inputs.indexOf(t);
|
|
3019
|
-
this.csvInputIndices.has(i) || this.csvMultisigInputs.has(i) || (t.sequence =
|
|
3021
|
+
this.csvInputIndices.has(i) || this.csvMultisigInputs.has(i) || (t.sequence = 4294967295);
|
|
3020
3022
|
}
|
|
3021
3023
|
}
|
|
3022
3024
|
getTweakerHash() {
|
|
3023
3025
|
return this.tapData?.hash;
|
|
3024
3026
|
}
|
|
3025
3027
|
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 *
|
|
3028
|
+
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
3029
|
return (h * 3n + (h + w)) / 4n * t;
|
|
3028
3030
|
}
|
|
3029
3031
|
getSignerForInput(t) {
|
|
@@ -3049,7 +3051,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3049
3051
|
}
|
|
3050
3052
|
}
|
|
3051
3053
|
internalPubKeyToXOnlyForInput(t) {
|
|
3052
|
-
return
|
|
3054
|
+
return O(this.getSignerForInput(t).publicKey);
|
|
3053
3055
|
}
|
|
3054
3056
|
getTweakedSignerForInput(t, i = !1) {
|
|
3055
3057
|
if (!this.addressRotationEnabled)
|
|
@@ -3062,21 +3064,21 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3062
3064
|
generateTapData() {
|
|
3063
3065
|
return this.useP2MR ? {
|
|
3064
3066
|
network: this.network,
|
|
3065
|
-
name:
|
|
3067
|
+
name: E.P2MR
|
|
3066
3068
|
} : {
|
|
3067
3069
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
3068
3070
|
network: this.network,
|
|
3069
|
-
name:
|
|
3071
|
+
name: E.P2TR
|
|
3070
3072
|
};
|
|
3071
3073
|
}
|
|
3072
3074
|
generateScriptAddress() {
|
|
3073
3075
|
return this.useP2MR ? {
|
|
3074
3076
|
network: this.network,
|
|
3075
|
-
name:
|
|
3077
|
+
name: E.P2MR
|
|
3076
3078
|
} : {
|
|
3077
3079
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
3078
3080
|
network: this.network,
|
|
3079
|
-
name:
|
|
3081
|
+
name: E.P2TR
|
|
3080
3082
|
};
|
|
3081
3083
|
}
|
|
3082
3084
|
getSignerKey() {
|
|
@@ -3085,7 +3087,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3085
3087
|
async signInput(t, i, r, s, n = !1, o = !1) {
|
|
3086
3088
|
if (this.anchorInputIndices.has(r)) return;
|
|
3087
3089
|
const a = s.publicKey;
|
|
3088
|
-
let c =
|
|
3090
|
+
let c = fe(i);
|
|
3089
3091
|
n && (c = !c);
|
|
3090
3092
|
let u = !1, l = !1;
|
|
3091
3093
|
if (c) try {
|
|
@@ -3093,7 +3095,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3093
3095
|
} catch (h) {
|
|
3094
3096
|
this.error(`Failed to sign Taproot script path input ${r} (reverse: ${n}): ${h.message}`), l = !0;
|
|
3095
3097
|
}
|
|
3096
|
-
else if (n ||
|
|
3098
|
+
else if (n || ge(i, a)) try {
|
|
3097
3099
|
await this.signNonTaprootInput(s, t, r), u = !0;
|
|
3098
3100
|
} catch (h) {
|
|
3099
3101
|
this.error(`Failed to sign non-Taproot input ${r}: ${h.stack}`), l = !0;
|
|
@@ -3121,18 +3123,27 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3121
3123
|
await this.signInputsNonWalletBased(t);
|
|
3122
3124
|
}
|
|
3123
3125
|
async signInputsNonWalletBased(t) {
|
|
3124
|
-
if (!this.noSignatures) if (this.canUseParallelSigning &&
|
|
3125
|
-
let
|
|
3126
|
+
if (!this.noSignatures) if (this.canUseParallelSigning && dt(this.signer)) {
|
|
3127
|
+
let r = /* @__PURE__ */ new Set();
|
|
3126
3128
|
try {
|
|
3127
|
-
const
|
|
3128
|
-
|
|
3129
|
-
} catch (
|
|
3130
|
-
this.error(`Parallel signing failed, falling back to sequential: ${
|
|
3129
|
+
const s = await this.signKeyPathInputsParallel(t);
|
|
3130
|
+
s.success && (r = new Set(s.signatures.keys()));
|
|
3131
|
+
} catch (s) {
|
|
3132
|
+
this.error(`Parallel signing failed, falling back to sequential: ${s.message}`);
|
|
3131
3133
|
}
|
|
3132
|
-
await this.signRemainingInputsSequential(t,
|
|
3134
|
+
await this.signRemainingInputsSequential(t, r);
|
|
3133
3135
|
} else await this.signInputsSequential(t);
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
+
let i = !0;
|
|
3137
|
+
for (let r = 0; r < t.data.inputs.length; r++) try {
|
|
3138
|
+
t.finalizeInput(r, this.customFinalizerP2SH.bind(this));
|
|
3139
|
+
} catch (s) {
|
|
3140
|
+
if (this.csvMultisigInputs.has(r)) {
|
|
3141
|
+
i = !1;
|
|
3142
|
+
continue;
|
|
3143
|
+
}
|
|
3144
|
+
throw s;
|
|
3145
|
+
}
|
|
3146
|
+
this.finalized = i;
|
|
3136
3147
|
}
|
|
3137
3148
|
async signInputsSequential(t) {
|
|
3138
3149
|
const i = t.data.inputs, r = 20, s = this.splitArray(i, r);
|
|
@@ -3170,11 +3181,11 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3170
3181
|
}
|
|
3171
3182
|
}
|
|
3172
3183
|
internalPubKeyToXOnly() {
|
|
3173
|
-
return
|
|
3184
|
+
return O(this.signer.publicKey);
|
|
3174
3185
|
}
|
|
3175
3186
|
internalInit() {
|
|
3176
3187
|
const t = this.generateScriptAddress(), i = this.generateTapData();
|
|
3177
|
-
t.name ===
|
|
3188
|
+
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
3189
|
}
|
|
3179
3190
|
tweakSigner() {
|
|
3180
3191
|
if (this.tweakedSigner) return;
|
|
@@ -3187,13 +3198,13 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3187
3198
|
const s = this.getTweakerHash();
|
|
3188
3199
|
s !== void 0 && (r.tweakHash = s);
|
|
3189
3200
|
}
|
|
3190
|
-
if (
|
|
3191
|
-
return
|
|
3201
|
+
if (dt(i))
|
|
3202
|
+
return pe.tweakSigner(i, r);
|
|
3192
3203
|
}
|
|
3193
3204
|
async signKeyPathInputsParallel(t, i) {
|
|
3194
3205
|
const r = this.signer, s = this.getTweakedSigner(!0);
|
|
3195
3206
|
if (!s) throw new Error("Cannot create tweaked signer for parallel signing");
|
|
3196
|
-
const n =
|
|
3207
|
+
const n = Je(r, s), o = Ui(t, n), a = i ? o.filter((l) => !i.has(l.inputIndex)) : o;
|
|
3197
3208
|
if (a.length === 0) return {
|
|
3198
3209
|
success: !0,
|
|
3199
3210
|
signatures: /* @__PURE__ */ new Map(),
|
|
@@ -3201,11 +3212,11 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3201
3212
|
durationMs: 0
|
|
3202
3213
|
};
|
|
3203
3214
|
let c, u = !1;
|
|
3204
|
-
this.parallelSigningConfig && "signBatch" in this.parallelSigningConfig ? c = this.parallelSigningConfig : (c =
|
|
3215
|
+
this.parallelSigningConfig && "signBatch" in this.parallelSigningConfig ? c = this.parallelSigningConfig : (c = Ki.getInstance(this.parallelSigningConfig), c.isPreservingWorkers || (u = !0));
|
|
3205
3216
|
try {
|
|
3206
3217
|
await c.initialize();
|
|
3207
3218
|
const l = await c.signBatch(a, n);
|
|
3208
|
-
if (l.success)
|
|
3219
|
+
if (l.success) Vi(t, l, n);
|
|
3209
3220
|
else {
|
|
3210
3221
|
const h = [...l.errors.entries()].map(([p, w]) => `Input ${p}: ${w}`).join(", ");
|
|
3211
3222
|
this.error(`Parallel signing had errors: ${h}`);
|
|
@@ -3216,30 +3227,30 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3216
3227
|
}
|
|
3217
3228
|
}
|
|
3218
3229
|
generateP2SHRedeemScript(t) {
|
|
3219
|
-
const i =
|
|
3230
|
+
const i = U.p2wsh({
|
|
3220
3231
|
redeem: { output: t },
|
|
3221
3232
|
network: this.network
|
|
3222
3233
|
});
|
|
3223
|
-
return
|
|
3234
|
+
return U.p2sh({
|
|
3224
3235
|
redeem: i,
|
|
3225
3236
|
network: this.network
|
|
3226
3237
|
}).output;
|
|
3227
3238
|
}
|
|
3228
3239
|
generateP2SHRedeemScriptLegacy(t) {
|
|
3229
|
-
const i = D.hash160(this.signer.publicKey), r =
|
|
3240
|
+
const i = D.hash160(this.signer.publicKey), r = b.compile([
|
|
3230
3241
|
d.OP_DUP,
|
|
3231
3242
|
d.OP_HASH160,
|
|
3232
3243
|
i,
|
|
3233
3244
|
d.OP_EQUALVERIFY,
|
|
3234
3245
|
d.OP_CHECKSIG
|
|
3235
|
-
]), s = D.hash160(r), n =
|
|
3246
|
+
]), s = D.hash160(r), n = b.compile([
|
|
3236
3247
|
d.OP_HASH160,
|
|
3237
3248
|
s,
|
|
3238
3249
|
d.OP_EQUAL
|
|
3239
|
-
]), o =
|
|
3250
|
+
]), o = U.p2wsh({
|
|
3240
3251
|
redeem: { output: r },
|
|
3241
3252
|
network: this.network
|
|
3242
|
-
}), a =
|
|
3253
|
+
}), a = U.p2sh({
|
|
3243
3254
|
redeem: o,
|
|
3244
3255
|
network: this.network
|
|
3245
3256
|
});
|
|
@@ -3249,10 +3260,10 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3249
3260
|
};
|
|
3250
3261
|
}
|
|
3251
3262
|
generateP2SHP2PKHRedeemScript(t, i) {
|
|
3252
|
-
const r = (this.addressRotationEnabled && i !== void 0 ? this.getSignerForInput(i) : this.signer).publicKey, s =
|
|
3263
|
+
const r = (this.addressRotationEnabled && i !== void 0 ? this.getSignerForInput(i) : this.signer).publicKey, s = U.p2wpkh({
|
|
3253
3264
|
pubkey: r,
|
|
3254
3265
|
network: this.network
|
|
3255
|
-
}), n =
|
|
3266
|
+
}), n = U.p2sh({
|
|
3256
3267
|
redeem: s,
|
|
3257
3268
|
network: this.network
|
|
3258
3269
|
}), o = n.address;
|
|
@@ -3272,11 +3283,11 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3272
3283
|
script: s
|
|
3273
3284
|
}
|
|
3274
3285
|
};
|
|
3275
|
-
if (
|
|
3286
|
+
if (Ci(s)) if (t.nonWitnessUtxo) n.nonWitnessUtxo = t.nonWitnessUtxo instanceof Uint8Array ? t.nonWitnessUtxo : g(t.nonWitnessUtxo);
|
|
3276
3287
|
else throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");
|
|
3277
|
-
else if (!(
|
|
3278
|
-
if (
|
|
3279
|
-
else if (
|
|
3288
|
+
else if (!(Ie(s) || Ri(s)))
|
|
3289
|
+
if (Pe(s)) this.processP2WSHInput(t, n, i);
|
|
3290
|
+
else if (Hi(s)) {
|
|
3280
3291
|
let o;
|
|
3281
3292
|
if (t.redeemScript) o = t.redeemScript instanceof Uint8Array ? t.redeemScript : g(t.redeemScript);
|
|
3282
3293
|
else {
|
|
@@ -3286,33 +3297,33 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3286
3297
|
o = u.redeemScript;
|
|
3287
3298
|
}
|
|
3288
3299
|
n.redeemScript = o;
|
|
3289
|
-
const a =
|
|
3300
|
+
const a = U.p2sh({ redeem: { output: n.redeemScript } });
|
|
3290
3301
|
if (!a.redeem) throw new Error("Failed to extract redeem script from P2SH UTXO");
|
|
3291
3302
|
const c = a.redeem.output;
|
|
3292
3303
|
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 (
|
|
3304
|
+
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");
|
|
3305
|
+
} else if (Rt(s)) {
|
|
3295
3306
|
if (this.sighashTypes) {
|
|
3296
|
-
const o =
|
|
3307
|
+
const o = re.calculateSignHash(this.sighashTypes);
|
|
3297
3308
|
o && (n.sighashType = o);
|
|
3298
3309
|
}
|
|
3299
3310
|
this.processCSVMultisigP2TRInput(t, n, i, s) || (this.addressRotationEnabled ? n.tapInternalKey = this.internalPubKeyToXOnlyForInput(i) : (this.tweakSigner(), n.tapInternalKey = this.internalPubKeyToXOnly()));
|
|
3300
|
-
} else if (
|
|
3311
|
+
} else if (Ce(s)) {
|
|
3301
3312
|
if (this.sighashTypes) {
|
|
3302
|
-
const o =
|
|
3313
|
+
const o = re.calculateSignHash(this.sighashTypes);
|
|
3303
3314
|
o && (n.sighashType = o);
|
|
3304
3315
|
}
|
|
3305
3316
|
i === 0 && this.tapData?.hash && (n.tapMerkleRoot = this.tapData.hash);
|
|
3306
|
-
} else if (
|
|
3317
|
+
} else if (zi(s))
|
|
3307
3318
|
this.anchorInputIndices.add(i), n.isPayToAnchor = !0;
|
|
3308
|
-
else if (
|
|
3319
|
+
else if (Di(s) || Wi(s)) if (t.nonWitnessUtxo) n.nonWitnessUtxo = t.nonWitnessUtxo instanceof Uint8Array ? t.nonWitnessUtxo : g(t.nonWitnessUtxo);
|
|
3309
3320
|
else throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");
|
|
3310
3321
|
else this.error(`Unknown or unsupported script type for output: ${t.scriptPubKey.hex}`);
|
|
3311
3322
|
return i === 0 && (this.tapLeafScript && !this.csvMultisigInputs.has(i) && (n.tapLeafScript = [this.tapLeafScript]), this.nonWitnessUtxo && (n.nonWitnessUtxo = this.nonWitnessUtxo)), n;
|
|
3312
3323
|
}
|
|
3313
3324
|
processCSVMultisigP2TRInput(t, i, r, s) {
|
|
3314
3325
|
if (!t.witnessScript) return !1;
|
|
3315
|
-
const n = t.witnessScript instanceof Uint8Array ? t.witnessScript : g(t.witnessScript), o =
|
|
3326
|
+
const n = t.witnessScript instanceof Uint8Array ? t.witnessScript : g(t.witnessScript), o = rt.deriveAddressFromTapscript(n, this.network);
|
|
3316
3327
|
return !o || !C(o.scriptPubKey, s) ? !1 : (i.tapLeafScript = [{
|
|
3317
3328
|
leafVersion: o.leafVersion,
|
|
3318
3329
|
script: o.tapscript,
|
|
@@ -3322,9 +3333,9 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3322
3333
|
processP2WSHInput(t, i, r) {
|
|
3323
3334
|
if (!t.witnessScript) throw new Error("Missing witnessScript for P2WSH UTXO");
|
|
3324
3335
|
i.witnessScript = t.witnessScript instanceof Uint8Array ? t.witnessScript : g(t.witnessScript);
|
|
3325
|
-
const s =
|
|
3336
|
+
const s = b.decompile(i.witnessScript);
|
|
3326
3337
|
if (s && this.isCSVScript(s)) {
|
|
3327
|
-
const n =
|
|
3338
|
+
const n = b.decompile(i.witnessScript);
|
|
3328
3339
|
if (n && this.isCSVScript(n)) {
|
|
3329
3340
|
this.csvInputIndices.add(r);
|
|
3330
3341
|
const o = this.extractCSVBlocks(n);
|
|
@@ -3351,7 +3362,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3351
3362
|
if (n && i.partialSig && c && c.redeemScript) {
|
|
3352
3363
|
const l = i.partialSig.map((h) => h.signature) || [];
|
|
3353
3364
|
return {
|
|
3354
|
-
finalScriptSig:
|
|
3365
|
+
finalScriptSig: b.compile([...l, c.redeemScript]),
|
|
3355
3366
|
finalScriptWitness: void 0
|
|
3356
3367
|
};
|
|
3357
3368
|
}
|
|
@@ -3364,31 +3375,40 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3364
3375
|
const l = i.tapScriptSig ?? [];
|
|
3365
3376
|
return {
|
|
3366
3377
|
finalScriptSig: void 0,
|
|
3367
|
-
finalScriptWitness:
|
|
3378
|
+
finalScriptWitness: It(rt.buildFinalWitnessFromTapScriptSigs(l, u))
|
|
3368
3379
|
};
|
|
3369
3380
|
}
|
|
3370
3381
|
if (o && s && i.witnessScript) {
|
|
3371
3382
|
if (!i.partialSig || i.partialSig.length === 0) throw new Error(`No signatures for P2WSH input #${t}`);
|
|
3372
|
-
if (
|
|
3383
|
+
if (X.isP2WDAWitnessScript(i.witnessScript)) return this.finalizeSecondaryP2WDA(t, i);
|
|
3373
3384
|
if (this.csvInputIndices.has(t)) return {
|
|
3374
3385
|
finalScriptSig: void 0,
|
|
3375
|
-
finalScriptWitness:
|
|
3386
|
+
finalScriptWitness: It([i.partialSig[0].signature, i.witnessScript])
|
|
3376
3387
|
};
|
|
3377
3388
|
}
|
|
3378
|
-
return
|
|
3389
|
+
return Ke(t, i, r, s, n, o, !0, this.unlockScript);
|
|
3379
3390
|
};
|
|
3380
3391
|
finalizeSecondaryP2WDA(t, i) {
|
|
3381
3392
|
if (!i.partialSig || i.partialSig.length === 0) throw new Error(`No signature for P2WDA input #${t}`);
|
|
3382
3393
|
if (!i.witnessScript) throw new Error(`No witness script for P2WDA input #${t}`);
|
|
3383
3394
|
return {
|
|
3384
3395
|
finalScriptSig: void 0,
|
|
3385
|
-
finalScriptWitness:
|
|
3396
|
+
finalScriptWitness: It(X.createSimpleP2WDAWitness(i.partialSig[0].signature, i.witnessScript))
|
|
3386
3397
|
};
|
|
3387
3398
|
}
|
|
3388
3399
|
async signInputsWalletBased(t) {
|
|
3389
3400
|
await this.signer.multiSignPsbt([t]);
|
|
3390
|
-
|
|
3391
|
-
|
|
3401
|
+
let i = !0;
|
|
3402
|
+
for (let r = 0; r < t.data.inputs.length; r++) try {
|
|
3403
|
+
t.finalizeInput(r, this.customFinalizerP2SH.bind(this));
|
|
3404
|
+
} catch (s) {
|
|
3405
|
+
if (this.csvMultisigInputs.has(r)) {
|
|
3406
|
+
i = !1;
|
|
3407
|
+
continue;
|
|
3408
|
+
}
|
|
3409
|
+
throw s;
|
|
3410
|
+
}
|
|
3411
|
+
this.finalized = i;
|
|
3392
3412
|
}
|
|
3393
3413
|
isCSVScript(t) {
|
|
3394
3414
|
return t.some((i) => i === d.OP_CHECKSEQUENCEVERIFY);
|
|
@@ -3398,15 +3418,15 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3398
3418
|
if (t > 65535) throw new Error(`CSV blocks ${t} exceeds maximum of 65,535`);
|
|
3399
3419
|
const r = (t & 1 << 22) !== 0;
|
|
3400
3420
|
let s = t & 65535;
|
|
3401
|
-
return r && (s |= 1 << 22), i ===
|
|
3421
|
+
return r && (s |= 1 << 22), i === 4294967293 && (s |= 1 << 25), s = s & 2147483647, s;
|
|
3402
3422
|
}
|
|
3403
3423
|
getCSVType(t) {
|
|
3404
|
-
return t & 1 << 22 ?
|
|
3424
|
+
return t & 1 << 22 ? 1 : 0;
|
|
3405
3425
|
}
|
|
3406
3426
|
extractCSVBlocks(t) {
|
|
3407
3427
|
for (let i = 0; i < t.length; i++) if (t[i] === d.OP_CHECKSEQUENCEVERIFY && i > 0) {
|
|
3408
3428
|
const r = t[i - 1];
|
|
3409
|
-
if (r instanceof Uint8Array) return
|
|
3429
|
+
if (r instanceof Uint8Array) return b.number.decode(r);
|
|
3410
3430
|
if (typeof r == "number") {
|
|
3411
3431
|
if (r === d.OP_0 || r === d.OP_FALSE) return 0;
|
|
3412
3432
|
if (r === d.OP_1NEGATE) return -1;
|
|
@@ -3431,7 +3451,7 @@ var m = /* @__PURE__ */ (function(e) {
|
|
|
3431
3451
|
}
|
|
3432
3452
|
isTaprootScriptSpend(t, i) {
|
|
3433
3453
|
if (t.tapLeafScript && t.tapLeafScript.length > 0) {
|
|
3434
|
-
for (const r of t.tapLeafScript) if (
|
|
3454
|
+
for (const r of t.tapLeafScript) if (Se(i, r.script)) return !0;
|
|
3435
3455
|
}
|
|
3436
3456
|
return !1;
|
|
3437
3457
|
}
|
|
@@ -3588,12 +3608,12 @@ var _r = /* @__PURE__ */ new Map([
|
|
|
3588
3608
|
6
|
|
3589
3609
|
])]
|
|
3590
3610
|
]);
|
|
3591
|
-
function
|
|
3611
|
+
function Be(e) {
|
|
3592
3612
|
const t = _r.get(bt(e));
|
|
3593
3613
|
if (!t) throw new Error("Unsupported network for chain ID retrieval");
|
|
3594
3614
|
return t.slice();
|
|
3595
3615
|
}
|
|
3596
|
-
var
|
|
3616
|
+
var ke = new Uint8Array([
|
|
3597
3617
|
231,
|
|
3598
3618
|
132,
|
|
3599
3619
|
153,
|
|
@@ -3626,7 +3646,7 @@ var Ce = new Uint8Array([
|
|
|
3626
3646
|
64,
|
|
3627
3647
|
121,
|
|
3628
3648
|
57
|
|
3629
|
-
]),
|
|
3649
|
+
]), Pt = 330n, ei = 297n, se = g("51024e73"), Ss = 1, B = class R extends ti {
|
|
3630
3650
|
static MINIMUM_DUST = 330n;
|
|
3631
3651
|
logColor = "#785def";
|
|
3632
3652
|
debugFees = !1;
|
|
@@ -3655,8 +3675,8 @@ var Ce = new Uint8Array([
|
|
|
3655
3675
|
note;
|
|
3656
3676
|
optionalOutputsAdded = !1;
|
|
3657
3677
|
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
|
|
3678
|
+
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");
|
|
3679
|
+
this.transaction = new N({
|
|
3660
3680
|
network: this.network,
|
|
3661
3681
|
version: this.txVersion
|
|
3662
3682
|
});
|
|
@@ -3665,13 +3685,13 @@ var Ce = new Uint8Array([
|
|
|
3665
3685
|
return t || I.getTaprootAddress(i, r);
|
|
3666
3686
|
}
|
|
3667
3687
|
static witnessStackToScriptWitness(t) {
|
|
3668
|
-
return
|
|
3688
|
+
return It(t);
|
|
3669
3689
|
}
|
|
3670
3690
|
[Symbol.dispose]() {
|
|
3671
3691
|
super[Symbol.dispose](), this.updateInputs.length = 0, this.outputs.length = 0, this.feeOutput = null, this.optionalOutputs = void 0, this.utxos = [], this.optionalInputs = [];
|
|
3672
3692
|
}
|
|
3673
3693
|
addOPReturn(t) {
|
|
3674
|
-
const i =
|
|
3694
|
+
const i = b.compile([d.OP_RETURN, t]);
|
|
3675
3695
|
this.addOutput({
|
|
3676
3696
|
value: L(0n),
|
|
3677
3697
|
script: i
|
|
@@ -3680,7 +3700,7 @@ var Ce = new Uint8Array([
|
|
|
3680
3700
|
addAnchor() {
|
|
3681
3701
|
this.addOutput({
|
|
3682
3702
|
value: L(0n),
|
|
3683
|
-
script:
|
|
3703
|
+
script: se
|
|
3684
3704
|
});
|
|
3685
3705
|
}
|
|
3686
3706
|
async getFundingTransactionParameters() {
|
|
@@ -3725,8 +3745,12 @@ var Ce = new Uint8Array([
|
|
|
3725
3745
|
}
|
|
3726
3746
|
}
|
|
3727
3747
|
async signPSBT() {
|
|
3728
|
-
if (
|
|
3729
|
-
throw new Error("
|
|
3748
|
+
if (!this.utxos.length) throw new Error("No UTXOs specified");
|
|
3749
|
+
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.");
|
|
3750
|
+
if (this.signed) throw new Error("Transaction is already signed");
|
|
3751
|
+
if (this.signed = !0, await this.buildTransaction(), !await this.internalBuildTransaction(this.transaction)) throw new Error("Could not sign transaction");
|
|
3752
|
+
if (this.regenerated) throw new Error("Transaction was regenerated");
|
|
3753
|
+
return this.transaction;
|
|
3730
3754
|
}
|
|
3731
3755
|
addInput(t) {
|
|
3732
3756
|
this.inputs.push(t);
|
|
@@ -3736,7 +3760,7 @@ var Ce = new Uint8Array([
|
|
|
3736
3760
|
const r = t;
|
|
3737
3761
|
if (!r.script || r.script.length === 0) throw new Error("Output value is 0 and no script provided");
|
|
3738
3762
|
if (r.script.length < 2) throw new Error("Output script is too short");
|
|
3739
|
-
if (r.script[0] !== d.OP_RETURN && !C(r.script,
|
|
3763
|
+
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
3764
|
} 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
3765
|
this.outputs.push(t);
|
|
3742
3766
|
}
|
|
@@ -3751,7 +3775,7 @@ var Ce = new Uint8Array([
|
|
|
3751
3775
|
}
|
|
3752
3776
|
async estimateTransactionFees() {
|
|
3753
3777
|
await Promise.resolve();
|
|
3754
|
-
const t = new
|
|
3778
|
+
const t = new N({ network: this.network }), i = this.getInputs(), r = this.getOutputs();
|
|
3755
3779
|
t.addInputs(i), t.addOutputs(r);
|
|
3756
3780
|
const s = new Uint8Array(64), n = new Uint8Array(72), o = new Uint8Array(33).fill(2), a = (h, p) => {
|
|
3757
3781
|
if (p.isPayToAnchor || this.anchorInputIndices.has(h)) return {
|
|
@@ -3759,8 +3783,8 @@ var Ce = new Uint8Array([
|
|
|
3759
3783
|
finalScriptWitness: Uint8Array.from([0])
|
|
3760
3784
|
};
|
|
3761
3785
|
const w = this.csvMultisigInputs.get(h);
|
|
3762
|
-
if (w) return { finalScriptWitness: R.witnessStackToScriptWitness(
|
|
3763
|
-
if (p.witnessScript &&
|
|
3786
|
+
if (w) return { finalScriptWitness: R.witnessStackToScriptWitness(rt.buildDummyWitness(w)) };
|
|
3787
|
+
if (p.witnessScript && X.isP2WDAWitnessScript(p.witnessScript)) {
|
|
3764
3788
|
const A = [];
|
|
3765
3789
|
for (let x = 0; x < 10; x++) A.push(new Uint8Array(0));
|
|
3766
3790
|
const k = new Uint8Array(72);
|
|
@@ -3800,11 +3824,11 @@ var Ce = new Uint8Array([
|
|
|
3800
3824
|
if (A && A.length >= 4) {
|
|
3801
3825
|
const k = A[0], x = A[A.length - 1];
|
|
3802
3826
|
if (typeof k == "number" && k >= d.OP_1 && x === d.OP_CHECKMULTISIG) {
|
|
3803
|
-
const yt = k - d.OP_1 + 1,
|
|
3804
|
-
for (let
|
|
3827
|
+
const yt = k - d.OP_1 + 1, be = [];
|
|
3828
|
+
for (let Ee = 0; Ee < yt; Ee++) be.push(n);
|
|
3805
3829
|
return { finalScriptWitness: R.witnessStackToScriptWitness([
|
|
3806
3830
|
new Uint8Array(0),
|
|
3807
|
-
...
|
|
3831
|
+
...be,
|
|
3808
3832
|
p.witnessScript
|
|
3809
3833
|
]) };
|
|
3810
3834
|
}
|
|
@@ -3822,7 +3846,7 @@ var Ce = new Uint8Array([
|
|
|
3822
3846
|
finalScriptWitness: void 0
|
|
3823
3847
|
};
|
|
3824
3848
|
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]) } :
|
|
3849
|
+
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
3850
|
finalScriptSig: void 0,
|
|
3827
3851
|
finalScriptWitness: void 0
|
|
3828
3852
|
};
|
|
@@ -3839,10 +3863,10 @@ var Ce = new Uint8Array([
|
|
|
3839
3863
|
return this.debugFees && this.log(`Estimating fees: feeRate=${this.feeRate}, accurate_vSize=${c}, fee=${l}n`), l;
|
|
3840
3864
|
}
|
|
3841
3865
|
async rebuildFromBase64(t) {
|
|
3842
|
-
return this.transaction =
|
|
3866
|
+
return this.transaction = N.fromBase64(t, {
|
|
3843
3867
|
network: this.network,
|
|
3844
3868
|
version: this.txVersion
|
|
3845
|
-
}), this.signed = !1, this.sighashTypes = [
|
|
3869
|
+
}), this.signed = !1, this.sighashTypes = [Xt.SIGHASH_ANYONECANPAY, Xt.SIGHASH_ALL], await this.signPSBT();
|
|
3846
3870
|
}
|
|
3847
3871
|
setPSBT(t) {
|
|
3848
3872
|
this.transaction = t;
|
|
@@ -3867,14 +3891,19 @@ var Ce = new Uint8Array([
|
|
|
3867
3891
|
this.feeOutput = this.createChangeOutput(s), this.overflowFees = s, this.transactionFee = r;
|
|
3868
3892
|
else {
|
|
3869
3893
|
this.feeOutput = null, this.overflowFees = 0n;
|
|
3870
|
-
const
|
|
3871
|
-
if (this.transactionFee =
|
|
3872
|
-
|
|
3894
|
+
const a = await this.estimateTransactionFees();
|
|
3895
|
+
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.`);
|
|
3896
|
+
}
|
|
3897
|
+
const n = t + this.transactionFee, o = BigInt(Math.ceil(1));
|
|
3898
|
+
if (this.totalInputAmount < t) throw new Error(`Insufficient funds: need ${n} sats but only have ${this.totalInputAmount} sats`);
|
|
3899
|
+
if (this.totalInputAmount < n - o) {
|
|
3900
|
+
const a = n - this.totalInputAmount - o;
|
|
3901
|
+
throw new Error(`Insufficient funds for fee: need at least ${a} more sats to cover fees.`);
|
|
3873
3902
|
}
|
|
3874
3903
|
this.debugFees && this.log(`Final fee: ${this.transactionFee} sats, Change output: ${this.feeOutput ? `${this.feeOutput.value} sats` : "none"}`);
|
|
3875
3904
|
}
|
|
3876
3905
|
defineLockScript() {
|
|
3877
|
-
return
|
|
3906
|
+
return b.compile([O(this.signer.publicKey), d.OP_CHECKSIG]);
|
|
3878
3907
|
}
|
|
3879
3908
|
addValueToToOutput(t) {
|
|
3880
3909
|
if (BigInt(t) < R.MINIMUM_DUST) throw new Error(`Value to send is less than the minimum dust ${t} < ${R.MINIMUM_DUST}`);
|
|
@@ -3892,25 +3921,25 @@ var Ce = new Uint8Array([
|
|
|
3892
3921
|
}
|
|
3893
3922
|
generateLegacySignature() {
|
|
3894
3923
|
if (this.tweakSigner(), !this.tweakedSigner) throw new Error("Tweaked signer is not defined");
|
|
3895
|
-
const t =
|
|
3924
|
+
const t = O(this.tweakedSigner.publicKey), i = this.signer.publicKey;
|
|
3896
3925
|
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 (!
|
|
3926
|
+
const r = Be(this.network), s = new V();
|
|
3927
|
+
s.writeU8(v.MLDSASecurityLevel.LEVEL2), s.writeBytes(this.hashedPublicKey), s.writeBytes(t), s.writeBytes(i), s.writeBytes(ke), s.writeBytes(r);
|
|
3928
|
+
const n = s.getBuffer(), o = st.signMessage(this.tweakedSigner, n);
|
|
3929
|
+
if (!st.verifySignature(t, n, o.signature)) throw new Error("Could not verify generated legacy signature for MLDSA link request");
|
|
3901
3930
|
return new Uint8Array(o.signature);
|
|
3902
3931
|
}
|
|
3903
3932
|
generateMLDSASignature() {
|
|
3904
3933
|
if (!this.mldsaSigner) throw new Error("MLDSA signer is not defined");
|
|
3905
3934
|
if (this.tweakSigner(), !this.tweakedSigner) throw new Error("Tweaked signer is not defined");
|
|
3906
|
-
const t =
|
|
3935
|
+
const t = O(this.tweakedSigner.publicKey), i = this.signer.publicKey;
|
|
3907
3936
|
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 (!
|
|
3937
|
+
const r = Be(this.network), s = ie(this.mldsaSigner.publicKey.length);
|
|
3938
|
+
if (s !== v.MLDSASecurityLevel.LEVEL2) throw new Error("Only MLDSA level 2 is supported for link requests");
|
|
3939
|
+
const n = new V();
|
|
3940
|
+
n.writeU8(s), n.writeBytes(this.hashedPublicKey), n.writeBytes(this.mldsaSigner.publicKey), n.writeBytes(t), n.writeBytes(i), n.writeBytes(ke), n.writeBytes(r);
|
|
3941
|
+
const o = n.getBuffer(), a = st.signMLDSAMessage(this.mldsaSigner, o);
|
|
3942
|
+
if (!st.verifyMLDSASignature(this.mldsaSigner, o, a.signature)) throw new Error("Could not verify generated MLDSA signature for link request");
|
|
3914
3943
|
return new Uint8Array(a.signature);
|
|
3915
3944
|
}
|
|
3916
3945
|
generateMLDSALinkRequest(t, i) {
|
|
@@ -3919,12 +3948,12 @@ var Ce = new Uint8Array([
|
|
|
3919
3948
|
t.revealMLDSAPublicKey && (n = this.generateMLDSASignature());
|
|
3920
3949
|
const o = {
|
|
3921
3950
|
priority: J.MLDSA_LINK_PUBKEY,
|
|
3922
|
-
opcode:
|
|
3951
|
+
opcode: q.MLDSA_LINK_PUBKEY,
|
|
3923
3952
|
data: {
|
|
3924
3953
|
verifyRequest: !!t.revealMLDSAPublicKey,
|
|
3925
3954
|
publicKey: r.publicKey,
|
|
3926
3955
|
hashedPublicKey: this.hashedPublicKey,
|
|
3927
|
-
level:
|
|
3956
|
+
level: ie(r.publicKey.length),
|
|
3928
3957
|
legacySignature: s,
|
|
3929
3958
|
mldsaSignature: n
|
|
3930
3959
|
}
|
|
@@ -3980,7 +4009,7 @@ var Ce = new Uint8Array([
|
|
|
3980
4009
|
addFeeToOutput(t, i, r, s) {
|
|
3981
4010
|
if (s) {
|
|
3982
4011
|
let n;
|
|
3983
|
-
t >
|
|
4012
|
+
t > 627n ? n = ei : n = t, this.addOutput({
|
|
3984
4013
|
value: L(n),
|
|
3985
4014
|
address: i
|
|
3986
4015
|
}, !0), n === 297n && t - 297n > 330n && this.addOutput({
|
|
@@ -3988,7 +4017,7 @@ var Ce = new Uint8Array([
|
|
|
3988
4017
|
address: r.address
|
|
3989
4018
|
}, !0);
|
|
3990
4019
|
} else {
|
|
3991
|
-
const n = t < 330n ?
|
|
4020
|
+
const n = t < 330n ? Pt : t;
|
|
3992
4021
|
this.addOutput({
|
|
3993
4022
|
value: L(n),
|
|
3994
4023
|
address: r.address
|
|
@@ -4024,13 +4053,13 @@ var Ce = new Uint8Array([
|
|
|
4024
4053
|
return !1;
|
|
4025
4054
|
}
|
|
4026
4055
|
createChangeOutput(t) {
|
|
4027
|
-
if (
|
|
4056
|
+
if (Et.isValidP2TRAddress(this.from, this.network)) return {
|
|
4028
4057
|
value: L(t),
|
|
4029
4058
|
address: this.from,
|
|
4030
4059
|
tapInternalKey: this.internalPubKeyToXOnly()
|
|
4031
4060
|
};
|
|
4032
|
-
if (
|
|
4033
|
-
const i =
|
|
4061
|
+
if (Et.isValidPublicKey(this.from, this.network)) {
|
|
4062
|
+
const i = b.compile([g(this.from.startsWith("0x") ? this.from.slice(2) : this.from), d.OP_CHECKSIG]);
|
|
4034
4063
|
return {
|
|
4035
4064
|
value: L(t),
|
|
4036
4065
|
script: i
|
|
@@ -4040,7 +4069,7 @@ var Ce = new Uint8Array([
|
|
|
4040
4069
|
address: this.from
|
|
4041
4070
|
};
|
|
4042
4071
|
}
|
|
4043
|
-
},
|
|
4072
|
+
}, Kt = class extends B {
|
|
4044
4073
|
type = m.CUSTOM_CODE;
|
|
4045
4074
|
_scriptAddress;
|
|
4046
4075
|
tapLeafScript = null;
|
|
@@ -4057,7 +4086,7 @@ var Ce = new Uint8Array([
|
|
|
4057
4086
|
constructor(e) {
|
|
4058
4087
|
if (super(e), !e.script) throw new Error("Bitcoin script is required");
|
|
4059
4088
|
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
|
|
4089
|
+
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
4090
|
}
|
|
4062
4091
|
get scriptAddress() {
|
|
4063
4092
|
return this._scriptAddress;
|
|
@@ -4072,7 +4101,7 @@ var Ce = new Uint8Array([
|
|
|
4072
4101
|
return this.randomBytes;
|
|
4073
4102
|
}
|
|
4074
4103
|
contractSignerXOnlyPubKey() {
|
|
4075
|
-
return
|
|
4104
|
+
return O(this.contractSigner.publicKey);
|
|
4076
4105
|
}
|
|
4077
4106
|
async buildTransaction() {
|
|
4078
4107
|
this.to || (this.to = this.getScriptAddress());
|
|
@@ -4102,7 +4131,7 @@ var Ce = new Uint8Array([
|
|
|
4102
4131
|
}
|
|
4103
4132
|
e.signInput(0, this.getSignerKey()), e.finalizeInput(0, this.customFinalizer);
|
|
4104
4133
|
const t = /* @__PURE__ */ new Set([0]);
|
|
4105
|
-
if (this.canUseParallelSigning &&
|
|
4134
|
+
if (this.canUseParallelSigning && dt(this.signer)) try {
|
|
4106
4135
|
const i = await this.signKeyPathInputsParallel(e, /* @__PURE__ */ new Set([0]));
|
|
4107
4136
|
if (i.success) for (const r of i.signatures.keys()) t.add(r);
|
|
4108
4137
|
} catch (i) {
|
|
@@ -4119,12 +4148,12 @@ var Ce = new Uint8Array([
|
|
|
4119
4148
|
return this.useP2MR ? {
|
|
4120
4149
|
network: this.network,
|
|
4121
4150
|
scriptTree: this.scriptTree,
|
|
4122
|
-
name:
|
|
4151
|
+
name: E.P2MR
|
|
4123
4152
|
} : {
|
|
4124
4153
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4125
4154
|
network: this.network,
|
|
4126
4155
|
scriptTree: this.scriptTree,
|
|
4127
|
-
name:
|
|
4156
|
+
name: E.P2TR
|
|
4128
4157
|
};
|
|
4129
4158
|
}
|
|
4130
4159
|
generateTapData() {
|
|
@@ -4135,13 +4164,13 @@ var Ce = new Uint8Array([
|
|
|
4135
4164
|
network: this.network,
|
|
4136
4165
|
scriptTree: this.scriptTree,
|
|
4137
4166
|
redeem: e,
|
|
4138
|
-
name:
|
|
4167
|
+
name: E.P2MR
|
|
4139
4168
|
} : {
|
|
4140
4169
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4141
4170
|
network: this.network,
|
|
4142
4171
|
scriptTree: this.scriptTree,
|
|
4143
4172
|
redeem: e,
|
|
4144
|
-
name:
|
|
4173
|
+
name: E.P2TR
|
|
4145
4174
|
};
|
|
4146
4175
|
}
|
|
4147
4176
|
getScriptSolution(e) {
|
|
@@ -4169,11 +4198,11 @@ var Ce = new Uint8Array([
|
|
|
4169
4198
|
};
|
|
4170
4199
|
generateRedeemScripts() {
|
|
4171
4200
|
this.targetScriptRedeem = {
|
|
4172
|
-
name:
|
|
4201
|
+
name: E.P2TR,
|
|
4173
4202
|
output: this.compiledTargetScript,
|
|
4174
4203
|
redeemVersion: 192
|
|
4175
4204
|
}, this.leftOverFundsScriptRedeem = {
|
|
4176
|
-
name:
|
|
4205
|
+
name: E.P2TR,
|
|
4177
4206
|
output: this.getLeafScript(),
|
|
4178
4207
|
redeemVersion: 192
|
|
4179
4208
|
};
|
|
@@ -4190,7 +4219,7 @@ var Ce = new Uint8Array([
|
|
|
4190
4219
|
version: 192
|
|
4191
4220
|
}];
|
|
4192
4221
|
}
|
|
4193
|
-
},
|
|
4222
|
+
}, ye = class extends B {
|
|
4194
4223
|
static MAXIMUM_CALLDATA_SIZE = 380 * 1024;
|
|
4195
4224
|
randomBytes;
|
|
4196
4225
|
targetScriptRedeem = null;
|
|
@@ -4204,7 +4233,7 @@ var Ce = new Uint8Array([
|
|
|
4204
4233
|
constructor(e) {
|
|
4205
4234
|
if (super(e), !e.calldata) throw new Error("Calldata is required");
|
|
4206
4235
|
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
|
|
4236
|
+
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
4237
|
}
|
|
4209
4238
|
exportCompiledTargetScript() {
|
|
4210
4239
|
return this.compiledTargetScript;
|
|
@@ -4219,7 +4248,7 @@ var Ce = new Uint8Array([
|
|
|
4219
4248
|
return this.challenge;
|
|
4220
4249
|
}
|
|
4221
4250
|
scriptSignerXOnlyPubKey() {
|
|
4222
|
-
return
|
|
4251
|
+
return O(this.scriptSigner.publicKey);
|
|
4223
4252
|
}
|
|
4224
4253
|
generateKeyPairFromSeed() {
|
|
4225
4254
|
return I.fromSeedKeyPair(this.randomBytes, this.network);
|
|
@@ -4246,12 +4275,12 @@ var Ce = new Uint8Array([
|
|
|
4246
4275
|
return this.useP2MR ? {
|
|
4247
4276
|
network: this.network,
|
|
4248
4277
|
scriptTree: this.scriptTree,
|
|
4249
|
-
name:
|
|
4278
|
+
name: E.P2MR
|
|
4250
4279
|
} : {
|
|
4251
4280
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4252
4281
|
network: this.network,
|
|
4253
4282
|
scriptTree: this.scriptTree,
|
|
4254
|
-
name:
|
|
4283
|
+
name: E.P2TR
|
|
4255
4284
|
};
|
|
4256
4285
|
}
|
|
4257
4286
|
generateTapData() {
|
|
@@ -4262,13 +4291,13 @@ var Ce = new Uint8Array([
|
|
|
4262
4291
|
network: this.network,
|
|
4263
4292
|
scriptTree: this.scriptTree,
|
|
4264
4293
|
redeem: e,
|
|
4265
|
-
name:
|
|
4294
|
+
name: E.P2MR
|
|
4266
4295
|
} : {
|
|
4267
4296
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4268
4297
|
network: this.network,
|
|
4269
4298
|
scriptTree: this.scriptTree,
|
|
4270
4299
|
redeem: e,
|
|
4271
|
-
name:
|
|
4300
|
+
name: E.P2TR
|
|
4272
4301
|
};
|
|
4273
4302
|
}
|
|
4274
4303
|
getScriptSolution(e) {
|
|
@@ -4306,7 +4335,7 @@ var Ce = new Uint8Array([
|
|
|
4306
4335
|
}
|
|
4307
4336
|
}
|
|
4308
4337
|
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 &&
|
|
4338
|
+
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
4339
|
let t = /* @__PURE__ */ new Set();
|
|
4311
4340
|
try {
|
|
4312
4341
|
const i = await this.signKeyPathInputsParallel(e, /* @__PURE__ */ new Set([0]));
|
|
@@ -4327,21 +4356,21 @@ var Ce = new Uint8Array([
|
|
|
4327
4356
|
if (!this.to) throw new Error("To address is required");
|
|
4328
4357
|
const e = this.getTransactionOPNetFee();
|
|
4329
4358
|
this.addFeeToOutput(e, this.to, this.epochChallenge, !1);
|
|
4330
|
-
const t = e < 330n ?
|
|
4359
|
+
const t = e < 330n ? Pt : e, i = this.addOptionalOutputsAndGetAmount();
|
|
4331
4360
|
this.disableAutoRefund || await this.addRefundOutput(t + i);
|
|
4332
4361
|
}
|
|
4333
4362
|
generateRedeemScripts() {
|
|
4334
4363
|
this.targetScriptRedeem = {
|
|
4335
|
-
name:
|
|
4364
|
+
name: E.P2TR,
|
|
4336
4365
|
output: this.compiledTargetScript,
|
|
4337
4366
|
redeemVersion: 192
|
|
4338
4367
|
}, this.leftOverFundsScriptRedeem = {
|
|
4339
|
-
name:
|
|
4368
|
+
name: E.P2TR,
|
|
4340
4369
|
output: this.LOCK_LEAF_SCRIPT,
|
|
4341
4370
|
redeemVersion: 192
|
|
4342
4371
|
};
|
|
4343
4372
|
}
|
|
4344
|
-
},
|
|
4373
|
+
}, Dt = class ii extends B {
|
|
4345
4374
|
static MAXIMUM_CONTRACT_SIZE = 1536 * 1024;
|
|
4346
4375
|
type = m.DEPLOYMENT;
|
|
4347
4376
|
challenge;
|
|
@@ -4363,12 +4392,12 @@ var Ce = new Uint8Array([
|
|
|
4363
4392
|
_computedAddress;
|
|
4364
4393
|
constructor(t) {
|
|
4365
4394
|
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
|
|
4395
|
+
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");
|
|
4396
|
+
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
4397
|
else if (typeof t.compiledTargetScript == "string") this.compiledTargetScript = g(t.compiledTargetScript);
|
|
4369
4398
|
else throw new Error("Invalid compiled target script format.");
|
|
4370
4399
|
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
|
|
4400
|
+
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + f(this.contractSeed), this._contractAddress = new z(this.contractSeed);
|
|
4372
4401
|
}
|
|
4373
4402
|
get contractPubKey() {
|
|
4374
4403
|
return this._contractPubKey;
|
|
@@ -4392,7 +4421,7 @@ var Ce = new Uint8Array([
|
|
|
4392
4421
|
return this._computedAddress ? this._computedAddress : (this._computedAddress = I.p2op(this.contractSeed, this.network, this.deploymentVersion), this._computedAddress);
|
|
4393
4422
|
}
|
|
4394
4423
|
contractSignerXOnlyPubKey() {
|
|
4395
|
-
return
|
|
4424
|
+
return O(this.contractSigner.publicKey);
|
|
4396
4425
|
}
|
|
4397
4426
|
async buildTransaction() {
|
|
4398
4427
|
this.to || (this.to = this.getScriptAddress());
|
|
@@ -4429,7 +4458,7 @@ var Ce = new Uint8Array([
|
|
|
4429
4458
|
}
|
|
4430
4459
|
t.signInput(0, this.contractSigner), t.signInput(0, this.getSignerKey()), t.finalizeInput(0, this.customFinalizer.bind(this));
|
|
4431
4460
|
const i = /* @__PURE__ */ new Set([0]);
|
|
4432
|
-
if (this.canUseParallelSigning &&
|
|
4461
|
+
if (this.canUseParallelSigning && dt(this.signer)) try {
|
|
4433
4462
|
const r = await this.signKeyPathInputsParallel(t, /* @__PURE__ */ new Set([0]));
|
|
4434
4463
|
if (r.success) for (const s of r.signatures.keys()) i.add(s);
|
|
4435
4464
|
} catch (r) {
|
|
@@ -4444,11 +4473,11 @@ var Ce = new Uint8Array([
|
|
|
4444
4473
|
}
|
|
4445
4474
|
generateScriptAddress() {
|
|
4446
4475
|
return this.useP2MR ? {
|
|
4447
|
-
name:
|
|
4476
|
+
name: E.P2MR,
|
|
4448
4477
|
network: this.network,
|
|
4449
4478
|
scriptTree: this.scriptTree
|
|
4450
4479
|
} : {
|
|
4451
|
-
name:
|
|
4480
|
+
name: E.P2TR,
|
|
4452
4481
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4453
4482
|
network: this.network,
|
|
4454
4483
|
scriptTree: this.scriptTree
|
|
@@ -4459,12 +4488,12 @@ var Ce = new Uint8Array([
|
|
|
4459
4488
|
if (!t) throw new Error("Left over funds script redeem is required");
|
|
4460
4489
|
if (!this.scriptTree) throw new Error("Script tree is required");
|
|
4461
4490
|
return this.useP2MR ? {
|
|
4462
|
-
name:
|
|
4491
|
+
name: E.P2MR,
|
|
4463
4492
|
network: this.network,
|
|
4464
4493
|
scriptTree: this.scriptTree,
|
|
4465
4494
|
redeem: t
|
|
4466
4495
|
} : {
|
|
4467
|
-
name:
|
|
4496
|
+
name: E.P2TR,
|
|
4468
4497
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4469
4498
|
network: this.network,
|
|
4470
4499
|
scriptTree: this.scriptTree,
|
|
@@ -4475,21 +4504,21 @@ var Ce = new Uint8Array([
|
|
|
4475
4504
|
const i = [], r = t.challenge.getSubmission();
|
|
4476
4505
|
if (r && i.push({
|
|
4477
4506
|
priority: J.MLDSA_LINK_PUBKEY,
|
|
4478
|
-
opcode:
|
|
4507
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
4479
4508
|
data: r
|
|
4480
4509
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress) throw new Error("To reveal the MLDSA public key, you must set linkMLDSAPublicKeyToAddress to true.");
|
|
4481
4510
|
return t.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(t, i), i;
|
|
4482
4511
|
}
|
|
4483
4512
|
verifyCalldata() {
|
|
4484
|
-
if (this.calldata && this.calldata.length >
|
|
4513
|
+
if (this.calldata && this.calldata.length > ye.MAXIMUM_CALLDATA_SIZE) throw new Error("Calldata size overflow.");
|
|
4485
4514
|
}
|
|
4486
4515
|
verifyBytecode() {
|
|
4487
4516
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
4488
|
-
if (this.bytecode.length >
|
|
4517
|
+
if (this.bytecode.length > ii.MAXIMUM_CONTRACT_SIZE) throw new Error("Contract size overflow.");
|
|
4489
4518
|
}
|
|
4490
4519
|
getContractSeed() {
|
|
4491
4520
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
4492
|
-
const t =
|
|
4521
|
+
const t = ht([
|
|
4493
4522
|
this.internalPubKeyToXOnly(),
|
|
4494
4523
|
D.hash256(this.randomBytes),
|
|
4495
4524
|
D.hash256(this.bytecode)
|
|
@@ -4508,11 +4537,11 @@ var Ce = new Uint8Array([
|
|
|
4508
4537
|
};
|
|
4509
4538
|
generateRedeemScripts() {
|
|
4510
4539
|
this.targetScriptRedeem = {
|
|
4511
|
-
name:
|
|
4540
|
+
name: E.P2TR,
|
|
4512
4541
|
output: this.compiledTargetScript,
|
|
4513
4542
|
redeemVersion: 192
|
|
4514
4543
|
}, this.leftOverFundsScriptRedeem = {
|
|
4515
|
-
name:
|
|
4544
|
+
name: E.P2TR,
|
|
4516
4545
|
output: this.getLeafScript(),
|
|
4517
4546
|
redeemVersion: 192
|
|
4518
4547
|
};
|
|
@@ -4530,7 +4559,7 @@ var Ce = new Uint8Array([
|
|
|
4530
4559
|
version: 192
|
|
4531
4560
|
}];
|
|
4532
4561
|
}
|
|
4533
|
-
},
|
|
4562
|
+
}, Mt = class extends B {
|
|
4534
4563
|
type = m.FUNDING;
|
|
4535
4564
|
amount;
|
|
4536
4565
|
splitInputsInto;
|
|
@@ -4544,28 +4573,30 @@ var Ce = new Uint8Array([
|
|
|
4544
4573
|
}
|
|
4545
4574
|
async buildTransaction() {
|
|
4546
4575
|
if (!this.to) throw new Error("Recipient address is required");
|
|
4547
|
-
if (this.addInputsFromUTXO(), this.autoAdjustAmount
|
|
4576
|
+
if (this.addInputsFromUTXO(), this.autoAdjustAmount) {
|
|
4548
4577
|
const t = this.splitInputsInto > 1 ? this.splitInputsInto : 1, i = this.amount / BigInt(t);
|
|
4549
|
-
for (let
|
|
4550
|
-
const
|
|
4578
|
+
for (let n = 0; n < t; n++) if (this.isPubKeyDestination) {
|
|
4579
|
+
const o = this.to.startsWith("0x") ? this.to.slice(2) : this.to, a = b.compile([g(o), d.OP_CHECKSIG]);
|
|
4551
4580
|
this.addOutput({
|
|
4552
4581
|
value: L(i),
|
|
4553
|
-
script:
|
|
4582
|
+
script: a
|
|
4554
4583
|
});
|
|
4555
4584
|
} else this.addOutput({
|
|
4556
4585
|
value: L(i),
|
|
4557
4586
|
address: this.to
|
|
4558
4587
|
});
|
|
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
|
-
|
|
4588
|
+
this.note && this.addOPReturn(this.note), this.anchor && this.addAnchor();
|
|
4589
|
+
const r = await this.estimateTransactionFees(), s = t + (this.note ? 1 : 0) + (this.anchor ? 1 : 0);
|
|
4590
|
+
for (let n = 0; n < s; n++) this.outputs.pop();
|
|
4591
|
+
if (this.amount + r > this.totalInputAmount) {
|
|
4592
|
+
const n = this.totalInputAmount - r;
|
|
4593
|
+
if (n < B.MINIMUM_DUST) throw new Error(`Insufficient funds: after deducting fee of ${r} sats, remaining amount ${n} sats is below minimum dust`);
|
|
4594
|
+
this.amount = n;
|
|
4595
|
+
}
|
|
4565
4596
|
}
|
|
4566
4597
|
if (this.splitInputsInto > 1) this.splitInputs(this.amount);
|
|
4567
4598
|
else if (this.isPubKeyDestination) {
|
|
4568
|
-
const t = this.to.startsWith("0x") ? this.to.slice(2) : this.to, i =
|
|
4599
|
+
const t = this.to.startsWith("0x") ? this.to.slice(2) : this.to, i = b.compile([g(t), d.OP_CHECKSIG]);
|
|
4569
4600
|
this.addOutput({
|
|
4570
4601
|
value: L(this.amount),
|
|
4571
4602
|
script: i
|
|
@@ -4591,7 +4622,7 @@ var Ce = new Uint8Array([
|
|
|
4591
4622
|
getSignerKey() {
|
|
4592
4623
|
return this.signer;
|
|
4593
4624
|
}
|
|
4594
|
-
},
|
|
4625
|
+
}, Nt = class extends ye {
|
|
4595
4626
|
type = m.INTERACTION;
|
|
4596
4627
|
compiledTargetScript;
|
|
4597
4628
|
scriptTree;
|
|
@@ -4610,18 +4641,18 @@ var Ce = new Uint8Array([
|
|
|
4610
4641
|
const t = [];
|
|
4611
4642
|
e.loadedStorage && t.push({
|
|
4612
4643
|
priority: J.ACCESS_LIST,
|
|
4613
|
-
opcode:
|
|
4644
|
+
opcode: q.ACCESS_LIST,
|
|
4614
4645
|
data: e.loadedStorage
|
|
4615
4646
|
});
|
|
4616
4647
|
const i = e.challenge.getSubmission();
|
|
4617
4648
|
if (i && t.push({
|
|
4618
4649
|
priority: J.EPOCH_SUBMISSION,
|
|
4619
|
-
opcode:
|
|
4650
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
4620
4651
|
data: i
|
|
4621
4652
|
}), e.revealMLDSAPublicKey && !e.linkMLDSAPublicKeyToAddress) throw new Error("To reveal the MLDSA public key, you must set linkMLDSAPublicKeyToAddress to true.");
|
|
4622
4653
|
return e.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(e, t), t;
|
|
4623
4654
|
}
|
|
4624
|
-
},
|
|
4655
|
+
}, ri = class lt extends B {
|
|
4625
4656
|
static MAX_WITNESS_FIELDS = 10;
|
|
4626
4657
|
static MAX_BYTES_PER_WITNESS = 80;
|
|
4627
4658
|
type = m.INTERACTION;
|
|
@@ -4640,7 +4671,7 @@ var Ce = new Uint8Array([
|
|
|
4640
4671
|
if (!t.contract) throw new Error("Contract secret is required");
|
|
4641
4672
|
if (!t.calldata) throw new Error("Calldata is required");
|
|
4642
4673
|
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
|
|
4674
|
+
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
4675
|
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
4676
|
else if (typeof t.compiledTargetScript == "string") this.compiledOperationData = g(t.compiledTargetScript);
|
|
4646
4677
|
else throw new Error("Invalid compiled target script format.");
|
|
@@ -4675,13 +4706,13 @@ var Ce = new Uint8Array([
|
|
|
4675
4706
|
const i = [];
|
|
4676
4707
|
t.loadedStorage && i.push({
|
|
4677
4708
|
priority: J.ACCESS_LIST,
|
|
4678
|
-
opcode:
|
|
4709
|
+
opcode: q.ACCESS_LIST,
|
|
4679
4710
|
data: t.loadedStorage
|
|
4680
4711
|
});
|
|
4681
4712
|
const r = t.challenge.getSubmission();
|
|
4682
4713
|
return r && i.push({
|
|
4683
4714
|
priority: J.EPOCH_SUBMISSION,
|
|
4684
|
-
opcode:
|
|
4715
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
4685
4716
|
data: r
|
|
4686
4717
|
}), i;
|
|
4687
4718
|
}
|
|
@@ -4689,32 +4720,32 @@ var Ce = new Uint8Array([
|
|
|
4689
4720
|
return I.fromSeedKeyPair(this.randomBytes, this.network);
|
|
4690
4721
|
}
|
|
4691
4722
|
scriptSignerXOnlyPubKey() {
|
|
4692
|
-
return
|
|
4723
|
+
return O(this.scriptSigner.publicKey);
|
|
4693
4724
|
}
|
|
4694
4725
|
validateP2WDAInputs() {
|
|
4695
|
-
if (this.utxos.length === 0 ||
|
|
4696
|
-
for (let t = 0; t < this.utxos.length; t++)
|
|
4726
|
+
if (this.utxos.length === 0 || !X.isP2WDAUTXO(this.utxos[0])) throw new Error("Input 0 must be a P2WDA UTXO");
|
|
4727
|
+
for (let t = 0; t < this.utxos.length; t++) X.isP2WDAUTXO(this.utxos[t]) && this.p2wdaInputIndices.add(t);
|
|
4697
4728
|
for (let t = 0; t < this.optionalInputs.length; t++) {
|
|
4698
4729
|
const i = this.utxos.length + t;
|
|
4699
|
-
|
|
4730
|
+
X.isP2WDAUTXO(this.optionalInputs[t]) && this.p2wdaInputIndices.add(i);
|
|
4700
4731
|
}
|
|
4701
4732
|
}
|
|
4702
4733
|
validateOperationDataSize() {
|
|
4703
4734
|
if (!this.compiledOperationData) throw new Error("Operation data not compiled");
|
|
4704
4735
|
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 ${
|
|
4736
|
+
if (!Jt.validateWitnessSize(t)) {
|
|
4737
|
+
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(r / lt.MAX_BYTES_PER_WITNESS);
|
|
4738
|
+
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
4739
|
}
|
|
4709
4740
|
}
|
|
4710
4741
|
finalizePrimaryP2WDA(t, i) {
|
|
4711
4742
|
if (!i.partialSig || i.partialSig.length === 0) throw new Error(`No signature for P2WDA input #${t}`);
|
|
4712
4743
|
if (!i.witnessScript) throw new Error(`No witness script for P2WDA input #${t}`);
|
|
4713
4744
|
if (!this.compiledOperationData) throw new Error("Operation data not compiled");
|
|
4714
|
-
const r = i.partialSig[0].signature, s =
|
|
4715
|
-
if (c.length >
|
|
4745
|
+
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);
|
|
4746
|
+
if (c.length > lt.MAX_WITNESS_FIELDS) throw new Error(`Compressed data needs ${c.length} witness fields, max is ${lt.MAX_WITNESS_FIELDS}`);
|
|
4716
4747
|
const u = [r];
|
|
4717
|
-
for (let l = 0; l <
|
|
4748
|
+
for (let l = 0; l < lt.MAX_WITNESS_FIELDS; l++) u.push(l < c.length ? c[l] : new Uint8Array(0));
|
|
4718
4749
|
return u.push(i.witnessScript), {
|
|
4719
4750
|
finalScriptSig: void 0,
|
|
4720
4751
|
finalScriptWitness: B.witnessStackToScriptWitness(u)
|
|
@@ -4724,12 +4755,12 @@ var Ce = new Uint8Array([
|
|
|
4724
4755
|
const i = [];
|
|
4725
4756
|
let r = 0;
|
|
4726
4757
|
for (; r < t.length; ) {
|
|
4727
|
-
const s = Math.min(
|
|
4758
|
+
const s = Math.min(lt.MAX_BYTES_PER_WITNESS, t.length - r);
|
|
4728
4759
|
i.push(t.slice(r, r + s)), r += s;
|
|
4729
4760
|
}
|
|
4730
4761
|
return i;
|
|
4731
4762
|
}
|
|
4732
|
-
},
|
|
4763
|
+
}, me = class extends B {
|
|
4733
4764
|
type = m.CANCEL;
|
|
4734
4765
|
tapLeafScript = null;
|
|
4735
4766
|
compiledTargetScript;
|
|
@@ -4760,12 +4791,12 @@ var Ce = new Uint8Array([
|
|
|
4760
4791
|
return this.useP2MR ? {
|
|
4761
4792
|
network: this.network,
|
|
4762
4793
|
scriptTree: this.scriptTree,
|
|
4763
|
-
name:
|
|
4794
|
+
name: E.P2MR
|
|
4764
4795
|
} : {
|
|
4765
4796
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4766
4797
|
network: this.network,
|
|
4767
4798
|
scriptTree: this.scriptTree,
|
|
4768
|
-
name:
|
|
4799
|
+
name: E.P2TR
|
|
4769
4800
|
};
|
|
4770
4801
|
}
|
|
4771
4802
|
generateTapData() {
|
|
@@ -4776,13 +4807,13 @@ var Ce = new Uint8Array([
|
|
|
4776
4807
|
network: this.network,
|
|
4777
4808
|
scriptTree: this.scriptTree,
|
|
4778
4809
|
redeem: e,
|
|
4779
|
-
name:
|
|
4810
|
+
name: E.P2MR
|
|
4780
4811
|
} : {
|
|
4781
4812
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4782
4813
|
network: this.network,
|
|
4783
4814
|
scriptTree: this.scriptTree,
|
|
4784
4815
|
redeem: e,
|
|
4785
|
-
name:
|
|
4816
|
+
name: E.P2TR
|
|
4786
4817
|
};
|
|
4787
4818
|
}
|
|
4788
4819
|
customFinalizer = (e, t) => {
|
|
@@ -4806,7 +4837,7 @@ var Ce = new Uint8Array([
|
|
|
4806
4837
|
async signInputsNonWalletBased(e) {
|
|
4807
4838
|
await this.signInput(e, e.data.inputs[0], 0, this.getSignerKey()), e.finalizeInput(0, this.customFinalizer.bind(this));
|
|
4808
4839
|
let t = /* @__PURE__ */ new Set();
|
|
4809
|
-
if (this.canUseParallelSigning &&
|
|
4840
|
+
if (this.canUseParallelSigning && dt(this.signer)) try {
|
|
4810
4841
|
const i = await this.signKeyPathInputsParallel(e, /* @__PURE__ */ new Set([0]));
|
|
4811
4842
|
i.success && (t = new Set(i.signatures.keys()));
|
|
4812
4843
|
} catch (i) {
|
|
@@ -4831,12 +4862,12 @@ var Ce = new Uint8Array([
|
|
|
4831
4862
|
}
|
|
4832
4863
|
generateLeftoverFundsRedeem() {
|
|
4833
4864
|
this.leftOverFundsScriptRedeem = {
|
|
4834
|
-
name:
|
|
4865
|
+
name: E.P2TR,
|
|
4835
4866
|
output: this.LOCK_LEAF_SCRIPT,
|
|
4836
4867
|
redeemVersion: 192
|
|
4837
4868
|
};
|
|
4838
4869
|
}
|
|
4839
|
-
},
|
|
4870
|
+
}, si = class extends B {
|
|
4840
4871
|
type = m.INTERACTION;
|
|
4841
4872
|
randomBytes;
|
|
4842
4873
|
contractAddress;
|
|
@@ -4857,12 +4888,12 @@ var Ce = new Uint8Array([
|
|
|
4857
4888
|
if (!e.contract) throw new Error("Contract secret (contract) is required");
|
|
4858
4889
|
if (!e.calldata) throw new Error("Calldata is required");
|
|
4859
4890
|
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
|
|
4891
|
+
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.");
|
|
4892
|
+
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
4893
|
else if (typeof e.compiledTargetScript == "string") this.compiledTargetScript = g(e.compiledTargetScript);
|
|
4863
4894
|
else throw new Error("Invalid compiled target script format.");
|
|
4864
4895
|
else this.compiledTargetScript = this.calldataGenerator.compile(this.calldata, this.contractSecret, this.challenge, this.priorityFee, this.generateFeatures(e));
|
|
4865
|
-
this.hashCommitmentGenerator = new
|
|
4896
|
+
this.hashCommitmentGenerator = new St(this.signer.publicKey, this.network), this.commitmentOutputs = this.hashCommitmentGenerator.prepareChunks(this.compiledTargetScript, this.maxChunkSize), this.validateOutputCount();
|
|
4866
4897
|
const t = this.commitmentOutputs.reduce((i, r) => i + r.dataChunks.length, 0);
|
|
4867
4898
|
this.log(`ConsolidatedInteractionTransaction: ${this.commitmentOutputs.length} outputs, ${t} chunks from ${this.compiledTargetScript.length} bytes compiled data`), this.internalInit();
|
|
4868
4899
|
}
|
|
@@ -4905,7 +4936,7 @@ var Ce = new Uint8Array([
|
|
|
4905
4936
|
};
|
|
4906
4937
|
}
|
|
4907
4938
|
buildRevealTransaction(e) {
|
|
4908
|
-
const t = new
|
|
4939
|
+
const t = new N({ network: this.network }), i = this.calculateValuePerOutput();
|
|
4909
4940
|
for (let h = 0; h < this.commitmentOutputs.length; h++) {
|
|
4910
4941
|
const p = this.commitmentOutputs[h];
|
|
4911
4942
|
t.addInput({
|
|
@@ -4918,7 +4949,7 @@ var Ce = new Uint8Array([
|
|
|
4918
4949
|
witnessScript: p.witnessScript
|
|
4919
4950
|
});
|
|
4920
4951
|
}
|
|
4921
|
-
const r = BigInt(this.commitmentOutputs.length) * i, s = this.getTransactionOPNetFee(), n = s < 330n ?
|
|
4952
|
+
const r = BigInt(this.commitmentOutputs.length) * i, s = this.getTransactionOPNetFee(), n = s < 330n ? Pt : s;
|
|
4922
4953
|
t.addOutput({
|
|
4923
4954
|
address: this.epochChallenge.address,
|
|
4924
4955
|
value: L(n)
|
|
@@ -4982,35 +5013,35 @@ var Ce = new Uint8Array([
|
|
|
4982
5013
|
}
|
|
4983
5014
|
calculateValuePerOutput() {
|
|
4984
5015
|
if (this.cachedValuePerOutput !== null) return this.cachedValuePerOutput;
|
|
4985
|
-
const e = this.commitmentOutputs.length, t = this.getTransactionOPNetFee(), i = t < 330n ?
|
|
5016
|
+
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
5017
|
return this.cachedValuePerOutput = n > o ? n : o, this.cachedValuePerOutput;
|
|
4987
5018
|
}
|
|
4988
5019
|
getRefundAddress() {
|
|
4989
|
-
return this.from ? this.from :
|
|
5020
|
+
return this.from ? this.from : de.generatePKSH(this.signer.publicKey, this.network);
|
|
4990
5021
|
}
|
|
4991
5022
|
generateFeatures(e) {
|
|
4992
5023
|
const t = [];
|
|
4993
5024
|
e.loadedStorage && t.push({
|
|
4994
5025
|
priority: J.ACCESS_LIST,
|
|
4995
|
-
opcode:
|
|
5026
|
+
opcode: q.ACCESS_LIST,
|
|
4996
5027
|
data: e.loadedStorage
|
|
4997
5028
|
});
|
|
4998
5029
|
const i = e.challenge.getSubmission();
|
|
4999
5030
|
if (i && t.push({
|
|
5000
5031
|
priority: J.EPOCH_SUBMISSION,
|
|
5001
|
-
opcode:
|
|
5032
|
+
opcode: q.EPOCH_SUBMISSION,
|
|
5002
5033
|
data: i
|
|
5003
5034
|
}), e.revealMLDSAPublicKey && !e.linkMLDSAPublicKeyToAddress) throw new Error("To reveal the MLDSA public key, you must set linkMLDSAPublicKeyToAddress to true.");
|
|
5004
5035
|
return e.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(e, t), t;
|
|
5005
5036
|
}
|
|
5006
5037
|
validateOutputCount() {
|
|
5007
|
-
const e =
|
|
5038
|
+
const e = St.calculateMaxInputsPerTx();
|
|
5008
5039
|
if (this.commitmentOutputs.length > e) {
|
|
5009
|
-
const t =
|
|
5040
|
+
const t = St.calculateMaxDataPerTx();
|
|
5010
5041
|
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
5042
|
}
|
|
5012
5043
|
}
|
|
5013
|
-
},
|
|
5044
|
+
}, ni = class {
|
|
5014
5045
|
debug = !1;
|
|
5015
5046
|
DUMMY_PUBKEY = new Uint8Array(32).fill(1);
|
|
5016
5047
|
P2TR_SCRIPT = Uint8Array.from([
|
|
@@ -5027,7 +5058,7 @@ var Ce = new Uint8Array([
|
|
|
5027
5058
|
const t = await this.detectCancelOPWallet(e);
|
|
5028
5059
|
if (t) return t;
|
|
5029
5060
|
if (!("signer" in e)) throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
5030
|
-
const i = await new
|
|
5061
|
+
const i = await new me(e).signTransaction();
|
|
5031
5062
|
return {
|
|
5032
5063
|
transaction: i.toHex(),
|
|
5033
5064
|
nextUTXOs: this.getUTXOAsTransaction(i, e.from, 0),
|
|
@@ -5042,7 +5073,7 @@ var Ce = new Uint8Array([
|
|
|
5042
5073
|
const t = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: i, estimatedAmount: r } = await this.iterateFundingAmount({
|
|
5043
5074
|
...e,
|
|
5044
5075
|
optionalInputs: t
|
|
5045
|
-
},
|
|
5076
|
+
}, Kt, async (c) => {
|
|
5046
5077
|
const u = await c.estimateTransactionFees(), l = this.getPriorityFee(e), h = c.getOptionalOutputValue();
|
|
5047
5078
|
return u + l + h;
|
|
5048
5079
|
}, "CustomScript"), s = await i.getFundingTransactionParameters();
|
|
@@ -5060,7 +5091,7 @@ var Ce = new Uint8Array([
|
|
|
5060
5091
|
optionalInputs: []
|
|
5061
5092
|
});
|
|
5062
5093
|
if (!o) throw new Error("Could not sign funding transaction.");
|
|
5063
|
-
const a = await new
|
|
5094
|
+
const a = await new Kt({
|
|
5064
5095
|
...e,
|
|
5065
5096
|
utxos: this.getUTXOAsTransaction(o.tx, e.to, 0),
|
|
5066
5097
|
randomBytes: i.getRndBytes(),
|
|
@@ -5087,7 +5118,7 @@ var Ce = new Uint8Array([
|
|
|
5087
5118
|
const i = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: n } = await this.iterateFundingAmount({
|
|
5088
5119
|
...e,
|
|
5089
5120
|
optionalInputs: i
|
|
5090
|
-
},
|
|
5121
|
+
}, Nt, async (p) => {
|
|
5091
5122
|
const w = await p.estimateTransactionFees() + p.getTotalOutputValue();
|
|
5092
5123
|
if (e.subtractExtraUTXOFromAmountRequired && e.optionalInputs && e.optionalInputs.length > 0) {
|
|
5093
5124
|
const T = e.optionalInputs.reduce((k, x) => k + x.value, 0n), A = w > T ? w - T : 0n;
|
|
@@ -5111,7 +5142,7 @@ var Ce = new Uint8Array([
|
|
|
5111
5142
|
optionalInputs: []
|
|
5112
5143
|
});
|
|
5113
5144
|
if (!c) throw new Error("Could not sign funding transaction.");
|
|
5114
|
-
const u = this.getUTXOAsTransaction(c.tx, r.getScriptAddress(), 0), l = new
|
|
5145
|
+
const u = this.getUTXOAsTransaction(c.tx, r.getScriptAddress(), 0), l = new Nt({
|
|
5115
5146
|
...e,
|
|
5116
5147
|
utxos: u,
|
|
5117
5148
|
randomBytes: r.getRndBytes(),
|
|
@@ -5139,7 +5170,7 @@ var Ce = new Uint8Array([
|
|
|
5139
5170
|
if (!e.utxos[0]) throw new Error("Missing at least one UTXO.");
|
|
5140
5171
|
if (!("signer" in e)) throw new Error('Field "signer" not provided.');
|
|
5141
5172
|
if (!e.challenge) throw new Error('Field "challenge" not provided.');
|
|
5142
|
-
const t = this.parseOptionalInputs(e.optionalInputs), i = new
|
|
5173
|
+
const t = this.parseOptionalInputs(e.optionalInputs), i = new si({
|
|
5143
5174
|
...e,
|
|
5144
5175
|
optionalInputs: t
|
|
5145
5176
|
}), r = await i.build();
|
|
@@ -5163,7 +5194,7 @@ var Ce = new Uint8Array([
|
|
|
5163
5194
|
const i = this.parseOptionalInputs(e.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: n } = await this.iterateFundingAmount({
|
|
5164
5195
|
...e,
|
|
5165
5196
|
optionalInputs: i
|
|
5166
|
-
},
|
|
5197
|
+
}, Dt, async (A) => {
|
|
5167
5198
|
const k = await A.estimateTransactionFees(), x = this.getPriorityFee(e), yt = A.getOptionalOutputValue();
|
|
5168
5199
|
return k + x + yt;
|
|
5169
5200
|
}, "Deployment");
|
|
@@ -5177,7 +5208,7 @@ var Ce = new Uint8Array([
|
|
|
5177
5208
|
});
|
|
5178
5209
|
if (!a) throw new Error("Could not sign funding transaction.");
|
|
5179
5210
|
o.estimatedFees = a.estimatedFees;
|
|
5180
|
-
const c = await new
|
|
5211
|
+
const c = await new Mt({
|
|
5181
5212
|
...o,
|
|
5182
5213
|
optionalInputs: [],
|
|
5183
5214
|
optionalOutputs: []
|
|
@@ -5191,7 +5222,7 @@ var Ce = new Uint8Array([
|
|
|
5191
5222
|
address: r.getScriptAddress()
|
|
5192
5223
|
},
|
|
5193
5224
|
value: BigInt(u.value)
|
|
5194
|
-
}, h = new
|
|
5225
|
+
}, h = new Dt({
|
|
5195
5226
|
...e,
|
|
5196
5227
|
utxos: [l],
|
|
5197
5228
|
randomBytes: r.getRndBytes(),
|
|
@@ -5229,7 +5260,7 @@ var Ce = new Uint8Array([
|
|
|
5229
5260
|
estimatedFees: i.estimatedFees,
|
|
5230
5261
|
tx: i.tx.toHex(),
|
|
5231
5262
|
nextUTXOs: this.getAllNewUTXOs(i.original, i.tx, e.from),
|
|
5232
|
-
inputUtxos: e.utxos
|
|
5263
|
+
inputUtxos: [...e.utxos, ...e.feeUtxos ?? []]
|
|
5233
5264
|
};
|
|
5234
5265
|
}
|
|
5235
5266
|
getAllNewUTXOs(e, t, i) {
|
|
@@ -5310,7 +5341,7 @@ var Ce = new Uint8Array([
|
|
|
5310
5341
|
}
|
|
5311
5342
|
async createFundTransaction(e) {
|
|
5312
5343
|
if (!e.to) throw new Error('Field "to" not provided.');
|
|
5313
|
-
const t = new
|
|
5344
|
+
const t = new Mt(e), i = await t.signTransaction();
|
|
5314
5345
|
if (!i) throw new Error("Could not sign funding transaction.");
|
|
5315
5346
|
return {
|
|
5316
5347
|
tx: i,
|
|
@@ -5321,12 +5352,12 @@ var Ce = new Uint8Array([
|
|
|
5321
5352
|
};
|
|
5322
5353
|
}
|
|
5323
5354
|
hasP2WDAInputs(e) {
|
|
5324
|
-
return e.some((t) =>
|
|
5355
|
+
return e.some((t) => X.isP2WDAUTXO(t));
|
|
5325
5356
|
}
|
|
5326
5357
|
async signP2WDAInteraction(e) {
|
|
5327
5358
|
if (!e.from) throw new Error('Field "from" not provided.');
|
|
5328
5359
|
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
|
|
5360
|
+
const t = this.parseOptionalInputs(e.optionalInputs), i = new ri({
|
|
5330
5361
|
...e,
|
|
5331
5362
|
optionalInputs: t
|
|
5332
5363
|
}), r = await i.signTransaction();
|
|
@@ -5347,11 +5378,11 @@ var Ce = new Uint8Array([
|
|
|
5347
5378
|
return t < B.MINIMUM_DUST ? B.MINIMUM_DUST : t;
|
|
5348
5379
|
}
|
|
5349
5380
|
async iterateFundingAmount(e, t, i, r) {
|
|
5350
|
-
const s = "randomBytes" in e ? e.randomBytes ?? W.rndBytes() : W.rndBytes(), n =
|
|
5381
|
+
const s = "randomBytes" in e ? e.randomBytes ?? W.rndBytes() : W.rndBytes(), n = z.dead().p2tr(e.network);
|
|
5351
5382
|
let o = this.INITIAL_FUNDING_ESTIMATE, a = 0n, c = 0, u = null, l = null;
|
|
5352
5383
|
for (; c < this.MAX_ITERATIONS && o !== a; ) {
|
|
5353
5384
|
a = o;
|
|
5354
|
-
const h = new
|
|
5385
|
+
const h = new Xt();
|
|
5355
5386
|
h.addOutput(this.P2TR_SCRIPT, L(o));
|
|
5356
5387
|
const p = {
|
|
5357
5388
|
transactionId: f(new Uint8Array(32)),
|
|
@@ -5409,7 +5440,7 @@ var Ce = new Uint8Array([
|
|
|
5409
5440
|
}];
|
|
5410
5441
|
}
|
|
5411
5442
|
}, Q = class F extends B {
|
|
5412
|
-
static LOCK_LEAF_SCRIPT =
|
|
5443
|
+
static LOCK_LEAF_SCRIPT = b.compile([
|
|
5413
5444
|
d.OP_XOR,
|
|
5414
5445
|
d.OP_NOP,
|
|
5415
5446
|
d.OP_CODESEPARATOR
|
|
@@ -5438,10 +5469,10 @@ var Ce = new Uint8Array([
|
|
|
5438
5469
|
priorityFee: 0n,
|
|
5439
5470
|
gasSatFee: 0n
|
|
5440
5471
|
}), !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 =
|
|
5472
|
+
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
5473
|
}
|
|
5443
5474
|
static fromBase64(t) {
|
|
5444
|
-
const i =
|
|
5475
|
+
const i = N.fromBase64(t.psbt, { network: t.network });
|
|
5445
5476
|
return new F({
|
|
5446
5477
|
...t,
|
|
5447
5478
|
psbt: i
|
|
@@ -5468,7 +5499,7 @@ var Ce = new Uint8Array([
|
|
|
5468
5499
|
let n = !1, o = !0;
|
|
5469
5500
|
for (let a = r; a < t.data.inputs.length; a++) {
|
|
5470
5501
|
const c = t.data.inputs[a];
|
|
5471
|
-
c.tapInternalKey || (c.tapInternalKey =
|
|
5502
|
+
c.tapInternalKey || (c.tapInternalKey = O(F.numsPoint));
|
|
5472
5503
|
const u = [];
|
|
5473
5504
|
if (c.finalScriptWitness) {
|
|
5474
5505
|
const h = B.readScriptWitnessToWitnessStack(c.finalScriptWitness);
|
|
@@ -5513,7 +5544,7 @@ var Ce = new Uint8Array([
|
|
|
5513
5544
|
else {
|
|
5514
5545
|
for (const u of s) {
|
|
5515
5546
|
let l = !1;
|
|
5516
|
-
for (const h of i.tapScriptSig) C(h.pubkey,
|
|
5547
|
+
for (const h of i.tapScriptSig) C(h.pubkey, O(u)) && (o.push(h.signature), l = !0);
|
|
5517
5548
|
l || o.push(new Uint8Array(0));
|
|
5518
5549
|
}
|
|
5519
5550
|
o = o.reverse();
|
|
@@ -5532,7 +5563,7 @@ var Ce = new Uint8Array([
|
|
|
5532
5563
|
let n = 0;
|
|
5533
5564
|
for (let o = i; o < t.data.inputs.length; o++) try {
|
|
5534
5565
|
const a = t.data.inputs[o];
|
|
5535
|
-
a.tapInternalKey || (a.tapInternalKey =
|
|
5566
|
+
a.tapInternalKey || (a.tapInternalKey = O(F.numsPoint));
|
|
5536
5567
|
const c = [];
|
|
5537
5568
|
if (a.finalScriptWitness) {
|
|
5538
5569
|
const u = B.readScriptWitnessToWitnessStack(a.finalScriptWitness);
|
|
@@ -5605,12 +5636,12 @@ var Ce = new Uint8Array([
|
|
|
5605
5636
|
return this.useP2MR ? {
|
|
5606
5637
|
network: this.network,
|
|
5607
5638
|
scriptTree: this.scriptTree,
|
|
5608
|
-
name:
|
|
5639
|
+
name: E.P2MR
|
|
5609
5640
|
} : {
|
|
5610
|
-
internalPubkey:
|
|
5641
|
+
internalPubkey: O(F.numsPoint),
|
|
5611
5642
|
network: this.network,
|
|
5612
5643
|
scriptTree: this.scriptTree,
|
|
5613
|
-
name:
|
|
5644
|
+
name: E.P2TR
|
|
5614
5645
|
};
|
|
5615
5646
|
}
|
|
5616
5647
|
generateTapData() {
|
|
@@ -5621,13 +5652,13 @@ var Ce = new Uint8Array([
|
|
|
5621
5652
|
network: this.network,
|
|
5622
5653
|
scriptTree: this.scriptTree,
|
|
5623
5654
|
redeem: t,
|
|
5624
|
-
name:
|
|
5655
|
+
name: E.P2MR
|
|
5625
5656
|
} : {
|
|
5626
|
-
internalPubkey:
|
|
5657
|
+
internalPubkey: O(F.numsPoint),
|
|
5627
5658
|
network: this.network,
|
|
5628
5659
|
scriptTree: this.scriptTree,
|
|
5629
5660
|
redeem: t,
|
|
5630
|
-
name:
|
|
5661
|
+
name: E.P2TR
|
|
5631
5662
|
};
|
|
5632
5663
|
}
|
|
5633
5664
|
getScriptSolution(t) {
|
|
@@ -5657,41 +5688,41 @@ var Ce = new Uint8Array([
|
|
|
5657
5688
|
};
|
|
5658
5689
|
generateRedeemScripts() {
|
|
5659
5690
|
this.targetScriptRedeem = {
|
|
5660
|
-
name:
|
|
5691
|
+
name: E.P2TR,
|
|
5661
5692
|
output: this.compiledTargetScript,
|
|
5662
5693
|
redeemVersion: 192
|
|
5663
5694
|
}, this.leftOverFundsScriptRedeem = {
|
|
5664
|
-
name:
|
|
5695
|
+
name: E.P2TR,
|
|
5665
5696
|
output: F.LOCK_LEAF_SCRIPT,
|
|
5666
5697
|
redeemVersion: 192
|
|
5667
5698
|
};
|
|
5668
5699
|
}
|
|
5669
|
-
},
|
|
5670
|
-
function
|
|
5700
|
+
}, ws = 2, ys = 66;
|
|
5701
|
+
function oi(e) {
|
|
5671
5702
|
return e.type === m.FUNDING;
|
|
5672
5703
|
}
|
|
5673
|
-
function
|
|
5704
|
+
function ai(e) {
|
|
5674
5705
|
return e.type === m.DEPLOYMENT;
|
|
5675
5706
|
}
|
|
5676
|
-
function
|
|
5707
|
+
function ci(e) {
|
|
5677
5708
|
return e.type === m.INTERACTION;
|
|
5678
5709
|
}
|
|
5679
5710
|
function et(e) {
|
|
5680
5711
|
return e.type === m.MULTI_SIG;
|
|
5681
5712
|
}
|
|
5682
|
-
function
|
|
5713
|
+
function ui(e) {
|
|
5683
5714
|
return e.type === m.CUSTOM_CODE;
|
|
5684
5715
|
}
|
|
5685
|
-
function
|
|
5716
|
+
function li(e) {
|
|
5686
5717
|
return e.type === m.CANCEL;
|
|
5687
5718
|
}
|
|
5688
|
-
function
|
|
5719
|
+
function G(e) {
|
|
5689
5720
|
return e.startsWith("0x") ? e.slice(2) : e;
|
|
5690
5721
|
}
|
|
5691
|
-
var
|
|
5722
|
+
var P = class {
|
|
5692
5723
|
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);
|
|
5724
|
+
const t = new V();
|
|
5725
|
+
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
5726
|
const i = t.getBuffer(), r = this.calculateChecksum(i), s = new Uint8Array(i.length + r.length);
|
|
5696
5727
|
return s.set(i, 0), s.set(r, i.length), s;
|
|
5697
5728
|
}
|
|
@@ -5699,18 +5730,25 @@ var U = class {
|
|
|
5699
5730
|
if (e.length < 32) throw new Error("Invalid serialized data: too short");
|
|
5700
5731
|
const t = e.subarray(-32), i = e.subarray(0, -32), r = this.calculateChecksum(i);
|
|
5701
5732
|
if (!this.bytesEqual(t, r)) throw new Error("Invalid checksum - data may be corrupted");
|
|
5702
|
-
const s = new
|
|
5703
|
-
if (n.formatVersion >
|
|
5733
|
+
const s = new Ht(i), n = this.readHeader(s);
|
|
5734
|
+
if (n.formatVersion > 2) throw new Error(`Unsupported format version: ${n.formatVersion}`);
|
|
5735
|
+
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);
|
|
5736
|
+
let T;
|
|
5737
|
+
if (n.formatVersion >= 2) {
|
|
5738
|
+
const A = s.readStringWithLength();
|
|
5739
|
+
T = A.length > 0 ? A : void 0;
|
|
5740
|
+
}
|
|
5704
5741
|
return {
|
|
5705
5742
|
header: n,
|
|
5706
|
-
baseParams:
|
|
5707
|
-
utxos:
|
|
5708
|
-
optionalInputs:
|
|
5709
|
-
optionalOutputs:
|
|
5710
|
-
addressRotationEnabled:
|
|
5711
|
-
signerMappings:
|
|
5712
|
-
typeSpecificData:
|
|
5713
|
-
precomputedData:
|
|
5743
|
+
baseParams: o,
|
|
5744
|
+
utxos: a,
|
|
5745
|
+
optionalInputs: c,
|
|
5746
|
+
optionalOutputs: u,
|
|
5747
|
+
addressRotationEnabled: l,
|
|
5748
|
+
signerMappings: h,
|
|
5749
|
+
typeSpecificData: p,
|
|
5750
|
+
precomputedData: w,
|
|
5751
|
+
...T !== void 0 ? { partialPsbtBase64: T } : {}
|
|
5714
5752
|
};
|
|
5715
5753
|
}
|
|
5716
5754
|
static toBase64(e) {
|
|
@@ -5970,11 +6008,11 @@ var U = class {
|
|
|
5970
6008
|
};
|
|
5971
6009
|
}
|
|
5972
6010
|
static writeChallenge(e, t) {
|
|
5973
|
-
e.writeU64(BigInt(t.epochNumber)), e.writeStringWithLength(t.mldsaPublicKey), e.writeStringWithLength(t.legacyPublicKey), e.writeBytesWithLength(g(
|
|
6011
|
+
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
6012
|
}
|
|
5975
6013
|
static writeChallengeVerification(e, t) {
|
|
5976
|
-
e.writeBytesWithLength(g(
|
|
5977
|
-
for (const i of t.proofs) e.writeBytesWithLength(g(
|
|
6014
|
+
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);
|
|
6015
|
+
for (const i of t.proofs) e.writeBytesWithLength(g(G(i)));
|
|
5978
6016
|
}
|
|
5979
6017
|
static readChallenge(e) {
|
|
5980
6018
|
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 +6080,8 @@ var U = class {
|
|
|
6042
6080
|
};
|
|
6043
6081
|
}
|
|
6044
6082
|
static calculateChecksum(e) {
|
|
6045
|
-
const t =
|
|
6046
|
-
return new Uint8Array(
|
|
6083
|
+
const t = jt("sha256").update(e).digest();
|
|
6084
|
+
return new Uint8Array(jt("sha256").update(t).digest());
|
|
6047
6085
|
}
|
|
6048
6086
|
static bytesEqual(e, t) {
|
|
6049
6087
|
if (e.length !== t.length) return !1;
|
|
@@ -6088,13 +6126,13 @@ var U = class {
|
|
|
6088
6126
|
throw new Error(`Unknown network value: ${e}`);
|
|
6089
6127
|
}
|
|
6090
6128
|
}
|
|
6091
|
-
},
|
|
6129
|
+
}, Vt = /* @__PURE__ */ (function(e) {
|
|
6092
6130
|
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:
|
|
6131
|
+
})({}), hi = {
|
|
6132
|
+
CONSENSUS: Vt.Roswell,
|
|
6095
6133
|
CONSENSUS_NAME: "Roswell",
|
|
6096
6134
|
ENABLED_AT_BLOCK: 0n
|
|
6097
|
-
},
|
|
6135
|
+
}, di = { [Vt.Roswell]: hi }, Te = Vt.Roswell, Ur = di[Te], $ = class {
|
|
6098
6136
|
static fromFunding(e, t) {
|
|
6099
6137
|
return this.captureState({
|
|
6100
6138
|
params: e,
|
|
@@ -6153,8 +6191,8 @@ var U = class {
|
|
|
6153
6191
|
}
|
|
6154
6192
|
static createHeader(e, t, i) {
|
|
6155
6193
|
return {
|
|
6156
|
-
formatVersion:
|
|
6157
|
-
consensusVersion:
|
|
6194
|
+
formatVersion: 2,
|
|
6195
|
+
consensusVersion: Te,
|
|
6158
6196
|
transactionType: e,
|
|
6159
6197
|
chainId: i ?? this.networkToChainId(t),
|
|
6160
6198
|
timestamp: Date.now()
|
|
@@ -6320,13 +6358,13 @@ var U = class {
|
|
|
6320
6358
|
return e.bech32 === "bc" ? "mainnet" : e.bech32 === "tb" ? "testnet" : e.bech32 === "opt" ? "opnetTestnet" : "regtest";
|
|
6321
6359
|
}
|
|
6322
6360
|
static networkToChainId(e) {
|
|
6323
|
-
return
|
|
6361
|
+
return Qe.Bitcoin;
|
|
6324
6362
|
}
|
|
6325
6363
|
};
|
|
6326
|
-
function
|
|
6364
|
+
function M(e) {
|
|
6327
6365
|
return g(e.startsWith("0x") ? e.slice(2) : e);
|
|
6328
6366
|
}
|
|
6329
|
-
var
|
|
6367
|
+
var wt = class {
|
|
6330
6368
|
static BLOCKS_PER_EPOCH = 5n;
|
|
6331
6369
|
static sha1(e) {
|
|
6332
6370
|
return D.sha1(e);
|
|
@@ -6364,14 +6402,14 @@ var St = class {
|
|
|
6364
6402
|
}
|
|
6365
6403
|
static validateEpochWinner(e) {
|
|
6366
6404
|
try {
|
|
6367
|
-
const t = BigInt(e.epochNumber), i =
|
|
6368
|
-
epochHash:
|
|
6369
|
-
epochRoot:
|
|
6370
|
-
targetHash:
|
|
6371
|
-
targetChecksum:
|
|
6405
|
+
const t = BigInt(e.epochNumber), i = z.fromString(e.mldsaPublicKey, e.legacyPublicKey), r = M(e.solution), s = M(e.salt), n = e.difficulty, o = {
|
|
6406
|
+
epochHash: M(e.verification.epochHash),
|
|
6407
|
+
epochRoot: M(e.verification.epochRoot),
|
|
6408
|
+
targetHash: M(e.verification.targetHash),
|
|
6409
|
+
targetChecksum: M(e.verification.targetChecksum),
|
|
6372
6410
|
startBlock: BigInt(e.verification.startBlock),
|
|
6373
6411
|
endBlock: BigInt(e.verification.endBlock),
|
|
6374
|
-
proofs: Object.freeze(e.verification.proofs.map((h) =>
|
|
6412
|
+
proofs: Object.freeze(e.verification.proofs.map((h) => M(h)))
|
|
6375
6413
|
}, a = this.calculatePreimage(o.targetChecksum, i.toBuffer(), s), c = this.sha1(a);
|
|
6376
6414
|
if (!C(c, r) || this.countMatchingBits(c, o.targetHash) !== n) return !1;
|
|
6377
6415
|
const u = t * this.BLOCKS_PER_EPOCH, l = u + this.BLOCKS_PER_EPOCH - 1n;
|
|
@@ -6394,7 +6432,7 @@ var St = class {
|
|
|
6394
6432
|
difficulty: r
|
|
6395
6433
|
};
|
|
6396
6434
|
}
|
|
6397
|
-
},
|
|
6435
|
+
}, pi = class {
|
|
6398
6436
|
epochHash;
|
|
6399
6437
|
epochRoot;
|
|
6400
6438
|
targetHash;
|
|
@@ -6403,23 +6441,24 @@ var St = class {
|
|
|
6403
6441
|
endBlock;
|
|
6404
6442
|
proofs;
|
|
6405
6443
|
constructor(e) {
|
|
6406
|
-
this.epochHash =
|
|
6444
|
+
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
6445
|
}
|
|
6408
|
-
},
|
|
6446
|
+
}, fi = class {
|
|
6447
|
+
epochNumber;
|
|
6409
6448
|
publicKey;
|
|
6410
6449
|
solution;
|
|
6411
6450
|
graffiti;
|
|
6412
6451
|
signature;
|
|
6413
6452
|
constructor(e, t) {
|
|
6414
|
-
this.epochNumber = t, this.publicKey =
|
|
6453
|
+
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
6454
|
}
|
|
6416
6455
|
verifySignature() {
|
|
6417
|
-
const e = new
|
|
6456
|
+
const e = new V();
|
|
6418
6457
|
e.writeAddress(this.publicKey), e.writeU64(this.epochNumber), e.writeBytes(this.solution), this.graffiti && e.writeBytes(this.graffiti);
|
|
6419
6458
|
const t = e.getBuffer();
|
|
6420
|
-
return
|
|
6459
|
+
return st.verifySignature(this.publicKey.tweakedPublicKeyToBuffer(), t, this.signature);
|
|
6421
6460
|
}
|
|
6422
|
-
},
|
|
6461
|
+
}, ne = class {
|
|
6423
6462
|
epochNumber;
|
|
6424
6463
|
publicKey;
|
|
6425
6464
|
solution;
|
|
@@ -6429,10 +6468,10 @@ var St = class {
|
|
|
6429
6468
|
verification;
|
|
6430
6469
|
submission;
|
|
6431
6470
|
constructor(e) {
|
|
6432
|
-
this.epochNumber = BigInt(e.epochNumber), this.publicKey =
|
|
6471
|
+
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
6472
|
}
|
|
6434
6473
|
static validateRaw(e) {
|
|
6435
|
-
return
|
|
6474
|
+
return wt.validateEpochWinner(e);
|
|
6436
6475
|
}
|
|
6437
6476
|
verifySubmissionSignature() {
|
|
6438
6477
|
if (!this.submission) throw new Error("No submission provided in request.");
|
|
@@ -6445,7 +6484,7 @@ var St = class {
|
|
|
6445
6484
|
}
|
|
6446
6485
|
}
|
|
6447
6486
|
verify() {
|
|
6448
|
-
return
|
|
6487
|
+
return wt.validateChallengeSolution(this);
|
|
6449
6488
|
}
|
|
6450
6489
|
toBuffer() {
|
|
6451
6490
|
return this.solution;
|
|
@@ -6474,15 +6513,15 @@ var St = class {
|
|
|
6474
6513
|
};
|
|
6475
6514
|
}
|
|
6476
6515
|
calculateSolution() {
|
|
6477
|
-
return
|
|
6516
|
+
return wt.calculateSolution(this.verification.targetChecksum, this.publicKey.toBuffer(), this.salt);
|
|
6478
6517
|
}
|
|
6479
6518
|
checkDifficulty(e) {
|
|
6480
|
-
return
|
|
6519
|
+
return wt.checkDifficulty(this.solution, this.verification.targetHash, e);
|
|
6481
6520
|
}
|
|
6482
6521
|
getMiningTargetBlock() {
|
|
6483
|
-
return
|
|
6522
|
+
return wt.getMiningTargetBlock(this.epochNumber);
|
|
6484
6523
|
}
|
|
6485
|
-
},
|
|
6524
|
+
}, j = class {
|
|
6486
6525
|
static reconstruct(e, t) {
|
|
6487
6526
|
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
6527
|
signer: t.signer,
|
|
@@ -6505,24 +6544,24 @@ var St = class {
|
|
|
6505
6544
|
...e.precomputedData.estimatedFees !== void 0 ? { estimatedFees: BigInt(e.precomputedData.estimatedFees) } : {},
|
|
6506
6545
|
...e.precomputedData.compiledTargetScript !== void 0 ? { compiledTargetScript: g(e.precomputedData.compiledTargetScript) } : {}
|
|
6507
6546
|
}, h = e.typeSpecificData;
|
|
6508
|
-
if (
|
|
6509
|
-
if (
|
|
6510
|
-
if (
|
|
6547
|
+
if (oi(h)) return this.reconstructFunding(l, h);
|
|
6548
|
+
if (ai(h)) return this.reconstructDeployment(l, h, e);
|
|
6549
|
+
if (ci(h)) return this.reconstructInteraction(l, h, e);
|
|
6511
6550
|
if (et(h)) return this.reconstructMultiSig(l, h);
|
|
6512
|
-
if (
|
|
6513
|
-
if (
|
|
6551
|
+
if (ui(h)) return this.reconstructCustomScript(l, h, e);
|
|
6552
|
+
if (li(h)) return this.reconstructCancel(l, h);
|
|
6514
6553
|
throw new Error(`Unsupported transaction type: ${e.header.transactionType}`);
|
|
6515
6554
|
}
|
|
6516
6555
|
static reconstructFunding(e, t) {
|
|
6517
|
-
return new
|
|
6556
|
+
return new Mt({
|
|
6518
6557
|
...e,
|
|
6519
6558
|
amount: BigInt(t.amount),
|
|
6520
6559
|
splitInputsInto: t.splitInputsInto
|
|
6521
6560
|
});
|
|
6522
6561
|
}
|
|
6523
6562
|
static reconstructDeployment(e, t, i) {
|
|
6524
|
-
const r = new
|
|
6525
|
-
return new
|
|
6563
|
+
const r = new ne(t.challenge);
|
|
6564
|
+
return new Dt({
|
|
6526
6565
|
...e,
|
|
6527
6566
|
bytecode: g(t.bytecode),
|
|
6528
6567
|
challenge: r,
|
|
@@ -6533,9 +6572,9 @@ var St = class {
|
|
|
6533
6572
|
});
|
|
6534
6573
|
}
|
|
6535
6574
|
static reconstructInteraction(e, t, i) {
|
|
6536
|
-
const r = new
|
|
6575
|
+
const r = new ne(t.challenge);
|
|
6537
6576
|
if (!e.to) throw new Error('InteractionTransaction requires a "to" address');
|
|
6538
|
-
return new
|
|
6577
|
+
return new Nt({
|
|
6539
6578
|
...e,
|
|
6540
6579
|
to: e.to,
|
|
6541
6580
|
calldata: g(t.calldata),
|
|
@@ -6583,7 +6622,7 @@ var St = class {
|
|
|
6583
6622
|
static reconstructCustomScript(e, t, i) {
|
|
6584
6623
|
const r = t.scriptElements.map((n) => n.elementType === "buffer" ? g(n.value) : [n.value]), s = t.witnesses.map((n) => g(n));
|
|
6585
6624
|
if (!e.to) throw new Error('CustomScriptTransaction requires a "to" address');
|
|
6586
|
-
return new
|
|
6625
|
+
return new Kt({
|
|
6587
6626
|
...e,
|
|
6588
6627
|
to: e.to,
|
|
6589
6628
|
script: r,
|
|
@@ -6593,7 +6632,7 @@ var St = class {
|
|
|
6593
6632
|
});
|
|
6594
6633
|
}
|
|
6595
6634
|
static reconstructCancel(e, t) {
|
|
6596
|
-
return new
|
|
6635
|
+
return new me({
|
|
6597
6636
|
...e,
|
|
6598
6637
|
compiledTargetScript: g(t.compiledTargetScript)
|
|
6599
6638
|
});
|
|
@@ -6655,50 +6694,50 @@ var St = class {
|
|
|
6655
6694
|
}
|
|
6656
6695
|
}, Br = class {
|
|
6657
6696
|
static exportFunding(e, t) {
|
|
6658
|
-
const i =
|
|
6659
|
-
return
|
|
6697
|
+
const i = $.fromFunding(e, t);
|
|
6698
|
+
return P.toBase64(i);
|
|
6660
6699
|
}
|
|
6661
6700
|
static exportDeployment(e, t) {
|
|
6662
|
-
const i =
|
|
6663
|
-
return
|
|
6701
|
+
const i = $.fromDeployment(e, t);
|
|
6702
|
+
return P.toBase64(i);
|
|
6664
6703
|
}
|
|
6665
6704
|
static exportInteraction(e, t) {
|
|
6666
|
-
const i =
|
|
6667
|
-
return
|
|
6705
|
+
const i = $.fromInteraction(e, t);
|
|
6706
|
+
return P.toBase64(i);
|
|
6668
6707
|
}
|
|
6669
6708
|
static exportMultiSig(e, t) {
|
|
6670
|
-
const i =
|
|
6671
|
-
return
|
|
6709
|
+
const i = $.fromMultiSig(e, t);
|
|
6710
|
+
return P.toBase64(i);
|
|
6672
6711
|
}
|
|
6673
6712
|
static exportCustomScript(e, t) {
|
|
6674
|
-
const i =
|
|
6675
|
-
return
|
|
6713
|
+
const i = $.fromCustomScript(e, t);
|
|
6714
|
+
return P.toBase64(i);
|
|
6676
6715
|
}
|
|
6677
6716
|
static exportCancel(e, t) {
|
|
6678
|
-
const i =
|
|
6679
|
-
return
|
|
6717
|
+
const i = $.fromCancel(e, t);
|
|
6718
|
+
return P.toBase64(i);
|
|
6680
6719
|
}
|
|
6681
6720
|
static exportFromBuilder(e, t, i) {
|
|
6682
6721
|
const r = e.type;
|
|
6683
6722
|
let s;
|
|
6684
6723
|
switch (r) {
|
|
6685
6724
|
case m.FUNDING:
|
|
6686
|
-
s =
|
|
6725
|
+
s = $.fromFunding(t, i);
|
|
6687
6726
|
break;
|
|
6688
6727
|
case m.DEPLOYMENT:
|
|
6689
|
-
s =
|
|
6728
|
+
s = $.fromDeployment(t, i);
|
|
6690
6729
|
break;
|
|
6691
6730
|
case m.INTERACTION:
|
|
6692
|
-
s =
|
|
6731
|
+
s = $.fromInteraction(t, i);
|
|
6693
6732
|
break;
|
|
6694
6733
|
default:
|
|
6695
6734
|
throw new Error(`Unsupported transaction type for export: ${r}`);
|
|
6696
6735
|
}
|
|
6697
|
-
return
|
|
6736
|
+
return P.toBase64(s);
|
|
6698
6737
|
}
|
|
6699
6738
|
static importForSigning(e, t) {
|
|
6700
|
-
const i =
|
|
6701
|
-
return
|
|
6739
|
+
const i = P.fromBase64(e);
|
|
6740
|
+
return j.reconstruct(i, t);
|
|
6702
6741
|
}
|
|
6703
6742
|
static async signAndExport(e) {
|
|
6704
6743
|
return (await e.signTransaction()).toHex();
|
|
@@ -6708,14 +6747,14 @@ var St = class {
|
|
|
6708
6747
|
return this.signAndExport(i);
|
|
6709
6748
|
}
|
|
6710
6749
|
static rebuildWithNewFees(e, t) {
|
|
6711
|
-
const i =
|
|
6750
|
+
const i = P.fromBase64(e), r = {
|
|
6712
6751
|
...i,
|
|
6713
6752
|
baseParams: {
|
|
6714
6753
|
...i.baseParams,
|
|
6715
6754
|
feeRate: t
|
|
6716
6755
|
}
|
|
6717
6756
|
};
|
|
6718
|
-
return
|
|
6757
|
+
return P.toBase64(r);
|
|
6719
6758
|
}
|
|
6720
6759
|
static async rebuildSignAndExport(e, t, i) {
|
|
6721
6760
|
const r = this.importForSigning(e, {
|
|
@@ -6725,39 +6764,39 @@ var St = class {
|
|
|
6725
6764
|
return this.signAndExport(r);
|
|
6726
6765
|
}
|
|
6727
6766
|
static inspect(e) {
|
|
6728
|
-
return
|
|
6767
|
+
return P.fromBase64(e);
|
|
6729
6768
|
}
|
|
6730
6769
|
static validate(e) {
|
|
6731
6770
|
try {
|
|
6732
|
-
return
|
|
6771
|
+
return P.fromBase64(e), !0;
|
|
6733
6772
|
} catch {
|
|
6734
6773
|
return !1;
|
|
6735
6774
|
}
|
|
6736
6775
|
}
|
|
6737
6776
|
static getType(e) {
|
|
6738
|
-
return
|
|
6777
|
+
return P.fromBase64(e).header.transactionType;
|
|
6739
6778
|
}
|
|
6740
6779
|
static fromBase64(e) {
|
|
6741
|
-
return
|
|
6780
|
+
return P.fromBase64(e);
|
|
6742
6781
|
}
|
|
6743
6782
|
static toBase64(e) {
|
|
6744
|
-
return
|
|
6783
|
+
return P.toBase64(e);
|
|
6745
6784
|
}
|
|
6746
6785
|
static toHex(e) {
|
|
6747
|
-
const t =
|
|
6748
|
-
return
|
|
6786
|
+
const t = P.fromBase64(e);
|
|
6787
|
+
return P.toHex(t);
|
|
6749
6788
|
}
|
|
6750
6789
|
static fromHex(e) {
|
|
6751
|
-
const t =
|
|
6752
|
-
return
|
|
6790
|
+
const t = P.fromHex(e);
|
|
6791
|
+
return P.toBase64(t);
|
|
6753
6792
|
}
|
|
6754
6793
|
static async multiSigAddSignature(e, t) {
|
|
6755
|
-
const i =
|
|
6794
|
+
const i = P.fromBase64(e);
|
|
6756
6795
|
if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6757
6796
|
const r = i.typeSpecificData, s = r.pubkeys.map((p) => g(p));
|
|
6758
6797
|
let n;
|
|
6759
|
-
const o =
|
|
6760
|
-
r.existingPsbtBase64 ? n =
|
|
6798
|
+
const o = j.nameToNetwork(i.baseParams.networkName);
|
|
6799
|
+
r.existingPsbtBase64 ? n = N.fromBase64(r.existingPsbtBase64, { network: o }) : n = await this.importForSigning(e, { signer: t }).signPSBT();
|
|
6761
6800
|
const a = [];
|
|
6762
6801
|
for (let p = r.originalInputCount; p < n.data.inputs.length; p++) a.push(r.minimumSignatures);
|
|
6763
6802
|
const c = Q.signPartial(n, t, r.originalInputCount, a), u = [];
|
|
@@ -6771,22 +6810,22 @@ var St = class {
|
|
|
6771
6810
|
}
|
|
6772
6811
|
};
|
|
6773
6812
|
return {
|
|
6774
|
-
state:
|
|
6813
|
+
state: P.toBase64(h),
|
|
6775
6814
|
signed: c.signed,
|
|
6776
6815
|
final: c.final,
|
|
6777
6816
|
psbtBase64: l
|
|
6778
6817
|
};
|
|
6779
6818
|
}
|
|
6780
6819
|
static multiSigHasSigned(e, t) {
|
|
6781
|
-
const i =
|
|
6820
|
+
const i = P.fromBase64(e);
|
|
6782
6821
|
if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6783
6822
|
const r = i.typeSpecificData;
|
|
6784
6823
|
if (!r.existingPsbtBase64) return !1;
|
|
6785
|
-
const s =
|
|
6824
|
+
const s = j.nameToNetwork(i.baseParams.networkName), n = N.fromBase64(r.existingPsbtBase64, { network: s }), o = t instanceof Uint8Array ? t : g(t);
|
|
6786
6825
|
return Q.verifyIfSigned(n, o);
|
|
6787
6826
|
}
|
|
6788
6827
|
static multiSigGetSignatureStatus(e) {
|
|
6789
|
-
const t =
|
|
6828
|
+
const t = P.fromBase64(e);
|
|
6790
6829
|
if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6791
6830
|
const i = t.typeSpecificData, r = i.minimumSignatures;
|
|
6792
6831
|
if (!i.existingPsbtBase64) return {
|
|
@@ -6795,7 +6834,7 @@ var St = class {
|
|
|
6795
6834
|
isComplete: !1,
|
|
6796
6835
|
signers: []
|
|
6797
6836
|
};
|
|
6798
|
-
const s =
|
|
6837
|
+
const s = j.nameToNetwork(t.baseParams.networkName), n = N.fromBase64(i.existingPsbtBase64, { network: s }), o = /* @__PURE__ */ new Set();
|
|
6799
6838
|
for (let c = i.originalInputCount; c < n.data.inputs.length; c++) {
|
|
6800
6839
|
const u = n.data.inputs[c];
|
|
6801
6840
|
if (u.tapScriptSig) for (const l of u.tapScriptSig) o.add(f(l.pubkey));
|
|
@@ -6816,22 +6855,22 @@ var St = class {
|
|
|
6816
6855
|
};
|
|
6817
6856
|
}
|
|
6818
6857
|
static multiSigFinalize(e) {
|
|
6819
|
-
const t =
|
|
6858
|
+
const t = P.fromBase64(e);
|
|
6820
6859
|
if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6821
6860
|
const i = t.typeSpecificData;
|
|
6822
6861
|
if (!i.existingPsbtBase64) throw new Error("No PSBT found in state - transaction has not been signed");
|
|
6823
|
-
const r =
|
|
6862
|
+
const r = j.nameToNetwork(t.baseParams.networkName), s = N.fromBase64(i.existingPsbtBase64, { network: r }), n = i.pubkeys.map((a) => g(a)), o = [];
|
|
6824
6863
|
for (let a = i.originalInputCount; a < s.data.inputs.length; a++) o.push(n);
|
|
6825
6864
|
if (!Q.attemptFinalizeInputs(s, i.originalInputCount, o, !0)) throw new Error("Failed to finalize multisig transaction - not enough signatures");
|
|
6826
6865
|
return s.extractTransaction(!0, !0).toHex();
|
|
6827
6866
|
}
|
|
6828
6867
|
static multiSigGetPsbt(e) {
|
|
6829
|
-
const t =
|
|
6868
|
+
const t = P.fromBase64(e);
|
|
6830
6869
|
if (!et(t.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6831
6870
|
return t.typeSpecificData.existingPsbtBase64 || null;
|
|
6832
6871
|
}
|
|
6833
6872
|
static multiSigUpdatePsbt(e, t) {
|
|
6834
|
-
const i =
|
|
6873
|
+
const i = P.fromBase64(e);
|
|
6835
6874
|
if (!et(i.typeSpecificData)) throw new Error("State is not a multisig transaction");
|
|
6836
6875
|
const r = {
|
|
6837
6876
|
...i,
|
|
@@ -6840,9 +6879,83 @@ var St = class {
|
|
|
6840
6879
|
existingPsbtBase64: t
|
|
6841
6880
|
}
|
|
6842
6881
|
};
|
|
6843
|
-
return
|
|
6882
|
+
return P.toBase64(r);
|
|
6883
|
+
}
|
|
6884
|
+
static csvMultisigGetStatus(e) {
|
|
6885
|
+
const t = P.fromBase64(e);
|
|
6886
|
+
if (!t.partialPsbtBase64) return [];
|
|
6887
|
+
const i = j.nameToNetwork(t.baseParams.networkName), r = N.fromBase64(t.partialPsbtBase64, { network: i });
|
|
6888
|
+
return this.computeCSVMultisigStatus(t, r, i);
|
|
6889
|
+
}
|
|
6890
|
+
static async addCSVMultisigSignature(e, t) {
|
|
6891
|
+
const i = P.fromBase64(e), r = j.nameToNetwork(i.baseParams.networkName);
|
|
6892
|
+
let s;
|
|
6893
|
+
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));
|
|
6894
|
+
const n = this.computeCSVMultisigStatus(i, s, r), o = n.length > 0 && n.every((c) => c.collected >= c.required), a = {
|
|
6895
|
+
...i,
|
|
6896
|
+
partialPsbtBase64: s.toBase64()
|
|
6897
|
+
};
|
|
6898
|
+
return {
|
|
6899
|
+
state: P.toBase64(a),
|
|
6900
|
+
final: o,
|
|
6901
|
+
perInput: n
|
|
6902
|
+
};
|
|
6903
|
+
}
|
|
6904
|
+
static csvMultisigFinalize(e) {
|
|
6905
|
+
const t = P.fromBase64(e);
|
|
6906
|
+
if (!t.partialPsbtBase64) throw new Error("No partial PSBT in state — call addCSVMultisigSignature first");
|
|
6907
|
+
const i = j.nameToNetwork(t.baseParams.networkName), r = N.fromBase64(t.partialPsbtBase64, { network: i });
|
|
6908
|
+
for (let s = 0; s < r.data.inputs.length; s++) {
|
|
6909
|
+
const n = r.data.inputs[s];
|
|
6910
|
+
if (!n.tapLeafScript || n.tapLeafScript.length === 0) continue;
|
|
6911
|
+
const o = n.tapLeafScript[0];
|
|
6912
|
+
if (!o) continue;
|
|
6913
|
+
const a = rt.deriveAddressFromTapscript(o.script, i);
|
|
6914
|
+
a && rt.finalizePsbtInput(r, s, i, a);
|
|
6915
|
+
}
|
|
6916
|
+
return r.extractTransaction(!0, !0).toHex();
|
|
6917
|
+
}
|
|
6918
|
+
static addSignerToCSVInputs(e, t, i) {
|
|
6919
|
+
const r = f(O(t.publicKey));
|
|
6920
|
+
for (let s = 0; s < e.data.inputs.length; s++) {
|
|
6921
|
+
const n = e.data.inputs[s];
|
|
6922
|
+
if (!n.tapLeafScript || n.tapLeafScript.length === 0) continue;
|
|
6923
|
+
const o = n.tapLeafScript[0];
|
|
6924
|
+
if (!o) continue;
|
|
6925
|
+
const a = rt.deriveAddressFromTapscript(o.script, i);
|
|
6926
|
+
a && a.config.pubkeys.some((c) => f(c) === r) && ((n.tapScriptSig ?? []).some((c) => f(c.pubkey) === r) || e.signTaprootInput(s, t));
|
|
6927
|
+
}
|
|
6928
|
+
}
|
|
6929
|
+
static computeCSVMultisigStatus(e, t, i) {
|
|
6930
|
+
const r = [];
|
|
6931
|
+
for (let s = 0; s < e.utxos.length; s++) {
|
|
6932
|
+
const n = e.utxos[s];
|
|
6933
|
+
if (!n?.witnessScript) continue;
|
|
6934
|
+
const o = g(n.witnessScript), a = rt.deriveAddressFromTapscript(o, i);
|
|
6935
|
+
if (!a) continue;
|
|
6936
|
+
const c = t.data.inputs[s];
|
|
6937
|
+
if (!c) continue;
|
|
6938
|
+
if (c.finalScriptWitness) {
|
|
6939
|
+
r.push({
|
|
6940
|
+
inputIndex: s,
|
|
6941
|
+
required: a.config.threshold,
|
|
6942
|
+
collected: a.config.threshold,
|
|
6943
|
+
signers: []
|
|
6944
|
+
});
|
|
6945
|
+
continue;
|
|
6946
|
+
}
|
|
6947
|
+
const u = c.tapScriptSig ?? [];
|
|
6948
|
+
r.push({
|
|
6949
|
+
inputIndex: s,
|
|
6950
|
+
required: a.config.threshold,
|
|
6951
|
+
collected: u.length,
|
|
6952
|
+
signers: u.map((l) => f(l.pubkey))
|
|
6953
|
+
});
|
|
6954
|
+
}
|
|
6955
|
+
return r;
|
|
6844
6956
|
}
|
|
6845
6957
|
}, kr = class {
|
|
6958
|
+
opnetAPIUrl;
|
|
6846
6959
|
utxoPath = "address/utxos";
|
|
6847
6960
|
rpc = "json-rpc";
|
|
6848
6961
|
constructor(e) {
|
|
@@ -6872,7 +6985,7 @@ var St = class {
|
|
|
6872
6985
|
const k = n[A];
|
|
6873
6986
|
if (!k) throw new Error(`Invalid raw index ${A} - not found in raw transactions array`);
|
|
6874
6987
|
let x = p.get(A);
|
|
6875
|
-
if (x === void 0 && (x =
|
|
6988
|
+
if (x === void 0 && (x = Ni(k), p.set(A, x)), l += T, u.push({
|
|
6876
6989
|
transactionId: w.transactionId,
|
|
6877
6990
|
outputIndex: w.outputIndex,
|
|
6878
6991
|
value: T,
|
|
@@ -6927,7 +7040,7 @@ var St = class {
|
|
|
6927
7040
|
priorityFee: 0n,
|
|
6928
7041
|
gasSatFee: 330n,
|
|
6929
7042
|
mldsaSigner: null
|
|
6930
|
-
}, a = await new
|
|
7043
|
+
}, a = await new ni().createBTCTransfer(o), c = await this.broadcastTransaction(a.tx, !1);
|
|
6931
7044
|
return c || { error: "Could not broadcast transaction" };
|
|
6932
7045
|
}
|
|
6933
7046
|
async rpcMethod(e, t) {
|
|
@@ -6987,7 +7100,7 @@ var St = class {
|
|
|
6987
7100
|
if (!s) throw new Error("Failed to generate address");
|
|
6988
7101
|
return s;
|
|
6989
7102
|
}
|
|
6990
|
-
}, Kr = /* @__PURE__ */
|
|
7103
|
+
}, Kr = /* @__PURE__ */ ae(vi(), 1), S = /* @__PURE__ */ (function(e) {
|
|
6991
7104
|
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
7105
|
})({}), Dr = {
|
|
6993
7106
|
address: S.ADDRESS,
|
|
@@ -7023,7 +7136,7 @@ var St = class {
|
|
|
7023
7136
|
"buffer[]": S.ARRAY_OF_BUFFERS,
|
|
7024
7137
|
"string[]": S.ARRAY_OF_STRING,
|
|
7025
7138
|
boolean: S.BOOL
|
|
7026
|
-
},
|
|
7139
|
+
}, gi = {
|
|
7027
7140
|
[S.ADDRESS]: "address",
|
|
7028
7141
|
[S.EXTENDED_ADDRESS]: "extendedAddress",
|
|
7029
7142
|
[S.BOOL]: "bool",
|
|
@@ -7057,28 +7170,28 @@ var St = class {
|
|
|
7057
7170
|
[S.ARRAY_OF_STRING]: "string[]",
|
|
7058
7171
|
[S.ARRAY_OF_BUFFERS]: "buffer[]"
|
|
7059
7172
|
};
|
|
7060
|
-
function
|
|
7173
|
+
function Si(e) {
|
|
7061
7174
|
return Array.isArray(e);
|
|
7062
7175
|
}
|
|
7063
|
-
function
|
|
7176
|
+
function Ae(e) {
|
|
7064
7177
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
7065
7178
|
}
|
|
7066
|
-
function
|
|
7179
|
+
function wi(e) {
|
|
7067
7180
|
return typeof e == "string";
|
|
7068
7181
|
}
|
|
7069
|
-
function
|
|
7070
|
-
if (
|
|
7071
|
-
const i =
|
|
7182
|
+
function Lt(e) {
|
|
7183
|
+
if (wi(e)) {
|
|
7184
|
+
const i = gi[e];
|
|
7072
7185
|
if (!i) throw new Error(`Unknown ABI type: ${e}`);
|
|
7073
7186
|
return i;
|
|
7074
7187
|
}
|
|
7075
|
-
if (
|
|
7188
|
+
if (Ae(e)) return `tuple(${Object.values(e).map((i) => Lt(i)).join(",")})`;
|
|
7076
7189
|
const t = e[0];
|
|
7077
|
-
return e.length === 1 && t !== void 0 ? `${
|
|
7190
|
+
return e.length === 1 && t !== void 0 ? `${Lt(t)}[]` : `tuple(${e.map((i) => Lt(i)).join(",")})[]`;
|
|
7078
7191
|
}
|
|
7079
7192
|
var Mr = class {
|
|
7080
7193
|
decodeData(e, t) {
|
|
7081
|
-
const i = new
|
|
7194
|
+
const i = new Ht(e), r = [];
|
|
7082
7195
|
for (const s of t) r.push(this.decodeSingleValue(i, s));
|
|
7083
7196
|
return r;
|
|
7084
7197
|
}
|
|
@@ -7090,11 +7203,11 @@ var Mr = class {
|
|
|
7090
7203
|
return e.toString(16);
|
|
7091
7204
|
}
|
|
7092
7205
|
decodeSingleValue(e, t) {
|
|
7093
|
-
if (
|
|
7206
|
+
if (Si(t)) {
|
|
7094
7207
|
const i = t[0];
|
|
7095
7208
|
return t.length === 1 && i !== void 0 ? this.decodeArray(e, i) : this.decodeTuple(e, t);
|
|
7096
7209
|
}
|
|
7097
|
-
if (
|
|
7210
|
+
if (Ae(t)) return this.decodeStruct(e, t);
|
|
7098
7211
|
switch (t) {
|
|
7099
7212
|
case S.UINT8:
|
|
7100
7213
|
return e.readU8();
|
|
@@ -7186,7 +7299,7 @@ var Mr = class {
|
|
|
7186
7299
|
sha256(e) {
|
|
7187
7300
|
return new Uint8Array(new Kr.default.sha256().update(e).digest());
|
|
7188
7301
|
}
|
|
7189
|
-
}, Nr = class
|
|
7302
|
+
}, Nr = class yi {
|
|
7190
7303
|
items;
|
|
7191
7304
|
keys;
|
|
7192
7305
|
constructor(t = []) {
|
|
@@ -7208,7 +7321,7 @@ var Mr = class {
|
|
|
7208
7321
|
this.items.delete(i) && (this.keys = this.keys.filter((r) => r.toBigInt() !== i));
|
|
7209
7322
|
}
|
|
7210
7323
|
clone() {
|
|
7211
|
-
return new
|
|
7324
|
+
return new yi(this.keys);
|
|
7212
7325
|
}
|
|
7213
7326
|
clear() {
|
|
7214
7327
|
this.items.clear(), this.keys = [];
|
|
@@ -7224,17 +7337,18 @@ var Mr = class {
|
|
|
7224
7337
|
*[Symbol.iterator]() {
|
|
7225
7338
|
yield* this.keys;
|
|
7226
7339
|
}
|
|
7227
|
-
}, xr = class
|
|
7340
|
+
}, xr = class mi {
|
|
7341
|
+
compareFn;
|
|
7228
7342
|
map;
|
|
7229
7343
|
#t;
|
|
7230
7344
|
constructor(t) {
|
|
7231
|
-
this.compareFn = t, this.map = new
|
|
7345
|
+
this.compareFn = t, this.map = new Wt(), this.#t = [];
|
|
7232
7346
|
}
|
|
7233
7347
|
get size() {
|
|
7234
7348
|
return this.map.size;
|
|
7235
7349
|
}
|
|
7236
7350
|
static fromMap(t, i) {
|
|
7237
|
-
const r = new
|
|
7351
|
+
const r = new mi(i);
|
|
7238
7352
|
for (const [s, n] of t) r.set(s, n);
|
|
7239
7353
|
return r;
|
|
7240
7354
|
}
|
|
@@ -7293,7 +7407,8 @@ var Mr = class {
|
|
|
7293
7407
|
*[Symbol.iterator]() {
|
|
7294
7408
|
for (const t of this.#t) yield [t, this.map.get(t)];
|
|
7295
7409
|
}
|
|
7296
|
-
}, Fr = class
|
|
7410
|
+
}, Fr = class Ti {
|
|
7411
|
+
compareFn;
|
|
7297
7412
|
elements;
|
|
7298
7413
|
constructor(t) {
|
|
7299
7414
|
this.compareFn = t, this.elements = [];
|
|
@@ -7302,7 +7417,7 @@ var Mr = class {
|
|
|
7302
7417
|
return this.elements.length;
|
|
7303
7418
|
}
|
|
7304
7419
|
static fromSet(t, i) {
|
|
7305
|
-
const r = new
|
|
7420
|
+
const r = new Ti(i);
|
|
7306
7421
|
for (const s of t) r.add(s);
|
|
7307
7422
|
return r;
|
|
7308
7423
|
}
|
|
@@ -7348,6 +7463,8 @@ var Mr = class {
|
|
|
7348
7463
|
};
|
|
7349
7464
|
}
|
|
7350
7465
|
}, Wr = class {
|
|
7466
|
+
type;
|
|
7467
|
+
data;
|
|
7351
7468
|
constructor(e, t) {
|
|
7352
7469
|
this.type = e, this.data = t;
|
|
7353
7470
|
}
|
|
@@ -7356,8 +7473,8 @@ var Mr = class {
|
|
|
7356
7473
|
})({}), Vr = /* @__PURE__ */ (function(e) {
|
|
7357
7474
|
return e.ECDSA = "ECDSA", e.BIP322 = "BIP322", e;
|
|
7358
7475
|
})({});
|
|
7359
|
-
|
|
7360
|
-
var zr = class extends
|
|
7476
|
+
vt();
|
|
7477
|
+
var zr = class extends we {
|
|
7361
7478
|
isInitialized = !1;
|
|
7362
7479
|
constructor() {
|
|
7363
7480
|
if (super(), !window) throw new Error("XverseSigner can only be used in a browser environment");
|
|
@@ -7400,7 +7517,7 @@ var zr = class extends Te {
|
|
|
7400
7517
|
if (!t) throw new Error("Payment address not found");
|
|
7401
7518
|
const i = t.address.startsWith("opt") ? y.opnetTestnet : t.address.startsWith("tb") ? y.testnet : t.address.startsWith("bc") ? y.bitcoin : null;
|
|
7402
7519
|
if (!i) throw new Error("Network not supported");
|
|
7403
|
-
this._network = i, this._publicKey =
|
|
7520
|
+
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
7521
|
}
|
|
7405
7522
|
async signData(e, t, i) {
|
|
7406
7523
|
if (!this.isInitialized) throw new Error("UnisatSigner not initialized");
|
|
@@ -7446,18 +7563,18 @@ var zr = class extends Te {
|
|
|
7446
7563
|
t.push(a);
|
|
7447
7564
|
const c = o.data.inputs.map((u, l) => {
|
|
7448
7565
|
let h = !1, p = !1;
|
|
7449
|
-
if (
|
|
7566
|
+
if (fe(u)) {
|
|
7450
7567
|
if (u.tapLeafScript && u.tapLeafScript.length > 0) {
|
|
7451
|
-
for (const w of u.tapLeafScript) if (
|
|
7568
|
+
for (const w of u.tapLeafScript) if (Se(this.publicKey, w.script)) {
|
|
7452
7569
|
h = !0, p = !1;
|
|
7453
7570
|
break;
|
|
7454
7571
|
}
|
|
7455
7572
|
}
|
|
7456
7573
|
if (!h && u.tapInternalKey) {
|
|
7457
7574
|
const w = u.tapInternalKey;
|
|
7458
|
-
C(w,
|
|
7575
|
+
C(w, O(this.publicKey)) && (h = !0, p = !0);
|
|
7459
7576
|
}
|
|
7460
|
-
} else
|
|
7577
|
+
} else ge(u, this.publicKey) && (h = !0, p = !1);
|
|
7461
7578
|
return h ? {
|
|
7462
7579
|
index: l,
|
|
7463
7580
|
publicKey: f(this.publicKey),
|
|
@@ -7474,7 +7591,7 @@ var zr = class extends Te {
|
|
|
7474
7591
|
signInputs: r
|
|
7475
7592
|
});
|
|
7476
7593
|
if ("error" in s) throw new Error(s.error.message);
|
|
7477
|
-
const n =
|
|
7594
|
+
const n = N.fromBase64(s.result.psbt);
|
|
7478
7595
|
e[0].combine(n);
|
|
7479
7596
|
}
|
|
7480
7597
|
hasAlreadySignedTapScriptSig(e) {
|
|
@@ -7515,7 +7632,7 @@ var zr = class extends Te {
|
|
|
7515
7632
|
signInputs: o
|
|
7516
7633
|
});
|
|
7517
7634
|
if ("error" in a) throw new Error(a.error.message);
|
|
7518
|
-
return
|
|
7635
|
+
return N.fromBase64(a.result.psbt);
|
|
7519
7636
|
}
|
|
7520
7637
|
getNonDuplicateScriptSig(e, t) {
|
|
7521
7638
|
const i = [];
|
|
@@ -7525,7 +7642,7 @@ var zr = class extends Te {
|
|
|
7525
7642
|
}
|
|
7526
7643
|
return i;
|
|
7527
7644
|
}
|
|
7528
|
-
}, qr = class
|
|
7645
|
+
}, qr = class oe {
|
|
7529
7646
|
static INITIAL_CAPACITY = 16;
|
|
7530
7647
|
static LOAD_FACTOR = 0.75;
|
|
7531
7648
|
#t;
|
|
@@ -7533,7 +7650,7 @@ var zr = class extends Te {
|
|
|
7533
7650
|
deleted;
|
|
7534
7651
|
capacity;
|
|
7535
7652
|
constructor() {
|
|
7536
|
-
this.capacity =
|
|
7653
|
+
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
7654
|
}
|
|
7538
7655
|
_size = 0;
|
|
7539
7656
|
get size() {
|
|
@@ -7542,7 +7659,7 @@ var zr = class extends Te {
|
|
|
7542
7659
|
set(t, i) {
|
|
7543
7660
|
let r = !0;
|
|
7544
7661
|
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 *
|
|
7662
|
+
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
7663
|
}
|
|
7547
7664
|
get(t) {
|
|
7548
7665
|
const i = this.findIndex(t);
|
|
@@ -7670,284 +7787,286 @@ var zr = class extends Te {
|
|
|
7670
7787
|
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
7788
|
for (let r = 0; r < t.length; r++) t[r] !== void 0 && !this.deleted[r] && this.set(t[r], i[r]);
|
|
7672
7789
|
}
|
|
7673
|
-
},
|
|
7790
|
+
}, ms = /* @__PURE__ */ Ai({
|
|
7674
7791
|
ABICoder: () => Mr,
|
|
7675
7792
|
ABIDataTypes: () => S,
|
|
7676
7793
|
ADDRESS_BYTE_LENGTH: () => 32,
|
|
7677
|
-
ANCHOR_SCRIPT: () =>
|
|
7678
|
-
AbiTypeToStr: () =>
|
|
7679
|
-
Address: () =>
|
|
7680
|
-
AddressGenerator: () =>
|
|
7681
|
-
AddressMap: () =>
|
|
7794
|
+
ANCHOR_SCRIPT: () => se,
|
|
7795
|
+
AbiTypeToStr: () => gi,
|
|
7796
|
+
Address: () => z,
|
|
7797
|
+
AddressGenerator: () => de,
|
|
7798
|
+
AddressMap: () => Fe,
|
|
7682
7799
|
AddressSet: () => Nr,
|
|
7683
|
-
AddressTypes: () =>
|
|
7684
|
-
AddressVerificator: () =>
|
|
7685
|
-
BIPStandard: () =>
|
|
7800
|
+
AddressTypes: () => ct,
|
|
7801
|
+
AddressVerificator: () => Et,
|
|
7802
|
+
BIPStandard: () => kt,
|
|
7686
7803
|
BOOLEAN_BYTE_LENGTH: () => 1,
|
|
7687
|
-
BinaryReader: () =>
|
|
7688
|
-
BinaryWriter: () =>
|
|
7804
|
+
BinaryReader: () => Ht,
|
|
7805
|
+
BinaryWriter: () => V,
|
|
7689
7806
|
BitcoinUtils: () => W,
|
|
7690
|
-
BufferHelper: () =>
|
|
7691
|
-
CSVModes: () =>
|
|
7692
|
-
CSVMultisigProvider: () =>
|
|
7693
|
-
CalldataGenerator: () =>
|
|
7694
|
-
CancelTransaction: () =>
|
|
7695
|
-
ChainId: () =>
|
|
7696
|
-
ChallengeSolution: () =>
|
|
7697
|
-
ChallengeSubmission: () =>
|
|
7698
|
-
ChallengeVerification: () =>
|
|
7807
|
+
BufferHelper: () => _t,
|
|
7808
|
+
CSVModes: () => Or,
|
|
7809
|
+
CSVMultisigProvider: () => rt,
|
|
7810
|
+
CalldataGenerator: () => le,
|
|
7811
|
+
CancelTransaction: () => me,
|
|
7812
|
+
ChainId: () => Qe,
|
|
7813
|
+
ChallengeSolution: () => ne,
|
|
7814
|
+
ChallengeSubmission: () => fi,
|
|
7815
|
+
ChallengeVerification: () => pi,
|
|
7699
7816
|
Compressor: () => Z,
|
|
7700
|
-
Consensus: () =>
|
|
7701
|
-
ConsolidatedInteractionTransaction: () =>
|
|
7702
|
-
ContractAddress: () =>
|
|
7703
|
-
ContractBaseMetadata: () =>
|
|
7704
|
-
CustomGenerator: () =>
|
|
7705
|
-
CustomKeypair: () =>
|
|
7817
|
+
Consensus: () => Vt,
|
|
7818
|
+
ConsolidatedInteractionTransaction: () => si,
|
|
7819
|
+
ContractAddress: () => Qt,
|
|
7820
|
+
ContractBaseMetadata: () => yr,
|
|
7821
|
+
CustomGenerator: () => ze,
|
|
7822
|
+
CustomKeypair: () => we,
|
|
7706
7823
|
CustomMap: () => qr,
|
|
7707
|
-
CustomScriptTransaction: () =>
|
|
7708
|
-
DeploymentGenerator: () =>
|
|
7709
|
-
DeploymentTransaction: () =>
|
|
7824
|
+
CustomScriptTransaction: () => Kt,
|
|
7825
|
+
DeploymentGenerator: () => he,
|
|
7826
|
+
DeploymentTransaction: () => Dt,
|
|
7710
7827
|
DeterministicMap: () => xr,
|
|
7711
7828
|
DeterministicSet: () => Fr,
|
|
7712
7829
|
EXTENDED_ADDRESS_BYTE_LENGTH: () => 64,
|
|
7713
7830
|
EcKeyPair: () => I,
|
|
7714
|
-
EpochValidator: () =>
|
|
7715
|
-
ExtendedAddressMap: () =>
|
|
7716
|
-
FastMap: () =>
|
|
7831
|
+
EpochValidator: () => wt,
|
|
7832
|
+
ExtendedAddressMap: () => We,
|
|
7833
|
+
FastMap: () => Wt,
|
|
7717
7834
|
FeaturePriority: () => J,
|
|
7718
|
-
Features: () =>
|
|
7719
|
-
FundingTransaction: () =>
|
|
7835
|
+
Features: () => q,
|
|
7836
|
+
FundingTransaction: () => Mt,
|
|
7720
7837
|
Generator: () => tt,
|
|
7721
|
-
HashCommitmentGenerator: () =>
|
|
7838
|
+
HashCommitmentGenerator: () => St,
|
|
7722
7839
|
I128_BYTE_LENGTH: () => 16,
|
|
7723
7840
|
I16_BYTE_LENGTH: () => 2,
|
|
7724
7841
|
I256_BYTE_LENGTH: () => 32,
|
|
7725
7842
|
I32_BYTE_LENGTH: () => 4,
|
|
7726
7843
|
I64_BYTE_LENGTH: () => 8,
|
|
7727
7844
|
I8_BYTE_LENGTH: () => 1,
|
|
7728
|
-
InteractionTransaction: () =>
|
|
7729
|
-
InteractionTransactionP2WDA: () =>
|
|
7845
|
+
InteractionTransaction: () => Nt,
|
|
7846
|
+
InteractionTransactionP2WDA: () => ri,
|
|
7730
7847
|
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: () =>
|
|
7848
|
+
LegacyCalldataGenerator: () => ur,
|
|
7849
|
+
MINIMUM_AMOUNT_CA: () => ei,
|
|
7850
|
+
MINIMUM_AMOUNT_REWARD: () => Pt,
|
|
7851
|
+
MLDSAPublicKeyMetadata: () => wr,
|
|
7852
|
+
MLDSASecurityLevel: () => v.MLDSASecurityLevel,
|
|
7853
|
+
MessageSigner: () => st,
|
|
7854
|
+
MessageType: () => dr,
|
|
7855
|
+
Mnemonic: () => Sr,
|
|
7856
|
+
MnemonicStrength: () => ee,
|
|
7857
|
+
MultiSignGenerator: () => Ge,
|
|
7741
7858
|
MultiSignTransaction: () => Q,
|
|
7742
|
-
NUMS_INTERNAL_KEY: () =>
|
|
7859
|
+
NUMS_INTERNAL_KEY: () => Ut,
|
|
7743
7860
|
NetEvent: () => Wr,
|
|
7744
7861
|
OPNET_DEPLOYMENT_VERSION: () => 0,
|
|
7745
|
-
OPNetConsensusConfig: () =>
|
|
7862
|
+
OPNetConsensusConfig: () => di,
|
|
7746
7863
|
OPNetLimitedProvider: () => kr,
|
|
7747
7864
|
OfflineTransactionManager: () => Br,
|
|
7748
7865
|
P2MR_MS: () => Cr,
|
|
7749
7866
|
P2TR_MS: () => Rr,
|
|
7750
|
-
P2WDADetector: () =>
|
|
7751
|
-
P2WDAGenerator: () =>
|
|
7867
|
+
P2WDADetector: () => X,
|
|
7868
|
+
P2WDAGenerator: () => Jt,
|
|
7752
7869
|
PSBTTypes: () => Lr,
|
|
7753
|
-
QuantumBIP32Factory: () =>
|
|
7754
|
-
QuantumDerivationPath: () =>
|
|
7755
|
-
RoswellConsensus: () =>
|
|
7870
|
+
QuantumBIP32Factory: () => v.QuantumBIP32Factory,
|
|
7871
|
+
QuantumDerivationPath: () => v.QuantumDerivationPath,
|
|
7872
|
+
RoswellConsensus: () => hi,
|
|
7756
7873
|
SCHNORR_SIGNATURE_BYTE_LENGTH: () => 64,
|
|
7757
7874
|
SELECTOR_BYTE_LENGTH: () => 4,
|
|
7758
|
-
SERIALIZATION_FORMAT_VERSION: () =>
|
|
7875
|
+
SERIALIZATION_FORMAT_VERSION: () => 2,
|
|
7759
7876
|
SERIALIZATION_MAGIC_BYTE: () => 66,
|
|
7760
|
-
Secp256k1PointDeriver: () =>
|
|
7761
|
-
SharedInteractionTransaction: () =>
|
|
7762
|
-
SignatureType: () =>
|
|
7877
|
+
Secp256k1PointDeriver: () => Ne,
|
|
7878
|
+
SharedInteractionTransaction: () => ye,
|
|
7879
|
+
SignatureType: () => te,
|
|
7763
7880
|
SigningProtocol: () => Vr,
|
|
7764
7881
|
StrToAbiType: () => Dr,
|
|
7765
|
-
|
|
7882
|
+
TOLERANCE: () => 1,
|
|
7883
|
+
TapscriptVerificator: () => lr,
|
|
7766
7884
|
TimeLockGenerator: () => nt,
|
|
7767
7885
|
TransactionBuilder: () => B,
|
|
7768
|
-
TransactionFactory: () =>
|
|
7769
|
-
TransactionReconstructor: () =>
|
|
7770
|
-
TransactionSequence: () =>
|
|
7771
|
-
TransactionSerializer: () =>
|
|
7772
|
-
TransactionStateCapture: () =>
|
|
7886
|
+
TransactionFactory: () => ni,
|
|
7887
|
+
TransactionReconstructor: () => j,
|
|
7888
|
+
TransactionSequence: () => vr,
|
|
7889
|
+
TransactionSerializer: () => P,
|
|
7890
|
+
TransactionStateCapture: () => $,
|
|
7773
7891
|
TransactionType: () => m,
|
|
7774
|
-
TweakedSigner: () =>
|
|
7775
|
-
TweakedTransaction: () =>
|
|
7892
|
+
TweakedSigner: () => pe,
|
|
7893
|
+
TweakedTransaction: () => ti,
|
|
7776
7894
|
U128_BYTE_LENGTH: () => 16,
|
|
7777
7895
|
U16_BYTE_LENGTH: () => 2,
|
|
7778
7896
|
U256_BYTE_LENGTH: () => 32,
|
|
7779
7897
|
U32_BYTE_LENGTH: () => 4,
|
|
7780
7898
|
U64_BYTE_LENGTH: () => 8,
|
|
7781
7899
|
U8_BYTE_LENGTH: () => 1,
|
|
7782
|
-
UnisatChainType: () =>
|
|
7783
|
-
UnisatSigner: () =>
|
|
7784
|
-
Wallet: () =>
|
|
7900
|
+
UnisatChainType: () => hr,
|
|
7901
|
+
UnisatSigner: () => Tr,
|
|
7902
|
+
Wallet: () => Bt,
|
|
7785
7903
|
WalletNetworks: () => Tt,
|
|
7786
7904
|
XverseNetwork: () => Hr,
|
|
7787
7905
|
XverseSigner: () => zr,
|
|
7788
|
-
abiTypeToSelectorString: () =>
|
|
7789
|
-
buildBIPPath: () =>
|
|
7790
|
-
createAddressRotation: () =>
|
|
7791
|
-
createSignerMap: () =>
|
|
7792
|
-
currentConsensus: () =>
|
|
7906
|
+
abiTypeToSelectorString: () => Lt,
|
|
7907
|
+
buildBIPPath: () => Ye,
|
|
7908
|
+
createAddressRotation: () => Er,
|
|
7909
|
+
createSignerMap: () => Ze,
|
|
7910
|
+
currentConsensus: () => Te,
|
|
7793
7911
|
currentConsensusConfig: () => Ur,
|
|
7794
|
-
disabledAddressRotation: () =>
|
|
7795
|
-
getBIPDescription: () =>
|
|
7796
|
-
getLevelFromPublicKeyLength: () =>
|
|
7797
|
-
isAbiStruct: () =>
|
|
7798
|
-
isAbiTuple: () =>
|
|
7799
|
-
isCancelSpecificData: () =>
|
|
7800
|
-
isCustomScriptSpecificData: () =>
|
|
7801
|
-
isDeploymentSpecificData: () =>
|
|
7802
|
-
isFundingSpecificData: () =>
|
|
7803
|
-
isInteractionSpecificData: () =>
|
|
7912
|
+
disabledAddressRotation: () => Ir,
|
|
7913
|
+
getBIPDescription: () => fr,
|
|
7914
|
+
getLevelFromPublicKeyLength: () => ie,
|
|
7915
|
+
isAbiStruct: () => Ae,
|
|
7916
|
+
isAbiTuple: () => Si,
|
|
7917
|
+
isCancelSpecificData: () => li,
|
|
7918
|
+
isCustomScriptSpecificData: () => ui,
|
|
7919
|
+
isDeploymentSpecificData: () => ai,
|
|
7920
|
+
isFundingSpecificData: () => oi,
|
|
7921
|
+
isInteractionSpecificData: () => ci,
|
|
7804
7922
|
isMultiSigSpecificData: () => et,
|
|
7805
|
-
isOPWallet: () =>
|
|
7806
|
-
isSimpleAbiType: () =>
|
|
7807
|
-
isUniversalSigner: () =>
|
|
7808
|
-
toParallelKeyPair: () =>
|
|
7809
|
-
toTweakedParallelKeyPair: () =>
|
|
7810
|
-
version: () =>
|
|
7811
|
-
versionBuffer: () =>
|
|
7812
|
-
}),
|
|
7923
|
+
isOPWallet: () => $e,
|
|
7924
|
+
isSimpleAbiType: () => wi,
|
|
7925
|
+
isUniversalSigner: () => dt,
|
|
7926
|
+
toParallelKeyPair: () => Pr,
|
|
7927
|
+
toTweakedParallelKeyPair: () => Je,
|
|
7928
|
+
version: () => ji,
|
|
7929
|
+
versionBuffer: () => qe
|
|
7930
|
+
}), Ts = v.MLDSASecurityLevel, As = v.QuantumBIP32Factory, bs = v.QuantumDerivationPath;
|
|
7813
7931
|
export {
|
|
7814
7932
|
Mr as ABICoder,
|
|
7815
7933
|
S as ABIDataTypes,
|
|
7816
7934
|
jr as ADDRESS_BYTE_LENGTH,
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7935
|
+
se as ANCHOR_SCRIPT,
|
|
7936
|
+
gi as AbiTypeToStr,
|
|
7937
|
+
z as Address,
|
|
7938
|
+
de as AddressGenerator,
|
|
7939
|
+
Fe as AddressMap,
|
|
7822
7940
|
Nr as AddressSet,
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7941
|
+
ct as AddressTypes,
|
|
7942
|
+
Et as AddressVerificator,
|
|
7943
|
+
kt as BIPStandard,
|
|
7826
7944
|
ds as BOOLEAN_BYTE_LENGTH,
|
|
7827
|
-
|
|
7828
|
-
|
|
7945
|
+
Ht as BinaryReader,
|
|
7946
|
+
V as BinaryWriter,
|
|
7829
7947
|
W as BitcoinUtils,
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7948
|
+
_t as BufferHelper,
|
|
7949
|
+
Or as CSVModes,
|
|
7950
|
+
rt as CSVMultisigProvider,
|
|
7951
|
+
le as CalldataGenerator,
|
|
7952
|
+
me as CancelTransaction,
|
|
7953
|
+
Qe as ChainId,
|
|
7954
|
+
ne as ChallengeSolution,
|
|
7955
|
+
fi as ChallengeSubmission,
|
|
7956
|
+
pi as ChallengeVerification,
|
|
7839
7957
|
Z as Compressor,
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7958
|
+
Vt as Consensus,
|
|
7959
|
+
si as ConsolidatedInteractionTransaction,
|
|
7960
|
+
Qt as ContractAddress,
|
|
7961
|
+
yr as ContractBaseMetadata,
|
|
7962
|
+
ze as CustomGenerator,
|
|
7963
|
+
we as CustomKeypair,
|
|
7846
7964
|
qr as CustomMap,
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7965
|
+
Kt as CustomScriptTransaction,
|
|
7966
|
+
he as DeploymentGenerator,
|
|
7967
|
+
Dt as DeploymentTransaction,
|
|
7850
7968
|
xr as DeterministicMap,
|
|
7851
7969
|
Fr as DeterministicSet,
|
|
7852
7970
|
Qr as EXTENDED_ADDRESS_BYTE_LENGTH,
|
|
7853
7971
|
I as EcKeyPair,
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7972
|
+
wt as EpochValidator,
|
|
7973
|
+
We as ExtendedAddressMap,
|
|
7974
|
+
Wt as FastMap,
|
|
7857
7975
|
J as FeaturePriority,
|
|
7858
|
-
|
|
7859
|
-
|
|
7976
|
+
q as Features,
|
|
7977
|
+
Mt as FundingTransaction,
|
|
7860
7978
|
tt as Generator,
|
|
7861
|
-
|
|
7979
|
+
St as HashCommitmentGenerator,
|
|
7862
7980
|
as as I128_BYTE_LENGTH,
|
|
7863
7981
|
ls as I16_BYTE_LENGTH,
|
|
7864
7982
|
os as I256_BYTE_LENGTH,
|
|
7865
7983
|
us as I32_BYTE_LENGTH,
|
|
7866
7984
|
cs as I64_BYTE_LENGTH,
|
|
7867
7985
|
hs as I8_BYTE_LENGTH,
|
|
7868
|
-
|
|
7869
|
-
|
|
7986
|
+
Nt as InteractionTransaction,
|
|
7987
|
+
ri as InteractionTransactionP2WDA,
|
|
7870
7988
|
gs as LEAF_VERSION_TAPSCRIPT,
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7989
|
+
ur as LegacyCalldataGenerator,
|
|
7990
|
+
ei as MINIMUM_AMOUNT_CA,
|
|
7991
|
+
Pt as MINIMUM_AMOUNT_REWARD,
|
|
7992
|
+
wr as MLDSAPublicKeyMetadata,
|
|
7993
|
+
Ts as MLDSASecurityLevel,
|
|
7994
|
+
st as MessageSigner,
|
|
7995
|
+
dr as MessageType,
|
|
7996
|
+
Sr as Mnemonic,
|
|
7997
|
+
ee as MnemonicStrength,
|
|
7998
|
+
Ge as MultiSignGenerator,
|
|
7881
7999
|
Q as MultiSignTransaction,
|
|
7882
|
-
|
|
8000
|
+
Ut as NUMS_INTERNAL_KEY,
|
|
7883
8001
|
Wr as NetEvent,
|
|
7884
8002
|
fs as OPNET_DEPLOYMENT_VERSION,
|
|
7885
|
-
|
|
8003
|
+
di as OPNetConsensusConfig,
|
|
7886
8004
|
kr as OPNetLimitedProvider,
|
|
7887
8005
|
Br as OfflineTransactionManager,
|
|
7888
8006
|
Cr as P2MR_MS,
|
|
7889
8007
|
Rr as P2TR_MS,
|
|
7890
|
-
|
|
7891
|
-
|
|
8008
|
+
X as P2WDADetector,
|
|
8009
|
+
Jt as P2WDAGenerator,
|
|
7892
8010
|
Lr as PSBTTypes,
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
8011
|
+
As as QuantumBIP32Factory,
|
|
8012
|
+
bs as QuantumDerivationPath,
|
|
8013
|
+
hi as RoswellConsensus,
|
|
7896
8014
|
Zr as SCHNORR_SIGNATURE_BYTE_LENGTH,
|
|
7897
8015
|
Jr as SELECTOR_BYTE_LENGTH,
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
8016
|
+
ws as SERIALIZATION_FORMAT_VERSION,
|
|
8017
|
+
ys as SERIALIZATION_MAGIC_BYTE,
|
|
8018
|
+
Ne as Secp256k1PointDeriver,
|
|
8019
|
+
ye as SharedInteractionTransaction,
|
|
8020
|
+
te as SignatureType,
|
|
7903
8021
|
Vr as SigningProtocol,
|
|
7904
8022
|
Dr as StrToAbiType,
|
|
7905
|
-
|
|
8023
|
+
Ss as TOLERANCE,
|
|
8024
|
+
lr as TapscriptVerificator,
|
|
7906
8025
|
nt as TimeLockGenerator,
|
|
7907
8026
|
B as TransactionBuilder,
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
8027
|
+
ni as TransactionFactory,
|
|
8028
|
+
j as TransactionReconstructor,
|
|
8029
|
+
vr as TransactionSequence,
|
|
8030
|
+
P as TransactionSerializer,
|
|
8031
|
+
$ as TransactionStateCapture,
|
|
7913
8032
|
m as TransactionType,
|
|
7914
|
-
|
|
7915
|
-
|
|
8033
|
+
pe as TweakedSigner,
|
|
8034
|
+
ti as TweakedTransaction,
|
|
7916
8035
|
es as U128_BYTE_LENGTH,
|
|
7917
8036
|
ss as U16_BYTE_LENGTH,
|
|
7918
8037
|
ts as U256_BYTE_LENGTH,
|
|
7919
8038
|
rs as U32_BYTE_LENGTH,
|
|
7920
8039
|
is as U64_BYTE_LENGTH,
|
|
7921
8040
|
ns as U8_BYTE_LENGTH,
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
8041
|
+
hr as UnisatChainType,
|
|
8042
|
+
Tr as UnisatSigner,
|
|
8043
|
+
Bt as Wallet,
|
|
7925
8044
|
Tt as WalletNetworks,
|
|
7926
8045
|
Hr as XverseNetwork,
|
|
7927
8046
|
zr as XverseSigner,
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
8047
|
+
Lt as abiTypeToSelectorString,
|
|
8048
|
+
Ye as buildBIPPath,
|
|
8049
|
+
Er as createAddressRotation,
|
|
8050
|
+
Ze as createSignerMap,
|
|
8051
|
+
Te as currentConsensus,
|
|
7933
8052
|
Ur as currentConsensusConfig,
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
8053
|
+
Ir as disabledAddressRotation,
|
|
8054
|
+
fr as getBIPDescription,
|
|
8055
|
+
ie as getLevelFromPublicKeyLength,
|
|
8056
|
+
Ae as isAbiStruct,
|
|
8057
|
+
Si as isAbiTuple,
|
|
8058
|
+
li as isCancelSpecificData,
|
|
8059
|
+
ui as isCustomScriptSpecificData,
|
|
8060
|
+
ai as isDeploymentSpecificData,
|
|
8061
|
+
oi as isFundingSpecificData,
|
|
8062
|
+
ci as isInteractionSpecificData,
|
|
7944
8063
|
et as isMultiSigSpecificData,
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
8064
|
+
$e as isOPWallet,
|
|
8065
|
+
wi as isSimpleAbiType,
|
|
8066
|
+
dt as isUniversalSigner,
|
|
8067
|
+
ms as opnet,
|
|
8068
|
+
Pr as toParallelKeyPair,
|
|
8069
|
+
Je as toTweakedParallelKeyPair,
|
|
8070
|
+
ji as version,
|
|
8071
|
+
qe as versionBuffer
|
|
7953
8072
|
};
|