@btc-vision/transaction 1.8.0-alpha.1 → 1.8.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/_version.d.ts +1 -1
- package/browser/abi/ABICoder.d.ts +8 -0
- package/browser/buffer/BinaryReader.d.ts +16 -1
- package/browser/buffer/BinaryWriter.d.ts +11 -1
- package/browser/deterministic/ExtendedAddressMap.d.ts +3 -1
- package/browser/index.js +1102 -861
- package/browser/keypair/Address.d.ts +1 -0
- package/browser/utils/lengths.d.ts +3 -1
- package/browser/utils/types.d.ts +3 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/abi/ABICoder.d.ts +8 -0
- package/build/abi/ABICoder.js +32 -0
- package/build/buffer/BinaryReader.d.ts +16 -1
- package/build/buffer/BinaryReader.js +66 -1
- package/build/buffer/BinaryWriter.d.ts +11 -1
- package/build/buffer/BinaryWriter.js +66 -1
- package/build/deterministic/ExtendedAddressMap.d.ts +3 -1
- package/build/deterministic/ExtendedAddressMap.js +44 -17
- package/build/keypair/Address.d.ts +1 -0
- package/build/keypair/Address.js +19 -4
- package/build/transaction/builders/MultiSignTransaction.js +2 -2
- package/build/transaction/shared/TweakedTransaction.js +3 -3
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utils/lengths.d.ts +3 -1
- package/build/utils/lengths.js +3 -1
- package/build/utils/types.d.ts +3 -0
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/abi/ABICoder.ts +43 -0
- package/src/buffer/BinaryReader.ts +158 -2
- package/src/buffer/BinaryWriter.ts +143 -1
- package/src/deterministic/ExtendedAddressMap.ts +59 -20
- package/src/keypair/Address.ts +27 -6
- package/src/transaction/builders/MultiSignTransaction.ts +2 -2
- package/src/transaction/shared/TweakedTransaction.ts +3 -3
- package/src/utils/lengths.ts +3 -1
- package/src/utils/types.ts +4 -1
- package/test/binary-reader-writer.test.ts +457 -0
- package/test/derivePath.test.ts +4 -4
package/browser/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { B as a, f as
|
|
2
|
-
import { i as ot, b as I, p as
|
|
3
|
-
import { s as
|
|
4
|
-
import { A as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
return a.from(
|
|
1
|
+
import { B as a, f as Gt, g as Be, h as E, j as G, s as mi, k as ie, a as T, L as De, d as Rt, l as Mt, m as wt, c as bi, e as Ii, b as Ti, n as Ei } from "./vendors.js";
|
|
2
|
+
import { i as ot, b as I, p as Pi, a as pt, c as re, t as O, d as rt, e as it, f as L, g as Ce, h as se, j as mt, k as xe, l as Ai, o as g, m as F, n as Ft, q as te, r as Re, s as Oi, u as Y, v as gt, w as Bi, x as xi, y as Fe, z as Lt, A as Qt, B as Ne, C as vi, D as Me, P as U, E as ki, F as ve, G as Ui, H as ke, I as Li, J as _i, K as Ki, L as Di, M as R, T as ne, N as Ci } from "./btc-vision-bitcoin.js";
|
|
3
|
+
import { s as Ri, m as Fi, e as Ni } from "./noble-curves.js";
|
|
4
|
+
import { A as Mi, z as le, y as Wi, v as Hi } from "./noble-hashes.js";
|
|
5
|
+
const Vi = "1.8.0-alpha.2";
|
|
6
|
+
function zi(n, t = {}) {
|
|
7
|
+
return a.from(Gt.gzip(n, { level: t.level || 6 }));
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return a.from(
|
|
9
|
+
function qi(n) {
|
|
10
|
+
return a.from(Gt.ungzip(n));
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return a.from(
|
|
12
|
+
function $i(n, t = {}) {
|
|
13
|
+
return a.from(Gt.deflate(n, { level: t.level || 6 }));
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return a.from(
|
|
15
|
+
function Xi(n) {
|
|
16
|
+
return a.from(Gt.inflate(n));
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
gzipSync:
|
|
20
|
-
gunzipSync:
|
|
21
|
-
deflateSync:
|
|
22
|
-
inflateSync:
|
|
18
|
+
const Ue = {
|
|
19
|
+
gzipSync: zi,
|
|
20
|
+
gunzipSync: qi,
|
|
21
|
+
deflateSync: $i,
|
|
22
|
+
inflateSync: Xi
|
|
23
23
|
};
|
|
24
|
-
class
|
|
24
|
+
class W {
|
|
25
25
|
static {
|
|
26
26
|
this.zlibOptions = {
|
|
27
27
|
level: 9,
|
|
@@ -35,7 +35,7 @@ class N {
|
|
|
35
35
|
* @returns {Buffer} The compressed data.
|
|
36
36
|
*/
|
|
37
37
|
static compress(t) {
|
|
38
|
-
return
|
|
38
|
+
return Ue.gzipSync(t, W.zlibOptions);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Decompresses the data using gunzip.
|
|
@@ -43,23 +43,23 @@ class N {
|
|
|
43
43
|
* @returns {Buffer} The decompressed data.
|
|
44
44
|
*/
|
|
45
45
|
static decompress(t) {
|
|
46
|
-
return
|
|
46
|
+
return Ue.gunzipSync(t, W.zlibOptions);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
ot(G);
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
50
|
+
const We = typeof Be == "function" ? Be : E.BIP32Factory;
|
|
51
|
+
if (!We)
|
|
52
52
|
throw new Error("Failed to load BIP32 library");
|
|
53
|
-
const at =
|
|
54
|
-
function
|
|
55
|
-
return
|
|
53
|
+
const at = Ri.Point, Yi = at.Fn.ORDER, Gi = Mi("TapTweak"), Le = le(Gi);
|
|
54
|
+
function Qi(n) {
|
|
55
|
+
return le(Hi(Le, Le, n));
|
|
56
56
|
}
|
|
57
57
|
class A {
|
|
58
58
|
static {
|
|
59
|
-
this.BIP32 =
|
|
59
|
+
this.BIP32 = We(G);
|
|
60
60
|
}
|
|
61
61
|
static {
|
|
62
|
-
this.ECPair =
|
|
62
|
+
this.ECPair = mi.ECPairFactory(G);
|
|
63
63
|
}
|
|
64
64
|
static {
|
|
65
65
|
at.BASE.precompute(8);
|
|
@@ -106,11 +106,11 @@ class A {
|
|
|
106
106
|
static generateMultiSigAddress(t, e, i = I) {
|
|
107
107
|
const r = this.verifyPubKeys(t, i);
|
|
108
108
|
if (r.length !== t.length) throw new Error("Contains invalid public keys");
|
|
109
|
-
const s =
|
|
109
|
+
const s = Pi({
|
|
110
110
|
m: e,
|
|
111
111
|
pubkeys: r,
|
|
112
112
|
network: i
|
|
113
|
-
}), c =
|
|
113
|
+
}), c = pt({ redeem: s, network: i }).address;
|
|
114
114
|
if (!c)
|
|
115
115
|
throw new Error("Failed to generate address");
|
|
116
116
|
return c;
|
|
@@ -137,7 +137,7 @@ class A {
|
|
|
137
137
|
* @returns {string} - The address
|
|
138
138
|
*/
|
|
139
139
|
static getP2WPKHAddress(t, e = I) {
|
|
140
|
-
const i =
|
|
140
|
+
const i = re({ pubkey: a.from(t.publicKey), network: e });
|
|
141
141
|
if (!i.address)
|
|
142
142
|
throw new Error("Failed to generate wallet");
|
|
143
143
|
return i.address;
|
|
@@ -152,7 +152,7 @@ class A {
|
|
|
152
152
|
static tweakedPubKeyToAddress(t, e) {
|
|
153
153
|
t.startsWith("0x") && (t = t.slice(2));
|
|
154
154
|
let i = a.from(t, "hex");
|
|
155
|
-
return i.length !== 32 && (i =
|
|
155
|
+
return i.length !== 32 && (i = O(i)), A.tweakedPubKeyBufferToAddress(i, e);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Get the address of a tweaked public key
|
|
@@ -185,7 +185,7 @@ class A {
|
|
|
185
185
|
if (r.length < 2 || r.length > 40)
|
|
186
186
|
throw new Error("Witness program must be 2-40 bytes.");
|
|
187
187
|
const s = L([g.OP_16, r]);
|
|
188
|
-
return
|
|
188
|
+
return Ce(s, e);
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Get the address of a xOnly tweaked public key
|
|
@@ -212,7 +212,7 @@ class A {
|
|
|
212
212
|
*/
|
|
213
213
|
static tweakPublicKey(t) {
|
|
214
214
|
typeof t == "string" && t.startsWith("0x") && (t = t.slice(2));
|
|
215
|
-
const e = at.fromHex(t), i = (e.y & 1n) === 0n ? e : e.negate(), r = a.from(i.toBytes(!0).subarray(1)), s =
|
|
215
|
+
const e = at.fromHex(t), i = (e.y & 1n) === 0n ? e : e.negate(), r = a.from(i.toBytes(!0).subarray(1)), s = Qi(r), o = Fi(Ni(s), Yi), c = i.add(at.BASE.multiply(o));
|
|
216
216
|
return a.from(c.toBytes(!0));
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
@@ -235,7 +235,7 @@ class A {
|
|
|
235
235
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
236
236
|
* @returns An object containing both classical and quantum key information
|
|
237
237
|
*/
|
|
238
|
-
static generateWallet(t = I, e =
|
|
238
|
+
static generateWallet(t = I, e = E.MLDSASecurityLevel.LEVEL2) {
|
|
239
239
|
const i = this.ECPair.makeRandom({
|
|
240
240
|
network: t
|
|
241
241
|
}), r = this.getP2WPKHAddress(i, t);
|
|
@@ -260,8 +260,8 @@ class A {
|
|
|
260
260
|
* @param network - The Bitcoin network (default: bitcoin mainnet)
|
|
261
261
|
* @returns A random ML-DSA keypair
|
|
262
262
|
*/
|
|
263
|
-
static generateQuantumKeyPair(t =
|
|
264
|
-
const i =
|
|
263
|
+
static generateQuantumKeyPair(t = E.MLDSASecurityLevel.LEVEL2, e = I) {
|
|
264
|
+
const i = Wi(64), r = E.QuantumBIP32Factory.fromSeed(
|
|
265
265
|
a.from(i),
|
|
266
266
|
e,
|
|
267
267
|
t
|
|
@@ -280,7 +280,7 @@ class A {
|
|
|
280
280
|
* @returns {boolean} - Whether the address is valid
|
|
281
281
|
*/
|
|
282
282
|
static verifyContractAddress(t, e = I) {
|
|
283
|
-
return !!
|
|
283
|
+
return !!se(t, e);
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* Get the legacy segwit address from a keypair
|
|
@@ -289,8 +289,8 @@ class A {
|
|
|
289
289
|
* @returns {string} - The legacy address
|
|
290
290
|
*/
|
|
291
291
|
static getLegacySegwitAddress(t, e = I) {
|
|
292
|
-
const i =
|
|
293
|
-
redeem:
|
|
292
|
+
const i = mt({
|
|
293
|
+
redeem: re({ pubkey: a.from(t.publicKey), network: e }),
|
|
294
294
|
network: e
|
|
295
295
|
});
|
|
296
296
|
if (!i.address)
|
|
@@ -304,7 +304,7 @@ class A {
|
|
|
304
304
|
* @returns {string} - The legacy address
|
|
305
305
|
*/
|
|
306
306
|
static getLegacyAddress(t, e = I) {
|
|
307
|
-
const i =
|
|
307
|
+
const i = xe({ pubkey: a.from(t.publicKey), network: e });
|
|
308
308
|
if (!i.address)
|
|
309
309
|
throw new Error("Failed to generate wallet");
|
|
310
310
|
return i.address;
|
|
@@ -316,7 +316,7 @@ class A {
|
|
|
316
316
|
* @returns {string} - The legacy address
|
|
317
317
|
*/
|
|
318
318
|
static getP2PKH(t, e = I) {
|
|
319
|
-
const i =
|
|
319
|
+
const i = xe({ pubkey: a.from(t), network: e });
|
|
320
320
|
if (!i.address)
|
|
321
321
|
throw new Error("Failed to generate wallet");
|
|
322
322
|
return i.address;
|
|
@@ -328,7 +328,7 @@ class A {
|
|
|
328
328
|
* @returns {string} - The legacy address
|
|
329
329
|
*/
|
|
330
330
|
static getP2PKAddress(t, e = I) {
|
|
331
|
-
const i =
|
|
331
|
+
const i = Ai({ pubkey: a.from(t.publicKey), network: e });
|
|
332
332
|
if (!i.output)
|
|
333
333
|
throw new Error("Failed to generate wallet");
|
|
334
334
|
return "0x" + i.output.toString("hex");
|
|
@@ -360,7 +360,7 @@ class A {
|
|
|
360
360
|
*/
|
|
361
361
|
static getTaprootAddress(t, e = I) {
|
|
362
362
|
const { address: i } = rt({
|
|
363
|
-
internalPubkey:
|
|
363
|
+
internalPubkey: O(a.from(t.publicKey)),
|
|
364
364
|
network: e
|
|
365
365
|
});
|
|
366
366
|
if (!i)
|
|
@@ -394,7 +394,7 @@ class A {
|
|
|
394
394
|
return this.ECPair.fromPrivateKey(a.from(r), { network: e });
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
const
|
|
397
|
+
const k = 32, ht = 64, lt = 64, ji = 4, At = 32, It = 16, Wt = 8, dt = 4, ft = 2, Ht = 1, Zi = 32, Tt = 16, Ot = 8, Bt = 4, xt = 2, vt = 1, Ji = 1;
|
|
398
398
|
class X {
|
|
399
399
|
static {
|
|
400
400
|
this.EXPECTED_BUFFER_LENGTH = 32;
|
|
@@ -426,7 +426,7 @@ class X {
|
|
|
426
426
|
const e = X.uint8ArrayToHex(t);
|
|
427
427
|
return BigInt("0x" + e);
|
|
428
428
|
}
|
|
429
|
-
static valueToUint8Array(t, e =
|
|
429
|
+
static valueToUint8Array(t, e = At) {
|
|
430
430
|
const i = t.toString(16).padStart(e * 2, "0");
|
|
431
431
|
return X.hexToUint8Array(i);
|
|
432
432
|
}
|
|
@@ -435,8 +435,8 @@ class X {
|
|
|
435
435
|
return BigInt(e ? "0x" + e : 0);
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
const
|
|
439
|
-
class
|
|
438
|
+
const tr = /^[0-9a-fA-F]+$/;
|
|
439
|
+
class D {
|
|
440
440
|
/**
|
|
441
441
|
* Converts satoshi to BTC
|
|
442
442
|
* @param {number} btc - The amount in BTC
|
|
@@ -451,7 +451,7 @@ class K {
|
|
|
451
451
|
* @returns {Buffer} The random bytes
|
|
452
452
|
*/
|
|
453
453
|
static rndBytes() {
|
|
454
|
-
const t =
|
|
454
|
+
const t = D.getSafeRandomValues(64);
|
|
455
455
|
return a.from(t);
|
|
456
456
|
}
|
|
457
457
|
static getSafeRandomValues(t) {
|
|
@@ -471,7 +471,7 @@ class K {
|
|
|
471
471
|
);
|
|
472
472
|
}
|
|
473
473
|
static isValidHex(t) {
|
|
474
|
-
return
|
|
474
|
+
return tr.test(t);
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
477
|
* Hashes the given data
|
|
@@ -479,7 +479,7 @@ class K {
|
|
|
479
479
|
* @returns {string} The hashed data
|
|
480
480
|
*/
|
|
481
481
|
static opnetHash(t) {
|
|
482
|
-
const e =
|
|
482
|
+
const e = ie("sha512");
|
|
483
483
|
e.update(t);
|
|
484
484
|
const i = e.digest();
|
|
485
485
|
return `0x${a.from(i).toString("hex")}`;
|
|
@@ -509,7 +509,7 @@ class z {
|
|
|
509
509
|
*/
|
|
510
510
|
static isP2WDAWitnessScript(t) {
|
|
511
511
|
try {
|
|
512
|
-
const e =
|
|
512
|
+
const e = F(t);
|
|
513
513
|
if (!e || e.length !== 7)
|
|
514
514
|
return !1;
|
|
515
515
|
for (let i = 0; i < 5; i++)
|
|
@@ -539,7 +539,7 @@ class z {
|
|
|
539
539
|
g.OP_2DROP,
|
|
540
540
|
t,
|
|
541
541
|
g.OP_CHECKSIG
|
|
542
|
-
]), r =
|
|
542
|
+
]), r = pt({
|
|
543
543
|
redeem: { output: i },
|
|
544
544
|
network: e
|
|
545
545
|
});
|
|
@@ -559,7 +559,7 @@ class z {
|
|
|
559
559
|
*/
|
|
560
560
|
static extractPublicKeyFromP2WDA(t) {
|
|
561
561
|
try {
|
|
562
|
-
const e =
|
|
562
|
+
const e = F(t);
|
|
563
563
|
if (!e || e.length !== 7)
|
|
564
564
|
return null;
|
|
565
565
|
for (let i = 0; i < 5; i++)
|
|
@@ -629,7 +629,7 @@ class H {
|
|
|
629
629
|
if (!t || t.length < 50) return !1;
|
|
630
630
|
let i = !1;
|
|
631
631
|
try {
|
|
632
|
-
|
|
632
|
+
se(t, e), i = Ft(t).version === 1;
|
|
633
633
|
} catch {
|
|
634
634
|
}
|
|
635
635
|
return i;
|
|
@@ -645,8 +645,8 @@ class H {
|
|
|
645
645
|
if (!t || t.length < 20 || t.length > 50) return !1;
|
|
646
646
|
let i = !1;
|
|
647
647
|
try {
|
|
648
|
-
const r =
|
|
649
|
-
|
|
648
|
+
const r = Ft(t);
|
|
649
|
+
se(t, e), i = r.version === 0 && r.data.length === 20;
|
|
650
650
|
} catch {
|
|
651
651
|
}
|
|
652
652
|
return i;
|
|
@@ -675,7 +675,7 @@ class H {
|
|
|
675
675
|
*/
|
|
676
676
|
static isP2PKHOrP2SH(t, e) {
|
|
677
677
|
try {
|
|
678
|
-
const i =
|
|
678
|
+
const i = te(t);
|
|
679
679
|
return i.version === e.pubKeyHash ? !0 : i.version === e.scriptHash;
|
|
680
680
|
} catch {
|
|
681
681
|
return !1;
|
|
@@ -691,7 +691,7 @@ class H {
|
|
|
691
691
|
*/
|
|
692
692
|
static isValidPublicKey(t, e) {
|
|
693
693
|
try {
|
|
694
|
-
if (t.startsWith("0x") && (t = t.slice(2)), !
|
|
694
|
+
if (t.startsWith("0x") && (t = t.slice(2)), !D.isValidHex(t))
|
|
695
695
|
return !1;
|
|
696
696
|
if (t.length === 64)
|
|
697
697
|
return !0;
|
|
@@ -721,19 +721,19 @@ class H {
|
|
|
721
721
|
if (a.isBuffer(t) || t instanceof Uint8Array)
|
|
722
722
|
e = t.length;
|
|
723
723
|
else {
|
|
724
|
-
if (t.startsWith("0x") && (t = t.slice(2)), !
|
|
724
|
+
if (t.startsWith("0x") && (t = t.slice(2)), !D.isValidHex(t))
|
|
725
725
|
return null;
|
|
726
726
|
e = t.length / 2;
|
|
727
727
|
}
|
|
728
728
|
switch (e) {
|
|
729
729
|
case 1312:
|
|
730
|
-
return
|
|
730
|
+
return E.MLDSASecurityLevel.LEVEL2;
|
|
731
731
|
// ML-DSA-44
|
|
732
732
|
case 1952:
|
|
733
|
-
return
|
|
733
|
+
return E.MLDSASecurityLevel.LEVEL3;
|
|
734
734
|
// ML-DSA-65
|
|
735
735
|
case 2592:
|
|
736
|
-
return
|
|
736
|
+
return E.MLDSASecurityLevel.LEVEL5;
|
|
737
737
|
// ML-DSA-87
|
|
738
738
|
default:
|
|
739
739
|
return null;
|
|
@@ -753,7 +753,7 @@ class H {
|
|
|
753
753
|
static isValidP2OPAddress(t, e) {
|
|
754
754
|
if (!t || t.length < 20) return !1;
|
|
755
755
|
try {
|
|
756
|
-
const i =
|
|
756
|
+
const i = Ft(t);
|
|
757
757
|
return i.prefix === e.bech32 || i.prefix === e.bech32Opnet ? i.version === 16 && i.data.length === 21 : !1;
|
|
758
758
|
} catch {
|
|
759
759
|
return !1;
|
|
@@ -767,7 +767,7 @@ class H {
|
|
|
767
767
|
*/
|
|
768
768
|
static requireRedeemScript(t, e) {
|
|
769
769
|
try {
|
|
770
|
-
const i =
|
|
770
|
+
const i = te(t);
|
|
771
771
|
return i.version === e.pubKeyHash ? !1 : i.version === e.scriptHash;
|
|
772
772
|
} catch {
|
|
773
773
|
return !1;
|
|
@@ -792,7 +792,7 @@ class H {
|
|
|
792
792
|
if (H.isValidPublicKey(t, e))
|
|
793
793
|
return "P2PK";
|
|
794
794
|
try {
|
|
795
|
-
const i =
|
|
795
|
+
const i = te(t);
|
|
796
796
|
if (i.version === e.pubKeyHash)
|
|
797
797
|
return "P2PKH";
|
|
798
798
|
if (i.version === e.scriptHash)
|
|
@@ -800,7 +800,7 @@ class H {
|
|
|
800
800
|
} catch {
|
|
801
801
|
}
|
|
802
802
|
try {
|
|
803
|
-
const i =
|
|
803
|
+
const i = Ft(t);
|
|
804
804
|
if ((i.prefix === e.bech32Opnet || i.prefix === e.bech32) && i.version === 16 && i.data.length === 21)
|
|
805
805
|
return "P2OP";
|
|
806
806
|
if (i.prefix === e.bech32) {
|
|
@@ -865,7 +865,7 @@ class H {
|
|
|
865
865
|
isDefinitelyP2WDA: !1,
|
|
866
866
|
error: "Witness script does not match P2WDA pattern"
|
|
867
867
|
};
|
|
868
|
-
if (
|
|
868
|
+
if (pt({
|
|
869
869
|
redeem: { output: i },
|
|
870
870
|
network: e
|
|
871
871
|
}).address !== t)
|
|
@@ -898,7 +898,7 @@ class H {
|
|
|
898
898
|
}
|
|
899
899
|
}
|
|
900
900
|
const nt = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
|
|
901
|
-
class
|
|
901
|
+
class He {
|
|
902
902
|
constructor(t = 1e4) {
|
|
903
903
|
this.maxTries = t;
|
|
904
904
|
}
|
|
@@ -1000,9 +1000,9 @@ class De {
|
|
|
1000
1000
|
return e;
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
class
|
|
1003
|
+
class er {
|
|
1004
1004
|
constructor() {
|
|
1005
|
-
this.deriver = new
|
|
1005
|
+
this.deriver = new He();
|
|
1006
1006
|
}
|
|
1007
1007
|
generateHybridKeyFromHash(t) {
|
|
1008
1008
|
const e = this.deriver.findOrDeriveValidPoint(this.cloneBuffer(t), !1), i = this.deriver.getCanonicalY(e.y1, e.y2);
|
|
@@ -1012,7 +1012,7 @@ class Zi {
|
|
|
1012
1012
|
return a.from(t);
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
|
-
const
|
|
1015
|
+
const oe = new er();
|
|
1016
1016
|
class M {
|
|
1017
1017
|
static {
|
|
1018
1018
|
this.UNSPENDABLE_INTERNAL_KEY = a.from(
|
|
@@ -1057,7 +1057,7 @@ class M {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
static generateTimeLockScript(t, e = M.CSV_BLOCKS) {
|
|
1059
1059
|
return L([
|
|
1060
|
-
|
|
1060
|
+
Re.encode(e),
|
|
1061
1061
|
g.OP_CHECKSEQUENCEVERIFY,
|
|
1062
1062
|
g.OP_DROP,
|
|
1063
1063
|
t,
|
|
@@ -1068,27 +1068,27 @@ class M {
|
|
|
1068
1068
|
class v extends Uint8Array {
|
|
1069
1069
|
#t;
|
|
1070
1070
|
#e;
|
|
1071
|
-
#
|
|
1071
|
+
#n;
|
|
1072
1072
|
#i;
|
|
1073
1073
|
#h;
|
|
1074
1074
|
#r;
|
|
1075
|
-
#
|
|
1075
|
+
#s;
|
|
1076
1076
|
#l;
|
|
1077
1077
|
#d;
|
|
1078
|
-
#o;
|
|
1079
1078
|
#a;
|
|
1080
1079
|
#c;
|
|
1080
|
+
#u;
|
|
1081
1081
|
#p;
|
|
1082
1082
|
#g;
|
|
1083
1083
|
// Lazy loading state - defers expensive EC operations until actually needed
|
|
1084
1084
|
#f;
|
|
1085
1085
|
#S = !1;
|
|
1086
1086
|
// After processing, this is 32-byte tweaked x-only (same as original behavior)
|
|
1087
|
-
#
|
|
1087
|
+
#o;
|
|
1088
1088
|
constructor(t, e) {
|
|
1089
|
-
if (super(
|
|
1089
|
+
if (super(k), !!t) {
|
|
1090
1090
|
if (e) {
|
|
1091
|
-
if (![
|
|
1091
|
+
if (![k, 33, 65].includes(e.length))
|
|
1092
1092
|
throw new Error(`Invalid public key length ${e.length}`);
|
|
1093
1093
|
this.#f = new Uint8Array(e.length), this.#f.set(e);
|
|
1094
1094
|
}
|
|
@@ -1122,7 +1122,7 @@ class v extends Uint8Array {
|
|
|
1122
1122
|
* Triggers lazy processing if not yet done.
|
|
1123
1123
|
*/
|
|
1124
1124
|
get legacyPublicKey() {
|
|
1125
|
-
return this.ensureLegacyProcessed(), this.#
|
|
1125
|
+
return this.ensureLegacyProcessed(), this.#o;
|
|
1126
1126
|
}
|
|
1127
1127
|
/**
|
|
1128
1128
|
* Get the key pair for the address
|
|
@@ -1149,13 +1149,13 @@ class v extends Uint8Array {
|
|
|
1149
1149
|
static fromString(t, e) {
|
|
1150
1150
|
if (!t)
|
|
1151
1151
|
throw new Error("Invalid public key");
|
|
1152
|
-
if (t.startsWith("0x") && (t = t.slice(2)), !
|
|
1152
|
+
if (t.startsWith("0x") && (t = t.slice(2)), !D.isValidHex(t))
|
|
1153
1153
|
throw new Error(
|
|
1154
1154
|
'You must only pass 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.'
|
|
1155
1155
|
);
|
|
1156
1156
|
let i;
|
|
1157
1157
|
if (e) {
|
|
1158
|
-
if (e.startsWith("0x") && (e = e.slice(2)), !
|
|
1158
|
+
if (e.startsWith("0x") && (e = e.slice(2)), !D.isValidHex(e))
|
|
1159
1159
|
throw new Error(
|
|
1160
1160
|
'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.'
|
|
1161
1161
|
);
|
|
@@ -1196,7 +1196,7 @@ class v extends Uint8Array {
|
|
|
1196
1196
|
* ```
|
|
1197
1197
|
*/
|
|
1198
1198
|
static fromBigInt(t, e) {
|
|
1199
|
-
const i = v.bigintToUint8Array(t), r = e ? v.bigintToUint8Array(e) : void 0;
|
|
1199
|
+
const i = v.bigintToUint8Array(t), r = e !== void 0 ? v.bigintToUint8Array(e) : void 0;
|
|
1200
1200
|
return new v(i, r);
|
|
1201
1201
|
}
|
|
1202
1202
|
/**
|
|
@@ -1252,22 +1252,22 @@ class v extends Uint8Array {
|
|
|
1252
1252
|
* ```
|
|
1253
1253
|
*/
|
|
1254
1254
|
toUint64Array() {
|
|
1255
|
-
if (this.#
|
|
1256
|
-
return this.#
|
|
1255
|
+
if (this.#u !== void 0)
|
|
1256
|
+
return this.#u;
|
|
1257
1257
|
const t = new DataView(this.buffer, this.byteOffset, 32);
|
|
1258
|
-
return this.#
|
|
1258
|
+
return this.#u = [
|
|
1259
1259
|
t.getBigUint64(0, !1),
|
|
1260
1260
|
t.getBigUint64(8, !1),
|
|
1261
1261
|
t.getBigUint64(16, !1),
|
|
1262
1262
|
t.getBigUint64(24, !1)
|
|
1263
|
-
], this.#
|
|
1263
|
+
], this.#u;
|
|
1264
1264
|
}
|
|
1265
1265
|
/**
|
|
1266
1266
|
* Check if the address is the dead address
|
|
1267
1267
|
* @returns {boolean}
|
|
1268
1268
|
*/
|
|
1269
1269
|
isDead() {
|
|
1270
|
-
for (let t = 0; t <
|
|
1270
|
+
for (let t = 0; t < k; t++)
|
|
1271
1271
|
if (this[t] !== 0)
|
|
1272
1272
|
return !1;
|
|
1273
1273
|
return !0;
|
|
@@ -1348,10 +1348,10 @@ class v extends Uint8Array {
|
|
|
1348
1348
|
* ```
|
|
1349
1349
|
*/
|
|
1350
1350
|
toBigInt() {
|
|
1351
|
-
if (this.#
|
|
1352
|
-
return this.#
|
|
1351
|
+
if (this.#a !== void 0)
|
|
1352
|
+
return this.#a;
|
|
1353
1353
|
const t = new DataView(this.buffer, this.byteOffset, 32);
|
|
1354
|
-
return this.#
|
|
1354
|
+
return this.#a = t.getBigUint64(0, !1) << 192n | t.getBigUint64(8, !1) << 128n | t.getBigUint64(16, !1) << 64n | t.getBigUint64(24, !1), this.#a;
|
|
1355
1355
|
}
|
|
1356
1356
|
/**
|
|
1357
1357
|
* Converts the tweaked public key to a BigInt representation.
|
|
@@ -1372,10 +1372,10 @@ class v extends Uint8Array {
|
|
|
1372
1372
|
tweakedToBigInt() {
|
|
1373
1373
|
if (!this.legacyPublicKey)
|
|
1374
1374
|
throw new Error("Legacy public key not set");
|
|
1375
|
-
if (this.#
|
|
1376
|
-
return this.#
|
|
1375
|
+
if (this.#c !== void 0)
|
|
1376
|
+
return this.#c;
|
|
1377
1377
|
const t = new DataView(this.legacyPublicKey.buffer, this.byteOffset, 32);
|
|
1378
|
-
return this.#
|
|
1378
|
+
return this.#c = t.getBigUint64(0, !1) << 192n | t.getBigUint64(8, !1) << 128n | t.getBigUint64(16, !1) << 64n | t.getBigUint64(24, !1), this.#c;
|
|
1379
1379
|
}
|
|
1380
1380
|
equals(t) {
|
|
1381
1381
|
const e = this;
|
|
@@ -1392,7 +1392,7 @@ class v extends Uint8Array {
|
|
|
1392
1392
|
*/
|
|
1393
1393
|
lessThan(t) {
|
|
1394
1394
|
const e = this;
|
|
1395
|
-
for (let i = 0; i <
|
|
1395
|
+
for (let i = 0; i < k; i++) {
|
|
1396
1396
|
const r = e[i], s = t[i];
|
|
1397
1397
|
if (r < s)
|
|
1398
1398
|
return !0;
|
|
@@ -1407,7 +1407,7 @@ class v extends Uint8Array {
|
|
|
1407
1407
|
*/
|
|
1408
1408
|
greaterThan(t) {
|
|
1409
1409
|
const e = this;
|
|
1410
|
-
for (let i = 0; i <
|
|
1410
|
+
for (let i = 0; i < k; i++) {
|
|
1411
1411
|
const r = e[i], s = t[i];
|
|
1412
1412
|
if (r > s)
|
|
1413
1413
|
return !0;
|
|
@@ -1479,14 +1479,14 @@ class v extends Uint8Array {
|
|
|
1479
1479
|
* @param {Network} network The network
|
|
1480
1480
|
*/
|
|
1481
1481
|
p2tr(t) {
|
|
1482
|
-
if (this.#t && this.#
|
|
1482
|
+
if (this.#t && this.#n === t)
|
|
1483
1483
|
return this.#t;
|
|
1484
1484
|
const e = this.legacyPublicKey;
|
|
1485
1485
|
if (!e)
|
|
1486
1486
|
throw new Error("Legacy public key not set");
|
|
1487
1487
|
const i = A.tweakedPubKeyBufferToAddress(e, t);
|
|
1488
1488
|
if (i)
|
|
1489
|
-
return this.#
|
|
1489
|
+
return this.#n = t, this.#t = i, i;
|
|
1490
1490
|
throw new Error("Legacy public key not set");
|
|
1491
1491
|
}
|
|
1492
1492
|
/**
|
|
@@ -1512,7 +1512,7 @@ class v extends Uint8Array {
|
|
|
1512
1512
|
* ```
|
|
1513
1513
|
*/
|
|
1514
1514
|
p2wda(t) {
|
|
1515
|
-
if (this.#l && this.#
|
|
1515
|
+
if (this.#l && this.#n === t)
|
|
1516
1516
|
return this.#l;
|
|
1517
1517
|
if (this.ensureLegacyProcessed(), !this.#i)
|
|
1518
1518
|
throw new Error("Cannot create P2WDA address: public key not set");
|
|
@@ -1521,7 +1521,7 @@ class v extends Uint8Array {
|
|
|
1521
1521
|
throw new Error("P2WDA requires a compressed public key (33 bytes)");
|
|
1522
1522
|
try {
|
|
1523
1523
|
const i = z.generateP2WDAAddress(e, t);
|
|
1524
|
-
return this.#
|
|
1524
|
+
return this.#n = t, this.#l = i, {
|
|
1525
1525
|
address: i.address,
|
|
1526
1526
|
witnessScript: i.witnessScript
|
|
1527
1527
|
};
|
|
@@ -1581,30 +1581,44 @@ class v extends Uint8Array {
|
|
|
1581
1581
|
* @returns The P2OP address in bech32m format
|
|
1582
1582
|
*/
|
|
1583
1583
|
p2op(t) {
|
|
1584
|
-
if (this.#e && this.#
|
|
1584
|
+
if (this.#e && this.#n === t)
|
|
1585
1585
|
return this.#e;
|
|
1586
1586
|
const e = A.p2op(this, t);
|
|
1587
1587
|
if (e)
|
|
1588
|
-
return this.#
|
|
1588
|
+
return this.#n = t, this.#e = e, e;
|
|
1589
1589
|
throw new Error("ML-DSA public key not set");
|
|
1590
1590
|
}
|
|
1591
1591
|
toTweakedHybridPublicKeyHex() {
|
|
1592
|
-
if (this.ensureLegacyProcessed(), !this.#
|
|
1592
|
+
if (this.ensureLegacyProcessed(), this.ensureTweakedUncompressed(), !this.#s)
|
|
1593
1593
|
throw new Error("Legacy public key not set");
|
|
1594
|
-
return "0x" + this.#
|
|
1594
|
+
return "0x" + this.#s.toString("hex");
|
|
1595
1595
|
}
|
|
1596
1596
|
toTweakedHybridPublicKeyBuffer() {
|
|
1597
|
-
if (this.ensureLegacyProcessed(), !this.#
|
|
1597
|
+
if (this.ensureLegacyProcessed(), this.ensureTweakedUncompressed(), !this.#s)
|
|
1598
1598
|
throw new Error("Legacy public key not set");
|
|
1599
|
-
return this.#
|
|
1599
|
+
return this.#s;
|
|
1600
|
+
}
|
|
1601
|
+
/**
|
|
1602
|
+
* Lazily generates the tweaked uncompressed/hybrid key from the legacy public key.
|
|
1603
|
+
* Only called when toTweakedHybridPublicKey* methods are accessed.
|
|
1604
|
+
*/
|
|
1605
|
+
ensureTweakedUncompressed() {
|
|
1606
|
+
if (this.#s) return;
|
|
1607
|
+
const t = this.#o;
|
|
1608
|
+
if (t && t.length === k && !this.#i)
|
|
1609
|
+
try {
|
|
1610
|
+
const e = a.alloc(k);
|
|
1611
|
+
e.set(t), this.#s = oe.generateHybridKeyFromHash(e);
|
|
1612
|
+
} catch {
|
|
1613
|
+
}
|
|
1600
1614
|
}
|
|
1601
1615
|
/**
|
|
1602
1616
|
* Sets the MLDSA key portion of the address.
|
|
1603
1617
|
* @param {ArrayLike<number>} mldsaPublicKey - The MLDSA public key or its hash
|
|
1604
1618
|
*/
|
|
1605
1619
|
setMldsaKey(t) {
|
|
1606
|
-
if (t.length ===
|
|
1607
|
-
const e = new Uint8Array(
|
|
1620
|
+
if (t.length === k) {
|
|
1621
|
+
const e = new Uint8Array(k);
|
|
1608
1622
|
e.set(t), super.set(e);
|
|
1609
1623
|
} else {
|
|
1610
1624
|
if (![1312, 1952, 2592].includes(t.length))
|
|
@@ -1612,7 +1626,7 @@ class v extends Uint8Array {
|
|
|
1612
1626
|
`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.`
|
|
1613
1627
|
);
|
|
1614
1628
|
this.#d = new Uint8Array(t.length), this.#d.set(t);
|
|
1615
|
-
const i =
|
|
1629
|
+
const i = le(new Uint8Array(t)), r = new Uint8Array(k);
|
|
1616
1630
|
r.set(i), super.set(r);
|
|
1617
1631
|
}
|
|
1618
1632
|
}
|
|
@@ -1624,12 +1638,7 @@ class v extends Uint8Array {
|
|
|
1624
1638
|
if (this.#S) return;
|
|
1625
1639
|
this.#S = !0;
|
|
1626
1640
|
const t = this.#f;
|
|
1627
|
-
|
|
1628
|
-
if (t.length === C) {
|
|
1629
|
-
const e = a.alloc(C);
|
|
1630
|
-
e.set(t), this.#n = te.generateHybridKeyFromHash(e), this.#u = t;
|
|
1631
|
-
} else
|
|
1632
|
-
this.autoFormat(t);
|
|
1641
|
+
t && (t.length === k ? this.#o = t : this.autoFormat(t));
|
|
1633
1642
|
}
|
|
1634
1643
|
/**
|
|
1635
1644
|
* Processes a 33 or 65 byte public key, performing EC operations.
|
|
@@ -1637,16 +1646,16 @@ class v extends Uint8Array {
|
|
|
1637
1646
|
*/
|
|
1638
1647
|
autoFormat(t) {
|
|
1639
1648
|
const e = t[0];
|
|
1640
|
-
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t = v.uncompressedToCompressed(t)), this.#i = Uint8Array.from(t), this.#h = A.fromPublicKey(this.#i), this.#r =
|
|
1641
|
-
const i =
|
|
1649
|
+
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t = v.uncompressedToCompressed(t)), this.#i = Uint8Array.from(t), this.#h = A.fromPublicKey(this.#i), this.#r = Oi(this.#i);
|
|
1650
|
+
const i = O(
|
|
1642
1651
|
A.tweakPublicKey(a.from(this.#i))
|
|
1643
1652
|
);
|
|
1644
|
-
this.#
|
|
1653
|
+
this.#s = oe.generateHybridKeyFromHash(i), this.#o = new Uint8Array(k), this.#o.set(i);
|
|
1645
1654
|
}
|
|
1646
1655
|
}
|
|
1647
|
-
class
|
|
1656
|
+
class yt {
|
|
1648
1657
|
constructor(t) {
|
|
1649
|
-
if (this._keys = [], this._values = {}, t instanceof
|
|
1658
|
+
if (this._keys = [], this._values = {}, t instanceof yt)
|
|
1650
1659
|
this.setAll(t);
|
|
1651
1660
|
else if (t)
|
|
1652
1661
|
for (const [e, i] of t)
|
|
@@ -1708,9 +1717,9 @@ class pt {
|
|
|
1708
1717
|
yield [t, this._values[t]];
|
|
1709
1718
|
}
|
|
1710
1719
|
}
|
|
1711
|
-
class
|
|
1720
|
+
class Ve {
|
|
1712
1721
|
constructor(t) {
|
|
1713
|
-
if (this.items = new
|
|
1722
|
+
if (this.items = new yt(), t)
|
|
1714
1723
|
for (const [e, i] of t)
|
|
1715
1724
|
this.set(e, i);
|
|
1716
1725
|
}
|
|
@@ -1762,7 +1771,70 @@ class Fe {
|
|
|
1762
1771
|
yield* this.entries();
|
|
1763
1772
|
}
|
|
1764
1773
|
}
|
|
1765
|
-
class
|
|
1774
|
+
class ze {
|
|
1775
|
+
constructor(t) {
|
|
1776
|
+
if (this._keys = [], this._values = [], this.indexMap = new yt(), t)
|
|
1777
|
+
for (const [e, i] of t)
|
|
1778
|
+
this.set(e, i);
|
|
1779
|
+
}
|
|
1780
|
+
get size() {
|
|
1781
|
+
return this._keys.length;
|
|
1782
|
+
}
|
|
1783
|
+
set(t, e) {
|
|
1784
|
+
const i = t.tweakedToBigInt(), r = this.indexMap.get(i);
|
|
1785
|
+
if (r !== void 0)
|
|
1786
|
+
this._values[r] = e;
|
|
1787
|
+
else {
|
|
1788
|
+
const s = this._keys.length;
|
|
1789
|
+
this._keys.push(t), this._values.push(e), this.indexMap.set(i, s);
|
|
1790
|
+
}
|
|
1791
|
+
return this;
|
|
1792
|
+
}
|
|
1793
|
+
get(t) {
|
|
1794
|
+
const e = t.tweakedToBigInt(), i = this.indexMap.get(e);
|
|
1795
|
+
if (i !== void 0)
|
|
1796
|
+
return this._values[i];
|
|
1797
|
+
}
|
|
1798
|
+
has(t) {
|
|
1799
|
+
return this.indexMap.has(t.tweakedToBigInt());
|
|
1800
|
+
}
|
|
1801
|
+
delete(t) {
|
|
1802
|
+
const e = t.tweakedToBigInt(), i = this.indexMap.get(e);
|
|
1803
|
+
if (i === void 0)
|
|
1804
|
+
return !1;
|
|
1805
|
+
this._keys.splice(i, 1), this._values.splice(i, 1), this.indexMap.clear();
|
|
1806
|
+
for (let r = 0; r < this._keys.length; r++)
|
|
1807
|
+
this.indexMap.set(this._keys[r].tweakedToBigInt(), r);
|
|
1808
|
+
return !0;
|
|
1809
|
+
}
|
|
1810
|
+
clear() {
|
|
1811
|
+
this.indexMap.clear(), this._keys = [], this._values = [];
|
|
1812
|
+
}
|
|
1813
|
+
indexOf(t) {
|
|
1814
|
+
const e = this.indexMap.get(t.tweakedToBigInt());
|
|
1815
|
+
return e !== void 0 ? e : -1;
|
|
1816
|
+
}
|
|
1817
|
+
*entries() {
|
|
1818
|
+
for (let t = 0; t < this._keys.length; t++)
|
|
1819
|
+
yield [this._keys[t], this._values[t]];
|
|
1820
|
+
}
|
|
1821
|
+
*keys() {
|
|
1822
|
+
for (const t of this._keys)
|
|
1823
|
+
yield t;
|
|
1824
|
+
}
|
|
1825
|
+
*values() {
|
|
1826
|
+
for (const t of this._values)
|
|
1827
|
+
yield t;
|
|
1828
|
+
}
|
|
1829
|
+
forEach(t, e) {
|
|
1830
|
+
for (let i = 0; i < this._keys.length; i++)
|
|
1831
|
+
t.call(e, this._values[i], this._keys[i], this);
|
|
1832
|
+
}
|
|
1833
|
+
*[Symbol.iterator]() {
|
|
1834
|
+
yield* this.entries();
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
class jt {
|
|
1766
1838
|
constructor(t) {
|
|
1767
1839
|
this.currentOffset = 0, this.buffer = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
1768
1840
|
}
|
|
@@ -1779,53 +1851,93 @@ class qt {
|
|
|
1779
1851
|
setBuffer(t) {
|
|
1780
1852
|
this.buffer = new DataView(t.buffer, t.byteOffset, t.byteLength), this.currentOffset = 0;
|
|
1781
1853
|
}
|
|
1854
|
+
get byteLength() {
|
|
1855
|
+
return this.buffer.byteLength;
|
|
1856
|
+
}
|
|
1782
1857
|
length() {
|
|
1783
1858
|
return this.buffer.byteLength;
|
|
1784
1859
|
}
|
|
1785
1860
|
bytesLeft() {
|
|
1786
1861
|
return this.buffer.byteLength - this.currentOffset;
|
|
1787
1862
|
}
|
|
1863
|
+
// ------------------- Signed Integer Readers ------------------- //
|
|
1864
|
+
/**
|
|
1865
|
+
* Reads a single signed byte (i8).
|
|
1866
|
+
*/
|
|
1867
|
+
readI8() {
|
|
1868
|
+
this.verifyEnd(this.currentOffset + vt);
|
|
1869
|
+
const t = this.buffer.getInt8(this.currentOffset);
|
|
1870
|
+
return this.currentOffset += vt, t;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Reads a signed 16-bit integer. By default, big-endian.
|
|
1874
|
+
* @param be - Endianness; true means big-endian (the default).
|
|
1875
|
+
*/
|
|
1876
|
+
readI16(t = !0) {
|
|
1877
|
+
this.verifyEnd(this.currentOffset + xt);
|
|
1878
|
+
const e = this.buffer.getInt16(this.currentOffset, !t);
|
|
1879
|
+
return this.currentOffset += xt, e;
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Reads a signed 32-bit integer. By default, big-endian.
|
|
1883
|
+
* @param be - Endianness; true means big-endian (the default).
|
|
1884
|
+
*/
|
|
1885
|
+
readI32(t = !0) {
|
|
1886
|
+
this.verifyEnd(this.currentOffset + Bt);
|
|
1887
|
+
const e = this.buffer.getInt32(this.currentOffset, !t);
|
|
1888
|
+
return this.currentOffset += Bt, e;
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Reads a signed 64-bit integer. By default, big-endian.
|
|
1892
|
+
* @param be - Endianness; true means big-endian (the default).
|
|
1893
|
+
*/
|
|
1894
|
+
readI64(t = !0) {
|
|
1895
|
+
this.verifyEnd(this.currentOffset + Ot);
|
|
1896
|
+
const e = this.buffer.getBigInt64(this.currentOffset, !t);
|
|
1897
|
+
return this.currentOffset += Ot, e;
|
|
1898
|
+
}
|
|
1899
|
+
// ------------------- Unsigned Integer Readers ------------------- //
|
|
1788
1900
|
/**
|
|
1789
1901
|
* Reads a single unsigned byte (u8).
|
|
1790
1902
|
*/
|
|
1791
1903
|
readU8() {
|
|
1792
|
-
this.verifyEnd(this.currentOffset +
|
|
1904
|
+
this.verifyEnd(this.currentOffset + Ht);
|
|
1793
1905
|
const t = this.buffer.getUint8(this.currentOffset);
|
|
1794
|
-
return this.currentOffset +=
|
|
1906
|
+
return this.currentOffset += Ht, t;
|
|
1795
1907
|
}
|
|
1796
1908
|
/**
|
|
1797
1909
|
* Reads an unsigned 16-bit integer. By default, big-endian.
|
|
1798
1910
|
* @param be - Endianness; true means big-endian (the default).
|
|
1799
1911
|
*/
|
|
1800
1912
|
readU16(t = !0) {
|
|
1801
|
-
this.verifyEnd(this.currentOffset +
|
|
1913
|
+
this.verifyEnd(this.currentOffset + ft);
|
|
1802
1914
|
const e = this.buffer.getUint16(this.currentOffset, !t);
|
|
1803
|
-
return this.currentOffset +=
|
|
1915
|
+
return this.currentOffset += ft, e;
|
|
1804
1916
|
}
|
|
1805
1917
|
/**
|
|
1806
1918
|
* Reads an unsigned 32-bit integer. By default, big-endian.
|
|
1807
1919
|
* @param be - Endianness; true means big-endian (the default).
|
|
1808
1920
|
*/
|
|
1809
1921
|
readU32(t = !0) {
|
|
1810
|
-
this.verifyEnd(this.currentOffset +
|
|
1922
|
+
this.verifyEnd(this.currentOffset + dt);
|
|
1811
1923
|
const e = this.buffer.getUint32(this.currentOffset, !t);
|
|
1812
|
-
return this.currentOffset +=
|
|
1924
|
+
return this.currentOffset += dt, e;
|
|
1813
1925
|
}
|
|
1814
1926
|
/**
|
|
1815
1927
|
* Reads an unsigned 64-bit integer. By default, big-endian.
|
|
1816
1928
|
* @param be - Endianness; true means big-endian (the default).
|
|
1817
1929
|
*/
|
|
1818
1930
|
readU64(t = !0) {
|
|
1819
|
-
this.verifyEnd(this.currentOffset +
|
|
1931
|
+
this.verifyEnd(this.currentOffset + Wt);
|
|
1820
1932
|
const e = this.buffer.getBigUint64(this.currentOffset, !t);
|
|
1821
|
-
return this.currentOffset +=
|
|
1933
|
+
return this.currentOffset += Wt, e;
|
|
1822
1934
|
}
|
|
1823
1935
|
/**
|
|
1824
1936
|
* Reads a 128-bit unsigned integer. By default, read big-endian.
|
|
1825
1937
|
* @param be - Endianness; true => big-endian (default).
|
|
1826
1938
|
*/
|
|
1827
1939
|
readU128(t = !0) {
|
|
1828
|
-
const e = this.readBytes(
|
|
1940
|
+
const e = this.readBytes(It);
|
|
1829
1941
|
let i = e;
|
|
1830
1942
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1831
1943
|
}
|
|
@@ -1834,7 +1946,7 @@ class qt {
|
|
|
1834
1946
|
* @param be - Endianness; true => big-endian (default).
|
|
1835
1947
|
*/
|
|
1836
1948
|
readU256(t = !0) {
|
|
1837
|
-
const e = this.readBytes(
|
|
1949
|
+
const e = this.readBytes(At);
|
|
1838
1950
|
let i = e;
|
|
1839
1951
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1840
1952
|
}
|
|
@@ -1843,7 +1955,7 @@ class qt {
|
|
|
1843
1955
|
* @param be - Endianness; true => big-endian (default).
|
|
1844
1956
|
*/
|
|
1845
1957
|
readI128(t = !0) {
|
|
1846
|
-
const e = this.readBytes(
|
|
1958
|
+
const e = this.readBytes(Tt);
|
|
1847
1959
|
let i = e;
|
|
1848
1960
|
t || (i = this.reverseBytes(e));
|
|
1849
1961
|
let r = BigInt("0x" + this.toHexString(i));
|
|
@@ -1898,12 +2010,48 @@ class qt {
|
|
|
1898
2010
|
return this.readString(e);
|
|
1899
2011
|
}
|
|
1900
2012
|
/**
|
|
1901
|
-
* Reads an address.
|
|
2013
|
+
* Reads an address (32 bytes MLDSA key hash only).
|
|
1902
2014
|
*/
|
|
1903
2015
|
readAddress() {
|
|
1904
|
-
const t = Array.from(this.readBytes(
|
|
2016
|
+
const t = Array.from(this.readBytes(k));
|
|
1905
2017
|
return new v(t);
|
|
1906
2018
|
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Reads the tweaked public key portion (32 bytes) and returns it as a raw Uint8Array.
|
|
2021
|
+
* Use this when you only need the tweaked key without the full Address object.
|
|
2022
|
+
*/
|
|
2023
|
+
readTweakedPublicKey() {
|
|
2024
|
+
return this.verifyEnd(this.currentOffset + k), this.readBytes(k);
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* Reads a full address with both MLDSA key hash and tweaked public key (64 bytes total).
|
|
2028
|
+
* Format: [32 bytes tweakedPublicKey][32 bytes MLDSA key hash]
|
|
2029
|
+
*
|
|
2030
|
+
* This is the equivalent of btc-runtime's readExtendedAddress().
|
|
2031
|
+
*
|
|
2032
|
+
* @returns An Address instance with both keys set
|
|
2033
|
+
*/
|
|
2034
|
+
readExtendedAddress() {
|
|
2035
|
+
this.verifyEnd(this.currentOffset + ht);
|
|
2036
|
+
const t = Array.from(this.readBytes(k)), e = Array.from(this.readBytes(k));
|
|
2037
|
+
return new v(e, t);
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
2040
|
+
* Reads a Schnorr signature with its associated full Address.
|
|
2041
|
+
* Format: [64 bytes full Address][64 bytes signature]
|
|
2042
|
+
*
|
|
2043
|
+
* Used for deserializing signed data where both the signer's address
|
|
2044
|
+
* and their Schnorr signature are stored together.
|
|
2045
|
+
*
|
|
2046
|
+
* @returns A SchnorrSignature containing the address and signature
|
|
2047
|
+
*/
|
|
2048
|
+
readSchnorrSignature() {
|
|
2049
|
+
this.verifyEnd(
|
|
2050
|
+
this.currentOffset + ht + lt
|
|
2051
|
+
);
|
|
2052
|
+
const t = this.readExtendedAddress(), e = this.readBytes(lt);
|
|
2053
|
+
return { address: t, signature: e };
|
|
2054
|
+
}
|
|
1907
2055
|
/**
|
|
1908
2056
|
* Reads bytes written as [u32 length][bytes].
|
|
1909
2057
|
* @param maxLength if > 0, enforces an upper bound
|
|
@@ -1980,7 +2128,7 @@ class qt {
|
|
|
1980
2128
|
* Reads [u16 length][ (address, u256) pairs ].
|
|
1981
2129
|
*/
|
|
1982
2130
|
readAddressValueTuple(t = !0) {
|
|
1983
|
-
const e = this.readU16(t), i = new
|
|
2131
|
+
const e = this.readU16(t), i = new Ve();
|
|
1984
2132
|
for (let r = 0; r < e; r++) {
|
|
1985
2133
|
const s = this.readAddress(), o = this.readU256(t);
|
|
1986
2134
|
if (i.has(s))
|
|
@@ -1989,6 +2137,32 @@ class qt {
|
|
|
1989
2137
|
}
|
|
1990
2138
|
return i;
|
|
1991
2139
|
}
|
|
2140
|
+
/**
|
|
2141
|
+
* Reads an array of full addresses (64 bytes each).
|
|
2142
|
+
* Format: [u16 length][FullAddress 0][FullAddress 1]...
|
|
2143
|
+
*/
|
|
2144
|
+
readExtendedAddressArray(t = !0) {
|
|
2145
|
+
const e = this.readU16(t), i = new Array(e);
|
|
2146
|
+
for (let r = 0; r < e; r++)
|
|
2147
|
+
i[r] = this.readExtendedAddress();
|
|
2148
|
+
return i;
|
|
2149
|
+
}
|
|
2150
|
+
/**
|
|
2151
|
+
* Reads a map of full Address -> u256 using the tweaked key for map lookup.
|
|
2152
|
+
* Format: [u16 length][FullAddress key][u256 value]...
|
|
2153
|
+
*
|
|
2154
|
+
* This is the equivalent of btc-runtime's readExtendedAddressMapU256().
|
|
2155
|
+
*/
|
|
2156
|
+
readExtendedAddressMapU256(t = !0) {
|
|
2157
|
+
const e = this.readU16(t), i = new ze();
|
|
2158
|
+
for (let r = 0; r < e; r++) {
|
|
2159
|
+
const s = this.readExtendedAddress(), o = this.readU256(t);
|
|
2160
|
+
if (i.has(s))
|
|
2161
|
+
throw new Error("Duplicate tweaked address found in map");
|
|
2162
|
+
i.set(s, o);
|
|
2163
|
+
}
|
|
2164
|
+
return i;
|
|
2165
|
+
}
|
|
1992
2166
|
// --------------------------------------------------- //
|
|
1993
2167
|
getOffset() {
|
|
1994
2168
|
return this.currentOffset;
|
|
@@ -2021,33 +2195,64 @@ class qt {
|
|
|
2021
2195
|
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
2022
2196
|
}
|
|
2023
2197
|
}
|
|
2024
|
-
class
|
|
2198
|
+
class C {
|
|
2025
2199
|
constructor(t = 0) {
|
|
2026
2200
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(t);
|
|
2027
2201
|
}
|
|
2028
2202
|
static estimateArrayOfBufferLength(t) {
|
|
2029
2203
|
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2030
|
-
let e =
|
|
2204
|
+
let e = ft;
|
|
2031
2205
|
for (let i = 0; i < t.length; i++)
|
|
2032
|
-
e +=
|
|
2206
|
+
e += dt + t[i].length;
|
|
2033
2207
|
return e;
|
|
2034
2208
|
}
|
|
2035
2209
|
writeU8(t) {
|
|
2036
2210
|
if (t > 255) throw new Error("u8 value is too large.");
|
|
2037
|
-
this.allocSafe(
|
|
2211
|
+
this.allocSafe(Ht), this.buffer.setUint8(this.currentOffset++, t);
|
|
2038
2212
|
}
|
|
2039
2213
|
writeU16(t, e = !0) {
|
|
2040
2214
|
if (t > 65535) throw new Error("u16 value is too large.");
|
|
2041
|
-
this.allocSafe(
|
|
2215
|
+
this.allocSafe(ft), this.buffer.setUint16(this.currentOffset, t, !e), this.currentOffset += 2;
|
|
2042
2216
|
}
|
|
2043
2217
|
writeU32(t, e = !0) {
|
|
2044
2218
|
if (t > 4294967295) throw new Error("u32 value is too large.");
|
|
2045
|
-
this.allocSafe(
|
|
2219
|
+
this.allocSafe(dt), this.buffer.setUint32(this.currentOffset, t, !e), this.currentOffset += 4;
|
|
2046
2220
|
}
|
|
2047
2221
|
writeU64(t, e = !0) {
|
|
2048
2222
|
if (t > 18446744073709551615n) throw new Error("u64 value is too large.");
|
|
2049
|
-
this.allocSafe(
|
|
2223
|
+
this.allocSafe(Wt), this.buffer.setBigUint64(this.currentOffset, t, !e), this.currentOffset += 8;
|
|
2050
2224
|
}
|
|
2225
|
+
// ------------------- Signed Integer Writers ------------------- //
|
|
2226
|
+
/**
|
|
2227
|
+
* Writes a signed 8-bit integer.
|
|
2228
|
+
*/
|
|
2229
|
+
writeI8(t) {
|
|
2230
|
+
if (t < -128 || t > 127) throw new Error("i8 value is out of range.");
|
|
2231
|
+
this.allocSafe(vt), this.buffer.setInt8(this.currentOffset, t), this.currentOffset += vt;
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* Writes a signed 16-bit integer. By default big-endian (be = true).
|
|
2235
|
+
*/
|
|
2236
|
+
writeI16(t, e = !0) {
|
|
2237
|
+
if (t < -32768 || t > 32767) throw new Error("i16 value is out of range.");
|
|
2238
|
+
this.allocSafe(xt), this.buffer.setInt16(this.currentOffset, t, !e), this.currentOffset += xt;
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Writes a signed 32-bit integer. By default big-endian (be = true).
|
|
2242
|
+
*/
|
|
2243
|
+
writeI32(t, e = !0) {
|
|
2244
|
+
if (t < -2147483648 || t > 2147483647) throw new Error("i32 value is out of range.");
|
|
2245
|
+
this.allocSafe(Bt), this.buffer.setInt32(this.currentOffset, t, !e), this.currentOffset += Bt;
|
|
2246
|
+
}
|
|
2247
|
+
/**
|
|
2248
|
+
* Writes a signed 64-bit integer. By default big-endian (be = true).
|
|
2249
|
+
*/
|
|
2250
|
+
writeI64(t, e = !0) {
|
|
2251
|
+
if (t < -9223372036854775808n || t > 9223372036854775807n)
|
|
2252
|
+
throw new Error("i64 value is out of range.");
|
|
2253
|
+
this.allocSafe(Ot), this.buffer.setBigInt64(this.currentOffset, t, !e), this.currentOffset += Ot;
|
|
2254
|
+
}
|
|
2255
|
+
// ---------------------------------------------------------------- //
|
|
2051
2256
|
writeSelector(t) {
|
|
2052
2257
|
this.writeU32(t, !0);
|
|
2053
2258
|
}
|
|
@@ -2057,9 +2262,9 @@ class D {
|
|
|
2057
2262
|
writeI128(t, e = !0) {
|
|
2058
2263
|
if (t > 170141183460469231731687303715884105727n || t < -170141183460469231731687303715884105728n)
|
|
2059
2264
|
throw new Error("i128 value is too large.");
|
|
2060
|
-
this.allocSafe(
|
|
2061
|
-
const i = X.valueToUint8Array(t,
|
|
2062
|
-
if (i.byteLength !==
|
|
2265
|
+
this.allocSafe(Tt);
|
|
2266
|
+
const i = X.valueToUint8Array(t, Tt);
|
|
2267
|
+
if (i.byteLength !== Tt)
|
|
2063
2268
|
throw new Error(`Invalid i128 value: ${t}`);
|
|
2064
2269
|
if (e)
|
|
2065
2270
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2071,9 +2276,9 @@ class D {
|
|
|
2071
2276
|
writeU256(t, e = !0) {
|
|
2072
2277
|
if (t > 115792089237316195423570985008687907853269984665640564039457584007913129639935n && t < 0n)
|
|
2073
2278
|
throw new Error("u256 value is too large or negative.");
|
|
2074
|
-
this.allocSafe(
|
|
2279
|
+
this.allocSafe(At);
|
|
2075
2280
|
const i = X.valueToUint8Array(t);
|
|
2076
|
-
if (i.byteLength !==
|
|
2281
|
+
if (i.byteLength !== At)
|
|
2077
2282
|
throw new Error(`Invalid u256 value: ${t}`);
|
|
2078
2283
|
if (e)
|
|
2079
2284
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2085,9 +2290,9 @@ class D {
|
|
|
2085
2290
|
writeU128(t, e = !0) {
|
|
2086
2291
|
if (t > 340282366920938463463374607431768211455n && t < 0n)
|
|
2087
2292
|
throw new Error("u128 value is too large or negative.");
|
|
2088
|
-
this.allocSafe(
|
|
2089
|
-
const i = X.valueToUint8Array(t,
|
|
2090
|
-
if (i.byteLength !==
|
|
2293
|
+
this.allocSafe(It);
|
|
2294
|
+
const i = X.valueToUint8Array(t, It);
|
|
2295
|
+
if (i.byteLength !== It)
|
|
2091
2296
|
throw new Error(`Invalid u128 value: ${t}`);
|
|
2092
2297
|
if (e)
|
|
2093
2298
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2107,11 +2312,51 @@ class D {
|
|
|
2107
2312
|
}
|
|
2108
2313
|
writeStringWithLength(t) {
|
|
2109
2314
|
const i = new TextEncoder().encode(t);
|
|
2110
|
-
this.allocSafe(
|
|
2315
|
+
this.allocSafe(dt + i.length), this.writeU32(i.length), this.writeBytes(i);
|
|
2111
2316
|
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Writes an address (32 bytes MLDSA key hash only).
|
|
2319
|
+
*/
|
|
2112
2320
|
writeAddress(t) {
|
|
2113
2321
|
this.verifyAddress(t), this.writeBytes(t);
|
|
2114
2322
|
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Writes the tweaked public key from an Address (32 bytes).
|
|
2325
|
+
* @param value - The Address containing the tweaked public key
|
|
2326
|
+
*/
|
|
2327
|
+
writeTweakedPublicKey(t) {
|
|
2328
|
+
const e = t.tweakedPublicKeyToBuffer();
|
|
2329
|
+
this.allocSafe(k), this.writeBytes(e);
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Writes a full address with both tweaked public key and MLDSA key hash (64 bytes total).
|
|
2333
|
+
* Format: [32 bytes tweakedPublicKey][32 bytes MLDSA key hash]
|
|
2334
|
+
*
|
|
2335
|
+
* This is the equivalent of btc-runtime's writeExtendedAddress().
|
|
2336
|
+
*
|
|
2337
|
+
* @param value - The Address containing both keys
|
|
2338
|
+
*/
|
|
2339
|
+
writeExtendedAddress(t) {
|
|
2340
|
+
this.allocSafe(ht), this.writeTweakedPublicKey(t), this.writeBytes(t);
|
|
2341
|
+
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Writes a Schnorr signature with its associated full Address.
|
|
2344
|
+
* Format: [64 bytes full Address][64 bytes signature]
|
|
2345
|
+
*
|
|
2346
|
+
* Used for serializing signed data where both the signer's address
|
|
2347
|
+
* and their Schnorr signature need to be stored together.
|
|
2348
|
+
*
|
|
2349
|
+
* @param address - The signer's Address (with both MLDSA and tweaked keys)
|
|
2350
|
+
* @param signature - The 64-byte Schnorr signature
|
|
2351
|
+
* @throws {Error} If signature is not exactly 64 bytes
|
|
2352
|
+
*/
|
|
2353
|
+
writeSchnorrSignature(t, e) {
|
|
2354
|
+
if (e.length !== lt)
|
|
2355
|
+
throw new Error(
|
|
2356
|
+
`Invalid Schnorr signature length: expected ${lt}, got ${e.length}`
|
|
2357
|
+
);
|
|
2358
|
+
this.allocSafe(ht + lt), this.writeExtendedAddress(t), this.writeBytes(e);
|
|
2359
|
+
}
|
|
2115
2360
|
getBuffer(t = !0) {
|
|
2116
2361
|
const e = new Uint8Array(this.buffer.byteLength);
|
|
2117
2362
|
for (let i = 0; i < this.buffer.byteLength; i++)
|
|
@@ -2122,7 +2367,7 @@ class D {
|
|
|
2122
2367
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(4);
|
|
2123
2368
|
}
|
|
2124
2369
|
toBytesReader() {
|
|
2125
|
-
return new
|
|
2370
|
+
return new jt(this.getBuffer());
|
|
2126
2371
|
}
|
|
2127
2372
|
getOffset() {
|
|
2128
2373
|
return this.currentOffset;
|
|
@@ -2146,11 +2391,23 @@ class D {
|
|
|
2146
2391
|
this.writeAddress(s), this.writeU256(o, e);
|
|
2147
2392
|
}
|
|
2148
2393
|
}
|
|
2394
|
+
/**
|
|
2395
|
+
* Writes a map of full Address -> u256 using the tweaked key for map lookup.
|
|
2396
|
+
* Format: [u16 length][FullAddress key][u256 value]...
|
|
2397
|
+
*
|
|
2398
|
+
* This is the equivalent of btc-runtime's writeExtendedAddressMapU256().
|
|
2399
|
+
*/
|
|
2400
|
+
writeExtendedAddressMapU256(t, e = !0) {
|
|
2401
|
+
if (t.size > 65535) throw new Error("Map size is too large");
|
|
2402
|
+
this.writeU16(t.size, e);
|
|
2403
|
+
for (const [i, r] of t.entries())
|
|
2404
|
+
this.writeExtendedAddress(i), this.writeU256(r, e);
|
|
2405
|
+
}
|
|
2149
2406
|
writeBytesWithLength(t) {
|
|
2150
2407
|
this.writeU32(t.length), this.writeBytes(t);
|
|
2151
2408
|
}
|
|
2152
2409
|
writeArrayOfBuffer(t, e = !0) {
|
|
2153
|
-
const i =
|
|
2410
|
+
const i = C.estimateArrayOfBufferLength(t);
|
|
2154
2411
|
this.allocSafe(i), this.writeU16(t.length, e);
|
|
2155
2412
|
for (let r = 0; r < t.length; r++)
|
|
2156
2413
|
this.writeU32(t[r].length, e), this.writeBytes(t[r]);
|
|
@@ -2161,6 +2418,16 @@ class D {
|
|
|
2161
2418
|
for (let e = 0; e < t.length; e++)
|
|
2162
2419
|
this.writeAddress(t[e]);
|
|
2163
2420
|
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Writes an array of full addresses (64 bytes each).
|
|
2423
|
+
* Format: [u16 length][FullAddress 0][FullAddress 1]...
|
|
2424
|
+
*/
|
|
2425
|
+
writeExtendedAddressArray(t) {
|
|
2426
|
+
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2427
|
+
this.allocSafe(ft + t.length * ht), this.writeU16(t.length);
|
|
2428
|
+
for (let e = 0; e < t.length; e++)
|
|
2429
|
+
this.writeExtendedAddress(t[e]);
|
|
2430
|
+
}
|
|
2164
2431
|
writeU32Array(t, e = !0) {
|
|
2165
2432
|
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2166
2433
|
this.writeU16(t.length, e);
|
|
@@ -2210,9 +2477,9 @@ class D {
|
|
|
2210
2477
|
this.writeBytesWithLength(t[e]);
|
|
2211
2478
|
}
|
|
2212
2479
|
verifyAddress(t) {
|
|
2213
|
-
if (t.byteLength >
|
|
2480
|
+
if (t.byteLength > k)
|
|
2214
2481
|
throw new Error(
|
|
2215
|
-
`Address is too long ${t.byteLength} > ${
|
|
2482
|
+
`Address is too long ${t.byteLength} > ${k} bytes`
|
|
2216
2483
|
);
|
|
2217
2484
|
}
|
|
2218
2485
|
resize(t) {
|
|
@@ -2225,10 +2492,10 @@ class D {
|
|
|
2225
2492
|
return new DataView(new ArrayBuffer(t));
|
|
2226
2493
|
}
|
|
2227
2494
|
}
|
|
2228
|
-
var
|
|
2495
|
+
var N = /* @__PURE__ */ ((n) => (n[n.ACCESS_LIST = 1] = "ACCESS_LIST", n[n.EPOCH_SUBMISSION = 2] = "EPOCH_SUBMISSION", n[n.MLDSA_LINK_PUBKEY = 4] = "MLDSA_LINK_PUBKEY", n))(N || {}), Q = /* @__PURE__ */ ((n) => (n[n.ACCESS_LIST = 1] = "ACCESS_LIST", n[n.EPOCH_SUBMISSION = 2] = "EPOCH_SUBMISSION", n[n.MLDSA_LINK_PUBKEY = 3] = "MLDSA_LINK_PUBKEY", n))(Q || {});
|
|
2229
2496
|
class q {
|
|
2230
2497
|
constructor(t, e, i = I) {
|
|
2231
|
-
this.network = I, this.senderPubKey = t, this.contractSaltPubKey = e, this.network = i, this.xSenderPubKey =
|
|
2498
|
+
this.network = I, this.senderPubKey = t, this.contractSaltPubKey = e, this.network = i, this.xSenderPubKey = O(t);
|
|
2232
2499
|
}
|
|
2233
2500
|
static {
|
|
2234
2501
|
this.DATA_CHUNK_SIZE = 512;
|
|
@@ -2244,7 +2511,7 @@ class q {
|
|
|
2244
2511
|
return i.writeUIntBE(e, 0, 3), a.from([this.senderPubKey[0], ...i]);
|
|
2245
2512
|
}
|
|
2246
2513
|
getHeader(t, e = []) {
|
|
2247
|
-
const i = new
|
|
2514
|
+
const i = new C(12);
|
|
2248
2515
|
return i.writeBytes(this.buildHeader(e)), i.writeU64(t), a.from(i.getBuffer());
|
|
2249
2516
|
}
|
|
2250
2517
|
/**
|
|
@@ -2266,21 +2533,21 @@ class q {
|
|
|
2266
2533
|
}
|
|
2267
2534
|
encodeFeature(t, e) {
|
|
2268
2535
|
switch (t.opcode) {
|
|
2269
|
-
case
|
|
2536
|
+
case N.ACCESS_LIST:
|
|
2270
2537
|
return this.encodeAccessListFeature(t, e);
|
|
2271
|
-
case
|
|
2538
|
+
case N.EPOCH_SUBMISSION:
|
|
2272
2539
|
return this.encodeChallengeSubmission(
|
|
2273
2540
|
t,
|
|
2274
2541
|
e
|
|
2275
2542
|
);
|
|
2276
|
-
case
|
|
2543
|
+
case N.MLDSA_LINK_PUBKEY:
|
|
2277
2544
|
return this.encodeLinkRequest(t, e);
|
|
2278
2545
|
default:
|
|
2279
2546
|
throw new Error(`Unknown feature type: ${t.opcode}`);
|
|
2280
2547
|
}
|
|
2281
2548
|
}
|
|
2282
2549
|
encodeAccessListFeature(t, e) {
|
|
2283
|
-
const i = new
|
|
2550
|
+
const i = new C();
|
|
2284
2551
|
i.writeU16(Object.keys(t.data).length);
|
|
2285
2552
|
for (const r in t.data) {
|
|
2286
2553
|
const s = v.fromString(r), o = t.data[r];
|
|
@@ -2292,16 +2559,16 @@ class q {
|
|
|
2292
2559
|
i.writeBytes(u);
|
|
2293
2560
|
}
|
|
2294
2561
|
}
|
|
2295
|
-
e.writeBytesWithLength(
|
|
2562
|
+
e.writeBytesWithLength(W.compress(a.from(i.getBuffer())));
|
|
2296
2563
|
}
|
|
2297
2564
|
encodeChallengeSubmission(t, e) {
|
|
2298
2565
|
if ("verifySignature" in t.data && !t.data.verifySignature())
|
|
2299
2566
|
throw new Error("Invalid signature in challenge submission feature");
|
|
2300
|
-
const i = new
|
|
2567
|
+
const i = new C();
|
|
2301
2568
|
i.writeBytes(t.data.publicKey.toBuffer()), i.writeBytes(t.data.solution), t.data.graffiti && i.writeBytesWithLength(t.data.graffiti), e.writeBytesWithLength(i.getBuffer());
|
|
2302
2569
|
}
|
|
2303
2570
|
encodeLinkRequest(t, e) {
|
|
2304
|
-
const i = t.data, r = new
|
|
2571
|
+
const i = t.data, r = new C();
|
|
2305
2572
|
if (r.writeU8(i.level), r.writeBytes(i.hashedPublicKey), r.writeBoolean(i.verifyRequest), i.verifyRequest) {
|
|
2306
2573
|
if (!i.publicKey || !i.mldsaSignature)
|
|
2307
2574
|
throw new Error(
|
|
@@ -2314,7 +2581,7 @@ class q {
|
|
|
2314
2581
|
r.writeBytes(i.legacySignature), e.writeBytesWithLength(r.getBuffer());
|
|
2315
2582
|
}
|
|
2316
2583
|
}
|
|
2317
|
-
class
|
|
2584
|
+
class de extends q {
|
|
2318
2585
|
constructor(t, e, i = I) {
|
|
2319
2586
|
super(t, e, i);
|
|
2320
2587
|
}
|
|
@@ -2334,7 +2601,7 @@ class oe extends q {
|
|
|
2334
2601
|
throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
2335
2602
|
i = a.concat([i, s]);
|
|
2336
2603
|
}
|
|
2337
|
-
const r =
|
|
2604
|
+
const r = W.compress(i);
|
|
2338
2605
|
return r.byteLength >= i.byteLength ? i : r;
|
|
2339
2606
|
}
|
|
2340
2607
|
/**
|
|
@@ -2355,7 +2622,7 @@ class oe extends q {
|
|
|
2355
2622
|
if (s && s.length) {
|
|
2356
2623
|
const f = s.sort(
|
|
2357
2624
|
(S, b) => S.priority - b.priority
|
|
2358
|
-
), y = new
|
|
2625
|
+
), y = new C();
|
|
2359
2626
|
for (let S = 0; S < f.length; S++) {
|
|
2360
2627
|
const b = f[S];
|
|
2361
2628
|
c.push(b.opcode), this.encodeFeature(b, y);
|
|
@@ -2379,7 +2646,7 @@ class oe extends q {
|
|
|
2379
2646
|
this.contractSaltPubKey,
|
|
2380
2647
|
g.OP_CHECKSIGVERIFY,
|
|
2381
2648
|
g.OP_HASH160,
|
|
2382
|
-
|
|
2649
|
+
gt(e),
|
|
2383
2650
|
g.OP_EQUALVERIFY,
|
|
2384
2651
|
g.OP_DEPTH,
|
|
2385
2652
|
g.OP_1,
|
|
@@ -2396,12 +2663,12 @@ class oe extends q {
|
|
|
2396
2663
|
g.OP_ENDIF
|
|
2397
2664
|
);
|
|
2398
2665
|
const l = h.flat(), d = L(l);
|
|
2399
|
-
if (!
|
|
2666
|
+
if (!F(d))
|
|
2400
2667
|
throw new Error("Failed to decompile script??");
|
|
2401
2668
|
return d;
|
|
2402
2669
|
}
|
|
2403
2670
|
}
|
|
2404
|
-
class
|
|
2671
|
+
class qe extends q {
|
|
2405
2672
|
constructor(t, e = I) {
|
|
2406
2673
|
super(t, void 0, e);
|
|
2407
2674
|
}
|
|
@@ -2413,13 +2680,13 @@ class Re extends q {
|
|
|
2413
2680
|
*/
|
|
2414
2681
|
compile(t) {
|
|
2415
2682
|
const e = t.flat(), i = L(e);
|
|
2416
|
-
if (!
|
|
2683
|
+
if (!F(i))
|
|
2417
2684
|
throw new Error("Failed to decompile script??");
|
|
2418
2685
|
return i;
|
|
2419
2686
|
}
|
|
2420
2687
|
}
|
|
2421
|
-
const
|
|
2422
|
-
class
|
|
2688
|
+
const $e = 0, Xe = a.from([$e]);
|
|
2689
|
+
class Vt extends q {
|
|
2423
2690
|
constructor(t, e, i = I) {
|
|
2424
2691
|
super(t, e, i);
|
|
2425
2692
|
}
|
|
@@ -2442,7 +2709,7 @@ class Ft extends q {
|
|
|
2442
2709
|
s,
|
|
2443
2710
|
o
|
|
2444
2711
|
), u = L(c);
|
|
2445
|
-
if (!
|
|
2712
|
+
if (!F(u))
|
|
2446
2713
|
throw new Error("Failed to decompile script??");
|
|
2447
2714
|
return u;
|
|
2448
2715
|
}
|
|
@@ -2452,7 +2719,7 @@ class Ft extends q {
|
|
|
2452
2719
|
if (o && o.length) {
|
|
2453
2720
|
const p = o.sort(
|
|
2454
2721
|
(y, S) => y.priority - S.priority
|
|
2455
|
-
), f = new
|
|
2722
|
+
), f = new C();
|
|
2456
2723
|
for (let y = 0; y < p.length; y++) {
|
|
2457
2724
|
const S = p[y];
|
|
2458
2725
|
h.push(S.opcode), this.encodeFeature(S, f);
|
|
@@ -2494,7 +2761,7 @@ class Ft extends q {
|
|
|
2494
2761
|
].flat();
|
|
2495
2762
|
}
|
|
2496
2763
|
}
|
|
2497
|
-
class
|
|
2764
|
+
class P extends De {
|
|
2498
2765
|
constructor(t, e = I) {
|
|
2499
2766
|
if (super(), this.logColor = "#4a90d9", t.length !== 33)
|
|
2500
2767
|
throw new Error("Public key must be 33 bytes (compressed)");
|
|
@@ -2525,21 +2792,21 @@ class E extends xe {
|
|
|
2525
2792
|
this.WITNESS_FIXED_OVERHEAD = 112;
|
|
2526
2793
|
}
|
|
2527
2794
|
static {
|
|
2528
|
-
this.WITNESS_PER_CHUNK_OVERHEAD =
|
|
2795
|
+
this.WITNESS_PER_CHUNK_OVERHEAD = P.MAX_CHUNK_SIZE + 1 + P.BYTES_PER_COMMITMENT;
|
|
2529
2796
|
}
|
|
2530
2797
|
static {
|
|
2531
2798
|
this.MAX_CHUNKS_PER_OUTPUT = Math.floor(
|
|
2532
|
-
(
|
|
2799
|
+
(P.MAX_WITNESS_SIZE - P.WITNESS_FIXED_OVERHEAD) / P.WITNESS_PER_CHUNK_OVERHEAD
|
|
2533
2800
|
);
|
|
2534
2801
|
}
|
|
2535
2802
|
static {
|
|
2536
2803
|
this.INPUT_BASE_WEIGHT = 164;
|
|
2537
2804
|
}
|
|
2538
2805
|
static {
|
|
2539
|
-
this.INPUT_WITNESS_WEIGHT_MAX =
|
|
2806
|
+
this.INPUT_WITNESS_WEIGHT_MAX = P.MAX_WITNESS_SIZE;
|
|
2540
2807
|
}
|
|
2541
2808
|
static {
|
|
2542
|
-
this.WEIGHT_PER_INPUT =
|
|
2809
|
+
this.WEIGHT_PER_INPUT = P.INPUT_BASE_WEIGHT + P.INPUT_WITNESS_WEIGHT_MAX;
|
|
2543
2810
|
}
|
|
2544
2811
|
/**
|
|
2545
2812
|
* Calculate the maximum number of inputs per standard reveal transaction.
|
|
@@ -2550,8 +2817,8 @@ class E extends xe {
|
|
|
2550
2817
|
* @returns Maximum inputs per reveal tx (~38 with max chunks)
|
|
2551
2818
|
*/
|
|
2552
2819
|
static calculateMaxInputsPerTx() {
|
|
2553
|
-
const i =
|
|
2554
|
-
return Math.floor(i /
|
|
2820
|
+
const i = P.MAX_STANDARD_WEIGHT - 40 - 200;
|
|
2821
|
+
return Math.floor(i / P.WEIGHT_PER_INPUT);
|
|
2555
2822
|
}
|
|
2556
2823
|
/**
|
|
2557
2824
|
* Calculate maximum data per standard reveal transaction.
|
|
@@ -2559,7 +2826,7 @@ class E extends xe {
|
|
|
2559
2826
|
* @returns Maximum data in bytes (~300KB with batched chunks at 70 chunks/output)
|
|
2560
2827
|
*/
|
|
2561
2828
|
static calculateMaxDataPerTx() {
|
|
2562
|
-
return
|
|
2829
|
+
return P.calculateMaxInputsPerTx() * P.MAX_CHUNKS_PER_OUTPUT * P.MAX_CHUNK_SIZE;
|
|
2563
2830
|
}
|
|
2564
2831
|
/**
|
|
2565
2832
|
* Estimate the number of P2WSH outputs needed for a given data size.
|
|
@@ -2569,7 +2836,7 @@ class E extends xe {
|
|
|
2569
2836
|
*/
|
|
2570
2837
|
static estimateOutputCount(t) {
|
|
2571
2838
|
return Math.ceil(
|
|
2572
|
-
t / (
|
|
2839
|
+
t / (P.MAX_CHUNKS_PER_OUTPUT * P.MAX_CHUNK_SIZE)
|
|
2573
2840
|
);
|
|
2574
2841
|
}
|
|
2575
2842
|
/**
|
|
@@ -2579,7 +2846,7 @@ class E extends xe {
|
|
|
2579
2846
|
* @returns Number of 80-byte chunks needed
|
|
2580
2847
|
*/
|
|
2581
2848
|
static estimateChunkCount(t) {
|
|
2582
|
-
return Math.ceil(t /
|
|
2849
|
+
return Math.ceil(t / P.MAX_CHUNK_SIZE);
|
|
2583
2850
|
}
|
|
2584
2851
|
/**
|
|
2585
2852
|
* Validate that a witness script is a valid multi-hash committed script.
|
|
@@ -2591,7 +2858,7 @@ class E extends xe {
|
|
|
2591
2858
|
*/
|
|
2592
2859
|
static validateHashCommittedScript(t) {
|
|
2593
2860
|
try {
|
|
2594
|
-
const e =
|
|
2861
|
+
const e = F(t);
|
|
2595
2862
|
if (!e || e.length < 5)
|
|
2596
2863
|
return !1;
|
|
2597
2864
|
const i = e.length - 1;
|
|
@@ -2621,8 +2888,8 @@ class E extends xe {
|
|
|
2621
2888
|
*/
|
|
2622
2889
|
static extractDataHashes(t) {
|
|
2623
2890
|
try {
|
|
2624
|
-
const e =
|
|
2625
|
-
if (!e || !
|
|
2891
|
+
const e = F(t);
|
|
2892
|
+
if (!e || !P.validateHashCommittedScript(t))
|
|
2626
2893
|
return null;
|
|
2627
2894
|
const i = e.slice(0, -2), r = [];
|
|
2628
2895
|
for (let s = 0; s < i.length; s += 3)
|
|
@@ -2640,8 +2907,8 @@ class E extends xe {
|
|
|
2640
2907
|
*/
|
|
2641
2908
|
static extractPublicKey(t) {
|
|
2642
2909
|
try {
|
|
2643
|
-
const e =
|
|
2644
|
-
return !e || !
|
|
2910
|
+
const e = F(t);
|
|
2911
|
+
return !e || !P.validateHashCommittedScript(t) ? null : e[e.length - 2];
|
|
2645
2912
|
} catch {
|
|
2646
2913
|
return null;
|
|
2647
2914
|
}
|
|
@@ -2654,11 +2921,11 @@ class E extends xe {
|
|
|
2654
2921
|
* @returns true if all chunks match their commitments
|
|
2655
2922
|
*/
|
|
2656
2923
|
static verifyChunkCommitments(t, e) {
|
|
2657
|
-
const i =
|
|
2924
|
+
const i = P.extractDataHashes(e);
|
|
2658
2925
|
if (!i || i.length !== t.length)
|
|
2659
2926
|
return !1;
|
|
2660
2927
|
for (let r = 0; r < t.length; r++) {
|
|
2661
|
-
const s =
|
|
2928
|
+
const s = gt(t[r]);
|
|
2662
2929
|
if (!i[r].equals(s))
|
|
2663
2930
|
return !1;
|
|
2664
2931
|
}
|
|
@@ -2673,7 +2940,7 @@ class E extends xe {
|
|
|
2673
2940
|
* @returns Fee estimates
|
|
2674
2941
|
*/
|
|
2675
2942
|
static estimateFees(t, e, i = 0.7) {
|
|
2676
|
-
const r = Math.ceil(t * i), s =
|
|
2943
|
+
const r = Math.ceil(t * i), s = P.estimateOutputCount(r), o = P.estimateChunkCount(r), c = 116, u = s * 43 + 43, l = 11 + c + u, d = 40 + s * P.WEIGHT_PER_INPUT + 200, p = Math.ceil(d / 4), f = BigInt(Math.ceil(l * e)), y = BigInt(Math.ceil(p * e)), S = f + y, b = BigInt(s) * P.MIN_OUTPUT_VALUE, K = S + b;
|
|
2677
2944
|
return {
|
|
2678
2945
|
compressedSize: r,
|
|
2679
2946
|
outputCount: s,
|
|
@@ -2684,7 +2951,7 @@ class E extends xe {
|
|
|
2684
2951
|
revealFee: y,
|
|
2685
2952
|
totalFee: S,
|
|
2686
2953
|
outputsValue: b,
|
|
2687
|
-
totalCost:
|
|
2954
|
+
totalCost: K
|
|
2688
2955
|
};
|
|
2689
2956
|
}
|
|
2690
2957
|
/**
|
|
@@ -2692,7 +2959,7 @@ class E extends xe {
|
|
|
2692
2959
|
* HASH160 = RIPEMD160(SHA256(data))
|
|
2693
2960
|
*/
|
|
2694
2961
|
hashChunk(t) {
|
|
2695
|
-
return
|
|
2962
|
+
return gt(t);
|
|
2696
2963
|
}
|
|
2697
2964
|
/**
|
|
2698
2965
|
* Generate a hash-committed witness script for multiple data chunks.
|
|
@@ -2714,9 +2981,9 @@ class E extends xe {
|
|
|
2714
2981
|
generateWitnessScript(t) {
|
|
2715
2982
|
if (t.length === 0)
|
|
2716
2983
|
throw new Error("At least one data hash is required");
|
|
2717
|
-
if (t.length >
|
|
2984
|
+
if (t.length > P.MAX_CHUNKS_PER_OUTPUT)
|
|
2718
2985
|
throw new Error(
|
|
2719
|
-
`Too many chunks: ${t.length} exceeds limit of ${
|
|
2986
|
+
`Too many chunks: ${t.length} exceeds limit of ${P.MAX_CHUNKS_PER_OUTPUT}`
|
|
2720
2987
|
);
|
|
2721
2988
|
for (const i of t)
|
|
2722
2989
|
if (i.length !== 20)
|
|
@@ -2733,7 +3000,7 @@ class E extends xe {
|
|
|
2733
3000
|
* @returns P2WSH address info
|
|
2734
3001
|
*/
|
|
2735
3002
|
generateP2WSHAddress(t) {
|
|
2736
|
-
const e =
|
|
3003
|
+
const e = pt({
|
|
2737
3004
|
redeem: { output: t },
|
|
2738
3005
|
network: this.network
|
|
2739
3006
|
});
|
|
@@ -2755,10 +3022,10 @@ class E extends xe {
|
|
|
2755
3022
|
* @param maxChunkSize Maximum bytes per stack item (default: 80, P2WSH stack item limit)
|
|
2756
3023
|
* @returns Array of hash-committed P2WSH outputs
|
|
2757
3024
|
*/
|
|
2758
|
-
prepareChunks(t, e =
|
|
2759
|
-
if (e >
|
|
3025
|
+
prepareChunks(t, e = P.MAX_CHUNK_SIZE) {
|
|
3026
|
+
if (e > P.MAX_CHUNK_SIZE)
|
|
2760
3027
|
throw new Error(
|
|
2761
|
-
`Chunk size ${e} exceeds P2WSH stack item limit of ${
|
|
3028
|
+
`Chunk size ${e} exceeds P2WSH stack item limit of ${P.MAX_CHUNK_SIZE}`
|
|
2762
3029
|
);
|
|
2763
3030
|
if (t.length === 0)
|
|
2764
3031
|
throw new Error("Data cannot be empty");
|
|
@@ -2773,7 +3040,7 @@ class E extends xe {
|
|
|
2773
3040
|
for (; o < i.length; ) {
|
|
2774
3041
|
const u = i.slice(
|
|
2775
3042
|
o,
|
|
2776
|
-
o +
|
|
3043
|
+
o + P.MAX_CHUNKS_PER_OUTPUT
|
|
2777
3044
|
), h = u, l = h.map((f) => this.hashChunk(f)), d = this.generateWitnessScript(l), p = this.generateP2WSHAddress(d);
|
|
2778
3045
|
s.push({
|
|
2779
3046
|
address: p.address,
|
|
@@ -2790,7 +3057,7 @@ class E extends xe {
|
|
|
2790
3057
|
), s;
|
|
2791
3058
|
}
|
|
2792
3059
|
}
|
|
2793
|
-
class
|
|
3060
|
+
class ir extends q {
|
|
2794
3061
|
constructor(t, e = I) {
|
|
2795
3062
|
super(t, a.alloc(0), e);
|
|
2796
3063
|
}
|
|
@@ -2810,7 +3077,7 @@ class Ji extends q {
|
|
|
2810
3077
|
throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
2811
3078
|
i = a.concat([i, s]);
|
|
2812
3079
|
}
|
|
2813
|
-
const r =
|
|
3080
|
+
const r = W.compress(i);
|
|
2814
3081
|
return r.byteLength >= i.byteLength ? i : r;
|
|
2815
3082
|
}
|
|
2816
3083
|
/**
|
|
@@ -2830,7 +3097,7 @@ class Ji extends q {
|
|
|
2830
3097
|
if (s && s.length) {
|
|
2831
3098
|
const f = s.sort(
|
|
2832
3099
|
(S, b) => S.priority - b.priority
|
|
2833
|
-
), y = new
|
|
3100
|
+
), y = new C();
|
|
2834
3101
|
for (let S = 0; S < f.length; S++) {
|
|
2835
3102
|
const b = f[S];
|
|
2836
3103
|
c.push(b.opcode), this.encodeFeature(b, y);
|
|
@@ -2866,12 +3133,12 @@ class Ji extends q {
|
|
|
2866
3133
|
g.OP_ENDIF
|
|
2867
3134
|
);
|
|
2868
3135
|
const l = h.flat(), d = L(l);
|
|
2869
|
-
if (!
|
|
3136
|
+
if (!F(d))
|
|
2870
3137
|
throw new Error("Failed to decompile script??");
|
|
2871
3138
|
return d;
|
|
2872
3139
|
}
|
|
2873
3140
|
}
|
|
2874
|
-
class
|
|
3141
|
+
class kt {
|
|
2875
3142
|
static {
|
|
2876
3143
|
this.MAXIMUM_SUPPORTED_SIGNATURE = 255;
|
|
2877
3144
|
}
|
|
@@ -2880,9 +3147,9 @@ class Et {
|
|
|
2880
3147
|
throw new Error("Minimum signatures must be greater than 1");
|
|
2881
3148
|
if (t.length < e)
|
|
2882
3149
|
throw new Error("The amount of public keys is lower than the minimum required");
|
|
2883
|
-
if (e >
|
|
3150
|
+
if (e > kt.MAXIMUM_SUPPORTED_SIGNATURE)
|
|
2884
3151
|
throw new Error(
|
|
2885
|
-
`The maximum amount of signatures is ${
|
|
3152
|
+
`The maximum amount of signatures is ${kt.MAXIMUM_SUPPORTED_SIGNATURE}`
|
|
2886
3153
|
);
|
|
2887
3154
|
const r = a.alloc(1);
|
|
2888
3155
|
r.writeUInt8(e), t = t.filter(
|
|
@@ -2890,7 +3157,7 @@ class Et {
|
|
|
2890
3157
|
), t = t.sort((d, p) => d.compare(p));
|
|
2891
3158
|
let s = !1;
|
|
2892
3159
|
const o = t.map((d) => {
|
|
2893
|
-
const p =
|
|
3160
|
+
const p = O(d);
|
|
2894
3161
|
return i && !s && (s = i.equals(p)), p;
|
|
2895
3162
|
});
|
|
2896
3163
|
i && !s && o.push(i);
|
|
@@ -2909,12 +3176,12 @@ class Et {
|
|
|
2909
3176
|
g.OP_NUMEQUAL
|
|
2910
3177
|
// Use NUMEQUALVERIFY to ensure the correct number of signatures
|
|
2911
3178
|
].flat(), h = L(u);
|
|
2912
|
-
if (!
|
|
3179
|
+
if (!F(h))
|
|
2913
3180
|
throw new Error("Failed to decompile script.");
|
|
2914
3181
|
return h;
|
|
2915
3182
|
}
|
|
2916
3183
|
}
|
|
2917
|
-
class
|
|
3184
|
+
class Ut extends q {
|
|
2918
3185
|
static {
|
|
2919
3186
|
this.P2WDA_VERSION = 1;
|
|
2920
3187
|
}
|
|
@@ -2954,8 +3221,8 @@ class At extends q {
|
|
|
2954
3221
|
throw new Error("Contract salt public key not set");
|
|
2955
3222
|
if (e.length !== 32)
|
|
2956
3223
|
throw new Error("Contract secret must be exactly 32 bytes");
|
|
2957
|
-
const o = new
|
|
2958
|
-
o.writeU8(
|
|
3224
|
+
const o = new C();
|
|
3225
|
+
o.writeU8(Ut.P2WDA_VERSION);
|
|
2959
3226
|
const c = s.sort((u, h) => u.priority - h.priority);
|
|
2960
3227
|
return o.writeBytes(
|
|
2961
3228
|
this.getHeader(
|
|
@@ -2983,23 +3250,23 @@ class At extends q {
|
|
|
2983
3250
|
}
|
|
2984
3251
|
}
|
|
2985
3252
|
ot(G);
|
|
2986
|
-
class
|
|
3253
|
+
class fe {
|
|
2987
3254
|
// Generate a valid SegWit address from random bytes
|
|
2988
3255
|
static generatePKSH(t, e) {
|
|
2989
3256
|
if (t.length !== 32) throw new Error("Invalid hash length");
|
|
2990
|
-
const i =
|
|
3257
|
+
const i = Bi(t);
|
|
2991
3258
|
return this.toSegwitAddress(i, e);
|
|
2992
3259
|
}
|
|
2993
3260
|
// Generate a valid Taproot address from a public key
|
|
2994
3261
|
static generateTaprootAddress(t, e) {
|
|
2995
3262
|
if (t.length !== 32) throw new Error("Invalid public key length");
|
|
2996
|
-
const i =
|
|
2997
|
-
return i.unshift(1),
|
|
3263
|
+
const i = Rt.bech32m.toWords(t);
|
|
3264
|
+
return i.unshift(1), Rt.bech32m.encode(e.bech32, i);
|
|
2998
3265
|
}
|
|
2999
3266
|
// Convert a hash to a SegWit address
|
|
3000
3267
|
static toSegwitAddress(t, e) {
|
|
3001
|
-
const i =
|
|
3002
|
-
return i.unshift(0),
|
|
3268
|
+
const i = Rt.bech32.toWords(t);
|
|
3269
|
+
return i.unshift(0), Rt.bech32.encode(e.bech32, i);
|
|
3003
3270
|
}
|
|
3004
3271
|
}
|
|
3005
3272
|
class tt {
|
|
@@ -3007,9 +3274,9 @@ class tt {
|
|
|
3007
3274
|
this.TAP_SCRIPT_VERSION = 192;
|
|
3008
3275
|
}
|
|
3009
3276
|
static getContractAddress(t) {
|
|
3010
|
-
const e = t.network || I, r = new
|
|
3277
|
+
const e = t.network || I, r = new Vt(
|
|
3011
3278
|
t.deployerPubKey,
|
|
3012
|
-
|
|
3279
|
+
O(t.contractSaltPubKey),
|
|
3013
3280
|
e
|
|
3014
3281
|
).compile(
|
|
3015
3282
|
t.bytecode,
|
|
@@ -3019,7 +3286,7 @@ class tt {
|
|
|
3019
3286
|
t.calldata,
|
|
3020
3287
|
t.features
|
|
3021
3288
|
), s = L([
|
|
3022
|
-
|
|
3289
|
+
O(t.deployerPubKey),
|
|
3023
3290
|
g.OP_CHECKSIG
|
|
3024
3291
|
]), o = [
|
|
3025
3292
|
{
|
|
@@ -3034,9 +3301,9 @@ class tt {
|
|
|
3034
3301
|
return tt.generateAddressFromScript(t, o);
|
|
3035
3302
|
}
|
|
3036
3303
|
static verifyControlBlock(t, e) {
|
|
3037
|
-
const i = t.network || I, s = new
|
|
3304
|
+
const i = t.network || I, s = new Vt(
|
|
3038
3305
|
t.deployerPubKey,
|
|
3039
|
-
|
|
3306
|
+
O(t.contractSaltPubKey),
|
|
3040
3307
|
i
|
|
3041
3308
|
).compile(
|
|
3042
3309
|
t.bytecode,
|
|
@@ -3046,7 +3313,7 @@ class tt {
|
|
|
3046
3313
|
t.calldata,
|
|
3047
3314
|
t.features
|
|
3048
3315
|
), o = L([
|
|
3049
|
-
|
|
3316
|
+
O(t.deployerPubKey),
|
|
3050
3317
|
g.OP_CHECKSIG
|
|
3051
3318
|
]), c = [
|
|
3052
3319
|
{
|
|
@@ -3058,7 +3325,7 @@ class tt {
|
|
|
3058
3325
|
version: tt.TAP_SCRIPT_VERSION
|
|
3059
3326
|
}
|
|
3060
3327
|
], h = rt({
|
|
3061
|
-
internalPubkey:
|
|
3328
|
+
internalPubkey: O(t.deployerPubKey),
|
|
3062
3329
|
network: i,
|
|
3063
3330
|
scriptTree: c,
|
|
3064
3331
|
redeem: {
|
|
@@ -3074,7 +3341,7 @@ class tt {
|
|
|
3074
3341
|
}
|
|
3075
3342
|
static generateAddressFromScript(t, e) {
|
|
3076
3343
|
const i = t.network || I, r = {
|
|
3077
|
-
internalPubkey:
|
|
3344
|
+
internalPubkey: O(t.deployerPubKey),
|
|
3078
3345
|
network: i,
|
|
3079
3346
|
scriptTree: e
|
|
3080
3347
|
};
|
|
@@ -3082,7 +3349,7 @@ class tt {
|
|
|
3082
3349
|
}
|
|
3083
3350
|
}
|
|
3084
3351
|
ot(G);
|
|
3085
|
-
class
|
|
3352
|
+
class pe {
|
|
3086
3353
|
/**
|
|
3087
3354
|
* Tweak a signer
|
|
3088
3355
|
* @param {Signer} signer - The signer to tweak
|
|
@@ -3093,22 +3360,22 @@ class ce {
|
|
|
3093
3360
|
let i = t.privateKey;
|
|
3094
3361
|
if (!i)
|
|
3095
3362
|
throw new Error("Private key is required for tweaking signer!");
|
|
3096
|
-
t.publicKey[0] === 3 && (i =
|
|
3097
|
-
const r =
|
|
3363
|
+
t.publicKey[0] === 3 && (i = Mt.privateNegate(i));
|
|
3364
|
+
const r = Mt.privateAdd(
|
|
3098
3365
|
i,
|
|
3099
|
-
|
|
3366
|
+
xi(O(a.from(t.publicKey)), e.tweakHash)
|
|
3100
3367
|
);
|
|
3101
3368
|
if (!r)
|
|
3102
3369
|
throw new Error("Invalid tweaked private key!");
|
|
3103
3370
|
return A.fromPrivateKey(a.from(r), e.network);
|
|
3104
3371
|
}
|
|
3105
3372
|
}
|
|
3106
|
-
function
|
|
3373
|
+
function Ye(n) {
|
|
3107
3374
|
return typeof n == "object" && n !== null && "web3" in n && typeof n.web3 == "object" && "getMLDSAPublicKey" in n.web3 && "signMLDSAMessage" in n.web3;
|
|
3108
3375
|
}
|
|
3109
|
-
class
|
|
3376
|
+
class rr {
|
|
3110
3377
|
sha256(t) {
|
|
3111
|
-
return
|
|
3378
|
+
return Fe(a.from(t));
|
|
3112
3379
|
}
|
|
3113
3380
|
/**
|
|
3114
3381
|
* Attempts to sign a message using OP_WALLET if available in browser environment.
|
|
@@ -3236,7 +3503,7 @@ class tr {
|
|
|
3236
3503
|
* @returns {SignedMessage} The Schnorr signature.
|
|
3237
3504
|
*/
|
|
3238
3505
|
tweakAndSignMessage(t, e, i) {
|
|
3239
|
-
const r =
|
|
3506
|
+
const r = pe.tweakSigner(t, { network: i });
|
|
3240
3507
|
return this.signMessage(r, e);
|
|
3241
3508
|
}
|
|
3242
3509
|
/**
|
|
@@ -3251,7 +3518,7 @@ class tr {
|
|
|
3251
3518
|
throw new Error("Private key not found in keypair.");
|
|
3252
3519
|
const i = this.sha256(e);
|
|
3253
3520
|
return {
|
|
3254
|
-
signature:
|
|
3521
|
+
signature: Mt.signSchnorr(i, t.privateKey),
|
|
3255
3522
|
message: i
|
|
3256
3523
|
};
|
|
3257
3524
|
}
|
|
@@ -3267,7 +3534,7 @@ class tr {
|
|
|
3267
3534
|
if (typeof e == "string" && (e = a.from(e, "utf-8")), i.length !== 64)
|
|
3268
3535
|
throw new Error("Invalid signature length.");
|
|
3269
3536
|
const r = this.sha256(e);
|
|
3270
|
-
return
|
|
3537
|
+
return Mt.verifySchnorr(r, O(a.from(t)), i);
|
|
3271
3538
|
}
|
|
3272
3539
|
/**
|
|
3273
3540
|
* Tweak the public key and verify a signature.
|
|
@@ -3322,10 +3589,10 @@ class tr {
|
|
|
3322
3589
|
if (typeof window > "u")
|
|
3323
3590
|
return null;
|
|
3324
3591
|
const t = window;
|
|
3325
|
-
return !t.opnet || !
|
|
3592
|
+
return !t.opnet || !Ye(t.opnet) ? null : t.opnet;
|
|
3326
3593
|
}
|
|
3327
3594
|
}
|
|
3328
|
-
const st = new
|
|
3595
|
+
const st = new rr();
|
|
3329
3596
|
ot(G);
|
|
3330
3597
|
class Z {
|
|
3331
3598
|
/**
|
|
@@ -3338,16 +3605,16 @@ class Z {
|
|
|
3338
3605
|
* @param chainCode - Optional chain code for BIP32 derivation (32 bytes)
|
|
3339
3606
|
* @throws {Error} If the private keys are invalid
|
|
3340
3607
|
*/
|
|
3341
|
-
constructor(t, e, i = I, r =
|
|
3608
|
+
constructor(t, e, i = I, r = E.MLDSASecurityLevel.LEVEL2, s) {
|
|
3342
3609
|
this.network = i, this._securityLevel = r;
|
|
3343
3610
|
const o = t.startsWith("0x") ? t.replace("0x", "") : t;
|
|
3344
|
-
|
|
3611
|
+
D.isValidHex(o) ? this._keypair = A.fromPrivateKey(
|
|
3345
3612
|
a.from(o, "hex"),
|
|
3346
3613
|
this.network
|
|
3347
3614
|
) : this._keypair = A.fromWIF(o, this.network);
|
|
3348
3615
|
const c = e.startsWith("0x") ? e.replace("0x", "") : e;
|
|
3349
|
-
if (
|
|
3350
|
-
const u = a.from(c, "hex"), h =
|
|
3616
|
+
if (D.isValidHex(c)) {
|
|
3617
|
+
const u = a.from(c, "hex"), h = E.getMLDSAConfig(r, this.network), l = h.privateKeySize, d = h.publicKeySize, p = l + d;
|
|
3351
3618
|
let f;
|
|
3352
3619
|
if (u.length === l)
|
|
3353
3620
|
f = u;
|
|
@@ -3359,14 +3626,14 @@ class Z {
|
|
|
3359
3626
|
);
|
|
3360
3627
|
if (s && s.length !== 32)
|
|
3361
3628
|
throw new Error("Chain code must be 32 bytes");
|
|
3362
|
-
this._chainCode = s || a.alloc(32), this._mldsaKeypair =
|
|
3629
|
+
this._chainCode = s || a.alloc(32), this._mldsaKeypair = E.QuantumBIP32Factory.fromPrivateKey(
|
|
3363
3630
|
f,
|
|
3364
3631
|
this._chainCode,
|
|
3365
3632
|
this.network,
|
|
3366
3633
|
r
|
|
3367
3634
|
);
|
|
3368
3635
|
} else
|
|
3369
|
-
this._mldsaKeypair =
|
|
3636
|
+
this._mldsaKeypair = E.QuantumBIP32Factory.fromBase58(c), this._chainCode = a.from(this._mldsaKeypair.chainCode), this._securityLevel = this._mldsaKeypair.securityLevel;
|
|
3370
3637
|
this._bufferPubKey = this._keypair.publicKey, this._address = new v(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();
|
|
3371
3638
|
}
|
|
3372
3639
|
/**
|
|
@@ -3482,7 +3749,7 @@ class Z {
|
|
|
3482
3749
|
*/
|
|
3483
3750
|
get xOnly() {
|
|
3484
3751
|
if (!this.keypair) throw new Error("Keypair not set");
|
|
3485
|
-
return
|
|
3752
|
+
return O(this._bufferPubKey);
|
|
3486
3753
|
}
|
|
3487
3754
|
/**
|
|
3488
3755
|
* Create a wallet from WIF strings
|
|
@@ -3494,7 +3761,7 @@ class Z {
|
|
|
3494
3761
|
* @param chainCode - Optional chain code for BIP32 derivation
|
|
3495
3762
|
* @returns A Wallet instance
|
|
3496
3763
|
*/
|
|
3497
|
-
static fromWif(t, e, i = I, r =
|
|
3764
|
+
static fromWif(t, e, i = I, r = E.MLDSASecurityLevel.LEVEL2, s) {
|
|
3498
3765
|
return new Z(t, e, i, r, s);
|
|
3499
3766
|
}
|
|
3500
3767
|
/**
|
|
@@ -3504,7 +3771,7 @@ class Z {
|
|
|
3504
3771
|
* @param securityLevel - The ML-DSA security level (default: LEVEL2/44)
|
|
3505
3772
|
* @returns A new Wallet instance with randomly generated keys
|
|
3506
3773
|
*/
|
|
3507
|
-
static generate(t = I, e =
|
|
3774
|
+
static generate(t = I, e = E.MLDSASecurityLevel.LEVEL2) {
|
|
3508
3775
|
const i = A.generateWallet(t, e);
|
|
3509
3776
|
if (!i.quantumPrivateKey)
|
|
3510
3777
|
throw new Error("Failed to generate quantum keys");
|
|
@@ -3525,7 +3792,7 @@ class Z {
|
|
|
3525
3792
|
* @param chainCode - Optional chain code for BIP32 derivation
|
|
3526
3793
|
* @returns A Wallet instance
|
|
3527
3794
|
*/
|
|
3528
|
-
static fromPrivateKeys(t, e, i = I, r =
|
|
3795
|
+
static fromPrivateKeys(t, e, i = I, r = E.MLDSASecurityLevel.LEVEL2, s) {
|
|
3529
3796
|
return new Z(
|
|
3530
3797
|
t,
|
|
3531
3798
|
e,
|
|
@@ -3597,8 +3864,8 @@ class Z {
|
|
|
3597
3864
|
);
|
|
3598
3865
|
}
|
|
3599
3866
|
}
|
|
3600
|
-
var
|
|
3601
|
-
function
|
|
3867
|
+
var zt = /* @__PURE__ */ ((n) => (n[n.MINIMUM = 128] = "MINIMUM", n[n.LOW = 160] = "LOW", n[n.MEDIUM = 192] = "MEDIUM", n[n.HIGH = 224] = "HIGH", n[n.MAXIMUM = 256] = "MAXIMUM", n))(zt || {}), Et = /* @__PURE__ */ ((n) => (n[n.BIP44 = 44] = "BIP44", n[n.BIP49 = 49] = "BIP49", n[n.BIP84 = 84] = "BIP84", n[n.BIP86 = 86] = "BIP86", n))(Et || {});
|
|
3868
|
+
function sr(n) {
|
|
3602
3869
|
switch (n) {
|
|
3603
3870
|
case 44:
|
|
3604
3871
|
return "BIP44: Legacy addresses (P2PKH), widely used by Unisat and other wallets";
|
|
@@ -3612,12 +3879,12 @@ function er(n) {
|
|
|
3612
3879
|
return "Unknown BIP standard";
|
|
3613
3880
|
}
|
|
3614
3881
|
}
|
|
3615
|
-
function
|
|
3882
|
+
function Ge(n, t, e, i, r) {
|
|
3616
3883
|
return `m/${n}'/${t}'/${e}'/${i}/${r}`;
|
|
3617
3884
|
}
|
|
3618
3885
|
ot(G);
|
|
3619
|
-
const
|
|
3620
|
-
class
|
|
3886
|
+
const nr = E.BIP32Factory(G);
|
|
3887
|
+
class ge {
|
|
3621
3888
|
/**
|
|
3622
3889
|
* Create a new Mnemonic instance from an existing phrase
|
|
3623
3890
|
*
|
|
@@ -3627,10 +3894,10 @@ class ue {
|
|
|
3627
3894
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
3628
3895
|
* @throws {Error} If the mnemonic phrase is invalid
|
|
3629
3896
|
*/
|
|
3630
|
-
constructor(t, e = "", i = I, r =
|
|
3631
|
-
if (!
|
|
3897
|
+
constructor(t, e = "", i = I, r = E.MLDSASecurityLevel.LEVEL2) {
|
|
3898
|
+
if (!wt.validateMnemonic(t))
|
|
3632
3899
|
throw new Error("Invalid mnemonic phrase");
|
|
3633
|
-
this._phrase = t, this._passphrase = e, this._network = i, this._securityLevel = r, this._seed =
|
|
3900
|
+
this._phrase = t, this._passphrase = e, this._network = i, this._securityLevel = r, this._seed = wt.mnemonicToSeedSync(this._phrase, this._passphrase), this._classicalRoot = nr.fromSeed(this._seed, this._network), this._quantumRoot = E.QuantumBIP32Factory.fromSeed(
|
|
3634
3901
|
this._seed,
|
|
3635
3902
|
this._network,
|
|
3636
3903
|
this._securityLevel
|
|
@@ -3676,8 +3943,8 @@ class ue {
|
|
|
3676
3943
|
* @param strength - The entropy strength in bits (default: 256 for 24 words)
|
|
3677
3944
|
* @returns A new random mnemonic phrase
|
|
3678
3945
|
*/
|
|
3679
|
-
static generatePhrase(t =
|
|
3680
|
-
return
|
|
3946
|
+
static generatePhrase(t = zt.MAXIMUM) {
|
|
3947
|
+
return wt.generateMnemonic(t);
|
|
3681
3948
|
}
|
|
3682
3949
|
/**
|
|
3683
3950
|
* Generate a new Mnemonic instance with a random phrase
|
|
@@ -3688,9 +3955,9 @@ class ue {
|
|
|
3688
3955
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
3689
3956
|
* @returns A new Mnemonic instance
|
|
3690
3957
|
*/
|
|
3691
|
-
static generate(t =
|
|
3692
|
-
const s =
|
|
3693
|
-
return new
|
|
3958
|
+
static generate(t = zt.MAXIMUM, e = "", i = I, r = E.MLDSASecurityLevel.LEVEL2) {
|
|
3959
|
+
const s = wt.generateMnemonic(t);
|
|
3960
|
+
return new ge(s, e, i, r);
|
|
3694
3961
|
}
|
|
3695
3962
|
/**
|
|
3696
3963
|
* Validate a mnemonic phrase
|
|
@@ -3699,7 +3966,7 @@ class ue {
|
|
|
3699
3966
|
* @returns True if the phrase is valid, false otherwise
|
|
3700
3967
|
*/
|
|
3701
3968
|
static validate(t) {
|
|
3702
|
-
return
|
|
3969
|
+
return wt.validateMnemonic(t);
|
|
3703
3970
|
}
|
|
3704
3971
|
/**
|
|
3705
3972
|
* Derive a wallet at a specific index using BIP360 (quantum) and configurable BIP standard (classical) paths
|
|
@@ -3725,7 +3992,7 @@ class ue {
|
|
|
3725
3992
|
* const wallet3 = mnemonic.derive(0, 0, false, BIPStandard.BIP86);
|
|
3726
3993
|
* ```
|
|
3727
3994
|
*/
|
|
3728
|
-
derive(t = 0, e = 0, i = !1, r =
|
|
3995
|
+
derive(t = 0, e = 0, i = !1, r = Et.BIP84) {
|
|
3729
3996
|
const s = this.buildClassicalPath(e, t, i, r), o = this._classicalRoot.derivePath(s);
|
|
3730
3997
|
if (!o.privateKey)
|
|
3731
3998
|
throw new Error(`Failed to derive classical private key at index ${t}`);
|
|
@@ -3813,7 +4080,7 @@ class ue {
|
|
|
3813
4080
|
* @param bipStandard - The BIP standard to use for classical derivation (default: BIP84)
|
|
3814
4081
|
* @returns An array of Wallet instances
|
|
3815
4082
|
*/
|
|
3816
|
-
deriveMultiple(t, e = 0, i = 0, r = !1, s =
|
|
4083
|
+
deriveMultiple(t, e = 0, i = 0, r = !1, s = Et.BIP84) {
|
|
3817
4084
|
const o = [];
|
|
3818
4085
|
for (let c = 0; c < t; c++)
|
|
3819
4086
|
o.push(this.derive(e + c, i, r, s));
|
|
@@ -3865,9 +4132,9 @@ class ue {
|
|
|
3865
4132
|
* @param bipStandard - The BIP standard to use (default: BIP84)
|
|
3866
4133
|
* @returns The derivation path string
|
|
3867
4134
|
*/
|
|
3868
|
-
buildClassicalPath(t, e, i, r =
|
|
4135
|
+
buildClassicalPath(t, e, i, r = Et.BIP84) {
|
|
3869
4136
|
const s = this.getCoinType();
|
|
3870
|
-
return
|
|
4137
|
+
return Ge(r, s, t, i ? 1 : 0, e);
|
|
3871
4138
|
}
|
|
3872
4139
|
/**
|
|
3873
4140
|
* Build a quantum derivation path (BIP360)
|
|
@@ -3886,23 +4153,23 @@ class ue {
|
|
|
3886
4153
|
* @returns The coin type (0 for mainnet, 1 for testnet/regtest)
|
|
3887
4154
|
*/
|
|
3888
4155
|
getCoinType() {
|
|
3889
|
-
return this._network.bech32 ===
|
|
4156
|
+
return this._network.bech32 === Lt.bech32 || this._network.bech32 === Qt.bech32 ? 1 : 0;
|
|
3890
4157
|
}
|
|
3891
4158
|
}
|
|
3892
|
-
var
|
|
3893
|
-
function
|
|
4159
|
+
var Qe = /* @__PURE__ */ ((n) => (n[n.MLDSA44 = 1312] = "MLDSA44", n[n.MLDSA65 = 1952] = "MLDSA65", n[n.MLDSA87 = 2592] = "MLDSA87", n))(Qe || {});
|
|
4160
|
+
function ae(n) {
|
|
3894
4161
|
switch (n) {
|
|
3895
4162
|
case 1312:
|
|
3896
|
-
return
|
|
4163
|
+
return E.MLDSASecurityLevel.LEVEL2;
|
|
3897
4164
|
case 1952:
|
|
3898
|
-
return
|
|
4165
|
+
return E.MLDSASecurityLevel.LEVEL3;
|
|
3899
4166
|
case 2592:
|
|
3900
|
-
return
|
|
4167
|
+
return E.MLDSASecurityLevel.LEVEL5;
|
|
3901
4168
|
default:
|
|
3902
4169
|
throw new Error(`Invalid MLDSA public key length: ${n}`);
|
|
3903
4170
|
}
|
|
3904
4171
|
}
|
|
3905
|
-
class
|
|
4172
|
+
class or {
|
|
3906
4173
|
constructor(t = I) {
|
|
3907
4174
|
this.network = t;
|
|
3908
4175
|
}
|
|
@@ -3920,25 +4187,25 @@ class rr {
|
|
|
3920
4187
|
return this.address;
|
|
3921
4188
|
}
|
|
3922
4189
|
}
|
|
3923
|
-
var
|
|
3924
|
-
function
|
|
4190
|
+
var Se = /* @__PURE__ */ ((n) => (n[n.Bitcoin = 0] = "Bitcoin", n[n.Fractal = 1] = "Fractal", n))(Se || {});
|
|
4191
|
+
function je(n) {
|
|
3925
4192
|
return new Map(n);
|
|
3926
4193
|
}
|
|
3927
|
-
function
|
|
4194
|
+
function ar(n) {
|
|
3928
4195
|
return {
|
|
3929
4196
|
enabled: !0,
|
|
3930
|
-
signerMap: n instanceof Map ? n :
|
|
4197
|
+
signerMap: n instanceof Map ? n : je(n)
|
|
3931
4198
|
};
|
|
3932
4199
|
}
|
|
3933
|
-
function
|
|
4200
|
+
function cr() {
|
|
3934
4201
|
return {
|
|
3935
4202
|
enabled: !1,
|
|
3936
4203
|
signerMap: /* @__PURE__ */ new Map()
|
|
3937
4204
|
};
|
|
3938
4205
|
}
|
|
3939
|
-
var w = /* @__PURE__ */ ((n) => (n[n.GENERIC = 0] = "GENERIC", n[n.FUNDING = 1] = "FUNDING", n[n.DEPLOYMENT = 2] = "DEPLOYMENT", n[n.INTERACTION = 3] = "INTERACTION", n[n.MULTI_SIG = 4] = "MULTI_SIG", n[n.CUSTOM_CODE = 5] = "CUSTOM_CODE", n[n.CANCEL = 6] = "CANCEL", n[n.CONSOLIDATED_SETUP = 7] = "CONSOLIDATED_SETUP", n[n.CONSOLIDATED_REVEAL = 8] = "CONSOLIDATED_REVEAL", n))(w || {}),
|
|
3940
|
-
const
|
|
3941
|
-
CONSENSUS:
|
|
4206
|
+
var w = /* @__PURE__ */ ((n) => (n[n.GENERIC = 0] = "GENERIC", n[n.FUNDING = 1] = "FUNDING", n[n.DEPLOYMENT = 2] = "DEPLOYMENT", n[n.INTERACTION = 3] = "INTERACTION", n[n.MULTI_SIG = 4] = "MULTI_SIG", n[n.CUSTOM_CODE = 5] = "CUSTOM_CODE", n[n.CANCEL = 6] = "CANCEL", n[n.CONSOLIDATED_SETUP = 7] = "CONSOLIDATED_SETUP", n[n.CONSOLIDATED_REVEAL = 8] = "CONSOLIDATED_REVEAL", n))(w || {}), _t = /* @__PURE__ */ ((n) => (n[n.Roswell = 0] = "Roswell", n[n.Rachel = 1] = "Rachel", n[n.Kecksburg = 2] = "Kecksburg", n[n.Phoenix = 3] = "Phoenix", n[n.Aurora = 4] = "Aurora", n[n.Rendlesham = 5] = "Rendlesham", n[n.Lazar = 6] = "Lazar", n[n.ShagHarbor = 7] = "ShagHarbor", n[n.Exeter = 8] = "Exeter", n[n.Stephenville = 9] = "Stephenville", n[n.Valensole = 10] = "Valensole", n[n.Socorro = 11] = "Socorro", n[n.Pascagoula = 12] = "Pascagoula", n[n.Tehran = 13] = "Tehran", n[n.Westall = 14] = "Westall", n[n.Hopkinsville = 15] = "Hopkinsville", n[n.Belgium = 16] = "Belgium", n[n.Breeze = 17] = "Breeze", n[n.Flatwoods = 18] = "Flatwoods", n[n.Maury = 20] = "Maury", n[n.Varginha = 21] = "Varginha", n[n.Trindade = 22] = "Trindade", n[n.Levelland = 23] = "Levelland", n[n.Wanaque = 24] = "Wanaque", n[n.Coyame = 25] = "Coyame", n[n.Delphos = 26] = "Delphos", n))(_t || {});
|
|
4207
|
+
const Ze = {
|
|
4208
|
+
CONSENSUS: _t.Roswell,
|
|
3942
4209
|
CONSENSUS_NAME: "Roswell",
|
|
3943
4210
|
// The block height at which this consensus was enabled.
|
|
3944
4211
|
ENABLED_AT_BLOCK: 0n
|
|
@@ -3954,17 +4221,17 @@ const qe = {
|
|
|
3954
4221
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES: 250n,
|
|
3955
4222
|
// Equivalent to 56500 satoshis, calculated from UNWRAP_CONSOLIDATION_PREPAID_FEES.
|
|
3956
4223
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT: 56500n,
|
|
3957
|
-
},
|
|
3958
|
-
[
|
|
3959
|
-
},
|
|
3960
|
-
function
|
|
4224
|
+
}, Je = {
|
|
4225
|
+
[_t.Roswell]: Ze
|
|
4226
|
+
}, Zt = _t.Roswell, ur = Je[Zt];
|
|
4227
|
+
function ce(n) {
|
|
3961
4228
|
let t = a.allocUnsafe(0);
|
|
3962
4229
|
function e(o) {
|
|
3963
4230
|
t = a.concat([t, a.from(o)]);
|
|
3964
4231
|
}
|
|
3965
4232
|
function i(o) {
|
|
3966
|
-
const c = t.length, u =
|
|
3967
|
-
t = a.concat([t, a.allocUnsafe(u)]),
|
|
4233
|
+
const c = t.length, u = bi(o);
|
|
4234
|
+
t = a.concat([t, a.allocUnsafe(u)]), Ii(o, t, c);
|
|
3968
4235
|
}
|
|
3969
4236
|
function r(o) {
|
|
3970
4237
|
i(o.length), e(o);
|
|
@@ -3974,23 +4241,23 @@ function ie(n) {
|
|
|
3974
4241
|
}
|
|
3975
4242
|
return s(n), t;
|
|
3976
4243
|
}
|
|
3977
|
-
function
|
|
3978
|
-
return n && !!(n.tapInternalKey || n.tapMerkleRoot || n.tapLeafScript && n.tapLeafScript.length || n.tapBip32Derivation && n.tapBip32Derivation.length || n.witnessUtxo &&
|
|
4244
|
+
function ye(n) {
|
|
4245
|
+
return n && !!(n.tapInternalKey || n.tapMerkleRoot || n.tapLeafScript && n.tapLeafScript.length || n.tapBip32Derivation && n.tapBip32Derivation.length || n.witnessUtxo && Ne(n.witnessUtxo.script));
|
|
3979
4246
|
}
|
|
3980
|
-
function
|
|
4247
|
+
function hr(n) {
|
|
3981
4248
|
return n.redeemScript ? n.redeemScript : n.witnessScript ? n.witnessScript : n.witnessUtxo ? n.witnessUtxo.script : (n.nonWitnessUtxo, null);
|
|
3982
4249
|
}
|
|
3983
|
-
function
|
|
4250
|
+
function we(n, t) {
|
|
3984
4251
|
if (n.nonWitnessUtxo && !n.redeemScript && !n.witnessScript && !n.witnessUtxo || n.redeemScript)
|
|
3985
4252
|
return !0;
|
|
3986
|
-
const e =
|
|
3987
|
-
return e ?
|
|
4253
|
+
const e = hr(n);
|
|
4254
|
+
return e ? me(t, e) : !1;
|
|
3988
4255
|
}
|
|
3989
|
-
function
|
|
3990
|
-
return
|
|
4256
|
+
function me(n, t) {
|
|
4257
|
+
return vi(n, t) !== -1;
|
|
3991
4258
|
}
|
|
3992
|
-
var
|
|
3993
|
-
class
|
|
4259
|
+
var ti = /* @__PURE__ */ ((n) => (n[n.REPLACE_BY_FEE = 4294967293] = "REPLACE_BY_FEE", n[n.FINAL = 4294967295] = "FINAL", n))(ti || {}), ei = /* @__PURE__ */ ((n) => (n[n.BLOCKS = 0] = "BLOCKS", n[n.TIMESTAMPS = 1] = "TIMESTAMPS", n))(ei || {});
|
|
4260
|
+
class Jt extends De {
|
|
3994
4261
|
constructor(t) {
|
|
3995
4262
|
super(), this.logColor = "#00ffe1", this.finalized = !1, this.signed = !1, this.scriptData = null, this.tapData = null, this.inputs = [], this.sequence = 4294967293, this.tapLeafScript = null, this.isBrowser = !1, this.csvInputIndices = /* @__PURE__ */ new Set(), this.anchorInputIndices = /* @__PURE__ */ new Set(), this.regenerated = !1, this.ignoreSignatureErrors = !1, this.noSignatures = !1, this.txVersion = 2, this._mldsaSigner = null, this._hashedPublicKey = null, this.addressRotationEnabled = !1, this.signerMap = /* @__PURE__ */ new Map(), this.inputSignerMap = /* @__PURE__ */ new Map(), this.tweakedSignerCache = /* @__PURE__ */ new Map(), this.customFinalizerP2SH = (e, i, r, s, o, c) => {
|
|
3996
4263
|
const u = this.inputs[e];
|
|
@@ -4015,11 +4282,11 @@ class Xt extends xe {
|
|
|
4015
4282
|
const d = [i.partialSig[0].signature, i.witnessScript];
|
|
4016
4283
|
return {
|
|
4017
4284
|
finalScriptSig: void 0,
|
|
4018
|
-
finalScriptWitness:
|
|
4285
|
+
finalScriptWitness: ce(d)
|
|
4019
4286
|
};
|
|
4020
4287
|
}
|
|
4021
4288
|
}
|
|
4022
|
-
return
|
|
4289
|
+
return Me(
|
|
4023
4290
|
e,
|
|
4024
4291
|
i,
|
|
4025
4292
|
r,
|
|
@@ -4060,7 +4327,7 @@ class Xt extends xe {
|
|
|
4060
4327
|
return e += c, u;
|
|
4061
4328
|
}
|
|
4062
4329
|
function r() {
|
|
4063
|
-
const c =
|
|
4330
|
+
const c = Ti(t, e);
|
|
4064
4331
|
return e += c.bytes, c.numberValue || 0;
|
|
4065
4332
|
}
|
|
4066
4333
|
function s() {
|
|
@@ -4216,7 +4483,7 @@ class Xt extends xe {
|
|
|
4216
4483
|
*/
|
|
4217
4484
|
internalPubKeyToXOnlyForInput(t) {
|
|
4218
4485
|
const e = this.getSignerForInput(t);
|
|
4219
|
-
return
|
|
4486
|
+
return O(T.from(e.publicKey));
|
|
4220
4487
|
}
|
|
4221
4488
|
/**
|
|
4222
4489
|
* Get the tweaked signer for a specific input.
|
|
@@ -4237,7 +4504,7 @@ class Xt extends xe {
|
|
|
4237
4504
|
return {
|
|
4238
4505
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4239
4506
|
network: this.network,
|
|
4240
|
-
name:
|
|
4507
|
+
name: U.P2TR
|
|
4241
4508
|
};
|
|
4242
4509
|
}
|
|
4243
4510
|
/**
|
|
@@ -4249,7 +4516,7 @@ class Xt extends xe {
|
|
|
4249
4516
|
return {
|
|
4250
4517
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4251
4518
|
network: this.network,
|
|
4252
|
-
name:
|
|
4519
|
+
name: U.P2TR
|
|
4253
4520
|
};
|
|
4254
4521
|
}
|
|
4255
4522
|
/**
|
|
@@ -4273,7 +4540,7 @@ class Xt extends xe {
|
|
|
4273
4540
|
async signInput(t, e, i, r, s = !1, o = !1) {
|
|
4274
4541
|
if (this.anchorInputIndices.has(i)) return;
|
|
4275
4542
|
const c = r.publicKey;
|
|
4276
|
-
let u =
|
|
4543
|
+
let u = ye(e);
|
|
4277
4544
|
s && (u = !u);
|
|
4278
4545
|
let h = !1, l = !1;
|
|
4279
4546
|
if (u)
|
|
@@ -4284,7 +4551,7 @@ class Xt extends xe {
|
|
|
4284
4551
|
`Failed to sign Taproot script path input ${i} (reverse: ${s}): ${d.message}`
|
|
4285
4552
|
), l = !0;
|
|
4286
4553
|
}
|
|
4287
|
-
else if (s ||
|
|
4554
|
+
else if (s || we(e, c))
|
|
4288
4555
|
try {
|
|
4289
4556
|
await this.signNonTaprootInput(r, t, i), h = !0;
|
|
4290
4557
|
} catch (d) {
|
|
@@ -4347,7 +4614,7 @@ class Xt extends xe {
|
|
|
4347
4614
|
* @returns {Buffer}
|
|
4348
4615
|
*/
|
|
4349
4616
|
internalPubKeyToXOnly() {
|
|
4350
|
-
return
|
|
4617
|
+
return O(T.from(this.signer.publicKey));
|
|
4351
4618
|
}
|
|
4352
4619
|
/**
|
|
4353
4620
|
* Internal init.
|
|
@@ -4373,49 +4640,49 @@ class Xt extends xe {
|
|
|
4373
4640
|
network: this.network
|
|
4374
4641
|
};
|
|
4375
4642
|
if (t && (i.tweakHash = this.getTweakerHash()), "privateKey" in e)
|
|
4376
|
-
return
|
|
4643
|
+
return pe.tweakSigner(e, i);
|
|
4377
4644
|
}
|
|
4378
4645
|
generateP2SHRedeemScript(t) {
|
|
4379
|
-
const e =
|
|
4646
|
+
const e = pt({
|
|
4380
4647
|
redeem: { output: t },
|
|
4381
4648
|
network: this.network
|
|
4382
4649
|
});
|
|
4383
|
-
return
|
|
4650
|
+
return mt({
|
|
4384
4651
|
redeem: e,
|
|
4385
4652
|
network: this.network
|
|
4386
4653
|
}).output;
|
|
4387
4654
|
}
|
|
4388
4655
|
generateP2SHRedeemScriptLegacy(t) {
|
|
4389
|
-
const e =
|
|
4656
|
+
const e = gt(this.signer.publicKey), i = L([
|
|
4390
4657
|
g.OP_DUP,
|
|
4391
4658
|
g.OP_HASH160,
|
|
4392
4659
|
e,
|
|
4393
4660
|
g.OP_EQUALVERIFY,
|
|
4394
4661
|
g.OP_CHECKSIG
|
|
4395
|
-
]), r =
|
|
4662
|
+
]), r = gt(i), s = L([
|
|
4396
4663
|
g.OP_HASH160,
|
|
4397
4664
|
r,
|
|
4398
4665
|
g.OP_EQUAL
|
|
4399
|
-
]), o =
|
|
4666
|
+
]), o = pt({
|
|
4400
4667
|
redeem: { output: i },
|
|
4401
4668
|
// Use the custom redeem script
|
|
4402
4669
|
network: this.network
|
|
4403
|
-
}), c =
|
|
4670
|
+
}), c = mt({
|
|
4404
4671
|
redeem: o,
|
|
4405
4672
|
// The P2WSH is wrapped inside the P2SH
|
|
4406
4673
|
network: this.network
|
|
4407
4674
|
});
|
|
4408
|
-
if (
|
|
4675
|
+
if (Ce(s, this.network) === t && c.redeem && c.redeem.output)
|
|
4409
4676
|
return {
|
|
4410
4677
|
redeemScript: i,
|
|
4411
4678
|
outputScript: c.redeem.output
|
|
4412
4679
|
};
|
|
4413
4680
|
}
|
|
4414
4681
|
generateP2SHP2PKHRedeemScript(t, e) {
|
|
4415
|
-
const i = this.addressRotationEnabled && e !== void 0 ? this.getSignerForInput(e) : this.signer, r = T.isBuffer(i.publicKey) ? i.publicKey : T.from(i.publicKey, "hex"), s =
|
|
4682
|
+
const i = this.addressRotationEnabled && e !== void 0 ? this.getSignerForInput(e) : this.signer, r = T.isBuffer(i.publicKey) ? i.publicKey : T.from(i.publicKey, "hex"), s = re({
|
|
4416
4683
|
pubkey: r,
|
|
4417
4684
|
network: this.network
|
|
4418
|
-
}), o =
|
|
4685
|
+
}), o = mt({
|
|
4419
4686
|
redeem: s,
|
|
4420
4687
|
network: this.network
|
|
4421
4688
|
}), c = o.address;
|
|
@@ -4445,14 +4712,14 @@ class Xt extends xe {
|
|
|
4445
4712
|
script: r
|
|
4446
4713
|
}
|
|
4447
4714
|
};
|
|
4448
|
-
if (
|
|
4715
|
+
if (ki(r))
|
|
4449
4716
|
if (t.nonWitnessUtxo)
|
|
4450
4717
|
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4451
4718
|
else
|
|
4452
4719
|
throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");
|
|
4453
|
-
else if (!(
|
|
4720
|
+
else if (!(ve(r) || Ui(r))) if (ke(r))
|
|
4454
4721
|
this.processP2WSHInput(t, s, e);
|
|
4455
|
-
else if (
|
|
4722
|
+
else if (Li(r)) {
|
|
4456
4723
|
let o;
|
|
4457
4724
|
if (t.redeemScript)
|
|
4458
4725
|
o = T.isBuffer(t.redeemScript) ? t.redeemScript : T.from(t.redeemScript, "hex");
|
|
@@ -4470,22 +4737,22 @@ class Xt extends xe {
|
|
|
4470
4737
|
o = h.redeemScript;
|
|
4471
4738
|
}
|
|
4472
4739
|
s.redeemScript = o;
|
|
4473
|
-
const c =
|
|
4740
|
+
const c = mt({ redeem: { output: s.redeemScript } });
|
|
4474
4741
|
if (!c.redeem)
|
|
4475
4742
|
throw new Error("Failed to extract redeem script from P2SH UTXO");
|
|
4476
4743
|
const u = c.redeem.output;
|
|
4477
4744
|
if (!u)
|
|
4478
4745
|
throw new Error("Failed to extract redeem output from P2SH UTXO");
|
|
4479
|
-
t.nonWitnessUtxo && (s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex")),
|
|
4480
|
-
} else if (
|
|
4746
|
+
t.nonWitnessUtxo && (s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex")), ve(u) ? Reflect.deleteProperty(s, "nonWitnessUtxo") : ke(u) ? (Reflect.deleteProperty(s, "nonWitnessUtxo"), this.processP2WSHInput(t, s, e)) : Reflect.deleteProperty(s, "witnessUtxo");
|
|
4747
|
+
} else if (Ne(r)) {
|
|
4481
4748
|
if (this.sighashTypes) {
|
|
4482
|
-
const o =
|
|
4749
|
+
const o = Jt.calculateSignHash(this.sighashTypes);
|
|
4483
4750
|
o && (s.sighashType = o);
|
|
4484
4751
|
}
|
|
4485
4752
|
this.addressRotationEnabled ? s.tapInternalKey = this.internalPubKeyToXOnlyForInput(e) : (this.tweakSigner(), s.tapInternalKey = this.internalPubKeyToXOnly());
|
|
4486
|
-
} else if (
|
|
4753
|
+
} else if (_i(r))
|
|
4487
4754
|
this.anchorInputIndices.add(e), s.isPayToAnchor = !0;
|
|
4488
|
-
else if (
|
|
4755
|
+
else if (Ki(r) || Di(r))
|
|
4489
4756
|
if (t.nonWitnessUtxo)
|
|
4490
4757
|
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4491
4758
|
else
|
|
@@ -4498,9 +4765,9 @@ class Xt extends xe {
|
|
|
4498
4765
|
if (!t.witnessScript)
|
|
4499
4766
|
throw new Error("Missing witnessScript for P2WSH UTXO");
|
|
4500
4767
|
e.witnessScript = T.isBuffer(t.witnessScript) ? t.witnessScript : T.from(t.witnessScript, "hex");
|
|
4501
|
-
const r =
|
|
4768
|
+
const r = F(e.witnessScript);
|
|
4502
4769
|
if (r && this.isCSVScript(r)) {
|
|
4503
|
-
const s =
|
|
4770
|
+
const s = F(e.witnessScript);
|
|
4504
4771
|
if (s && this.isCSVScript(s)) {
|
|
4505
4772
|
this.csvInputIndices.add(i);
|
|
4506
4773
|
const o = this.extractCSVBlocks(s);
|
|
@@ -4537,7 +4804,7 @@ class Xt extends xe {
|
|
|
4537
4804
|
);
|
|
4538
4805
|
return {
|
|
4539
4806
|
finalScriptSig: void 0,
|
|
4540
|
-
finalScriptWitness:
|
|
4807
|
+
finalScriptWitness: ce(i)
|
|
4541
4808
|
};
|
|
4542
4809
|
}
|
|
4543
4810
|
async signInputsWalletBased(t) {
|
|
@@ -4566,7 +4833,7 @@ class Xt extends xe {
|
|
|
4566
4833
|
if (t[e] === g.OP_CHECKSEQUENCEVERIFY && e > 0) {
|
|
4567
4834
|
const i = t[e - 1];
|
|
4568
4835
|
if (T.isBuffer(i))
|
|
4569
|
-
return
|
|
4836
|
+
return Re.decode(i);
|
|
4570
4837
|
if (typeof i == "number") {
|
|
4571
4838
|
if (i === g.OP_0 || i === g.OP_FALSE)
|
|
4572
4839
|
return 0;
|
|
@@ -4599,7 +4866,7 @@ class Xt extends xe {
|
|
|
4599
4866
|
isTaprootScriptSpend(t, e) {
|
|
4600
4867
|
if (t.tapLeafScript && t.tapLeafScript.length > 0) {
|
|
4601
4868
|
for (const i of t.tapLeafScript)
|
|
4602
|
-
if (
|
|
4869
|
+
if (me(e, i.script))
|
|
4603
4870
|
return !0;
|
|
4604
4871
|
}
|
|
4605
4872
|
return !1;
|
|
@@ -4618,22 +4885,22 @@ class Xt extends xe {
|
|
|
4618
4885
|
"signInput" in t ? await t.signInput(e, i) : e.signInput(i, t);
|
|
4619
4886
|
}
|
|
4620
4887
|
}
|
|
4621
|
-
function
|
|
4888
|
+
function ee(n, t) {
|
|
4622
4889
|
return JSON.stringify(n) === JSON.stringify(t);
|
|
4623
4890
|
}
|
|
4624
|
-
function
|
|
4625
|
-
if (
|
|
4891
|
+
function lr(n) {
|
|
4892
|
+
if (ee(n, I))
|
|
4626
4893
|
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
4627
|
-
if (
|
|
4894
|
+
if (ee(n, Lt))
|
|
4628
4895
|
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
4629
|
-
if (
|
|
4896
|
+
if (ee(n, Qt))
|
|
4630
4897
|
return "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";
|
|
4631
4898
|
throw new Error("Unsupported network for chain ID retrieval");
|
|
4632
4899
|
}
|
|
4633
|
-
function
|
|
4634
|
-
return Uint8Array.from(a.from(
|
|
4900
|
+
function _e(n) {
|
|
4901
|
+
return Uint8Array.from(a.from(lr(n), "hex"));
|
|
4635
4902
|
}
|
|
4636
|
-
const
|
|
4903
|
+
const Ke = Uint8Array.from(
|
|
4637
4904
|
a.from(
|
|
4638
4905
|
"e784995a412d773988c4b8e333d7b39dfb3cabf118d0d645411a916ca2407939",
|
|
4639
4906
|
// sha256("OP_NET")
|
|
@@ -4641,12 +4908,12 @@ const ve = Uint8Array.from(
|
|
|
4641
4908
|
)
|
|
4642
4909
|
);
|
|
4643
4910
|
ot(G);
|
|
4644
|
-
const V = 330n,
|
|
4645
|
-
class m extends
|
|
4911
|
+
const V = 330n, bt = 297n, ue = a.from("51024e73", "hex");
|
|
4912
|
+
class m extends Jt {
|
|
4646
4913
|
constructor(t) {
|
|
4647
4914
|
if (super(t), this.logColor = "#785def", this.debugFees = !1, this.overflowFees = 0n, this.transactionFee = 0n, this.estimatedFees = 0n, this.updateInputs = [], this.outputs = [], this.feeOutput = null, this._maximumFeeRate = 1e8, this.optionalOutputsAdded = !1, 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 = a.from(t.note, "utf8") : this.note = t.note), this.anchor = t.anchor ?? !1, this.isPubKeyDestination = this.to ? H.isValidPublicKey(this.to, this.network) : !1, this.optionalOutputs = t.optionalOutputs, this.from = m.getFrom(t.from, this.signer, this.network), this.totalInputAmount = this.calculateTotalUTXOAmount(), this.calculateTotalVOutAmount() < this.totalInputAmount)
|
|
4648
4915
|
throw new Error("Vout value is less than the value to send");
|
|
4649
|
-
this.transaction = new
|
|
4916
|
+
this.transaction = new R({
|
|
4650
4917
|
network: this.network,
|
|
4651
4918
|
version: this.txVersion
|
|
4652
4919
|
});
|
|
@@ -4664,7 +4931,7 @@ class m extends Xt {
|
|
|
4664
4931
|
* @returns {Buffer}
|
|
4665
4932
|
*/
|
|
4666
4933
|
static witnessStackToScriptWitness(t) {
|
|
4667
|
-
return
|
|
4934
|
+
return ce(t);
|
|
4668
4935
|
}
|
|
4669
4936
|
addOPReturn(t) {
|
|
4670
4937
|
const e = L([g.OP_RETURN, t]);
|
|
@@ -4676,7 +4943,7 @@ class m extends Xt {
|
|
|
4676
4943
|
addAnchor() {
|
|
4677
4944
|
this.addOutput({
|
|
4678
4945
|
value: 0,
|
|
4679
|
-
script:
|
|
4946
|
+
script: ue
|
|
4680
4947
|
});
|
|
4681
4948
|
}
|
|
4682
4949
|
async getFundingTransactionParameters() {
|
|
@@ -4782,7 +5049,7 @@ class m extends Xt {
|
|
|
4782
5049
|
throw new Error("Output value is 0 and no script provided");
|
|
4783
5050
|
if (i.script.length < 2)
|
|
4784
5051
|
throw new Error("Output script is too short");
|
|
4785
|
-
if (i.script[0] !== g.OP_RETURN && !i.script.equals(
|
|
5052
|
+
if (i.script[0] !== g.OP_RETURN && !i.script.equals(ue))
|
|
4786
5053
|
throw new Error(
|
|
4787
5054
|
"Output script must start with OP_RETURN or be an ANCHOR when value is 0"
|
|
4788
5055
|
);
|
|
@@ -4822,7 +5089,7 @@ class m extends Xt {
|
|
|
4822
5089
|
*/
|
|
4823
5090
|
async estimateTransactionFees() {
|
|
4824
5091
|
await Promise.resolve();
|
|
4825
|
-
const t = new
|
|
5092
|
+
const t = new R({ network: this.network }), e = this.getInputs(), i = this.getOutputs();
|
|
4826
5093
|
t.addInputs(e), t.addOutputs(i);
|
|
4827
5094
|
const r = a.alloc(64, 0), s = a.alloc(72, 0), o = a.alloc(33, 2), c = (p, f) => {
|
|
4828
5095
|
if (f.isPayToAnchor || this.anchorInputIndices.has(p))
|
|
@@ -4832,7 +5099,7 @@ class m extends Xt {
|
|
|
4832
5099
|
};
|
|
4833
5100
|
if (f.witnessScript && z.isP2WDAWitnessScript(f.witnessScript)) {
|
|
4834
5101
|
const S = [];
|
|
4835
|
-
for (let
|
|
5102
|
+
for (let K = 0; K < 10; K++)
|
|
4836
5103
|
S.push(a.alloc(0));
|
|
4837
5104
|
const b = a.alloc(72, 0);
|
|
4838
5105
|
return {
|
|
@@ -4844,7 +5111,7 @@ class m extends Xt {
|
|
|
4844
5111
|
};
|
|
4845
5112
|
}
|
|
4846
5113
|
if (p === 0 && this.tapLeafScript) {
|
|
4847
|
-
const S = a.alloc(32, 0), b = this.tapLeafScript.script,
|
|
5114
|
+
const S = a.alloc(32, 0), b = this.tapLeafScript.script, K = a.alloc(65, 0);
|
|
4848
5115
|
return {
|
|
4849
5116
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4850
5117
|
S,
|
|
@@ -4853,7 +5120,7 @@ class m extends Xt {
|
|
|
4853
5120
|
r,
|
|
4854
5121
|
// Second Schnorr signature
|
|
4855
5122
|
b,
|
|
4856
|
-
|
|
5123
|
+
K
|
|
4857
5124
|
])
|
|
4858
5125
|
};
|
|
4859
5126
|
}
|
|
@@ -4885,16 +5152,16 @@ class m extends Xt {
|
|
|
4885
5152
|
}
|
|
4886
5153
|
const S = it.script.decompile(f.witnessScript);
|
|
4887
5154
|
if (S && S.length >= 4) {
|
|
4888
|
-
const b = S[0],
|
|
4889
|
-
if (typeof b == "number" && b >= g.OP_1 &&
|
|
4890
|
-
const
|
|
4891
|
-
for (let
|
|
4892
|
-
|
|
5155
|
+
const b = S[0], K = S[S.length - 1];
|
|
5156
|
+
if (typeof b == "number" && b >= g.OP_1 && K === g.OP_CHECKMULTISIG) {
|
|
5157
|
+
const Kt = b - g.OP_1 + 1, Dt = [];
|
|
5158
|
+
for (let Ct = 0; Ct < Kt; Ct++)
|
|
5159
|
+
Dt.push(s);
|
|
4893
5160
|
return {
|
|
4894
5161
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4895
5162
|
a.alloc(0),
|
|
4896
5163
|
// OP_0 due to multisig bug
|
|
4897
|
-
...
|
|
5164
|
+
...Dt,
|
|
4898
5165
|
f.witnessScript
|
|
4899
5166
|
])
|
|
4900
5167
|
};
|
|
@@ -4937,7 +5204,7 @@ class m extends Xt {
|
|
|
4937
5204
|
s,
|
|
4938
5205
|
o
|
|
4939
5206
|
])
|
|
4940
|
-
} :
|
|
5207
|
+
} : Me(
|
|
4941
5208
|
p,
|
|
4942
5209
|
f,
|
|
4943
5210
|
y,
|
|
@@ -4960,10 +5227,10 @@ class m extends Xt {
|
|
|
4960
5227
|
), d;
|
|
4961
5228
|
}
|
|
4962
5229
|
async rebuildFromBase64(t) {
|
|
4963
|
-
return this.transaction =
|
|
5230
|
+
return this.transaction = R.fromBase64(t, {
|
|
4964
5231
|
network: this.network,
|
|
4965
5232
|
version: this.txVersion
|
|
4966
|
-
}), this.signed = !1, this.sighashTypes = [
|
|
5233
|
+
}), this.signed = !1, this.sighashTypes = [ne.SIGHASH_ANYONECANPAY, ne.SIGHASH_ALL], await this.signPSBT();
|
|
4967
5234
|
}
|
|
4968
5235
|
setPSBT(t) {
|
|
4969
5236
|
this.transaction = t;
|
|
@@ -5044,7 +5311,7 @@ class m extends Xt {
|
|
|
5044
5311
|
);
|
|
5045
5312
|
}
|
|
5046
5313
|
defineLockScript() {
|
|
5047
|
-
return L([
|
|
5314
|
+
return L([O(a.from(this.signer.publicKey)), g.OP_CHECKSIG]);
|
|
5048
5315
|
}
|
|
5049
5316
|
/**
|
|
5050
5317
|
* @description Adds the value to the output
|
|
@@ -5067,11 +5334,11 @@ class m extends Xt {
|
|
|
5067
5334
|
generateLegacySignature() {
|
|
5068
5335
|
if (this.tweakSigner(), !this.tweakedSigner)
|
|
5069
5336
|
throw new Error("Tweaked signer is not defined");
|
|
5070
|
-
const t =
|
|
5337
|
+
const t = O(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5071
5338
|
if (e.length !== 33)
|
|
5072
5339
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5073
|
-
const i =
|
|
5074
|
-
r.writeU8(
|
|
5340
|
+
const i = _e(this.network), r = new C();
|
|
5341
|
+
r.writeU8(E.MLDSASecurityLevel.LEVEL2), r.writeBytes(this.hashedPublicKey), r.writeBytes(t), r.writeBytes(e), r.writeBytes(Ke), r.writeBytes(i);
|
|
5075
5342
|
const s = r.getBuffer(), o = st.signMessage(this.tweakedSigner, s);
|
|
5076
5343
|
if (!st.verifySignature(t, s, o.signature))
|
|
5077
5344
|
throw new Error("Could not verify generated legacy signature for MLDSA link request");
|
|
@@ -5082,14 +5349,14 @@ class m extends Xt {
|
|
|
5082
5349
|
throw new Error("MLDSA signer is not defined");
|
|
5083
5350
|
if (this.tweakSigner(), !this.tweakedSigner)
|
|
5084
5351
|
throw new Error("Tweaked signer is not defined");
|
|
5085
|
-
const t =
|
|
5352
|
+
const t = O(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5086
5353
|
if (e.length !== 33)
|
|
5087
5354
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5088
|
-
const i =
|
|
5089
|
-
if (r !==
|
|
5355
|
+
const i = _e(this.network), r = ae(this.mldsaSigner.publicKey.length);
|
|
5356
|
+
if (r !== E.MLDSASecurityLevel.LEVEL2)
|
|
5090
5357
|
throw new Error("Only MLDSA level 2 is supported for link requests");
|
|
5091
|
-
const s = new
|
|
5092
|
-
s.writeU8(r), s.writeBytes(this.hashedPublicKey), s.writeBytes(this.mldsaSigner.publicKey), s.writeBytes(t), s.writeBytes(e), s.writeBytes(
|
|
5358
|
+
const s = new C();
|
|
5359
|
+
s.writeU8(r), s.writeBytes(this.hashedPublicKey), s.writeBytes(this.mldsaSigner.publicKey), s.writeBytes(t), s.writeBytes(e), s.writeBytes(Ke), s.writeBytes(i);
|
|
5093
5360
|
const o = s.getBuffer(), c = st.signMLDSAMessage(this.mldsaSigner, o);
|
|
5094
5361
|
if (!st.verifyMLDSASignature(
|
|
5095
5362
|
this.mldsaSigner,
|
|
@@ -5105,12 +5372,12 @@ class m extends Xt {
|
|
|
5105
5372
|
t.revealMLDSAPublicKey && (s = this.generateMLDSASignature());
|
|
5106
5373
|
const o = {
|
|
5107
5374
|
priority: Q.MLDSA_LINK_PUBKEY,
|
|
5108
|
-
opcode:
|
|
5375
|
+
opcode: N.MLDSA_LINK_PUBKEY,
|
|
5109
5376
|
data: {
|
|
5110
5377
|
verifyRequest: !!t.revealMLDSAPublicKey,
|
|
5111
5378
|
publicKey: i.publicKey,
|
|
5112
5379
|
hashedPublicKey: this.hashedPublicKey,
|
|
5113
|
-
level:
|
|
5380
|
+
level: ae(i.publicKey.length),
|
|
5114
5381
|
legacySignature: r,
|
|
5115
5382
|
mldsaSignature: s
|
|
5116
5383
|
}
|
|
@@ -5217,13 +5484,13 @@ class m extends Xt {
|
|
|
5217
5484
|
addFeeToOutput(t, e, i, r) {
|
|
5218
5485
|
if (r) {
|
|
5219
5486
|
let s;
|
|
5220
|
-
t > V +
|
|
5487
|
+
t > V + bt ? s = bt : s = t, this.addOutput(
|
|
5221
5488
|
{
|
|
5222
5489
|
value: Number(s),
|
|
5223
5490
|
address: e
|
|
5224
5491
|
},
|
|
5225
5492
|
!0
|
|
5226
|
-
), s ===
|
|
5493
|
+
), s === bt && t - bt > V && this.addOutput(
|
|
5227
5494
|
{
|
|
5228
5495
|
value: Number(t - s),
|
|
5229
5496
|
address: i.address
|
|
@@ -5369,7 +5636,7 @@ class m extends Xt {
|
|
|
5369
5636
|
return !1;
|
|
5370
5637
|
}
|
|
5371
5638
|
}
|
|
5372
|
-
class
|
|
5639
|
+
class qt extends m {
|
|
5373
5640
|
constructor(t) {
|
|
5374
5641
|
if (super(t), this.type = w.CUSTOM_CODE, this.tapLeafScript = null, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5375
5642
|
if (!this.tapLeafScript)
|
|
@@ -5384,7 +5651,7 @@ class Wt extends m {
|
|
|
5384
5651
|
};
|
|
5385
5652
|
}, !t.script) throw new Error("Bitcoin script is required");
|
|
5386
5653
|
if (!t.witnesses) throw new Error("Witness(es) are required");
|
|
5387
|
-
this.witnesses = t.witnesses, this.randomBytes = t.randomBytes ||
|
|
5654
|
+
this.witnesses = t.witnesses, this.randomBytes = t.randomBytes || D.rndBytes(), this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.scriptSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.scriptSeed, this.network), this.generator = new qe(this.internalPubKeyToXOnly(), this.network), this.compiledTargetScript = this.generator.compile(t.script), this.scriptTree = this.getScriptTree(), this.internalInit(), this._scriptAddress = fe.generatePKSH(this.scriptSeed, this.network);
|
|
5388
5655
|
}
|
|
5389
5656
|
/**
|
|
5390
5657
|
* @description Get the contract address (PKSH)
|
|
@@ -5413,7 +5680,7 @@ class Wt extends m {
|
|
|
5413
5680
|
* @protected
|
|
5414
5681
|
*/
|
|
5415
5682
|
contractSignerXOnlyPubKey() {
|
|
5416
|
-
return
|
|
5683
|
+
return O(a.from(this.contractSigner.publicKey));
|
|
5417
5684
|
}
|
|
5418
5685
|
/**
|
|
5419
5686
|
* Build the transaction
|
|
@@ -5468,7 +5735,7 @@ class Wt extends m {
|
|
|
5468
5735
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5469
5736
|
network: this.network,
|
|
5470
5737
|
scriptTree: this.scriptTree,
|
|
5471
|
-
name:
|
|
5738
|
+
name: U.P2TR
|
|
5472
5739
|
};
|
|
5473
5740
|
}
|
|
5474
5741
|
/**
|
|
@@ -5486,7 +5753,7 @@ class Wt extends m {
|
|
|
5486
5753
|
network: this.network,
|
|
5487
5754
|
scriptTree: this.scriptTree,
|
|
5488
5755
|
redeem: t,
|
|
5489
|
-
name:
|
|
5756
|
+
name: U.P2TR
|
|
5490
5757
|
};
|
|
5491
5758
|
}
|
|
5492
5759
|
getScriptSolution(t) {
|
|
@@ -5519,12 +5786,12 @@ class Wt extends m {
|
|
|
5519
5786
|
*/
|
|
5520
5787
|
generateRedeemScripts() {
|
|
5521
5788
|
this.targetScriptRedeem = {
|
|
5522
|
-
name:
|
|
5789
|
+
name: U.P2TR,
|
|
5523
5790
|
//pubkeys: this.getPubKeys(),
|
|
5524
5791
|
output: this.compiledTargetScript,
|
|
5525
5792
|
redeemVersion: 192
|
|
5526
5793
|
}, this.leftOverFundsScriptRedeem = {
|
|
5527
|
-
name:
|
|
5794
|
+
name: U.P2TR,
|
|
5528
5795
|
//pubkeys: this.getPubKeys(),
|
|
5529
5796
|
output: this.getLeafScript(),
|
|
5530
5797
|
redeemVersion: 192
|
|
@@ -5554,7 +5821,7 @@ class Wt extends m {
|
|
|
5554
5821
|
];
|
|
5555
5822
|
}
|
|
5556
5823
|
}
|
|
5557
|
-
class
|
|
5824
|
+
class be extends m {
|
|
5558
5825
|
constructor(t) {
|
|
5559
5826
|
if (super(t), this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5560
5827
|
if (!this.tapLeafScript)
|
|
@@ -5572,7 +5839,7 @@ class pe extends m {
|
|
|
5572
5839
|
this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.disableAutoRefund = t.disableAutoRefund || !1, this.epochChallenge = M.generateTimeLockAddress(
|
|
5573
5840
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
5574
5841
|
this.network
|
|
5575
|
-
), this.calldata =
|
|
5842
|
+
), this.calldata = W.compress(t.calldata), this.randomBytes = t.randomBytes || D.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.calldataGenerator = new de(
|
|
5576
5843
|
a.from(this.signer.publicKey),
|
|
5577
5844
|
this.scriptSignerXOnlyPubKey(),
|
|
5578
5845
|
this.network
|
|
@@ -5610,7 +5877,7 @@ class pe extends m {
|
|
|
5610
5877
|
* @returns {Buffer} The internal pubkey as an x-only key
|
|
5611
5878
|
*/
|
|
5612
5879
|
scriptSignerXOnlyPubKey() {
|
|
5613
|
-
return
|
|
5880
|
+
return O(a.from(this.scriptSigner.publicKey));
|
|
5614
5881
|
}
|
|
5615
5882
|
/**
|
|
5616
5883
|
* Generate a key pair from the seed
|
|
@@ -5661,7 +5928,7 @@ class pe extends m {
|
|
|
5661
5928
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5662
5929
|
network: this.network,
|
|
5663
5930
|
scriptTree: this.scriptTree,
|
|
5664
|
-
name:
|
|
5931
|
+
name: U.P2TR
|
|
5665
5932
|
};
|
|
5666
5933
|
}
|
|
5667
5934
|
generateTapData() {
|
|
@@ -5675,7 +5942,7 @@ class pe extends m {
|
|
|
5675
5942
|
network: this.network,
|
|
5676
5943
|
scriptTree: this.scriptTree,
|
|
5677
5944
|
redeem: t,
|
|
5678
|
-
name:
|
|
5945
|
+
name: U.P2TR
|
|
5679
5946
|
};
|
|
5680
5947
|
}
|
|
5681
5948
|
/**
|
|
@@ -5775,17 +6042,17 @@ class pe extends m {
|
|
|
5775
6042
|
*/
|
|
5776
6043
|
generateRedeemScripts() {
|
|
5777
6044
|
this.targetScriptRedeem = {
|
|
5778
|
-
name:
|
|
6045
|
+
name: U.P2TR,
|
|
5779
6046
|
output: this.compiledTargetScript,
|
|
5780
6047
|
redeemVersion: 192
|
|
5781
6048
|
}, this.leftOverFundsScriptRedeem = {
|
|
5782
|
-
name:
|
|
6049
|
+
name: U.P2TR,
|
|
5783
6050
|
output: this.LOCK_LEAF_SCRIPT,
|
|
5784
6051
|
redeemVersion: 192
|
|
5785
6052
|
};
|
|
5786
6053
|
}
|
|
5787
6054
|
}
|
|
5788
|
-
class
|
|
6055
|
+
class St extends m {
|
|
5789
6056
|
constructor(t) {
|
|
5790
6057
|
if (super(t), this.type = w.DEPLOYMENT, this.tapLeafScript = null, this.deploymentVersion = 0, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5791
6058
|
if (!this.tapLeafScript)
|
|
@@ -5802,11 +6069,11 @@ class ft extends m {
|
|
|
5802
6069
|
};
|
|
5803
6070
|
}, !this.hashedPublicKey)
|
|
5804
6071
|
throw new Error("MLDSA signer must be defined to deploy a contract.");
|
|
5805
|
-
if (this.bytecode =
|
|
5806
|
-
if (this.randomBytes = t.randomBytes ||
|
|
6072
|
+
if (this.bytecode = W.compress(a.concat([Xe, t.bytecode])), this.verifyBytecode(), t.calldata && (this.calldata = t.calldata, this.verifyCalldata()), !t.challenge) throw new Error("Challenge solution is required");
|
|
6073
|
+
if (this.randomBytes = t.randomBytes || D.rndBytes(), this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.epochChallenge = M.generateTimeLockAddress(
|
|
5807
6074
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
5808
6075
|
this.network
|
|
5809
|
-
), this.contractSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.contractSeed, this.network), this.deploymentGenerator = new
|
|
6076
|
+
), this.contractSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.contractSeed, this.network), this.deploymentGenerator = new Vt(
|
|
5810
6077
|
a.from(this.signer.publicKey),
|
|
5811
6078
|
this.contractSignerXOnlyPubKey(),
|
|
5812
6079
|
this.network
|
|
@@ -5878,7 +6145,7 @@ class ft extends m {
|
|
|
5878
6145
|
* @protected
|
|
5879
6146
|
*/
|
|
5880
6147
|
contractSignerXOnlyPubKey() {
|
|
5881
|
-
return
|
|
6148
|
+
return O(a.from(this.contractSigner.publicKey));
|
|
5882
6149
|
}
|
|
5883
6150
|
/**
|
|
5884
6151
|
* Build the transaction
|
|
@@ -5946,7 +6213,7 @@ class ft extends m {
|
|
|
5946
6213
|
*/
|
|
5947
6214
|
generateScriptAddress() {
|
|
5948
6215
|
return {
|
|
5949
|
-
name:
|
|
6216
|
+
name: U.P2TR,
|
|
5950
6217
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5951
6218
|
network: this.network,
|
|
5952
6219
|
scriptTree: this.scriptTree
|
|
@@ -5963,7 +6230,7 @@ class ft extends m {
|
|
|
5963
6230
|
if (!this.scriptTree)
|
|
5964
6231
|
throw new Error("Script tree is required");
|
|
5965
6232
|
return {
|
|
5966
|
-
name:
|
|
6233
|
+
name: U.P2TR,
|
|
5967
6234
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5968
6235
|
network: this.network,
|
|
5969
6236
|
scriptTree: this.scriptTree,
|
|
@@ -5974,7 +6241,7 @@ class ft extends m {
|
|
|
5974
6241
|
const e = [], i = t.challenge.getSubmission();
|
|
5975
6242
|
if (i && e.push({
|
|
5976
6243
|
priority: Q.MLDSA_LINK_PUBKEY,
|
|
5977
|
-
opcode:
|
|
6244
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
5978
6245
|
data: i
|
|
5979
6246
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
5980
6247
|
throw new Error(
|
|
@@ -5983,12 +6250,12 @@ class ft extends m {
|
|
|
5983
6250
|
return t.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(t, e), e;
|
|
5984
6251
|
}
|
|
5985
6252
|
verifyCalldata() {
|
|
5986
|
-
if (this.calldata && this.calldata.length >
|
|
6253
|
+
if (this.calldata && this.calldata.length > be.MAXIMUM_CALLDATA_SIZE)
|
|
5987
6254
|
throw new Error("Calldata size overflow.");
|
|
5988
6255
|
}
|
|
5989
6256
|
verifyBytecode() {
|
|
5990
6257
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
5991
|
-
if (this.bytecode.length >
|
|
6258
|
+
if (this.bytecode.length > St.MAXIMUM_CONTRACT_SIZE)
|
|
5992
6259
|
throw new Error("Contract size overflow.");
|
|
5993
6260
|
}
|
|
5994
6261
|
/**
|
|
@@ -6015,12 +6282,12 @@ class ft extends m {
|
|
|
6015
6282
|
*/
|
|
6016
6283
|
generateRedeemScripts() {
|
|
6017
6284
|
this.targetScriptRedeem = {
|
|
6018
|
-
name:
|
|
6285
|
+
name: U.P2TR,
|
|
6019
6286
|
//pubkeys: this.getPubKeys(),
|
|
6020
6287
|
output: this.compiledTargetScript,
|
|
6021
6288
|
redeemVersion: 192
|
|
6022
6289
|
}, this.leftOverFundsScriptRedeem = {
|
|
6023
|
-
name:
|
|
6290
|
+
name: U.P2TR,
|
|
6024
6291
|
//pubkeys: this.getPubKeys(),
|
|
6025
6292
|
output: this.getLeafScript(),
|
|
6026
6293
|
redeemVersion: 192
|
|
@@ -6052,7 +6319,7 @@ class ft extends m {
|
|
|
6052
6319
|
];
|
|
6053
6320
|
}
|
|
6054
6321
|
}
|
|
6055
|
-
class
|
|
6322
|
+
class $t extends m {
|
|
6056
6323
|
constructor(t) {
|
|
6057
6324
|
super(t), this.type = w.FUNDING, this.amount = t.amount, this.splitInputsInto = t.splitInputsInto ?? 1, this.internalInit();
|
|
6058
6325
|
}
|
|
@@ -6095,7 +6362,7 @@ class Mt extends m {
|
|
|
6095
6362
|
return this.signer;
|
|
6096
6363
|
}
|
|
6097
6364
|
}
|
|
6098
|
-
class
|
|
6365
|
+
class Xt extends be {
|
|
6099
6366
|
constructor(t) {
|
|
6100
6367
|
if (super(t), this.type = w.INTERACTION, this.tapLeafScript = null, !t.contract)
|
|
6101
6368
|
throw new Error("parameters.contract is required for interaction transaction.");
|
|
@@ -6122,13 +6389,13 @@ class Nt extends pe {
|
|
|
6122
6389
|
const e = [];
|
|
6123
6390
|
t.loadedStorage && e.push({
|
|
6124
6391
|
priority: Q.ACCESS_LIST,
|
|
6125
|
-
opcode:
|
|
6392
|
+
opcode: N.ACCESS_LIST,
|
|
6126
6393
|
data: t.loadedStorage
|
|
6127
6394
|
});
|
|
6128
6395
|
const i = t.challenge.getSubmission();
|
|
6129
6396
|
if (i && e.push({
|
|
6130
6397
|
priority: Q.EPOCH_SUBMISSION,
|
|
6131
|
-
opcode:
|
|
6398
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
6132
6399
|
data: i
|
|
6133
6400
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
6134
6401
|
throw new Error(
|
|
@@ -6147,7 +6414,7 @@ class j extends m {
|
|
|
6147
6414
|
throw new Error("Calldata is required");
|
|
6148
6415
|
if (!t.challenge)
|
|
6149
6416
|
throw new Error("Challenge solution is required");
|
|
6150
|
-
if (this.disableAutoRefund = t.disableAutoRefund || !1, this.contractAddress = t.to, this.contractSecret = T.from(t.contract.replace("0x", ""), "hex"), this.calldata =
|
|
6417
|
+
if (this.disableAutoRefund = t.disableAutoRefund || !1, this.contractAddress = t.to, this.contractSecret = T.from(t.contract.replace("0x", ""), "hex"), this.calldata = W.compress(t.calldata), this.challenge = t.challenge, this.randomBytes = t.randomBytes || D.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.p2wdaGenerator = new Ut(
|
|
6151
6418
|
T.from(this.signer.publicKey),
|
|
6152
6419
|
this.scriptSignerXOnlyPubKey(),
|
|
6153
6420
|
this.network
|
|
@@ -6227,13 +6494,13 @@ class j extends m {
|
|
|
6227
6494
|
const e = [];
|
|
6228
6495
|
t.loadedStorage && e.push({
|
|
6229
6496
|
priority: Q.ACCESS_LIST,
|
|
6230
|
-
opcode:
|
|
6497
|
+
opcode: N.ACCESS_LIST,
|
|
6231
6498
|
data: t.loadedStorage
|
|
6232
6499
|
});
|
|
6233
6500
|
const i = t.challenge.getSubmission();
|
|
6234
6501
|
return i && e.push({
|
|
6235
6502
|
priority: Q.EPOCH_SUBMISSION,
|
|
6236
|
-
opcode:
|
|
6503
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
6237
6504
|
data: i
|
|
6238
6505
|
}), e;
|
|
6239
6506
|
}
|
|
@@ -6247,7 +6514,7 @@ class j extends m {
|
|
|
6247
6514
|
* Get script signer x-only pubkey (same as SharedInteractionTransaction)
|
|
6248
6515
|
*/
|
|
6249
6516
|
scriptSignerXOnlyPubKey() {
|
|
6250
|
-
return
|
|
6517
|
+
return O(T.from(this.scriptSigner.publicKey));
|
|
6251
6518
|
}
|
|
6252
6519
|
/**
|
|
6253
6520
|
* Validate that input 0 is P2WDA
|
|
@@ -6269,7 +6536,7 @@ class j extends m {
|
|
|
6269
6536
|
if (!this.compiledOperationData)
|
|
6270
6537
|
throw new Error("Operation data not compiled");
|
|
6271
6538
|
const t = this.compiledOperationData.length;
|
|
6272
|
-
if (!
|
|
6539
|
+
if (!Ut.validateWitnessSize(t)) {
|
|
6273
6540
|
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(
|
|
6274
6541
|
r / j.MAX_BYTES_PER_WITNESS
|
|
6275
6542
|
);
|
|
@@ -6292,7 +6559,7 @@ class j extends m {
|
|
|
6292
6559
|
const i = e.partialSig[0].signature, r = T.concat([i, this.compiledOperationData]), s = st.signMessage(
|
|
6293
6560
|
this.signer,
|
|
6294
6561
|
r
|
|
6295
|
-
), o = T.from(s.signature), c = T.concat([o, this.compiledOperationData]), u =
|
|
6562
|
+
), o = T.from(s.signature), c = T.concat([o, this.compiledOperationData]), u = W.compress(c), h = this.splitIntoWitnessChunks(u);
|
|
6296
6563
|
if (h.length > j.MAX_WITNESS_FIELDS)
|
|
6297
6564
|
throw new Error(
|
|
6298
6565
|
`Compressed data needs ${h.length} witness fields, max is ${j.MAX_WITNESS_FIELDS}`
|
|
@@ -6321,7 +6588,7 @@ class j extends m {
|
|
|
6321
6588
|
return e;
|
|
6322
6589
|
}
|
|
6323
6590
|
}
|
|
6324
|
-
class
|
|
6591
|
+
class Ie extends m {
|
|
6325
6592
|
constructor(t) {
|
|
6326
6593
|
super({
|
|
6327
6594
|
...t,
|
|
@@ -6391,7 +6658,7 @@ class ge extends m {
|
|
|
6391
6658
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
6392
6659
|
network: this.network,
|
|
6393
6660
|
scriptTree: this.scriptTree,
|
|
6394
|
-
name:
|
|
6661
|
+
name: U.P2TR
|
|
6395
6662
|
};
|
|
6396
6663
|
}
|
|
6397
6664
|
/**
|
|
@@ -6418,7 +6685,7 @@ class ge extends m {
|
|
|
6418
6685
|
network: this.network,
|
|
6419
6686
|
scriptTree: this.scriptTree,
|
|
6420
6687
|
redeem: t,
|
|
6421
|
-
name:
|
|
6688
|
+
name: U.P2TR
|
|
6422
6689
|
};
|
|
6423
6690
|
}
|
|
6424
6691
|
async signInputs(t) {
|
|
@@ -6477,13 +6744,13 @@ class ge extends m {
|
|
|
6477
6744
|
*/
|
|
6478
6745
|
generateLeftoverFundsRedeem() {
|
|
6479
6746
|
this.leftOverFundsScriptRedeem = {
|
|
6480
|
-
name:
|
|
6747
|
+
name: U.P2TR,
|
|
6481
6748
|
output: this.LOCK_LEAF_SCRIPT,
|
|
6482
6749
|
redeemVersion: 192
|
|
6483
6750
|
};
|
|
6484
6751
|
}
|
|
6485
6752
|
}
|
|
6486
|
-
class
|
|
6753
|
+
class ii extends m {
|
|
6487
6754
|
constructor(t) {
|
|
6488
6755
|
if (super(t), this.type = w.INTERACTION, this.cachedValuePerOutput = null, !t.to)
|
|
6489
6756
|
throw new Error("Contract address (to) is required");
|
|
@@ -6493,14 +6760,14 @@ class Ge extends m {
|
|
|
6493
6760
|
throw new Error("Calldata is required");
|
|
6494
6761
|
if (!t.challenge)
|
|
6495
6762
|
throw new Error("Challenge solution is required");
|
|
6496
|
-
if (this.contractAddress = t.to, this.contractSecret = T.from(t.contract.replace("0x", ""), "hex"), this.disableAutoRefund = t.disableAutoRefund || !1, this.maxChunkSize = t.maxChunkSize ??
|
|
6763
|
+
if (this.contractAddress = t.to, this.contractSecret = T.from(t.contract.replace("0x", ""), "hex"), this.disableAutoRefund = t.disableAutoRefund || !1, this.maxChunkSize = t.maxChunkSize ?? P.MAX_CHUNK_SIZE, this.contractSecret.length !== 32)
|
|
6497
6764
|
throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
6498
|
-
if (this.calldata =
|
|
6765
|
+
if (this.calldata = W.compress(t.calldata), this.randomBytes = t.randomBytes || D.rndBytes(), this.scriptSigner = A.fromSeedKeyPair(this.randomBytes, this.network), this.challenge = t.challenge, this.epochChallenge = M.generateTimeLockAddress(
|
|
6499
6766
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
6500
6767
|
this.network
|
|
6501
|
-
), this.calldataGenerator = new
|
|
6768
|
+
), this.calldataGenerator = new de(
|
|
6502
6769
|
T.from(this.signer.publicKey),
|
|
6503
|
-
|
|
6770
|
+
O(T.from(this.scriptSigner.publicKey)),
|
|
6504
6771
|
this.network
|
|
6505
6772
|
), t.compiledTargetScript)
|
|
6506
6773
|
if (T.isBuffer(t.compiledTargetScript))
|
|
@@ -6517,7 +6784,7 @@ class Ge extends m {
|
|
|
6517
6784
|
this.priorityFee,
|
|
6518
6785
|
this.generateFeatures(t)
|
|
6519
6786
|
);
|
|
6520
|
-
this.hashCommitmentGenerator = new
|
|
6787
|
+
this.hashCommitmentGenerator = new P(
|
|
6521
6788
|
T.from(this.signer.publicKey),
|
|
6522
6789
|
this.network
|
|
6523
6790
|
), this.commitmentOutputs = this.hashCommitmentGenerator.prepareChunks(
|
|
@@ -6607,7 +6874,7 @@ class Ge extends m {
|
|
|
6607
6874
|
* @param setupTxId The transaction ID of the setup transaction
|
|
6608
6875
|
*/
|
|
6609
6876
|
buildRevealTransaction(t) {
|
|
6610
|
-
const e = new
|
|
6877
|
+
const e = new R({ network: this.network }), i = this.calculateValuePerOutput();
|
|
6611
6878
|
for (let p = 0; p < this.commitmentOutputs.length; p++) {
|
|
6612
6879
|
const f = this.commitmentOutputs[p];
|
|
6613
6880
|
e.addInput({
|
|
@@ -6716,14 +6983,14 @@ class Ge extends m {
|
|
|
6716
6983
|
calculateValuePerOutput() {
|
|
6717
6984
|
if (this.cachedValuePerOutput !== null)
|
|
6718
6985
|
return this.cachedValuePerOutput;
|
|
6719
|
-
const t = this.commitmentOutputs.length, e = this.getTransactionOPNetFee(), i = e < V ? V : e, r = this.estimateRevealVBytes(), s = BigInt(Math.ceil(r * this.feeRate)), o = i + s + m.MINIMUM_DUST, c = BigInt(Math.ceil(Number(o) / t)), u =
|
|
6986
|
+
const t = this.commitmentOutputs.length, e = this.getTransactionOPNetFee(), i = e < V ? V : e, r = this.estimateRevealVBytes(), s = BigInt(Math.ceil(r * this.feeRate)), o = i + s + m.MINIMUM_DUST, c = BigInt(Math.ceil(Number(o) / t)), u = P.MIN_OUTPUT_VALUE;
|
|
6720
6987
|
return this.cachedValuePerOutput = c > u ? c : u, this.cachedValuePerOutput;
|
|
6721
6988
|
}
|
|
6722
6989
|
/**
|
|
6723
6990
|
* Get refund address.
|
|
6724
6991
|
*/
|
|
6725
6992
|
getRefundAddress() {
|
|
6726
|
-
return this.from ? this.from :
|
|
6993
|
+
return this.from ? this.from : fe.generatePKSH(this.signer.publicKey, this.network);
|
|
6727
6994
|
}
|
|
6728
6995
|
/**
|
|
6729
6996
|
* Generate features (same as InteractionTransaction).
|
|
@@ -6732,13 +6999,13 @@ class Ge extends m {
|
|
|
6732
6999
|
const e = [];
|
|
6733
7000
|
t.loadedStorage && e.push({
|
|
6734
7001
|
priority: Q.ACCESS_LIST,
|
|
6735
|
-
opcode:
|
|
7002
|
+
opcode: N.ACCESS_LIST,
|
|
6736
7003
|
data: t.loadedStorage
|
|
6737
7004
|
});
|
|
6738
7005
|
const i = t.challenge.getSubmission();
|
|
6739
7006
|
if (i && e.push({
|
|
6740
7007
|
priority: Q.EPOCH_SUBMISSION,
|
|
6741
|
-
opcode:
|
|
7008
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
6742
7009
|
data: i
|
|
6743
7010
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
6744
7011
|
throw new Error(
|
|
@@ -6750,16 +7017,16 @@ class Ge extends m {
|
|
|
6750
7017
|
* Validate output count is within standard tx limits.
|
|
6751
7018
|
*/
|
|
6752
7019
|
validateOutputCount() {
|
|
6753
|
-
const t =
|
|
7020
|
+
const t = P.calculateMaxInputsPerTx();
|
|
6754
7021
|
if (this.commitmentOutputs.length > t) {
|
|
6755
|
-
const e =
|
|
7022
|
+
const e = P.calculateMaxDataPerTx();
|
|
6756
7023
|
throw new Error(
|
|
6757
7024
|
`Data too large: ${this.commitmentOutputs.length} P2WSH outputs needed, max ${t} per standard transaction (~${Math.floor(e / 1024)}KB). Compiled data: ${this.compiledTargetScript.length} bytes.`
|
|
6758
7025
|
);
|
|
6759
7026
|
}
|
|
6760
7027
|
}
|
|
6761
7028
|
}
|
|
6762
|
-
class
|
|
7029
|
+
class ri {
|
|
6763
7030
|
constructor() {
|
|
6764
7031
|
this.debug = !1, this.DUMMY_PUBKEY = a.alloc(32, 1), this.P2TR_SCRIPT = a.concat([a.from([81, 32]), this.DUMMY_PUBKEY]), this.INITIAL_FUNDING_ESTIMATE = 2000n, this.MAX_ITERATIONS = 10;
|
|
6765
7032
|
}
|
|
@@ -6780,7 +7047,7 @@ class Qe {
|
|
|
6780
7047
|
return e;
|
|
6781
7048
|
if (!("signer" in t))
|
|
6782
7049
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6783
|
-
const r = await new
|
|
7050
|
+
const r = await new Ie(t).signTransaction();
|
|
6784
7051
|
return {
|
|
6785
7052
|
transaction: r.toHex(),
|
|
6786
7053
|
nextUTXOs: this.getUTXOAsTransaction(r, t.from, 0),
|
|
@@ -6803,7 +7070,7 @@ class Qe {
|
|
|
6803
7070
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6804
7071
|
const e = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: i, estimatedAmount: r, challenge: s } = await this.iterateFundingAmount(
|
|
6805
7072
|
{ ...t, optionalInputs: e },
|
|
6806
|
-
|
|
7073
|
+
qt,
|
|
6807
7074
|
async (p) => {
|
|
6808
7075
|
const f = await p.estimateTransactionFees(), y = this.getPriorityFee(t), S = p.getOptionalOutputValue();
|
|
6809
7076
|
return f + y + S;
|
|
@@ -6834,7 +7101,7 @@ class Qe {
|
|
|
6834
7101
|
estimatedFees: i.estimatedFees,
|
|
6835
7102
|
compiledTargetScript: i.exportCompiledTargetScript(),
|
|
6836
7103
|
optionalInputs: e
|
|
6837
|
-
}, d = await new
|
|
7104
|
+
}, d = await new qt(h).signTransaction();
|
|
6838
7105
|
return [
|
|
6839
7106
|
u.tx.toHex(),
|
|
6840
7107
|
d.toHex(),
|
|
@@ -6863,10 +7130,10 @@ class Qe {
|
|
|
6863
7130
|
return this.signP2WDAInteraction(t);
|
|
6864
7131
|
const r = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: s, estimatedAmount: o, challenge: c } = await this.iterateFundingAmount(
|
|
6865
7132
|
{ ...t, optionalInputs: r },
|
|
6866
|
-
|
|
7133
|
+
Xt,
|
|
6867
7134
|
async (S) => {
|
|
6868
|
-
const b = await S.estimateTransactionFees(),
|
|
6869
|
-
return b +
|
|
7135
|
+
const b = await S.estimateTransactionFees(), K = S.getTotalOutputValue();
|
|
7136
|
+
return b + K;
|
|
6870
7137
|
},
|
|
6871
7138
|
"Interaction"
|
|
6872
7139
|
);
|
|
@@ -6902,7 +7169,7 @@ class Qe {
|
|
|
6902
7169
|
nonWitnessUtxo: l.tx.toBuffer(),
|
|
6903
7170
|
estimatedFees: s.estimatedFees,
|
|
6904
7171
|
optionalInputs: r
|
|
6905
|
-
}, f = new
|
|
7172
|
+
}, f = new Xt(p), y = await f.signTransaction();
|
|
6906
7173
|
return {
|
|
6907
7174
|
interactionAddress: s.getScriptAddress(),
|
|
6908
7175
|
fundingTransaction: l.tx.toHex(),
|
|
@@ -6946,7 +7213,7 @@ class Qe {
|
|
|
6946
7213
|
throw new Error('Field "signer" not provided.');
|
|
6947
7214
|
if (!t.challenge)
|
|
6948
7215
|
throw new Error('Field "challenge" not provided.');
|
|
6949
|
-
const e = this.parseOptionalInputs(t.optionalInputs), i = new
|
|
7216
|
+
const e = this.parseOptionalInputs(t.optionalInputs), i = new ii({
|
|
6950
7217
|
...t,
|
|
6951
7218
|
optionalInputs: e
|
|
6952
7219
|
}), r = await i.build();
|
|
@@ -6976,10 +7243,10 @@ class Qe {
|
|
|
6976
7243
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6977
7244
|
const i = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: o } = await this.iterateFundingAmount(
|
|
6978
7245
|
{ ...t, optionalInputs: i },
|
|
6979
|
-
|
|
6980
|
-
async (
|
|
6981
|
-
const
|
|
6982
|
-
return
|
|
7246
|
+
St,
|
|
7247
|
+
async (Kt) => {
|
|
7248
|
+
const Dt = await Kt.estimateTransactionFees(), Ct = this.getPriorityFee(t), wi = Kt.getOptionalOutputValue();
|
|
7249
|
+
return Dt + Ct + wi;
|
|
6983
7250
|
},
|
|
6984
7251
|
"Deployment"
|
|
6985
7252
|
);
|
|
@@ -6995,7 +7262,7 @@ class Qe {
|
|
|
6995
7262
|
if (!u)
|
|
6996
7263
|
throw new Error("Could not sign funding transaction.");
|
|
6997
7264
|
c.estimatedFees = u.estimatedFees;
|
|
6998
|
-
const l = await new
|
|
7265
|
+
const l = await new $t({
|
|
6999
7266
|
...c,
|
|
7000
7267
|
optionalInputs: [],
|
|
7001
7268
|
optionalOutputs: []
|
|
@@ -7019,7 +7286,7 @@ class Qe {
|
|
|
7019
7286
|
nonWitnessUtxo: l.toBuffer(),
|
|
7020
7287
|
estimatedFees: r.estimatedFees,
|
|
7021
7288
|
optionalInputs: i
|
|
7022
|
-
}, y = new
|
|
7289
|
+
}, y = new St(f), S = await y.signTransaction(), b = l.outs[1], K = {
|
|
7023
7290
|
transactionId: l.getId(),
|
|
7024
7291
|
outputIndex: 1,
|
|
7025
7292
|
scriptPubKey: {
|
|
@@ -7032,7 +7299,7 @@ class Qe {
|
|
|
7032
7299
|
transaction: [l.toHex(), S.toHex()],
|
|
7033
7300
|
contractAddress: y.getContractAddress(),
|
|
7034
7301
|
contractPubKey: y.contractPubKey,
|
|
7035
|
-
utxos: [
|
|
7302
|
+
utxos: [K],
|
|
7036
7303
|
challenge: o.toRaw(),
|
|
7037
7304
|
inputUtxos: t.utxos
|
|
7038
7305
|
};
|
|
@@ -7167,7 +7434,7 @@ class Qe {
|
|
|
7167
7434
|
*/
|
|
7168
7435
|
async createFundTransaction(t) {
|
|
7169
7436
|
if (!t.to) throw new Error('Field "to" not provided.');
|
|
7170
|
-
const e = new
|
|
7437
|
+
const e = new $t(t), i = await e.signTransaction();
|
|
7171
7438
|
if (!i)
|
|
7172
7439
|
throw new Error("Could not sign funding transaction.");
|
|
7173
7440
|
return {
|
|
@@ -7199,7 +7466,7 @@ class Qe {
|
|
|
7199
7466
|
*/
|
|
7200
7467
|
writePSBTHeader(t, e) {
|
|
7201
7468
|
const i = a.from(e, "base64"), r = a.alloc(2);
|
|
7202
|
-
return r.writeUInt8(t, 0), r.writeUInt8(
|
|
7469
|
+
return r.writeUInt8(t, 0), r.writeUInt8(Zt, 1), a.concat([r, i]).toString("hex");
|
|
7203
7470
|
}
|
|
7204
7471
|
/**
|
|
7205
7472
|
* Sign a P2WDA interaction transaction
|
|
@@ -7267,11 +7534,11 @@ class Qe {
|
|
|
7267
7534
|
* @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge: IChallengeSolution | null}>} - The final transaction and estimated amount
|
|
7268
7535
|
*/
|
|
7269
7536
|
async iterateFundingAmount(t, e, i, r) {
|
|
7270
|
-
const s = "randomBytes" in t ? t.randomBytes ??
|
|
7537
|
+
const s = "randomBytes" in t ? t.randomBytes ?? D.rndBytes() : D.rndBytes(), o = v.dead().p2tr(t.network);
|
|
7271
7538
|
let c = this.INITIAL_FUNDING_ESTIMATE, u = 0n, h = 0, l = null, d = null;
|
|
7272
7539
|
for (; h < this.MAX_ITERATIONS && c !== u; ) {
|
|
7273
7540
|
u = c;
|
|
7274
|
-
const p = new
|
|
7541
|
+
const p = new ne();
|
|
7275
7542
|
p.addOutput(this.P2TR_SCRIPT, Number(c));
|
|
7276
7543
|
const f = {
|
|
7277
7544
|
transactionId: a.alloc(32, 0).toString("hex"),
|
|
@@ -7299,9 +7566,9 @@ class Qe {
|
|
|
7299
7566
|
await S.generateTransactionMinimalSignatures(), c = await i(S);
|
|
7300
7567
|
} catch (b) {
|
|
7301
7568
|
if (b instanceof Error) {
|
|
7302
|
-
const
|
|
7303
|
-
if (
|
|
7304
|
-
c = BigInt(
|
|
7569
|
+
const K = b.message.match(/need (\d+) sats but only have (\d+) sats/);
|
|
7570
|
+
if (K)
|
|
7571
|
+
c = BigInt(K[1]), this.debug && console.log(
|
|
7305
7572
|
`${r}: Caught insufficient funds, updating to ${c}`
|
|
7306
7573
|
);
|
|
7307
7574
|
else
|
|
@@ -7353,7 +7620,7 @@ class x extends m {
|
|
|
7353
7620
|
if (super({
|
|
7354
7621
|
...t,
|
|
7355
7622
|
signer: A.fromPrivateKey(
|
|
7356
|
-
|
|
7623
|
+
Fe(a.from("aaaaaaaa", "utf-8"))
|
|
7357
7624
|
),
|
|
7358
7625
|
priorityFee: 0n,
|
|
7359
7626
|
gasSatFee: 0n
|
|
@@ -7366,7 +7633,7 @@ class x extends m {
|
|
|
7366
7633
|
};
|
|
7367
7634
|
}, !t.pubkeys)
|
|
7368
7635
|
throw new Error("Pubkeys are required");
|
|
7369
|
-
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 =
|
|
7636
|
+
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 = kt.compile(
|
|
7370
7637
|
t.pubkeys,
|
|
7371
7638
|
this.minimumSignatures
|
|
7372
7639
|
), this.scriptTree = this.getScriptTree(), this.internalInit();
|
|
@@ -7396,7 +7663,7 @@ class x extends m {
|
|
|
7396
7663
|
* @returns {MultiSignTransaction} The multisig transaction
|
|
7397
7664
|
*/
|
|
7398
7665
|
static fromBase64(t) {
|
|
7399
|
-
const e =
|
|
7666
|
+
const e = R.fromBase64(t.psbt, { network: t.network });
|
|
7400
7667
|
return new x({
|
|
7401
7668
|
...t,
|
|
7402
7669
|
psbt: e
|
|
@@ -7436,7 +7703,7 @@ class x extends m {
|
|
|
7436
7703
|
let s = !1, o = !0;
|
|
7437
7704
|
for (let c = i; c < t.data.inputs.length; c++) {
|
|
7438
7705
|
const u = t.data.inputs[c];
|
|
7439
|
-
u.tapInternalKey || (u.tapInternalKey =
|
|
7706
|
+
u.tapInternalKey || (u.tapInternalKey = O(x.numsPoint));
|
|
7440
7707
|
const h = [];
|
|
7441
7708
|
if (u.finalScriptWitness) {
|
|
7442
7709
|
const d = m.readScriptWitnessToWitnessStack(
|
|
@@ -7457,7 +7724,7 @@ class x extends m {
|
|
|
7457
7724
|
});
|
|
7458
7725
|
u.tapScriptSig = (u.tapScriptSig || []).concat(h);
|
|
7459
7726
|
}
|
|
7460
|
-
|
|
7727
|
+
Reflect.deleteProperty(u, "finalScriptWitness");
|
|
7461
7728
|
const l = x.signHashTypesArray ? [x.calculateSignHash(x.signHashTypesArray)] : [];
|
|
7462
7729
|
try {
|
|
7463
7730
|
x.signInput(t, u, c, e, l), s = !0;
|
|
@@ -7487,7 +7754,7 @@ class x extends m {
|
|
|
7487
7754
|
for (const u of r) {
|
|
7488
7755
|
let h = !1;
|
|
7489
7756
|
for (const l of e.tapScriptSig)
|
|
7490
|
-
l.pubkey.equals(
|
|
7757
|
+
l.pubkey.equals(O(u)) && (o.push(l.signature), h = !0);
|
|
7491
7758
|
h || o.push(a.alloc(0));
|
|
7492
7759
|
}
|
|
7493
7760
|
o = o.reverse();
|
|
@@ -7526,7 +7793,7 @@ class x extends m {
|
|
|
7526
7793
|
for (let o = e; o < t.data.inputs.length; o++)
|
|
7527
7794
|
try {
|
|
7528
7795
|
const c = t.data.inputs[o];
|
|
7529
|
-
c.tapInternalKey || (c.tapInternalKey =
|
|
7796
|
+
c.tapInternalKey || (c.tapInternalKey = O(x.numsPoint));
|
|
7530
7797
|
const u = [];
|
|
7531
7798
|
if (c.finalScriptWitness) {
|
|
7532
7799
|
const h = m.readScriptWitnessToWitnessStack(
|
|
@@ -7549,7 +7816,7 @@ class x extends m {
|
|
|
7549
7816
|
u
|
|
7550
7817
|
);
|
|
7551
7818
|
}
|
|
7552
|
-
|
|
7819
|
+
Reflect.deleteProperty(c, "finalScriptWitness"), t.finalizeInput(
|
|
7553
7820
|
o,
|
|
7554
7821
|
(h, l) => x.partialFinalizer(
|
|
7555
7822
|
h,
|
|
@@ -7653,11 +7920,11 @@ class x extends m {
|
|
|
7653
7920
|
}
|
|
7654
7921
|
generateScriptAddress() {
|
|
7655
7922
|
return {
|
|
7656
|
-
internalPubkey:
|
|
7923
|
+
internalPubkey: O(x.numsPoint),
|
|
7657
7924
|
//this.internalPubKeyToXOnly(),
|
|
7658
7925
|
network: this.network,
|
|
7659
7926
|
scriptTree: this.scriptTree,
|
|
7660
|
-
name:
|
|
7927
|
+
name: U.P2TR
|
|
7661
7928
|
};
|
|
7662
7929
|
}
|
|
7663
7930
|
generateTapData() {
|
|
@@ -7667,12 +7934,12 @@ class x extends m {
|
|
|
7667
7934
|
if (!this.scriptTree)
|
|
7668
7935
|
throw new Error("Script tree is required");
|
|
7669
7936
|
return {
|
|
7670
|
-
internalPubkey:
|
|
7937
|
+
internalPubkey: O(x.numsPoint),
|
|
7671
7938
|
//this.internalPubKeyToXOnly(),
|
|
7672
7939
|
network: this.network,
|
|
7673
7940
|
scriptTree: this.scriptTree,
|
|
7674
7941
|
redeem: t,
|
|
7675
|
-
name:
|
|
7942
|
+
name: U.P2TR
|
|
7676
7943
|
};
|
|
7677
7944
|
}
|
|
7678
7945
|
/**
|
|
@@ -7729,43 +7996,43 @@ class x extends m {
|
|
|
7729
7996
|
*/
|
|
7730
7997
|
generateRedeemScripts() {
|
|
7731
7998
|
this.targetScriptRedeem = {
|
|
7732
|
-
name:
|
|
7999
|
+
name: U.P2TR,
|
|
7733
8000
|
output: this.compiledTargetScript,
|
|
7734
8001
|
redeemVersion: 192
|
|
7735
8002
|
}, this.leftOverFundsScriptRedeem = {
|
|
7736
|
-
name:
|
|
8003
|
+
name: U.P2TR,
|
|
7737
8004
|
output: x.LOCK_LEAF_SCRIPT,
|
|
7738
8005
|
redeemVersion: 192
|
|
7739
8006
|
};
|
|
7740
8007
|
}
|
|
7741
8008
|
}
|
|
7742
|
-
const
|
|
7743
|
-
function
|
|
8009
|
+
const Te = 1, Nt = 66;
|
|
8010
|
+
function si(n) {
|
|
7744
8011
|
return n.type === w.FUNDING;
|
|
7745
8012
|
}
|
|
7746
|
-
function
|
|
8013
|
+
function ni(n) {
|
|
7747
8014
|
return n.type === w.DEPLOYMENT;
|
|
7748
8015
|
}
|
|
7749
|
-
function
|
|
8016
|
+
function oi(n) {
|
|
7750
8017
|
return n.type === w.INTERACTION;
|
|
7751
8018
|
}
|
|
7752
8019
|
function et(n) {
|
|
7753
8020
|
return n.type === w.MULTI_SIG;
|
|
7754
8021
|
}
|
|
7755
|
-
function
|
|
8022
|
+
function ai(n) {
|
|
7756
8023
|
return n.type === w.CUSTOM_CODE;
|
|
7757
8024
|
}
|
|
7758
|
-
function
|
|
8025
|
+
function ci(n) {
|
|
7759
8026
|
return n.type === w.CANCEL;
|
|
7760
8027
|
}
|
|
7761
|
-
class
|
|
8028
|
+
class B {
|
|
7762
8029
|
/**
|
|
7763
8030
|
* Serialize transaction state to binary format
|
|
7764
8031
|
* @param state - The transaction state to serialize
|
|
7765
8032
|
* @returns Buffer containing serialized state with checksum
|
|
7766
8033
|
*/
|
|
7767
8034
|
static serialize(t) {
|
|
7768
|
-
const e = new
|
|
8035
|
+
const e = new C();
|
|
7769
8036
|
this.writeHeader(e, t.header), this.writeBaseParams(e, t.baseParams), this.writeUTXOArray(e, t.utxos), this.writeUTXOArray(e, t.optionalInputs), this.writeOutputArray(e, t.optionalOutputs), e.writeBoolean(t.addressRotationEnabled), this.writeSignerMappings(e, t.signerMappings), this.writeTypeSpecificData(e, t.typeSpecificData), this.writePrecomputedData(e, t.precomputedData);
|
|
7770
8037
|
const i = a.from(e.getBuffer()), r = this.calculateChecksum(i);
|
|
7771
8038
|
return a.concat([i, r]);
|
|
@@ -7782,8 +8049,8 @@ class O {
|
|
|
7782
8049
|
const e = t.subarray(-32), i = t.subarray(0, -32), r = this.calculateChecksum(i);
|
|
7783
8050
|
if (!e.equals(r))
|
|
7784
8051
|
throw new Error("Invalid checksum - data may be corrupted");
|
|
7785
|
-
const s = new
|
|
7786
|
-
if (o.formatVersion >
|
|
8052
|
+
const s = new jt(i), o = this.readHeader(s);
|
|
8053
|
+
if (o.formatVersion > Te)
|
|
7787
8054
|
throw new Error(`Unsupported format version: ${o.formatVersion}`);
|
|
7788
8055
|
const c = this.readBaseParams(s), u = this.readUTXOArray(s), h = this.readUTXOArray(s), l = this.readOutputArray(s), d = s.readBoolean(), p = this.readSignerMappings(s), f = this.readTypeSpecificData(s, o.transactionType), y = this.readPrecomputedData(s);
|
|
7789
8056
|
return {
|
|
@@ -7831,13 +8098,13 @@ class O {
|
|
|
7831
8098
|
return this.deserialize(a.from(t, "hex"));
|
|
7832
8099
|
}
|
|
7833
8100
|
static writeHeader(t, e) {
|
|
7834
|
-
t.writeU8(
|
|
8101
|
+
t.writeU8(Nt), t.writeU8(e.formatVersion), t.writeU8(e.consensusVersion), t.writeU8(e.transactionType), t.writeU32(e.chainId), t.writeU64(BigInt(e.timestamp));
|
|
7835
8102
|
}
|
|
7836
8103
|
static readHeader(t) {
|
|
7837
8104
|
const e = t.readU8();
|
|
7838
|
-
if (e !==
|
|
8105
|
+
if (e !== Nt)
|
|
7839
8106
|
throw new Error(
|
|
7840
|
-
`Invalid magic byte: expected 0x${
|
|
8107
|
+
`Invalid magic byte: expected 0x${Nt.toString(16)}, got 0x${e.toString(16)}`
|
|
7841
8108
|
);
|
|
7842
8109
|
return {
|
|
7843
8110
|
formatVersion: t.readU8(),
|
|
@@ -8106,13 +8373,13 @@ class O {
|
|
|
8106
8373
|
const e = t.readU64().toString(), i = t.readStringWithLength(), r = t.readStringWithLength(), s = "0x" + a.from(t.readBytesWithLength()).toString("hex"), o = "0x" + a.from(t.readBytesWithLength()).toString("hex"), c = "0x" + a.from(t.readBytesWithLength()).toString("hex"), u = t.readU8(), h = this.readChallengeVerification(t), l = t.readBoolean();
|
|
8107
8374
|
let d;
|
|
8108
8375
|
if (l) {
|
|
8109
|
-
const p = t.readStringWithLength(), f = t.readStringWithLength(), y = "0x" + a.from(t.readBytesWithLength()).toString("hex"), b = t.readBoolean() ? "0x" + a.from(t.readBytesWithLength()).toString("hex") : void 0,
|
|
8376
|
+
const p = t.readStringWithLength(), f = t.readStringWithLength(), y = "0x" + a.from(t.readBytesWithLength()).toString("hex"), b = t.readBoolean() ? "0x" + a.from(t.readBytesWithLength()).toString("hex") : void 0, K = "0x" + a.from(t.readBytesWithLength()).toString("hex");
|
|
8110
8377
|
d = {
|
|
8111
8378
|
mldsaPublicKey: p,
|
|
8112
8379
|
legacyPublicKey: f,
|
|
8113
8380
|
solution: y,
|
|
8114
8381
|
graffiti: b,
|
|
8115
|
-
signature:
|
|
8382
|
+
signature: K
|
|
8116
8383
|
};
|
|
8117
8384
|
}
|
|
8118
8385
|
return {
|
|
@@ -8172,8 +8439,8 @@ class O {
|
|
|
8172
8439
|
* Calculate double SHA256 checksum (Bitcoin standard)
|
|
8173
8440
|
*/
|
|
8174
8441
|
static calculateChecksum(t) {
|
|
8175
|
-
const e =
|
|
8176
|
-
return
|
|
8442
|
+
const e = ie("sha256").update(t).digest();
|
|
8443
|
+
return ie("sha256").update(e).digest();
|
|
8177
8444
|
}
|
|
8178
8445
|
static networkNameToU8(t) {
|
|
8179
8446
|
switch (t) {
|
|
@@ -8283,8 +8550,8 @@ class $ {
|
|
|
8283
8550
|
*/
|
|
8284
8551
|
static createHeader(t, e, i) {
|
|
8285
8552
|
return {
|
|
8286
|
-
formatVersion:
|
|
8287
|
-
consensusVersion:
|
|
8553
|
+
formatVersion: Te,
|
|
8554
|
+
consensusVersion: Zt,
|
|
8288
8555
|
transactionType: t,
|
|
8289
8556
|
chainId: i ?? this.networkToChainId(e),
|
|
8290
8557
|
timestamp: Date.now()
|
|
@@ -8471,10 +8738,10 @@ class $ {
|
|
|
8471
8738
|
* Convert network to chain ID
|
|
8472
8739
|
*/
|
|
8473
8740
|
static networkToChainId(t) {
|
|
8474
|
-
return
|
|
8741
|
+
return Se.Bitcoin;
|
|
8475
8742
|
}
|
|
8476
8743
|
}
|
|
8477
|
-
function
|
|
8744
|
+
function _(n) {
|
|
8478
8745
|
return a.from(n.replace("0x", ""), "hex");
|
|
8479
8746
|
}
|
|
8480
8747
|
class ct {
|
|
@@ -8497,7 +8764,7 @@ class ct {
|
|
|
8497
8764
|
* Calculate SHA-1 hash
|
|
8498
8765
|
*/
|
|
8499
8766
|
static sha1(t) {
|
|
8500
|
-
return
|
|
8767
|
+
return Ci(a.isBuffer(t) ? t : a.from(t));
|
|
8501
8768
|
}
|
|
8502
8769
|
/**
|
|
8503
8770
|
* Calculate mining preimage
|
|
@@ -8566,14 +8833,14 @@ class ct {
|
|
|
8566
8833
|
const e = BigInt(t.epochNumber), i = v.fromString(
|
|
8567
8834
|
t.mldsaPublicKey,
|
|
8568
8835
|
t.legacyPublicKey
|
|
8569
|
-
), r =
|
|
8570
|
-
epochHash:
|
|
8571
|
-
epochRoot:
|
|
8572
|
-
targetHash:
|
|
8573
|
-
targetChecksum:
|
|
8836
|
+
), r = _(t.solution), s = _(t.salt), o = t.difficulty, c = {
|
|
8837
|
+
epochHash: _(t.verification.epochHash),
|
|
8838
|
+
epochRoot: _(t.verification.epochRoot),
|
|
8839
|
+
targetHash: _(t.verification.targetHash),
|
|
8840
|
+
targetChecksum: _(t.verification.targetChecksum),
|
|
8574
8841
|
startBlock: BigInt(t.verification.startBlock),
|
|
8575
8842
|
endBlock: BigInt(t.verification.endBlock),
|
|
8576
|
-
proofs: Object.freeze(t.verification.proofs.map((y) =>
|
|
8843
|
+
proofs: Object.freeze(t.verification.proofs.map((y) => _(y)))
|
|
8577
8844
|
}, u = this.calculatePreimage(
|
|
8578
8845
|
c.targetChecksum,
|
|
8579
8846
|
i.toBuffer(),
|
|
@@ -8618,17 +8885,17 @@ class ct {
|
|
|
8618
8885
|
};
|
|
8619
8886
|
}
|
|
8620
8887
|
}
|
|
8621
|
-
class
|
|
8888
|
+
class ui {
|
|
8622
8889
|
constructor(t) {
|
|
8623
|
-
this.epochHash =
|
|
8890
|
+
this.epochHash = _(t.epochHash), this.epochRoot = _(t.epochRoot), this.targetHash = _(t.targetHash), this.targetChecksum = _(t.targetChecksum), this.startBlock = BigInt(t.startBlock), this.endBlock = BigInt(t.endBlock), this.proofs = Object.freeze(t.proofs.map((e) => _(e)));
|
|
8624
8891
|
}
|
|
8625
8892
|
}
|
|
8626
|
-
class
|
|
8893
|
+
class hi {
|
|
8627
8894
|
constructor(t, e) {
|
|
8628
|
-
this.epochNumber = e, this.publicKey = v.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution =
|
|
8895
|
+
this.epochNumber = e, this.publicKey = v.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution = _(t.solution), this.graffiti = t.graffiti ? _(t.graffiti) : void 0, this.signature = _(t.signature);
|
|
8629
8896
|
}
|
|
8630
8897
|
verifySignature() {
|
|
8631
|
-
const t = new
|
|
8898
|
+
const t = new C();
|
|
8632
8899
|
t.writeAddress(this.publicKey), t.writeU64(this.epochNumber), t.writeBytes(this.solution), this.graffiti && t.writeBytes(this.graffiti);
|
|
8633
8900
|
const e = t.getBuffer();
|
|
8634
8901
|
return st.verifySignature(
|
|
@@ -8638,9 +8905,9 @@ class ri {
|
|
|
8638
8905
|
);
|
|
8639
8906
|
}
|
|
8640
8907
|
}
|
|
8641
|
-
class
|
|
8908
|
+
class he {
|
|
8642
8909
|
constructor(t) {
|
|
8643
|
-
this.epochNumber = BigInt(t.epochNumber), this.publicKey = v.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution =
|
|
8910
|
+
this.epochNumber = BigInt(t.epochNumber), this.publicKey = v.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution = _(t.solution), this.salt = _(t.salt), this.graffiti = _(t.graffiti), this.difficulty = t.difficulty, this.verification = new ui(t.verification), this.submission = t.submission ? new hi(t.submission, this.epochNumber + 2n) : t.submission;
|
|
8644
8911
|
}
|
|
8645
8912
|
/**
|
|
8646
8913
|
* Static method to validate from raw data directly
|
|
@@ -8767,17 +9034,17 @@ class ut {
|
|
|
8767
9034
|
estimatedFees: t.precomputedData.estimatedFees ? BigInt(t.precomputedData.estimatedFees) : void 0,
|
|
8768
9035
|
compiledTargetScript: t.precomputedData.compiledTargetScript ? a.from(t.precomputedData.compiledTargetScript, "hex") : void 0
|
|
8769
9036
|
}, p = t.typeSpecificData;
|
|
8770
|
-
if (
|
|
9037
|
+
if (si(p))
|
|
8771
9038
|
return this.reconstructFunding(d, p);
|
|
8772
|
-
if (
|
|
9039
|
+
if (ni(p))
|
|
8773
9040
|
return this.reconstructDeployment(d, p, t);
|
|
8774
|
-
if (
|
|
9041
|
+
if (oi(p))
|
|
8775
9042
|
return this.reconstructInteraction(d, p, t);
|
|
8776
9043
|
if (et(p))
|
|
8777
9044
|
return this.reconstructMultiSig(d, p);
|
|
8778
|
-
if (
|
|
9045
|
+
if (ai(p))
|
|
8779
9046
|
return this.reconstructCustomScript(d, p, t);
|
|
8780
|
-
if (
|
|
9047
|
+
if (ci(p))
|
|
8781
9048
|
return this.reconstructCancel(d, p);
|
|
8782
9049
|
throw new Error(`Unsupported transaction type: ${t.header.transactionType}`);
|
|
8783
9050
|
}
|
|
@@ -8790,13 +9057,13 @@ class ut {
|
|
|
8790
9057
|
amount: BigInt(e.amount),
|
|
8791
9058
|
splitInputsInto: e.splitInputsInto
|
|
8792
9059
|
};
|
|
8793
|
-
return new
|
|
9060
|
+
return new $t(i);
|
|
8794
9061
|
}
|
|
8795
9062
|
/**
|
|
8796
9063
|
* Reconstruct a DeploymentTransaction
|
|
8797
9064
|
*/
|
|
8798
9065
|
static reconstructDeployment(t, e, i) {
|
|
8799
|
-
const r = new
|
|
9066
|
+
const r = new he(e.challenge), s = {
|
|
8800
9067
|
...t,
|
|
8801
9068
|
bytecode: a.from(e.bytecode, "hex"),
|
|
8802
9069
|
calldata: e.calldata ? a.from(e.calldata, "hex") : void 0,
|
|
@@ -8805,13 +9072,13 @@ class ut {
|
|
|
8805
9072
|
revealMLDSAPublicKey: e.revealMLDSAPublicKey,
|
|
8806
9073
|
linkMLDSAPublicKeyToAddress: e.linkMLDSAPublicKeyToAddress
|
|
8807
9074
|
};
|
|
8808
|
-
return new
|
|
9075
|
+
return new St(s);
|
|
8809
9076
|
}
|
|
8810
9077
|
/**
|
|
8811
9078
|
* Reconstruct an InteractionTransaction
|
|
8812
9079
|
*/
|
|
8813
9080
|
static reconstructInteraction(t, e, i) {
|
|
8814
|
-
const r = new
|
|
9081
|
+
const r = new he(e.challenge);
|
|
8815
9082
|
if (!t.to)
|
|
8816
9083
|
throw new Error('InteractionTransaction requires a "to" address');
|
|
8817
9084
|
const s = {
|
|
@@ -8827,7 +9094,7 @@ class ut {
|
|
|
8827
9094
|
revealMLDSAPublicKey: e.revealMLDSAPublicKey,
|
|
8828
9095
|
linkMLDSAPublicKeyToAddress: e.linkMLDSAPublicKeyToAddress
|
|
8829
9096
|
};
|
|
8830
|
-
return new
|
|
9097
|
+
return new Xt(s);
|
|
8831
9098
|
}
|
|
8832
9099
|
/**
|
|
8833
9100
|
* Reconstruct a MultiSignTransaction
|
|
@@ -8881,7 +9148,7 @@ class ut {
|
|
|
8881
9148
|
annex: o,
|
|
8882
9149
|
randomBytes: i.precomputedData.randomBytes ? a.from(i.precomputedData.randomBytes, "hex") : void 0
|
|
8883
9150
|
};
|
|
8884
|
-
return new
|
|
9151
|
+
return new qt(c);
|
|
8885
9152
|
}
|
|
8886
9153
|
/**
|
|
8887
9154
|
* Reconstruct a CancelTransaction
|
|
@@ -8891,7 +9158,7 @@ class ut {
|
|
|
8891
9158
|
...t,
|
|
8892
9159
|
compiledTargetScript: a.from(e.compiledTargetScript, "hex")
|
|
8893
9160
|
};
|
|
8894
|
-
return new
|
|
9161
|
+
return new Ie(i);
|
|
8895
9162
|
}
|
|
8896
9163
|
/**
|
|
8897
9164
|
* Build address rotation config from options
|
|
@@ -8954,15 +9221,15 @@ class ut {
|
|
|
8954
9221
|
case "mainnet":
|
|
8955
9222
|
return I;
|
|
8956
9223
|
case "testnet":
|
|
8957
|
-
return
|
|
9224
|
+
return Lt;
|
|
8958
9225
|
case "regtest":
|
|
8959
|
-
return
|
|
9226
|
+
return Qt;
|
|
8960
9227
|
default:
|
|
8961
9228
|
throw new Error(`Unknown network: ${t}`);
|
|
8962
9229
|
}
|
|
8963
9230
|
}
|
|
8964
9231
|
}
|
|
8965
|
-
class
|
|
9232
|
+
class dr {
|
|
8966
9233
|
/**
|
|
8967
9234
|
* Export a FundingTransaction for offline signing
|
|
8968
9235
|
* @param params - Funding transaction parameters
|
|
@@ -8971,7 +9238,7 @@ class ur {
|
|
|
8971
9238
|
*/
|
|
8972
9239
|
static exportFunding(t, e) {
|
|
8973
9240
|
const i = $.fromFunding(t, e);
|
|
8974
|
-
return
|
|
9241
|
+
return B.toBase64(i);
|
|
8975
9242
|
}
|
|
8976
9243
|
/**
|
|
8977
9244
|
* Export a DeploymentTransaction for offline signing
|
|
@@ -8981,7 +9248,7 @@ class ur {
|
|
|
8981
9248
|
*/
|
|
8982
9249
|
static exportDeployment(t, e) {
|
|
8983
9250
|
const i = $.fromDeployment(t, e);
|
|
8984
|
-
return
|
|
9251
|
+
return B.toBase64(i);
|
|
8985
9252
|
}
|
|
8986
9253
|
/**
|
|
8987
9254
|
* Export an InteractionTransaction for offline signing
|
|
@@ -8991,7 +9258,7 @@ class ur {
|
|
|
8991
9258
|
*/
|
|
8992
9259
|
static exportInteraction(t, e) {
|
|
8993
9260
|
const i = $.fromInteraction(t, e);
|
|
8994
|
-
return
|
|
9261
|
+
return B.toBase64(i);
|
|
8995
9262
|
}
|
|
8996
9263
|
/**
|
|
8997
9264
|
* Export a MultiSignTransaction for offline signing
|
|
@@ -9001,7 +9268,7 @@ class ur {
|
|
|
9001
9268
|
*/
|
|
9002
9269
|
static exportMultiSig(t, e) {
|
|
9003
9270
|
const i = $.fromMultiSig(t, e);
|
|
9004
|
-
return
|
|
9271
|
+
return B.toBase64(i);
|
|
9005
9272
|
}
|
|
9006
9273
|
/**
|
|
9007
9274
|
* Export a CustomScriptTransaction for offline signing
|
|
@@ -9011,7 +9278,7 @@ class ur {
|
|
|
9011
9278
|
*/
|
|
9012
9279
|
static exportCustomScript(t, e) {
|
|
9013
9280
|
const i = $.fromCustomScript(t, e);
|
|
9014
|
-
return
|
|
9281
|
+
return B.toBase64(i);
|
|
9015
9282
|
}
|
|
9016
9283
|
/**
|
|
9017
9284
|
* Export a CancelTransaction for offline signing
|
|
@@ -9021,7 +9288,7 @@ class ur {
|
|
|
9021
9288
|
*/
|
|
9022
9289
|
static exportCancel(t, e) {
|
|
9023
9290
|
const i = $.fromCancel(t, e);
|
|
9024
|
-
return
|
|
9291
|
+
return B.toBase64(i);
|
|
9025
9292
|
}
|
|
9026
9293
|
/**
|
|
9027
9294
|
* Export transaction state from a builder instance.
|
|
@@ -9056,7 +9323,7 @@ class ur {
|
|
|
9056
9323
|
default:
|
|
9057
9324
|
throw new Error(`Unsupported transaction type for export: ${r}`);
|
|
9058
9325
|
}
|
|
9059
|
-
return
|
|
9326
|
+
return B.toBase64(s);
|
|
9060
9327
|
}
|
|
9061
9328
|
/**
|
|
9062
9329
|
* Import and reconstruct transaction for signing
|
|
@@ -9065,7 +9332,7 @@ class ur {
|
|
|
9065
9332
|
* @returns Reconstructed transaction builder ready for signing
|
|
9066
9333
|
*/
|
|
9067
9334
|
static importForSigning(t, e) {
|
|
9068
|
-
const i =
|
|
9335
|
+
const i = B.fromBase64(t);
|
|
9069
9336
|
return ut.reconstruct(i, e);
|
|
9070
9337
|
}
|
|
9071
9338
|
/**
|
|
@@ -9093,14 +9360,14 @@ class ur {
|
|
|
9093
9360
|
* @returns New serialized state with updated fees (not signed yet)
|
|
9094
9361
|
*/
|
|
9095
9362
|
static rebuildWithNewFees(t, e) {
|
|
9096
|
-
const i =
|
|
9363
|
+
const i = B.fromBase64(t), r = {
|
|
9097
9364
|
...i,
|
|
9098
9365
|
baseParams: {
|
|
9099
9366
|
...i.baseParams,
|
|
9100
9367
|
feeRate: e
|
|
9101
9368
|
}
|
|
9102
9369
|
};
|
|
9103
|
-
return
|
|
9370
|
+
return B.toBase64(r);
|
|
9104
9371
|
}
|
|
9105
9372
|
/**
|
|
9106
9373
|
* Rebuild and immediately sign with new fee rate
|
|
@@ -9122,7 +9389,7 @@ class ur {
|
|
|
9122
9389
|
* @returns Parsed state object for inspection
|
|
9123
9390
|
*/
|
|
9124
9391
|
static inspect(t) {
|
|
9125
|
-
return
|
|
9392
|
+
return B.fromBase64(t);
|
|
9126
9393
|
}
|
|
9127
9394
|
/**
|
|
9128
9395
|
* Validate serialized state integrity
|
|
@@ -9131,7 +9398,7 @@ class ur {
|
|
|
9131
9398
|
*/
|
|
9132
9399
|
static validate(t) {
|
|
9133
9400
|
try {
|
|
9134
|
-
return
|
|
9401
|
+
return B.fromBase64(t), !0;
|
|
9135
9402
|
} catch {
|
|
9136
9403
|
return !1;
|
|
9137
9404
|
}
|
|
@@ -9142,7 +9409,7 @@ class ur {
|
|
|
9142
9409
|
* @returns Transaction type enum value
|
|
9143
9410
|
*/
|
|
9144
9411
|
static getType(t) {
|
|
9145
|
-
return
|
|
9412
|
+
return B.fromBase64(t).header.transactionType;
|
|
9146
9413
|
}
|
|
9147
9414
|
/**
|
|
9148
9415
|
* Parse base64-encoded state into state object
|
|
@@ -9150,7 +9417,7 @@ class ur {
|
|
|
9150
9417
|
* @returns Parsed state object
|
|
9151
9418
|
*/
|
|
9152
9419
|
static fromBase64(t) {
|
|
9153
|
-
return
|
|
9420
|
+
return B.fromBase64(t);
|
|
9154
9421
|
}
|
|
9155
9422
|
/**
|
|
9156
9423
|
* Serialize state object to base64
|
|
@@ -9158,7 +9425,7 @@ class ur {
|
|
|
9158
9425
|
* @returns Base64-encoded state
|
|
9159
9426
|
*/
|
|
9160
9427
|
static toBase64(t) {
|
|
9161
|
-
return
|
|
9428
|
+
return B.toBase64(t);
|
|
9162
9429
|
}
|
|
9163
9430
|
/**
|
|
9164
9431
|
* Convert serialized state to hex format
|
|
@@ -9166,8 +9433,8 @@ class ur {
|
|
|
9166
9433
|
* @returns Hex-encoded state
|
|
9167
9434
|
*/
|
|
9168
9435
|
static toHex(t) {
|
|
9169
|
-
const e =
|
|
9170
|
-
return
|
|
9436
|
+
const e = B.fromBase64(t);
|
|
9437
|
+
return B.toHex(e);
|
|
9171
9438
|
}
|
|
9172
9439
|
/**
|
|
9173
9440
|
* Convert hex format back to base64
|
|
@@ -9175,8 +9442,8 @@ class ur {
|
|
|
9175
9442
|
* @returns Base64-encoded state
|
|
9176
9443
|
*/
|
|
9177
9444
|
static fromHex(t) {
|
|
9178
|
-
const e =
|
|
9179
|
-
return
|
|
9445
|
+
const e = B.fromHex(t);
|
|
9446
|
+
return B.toBase64(e);
|
|
9180
9447
|
}
|
|
9181
9448
|
/**
|
|
9182
9449
|
* Add a partial signature to a multisig transaction state.
|
|
@@ -9188,13 +9455,13 @@ class ur {
|
|
|
9188
9455
|
* @returns Updated state with new signature, and signing result
|
|
9189
9456
|
*/
|
|
9190
9457
|
static async multiSigAddSignature(t, e) {
|
|
9191
|
-
const i =
|
|
9458
|
+
const i = B.fromBase64(t);
|
|
9192
9459
|
if (!et(i.typeSpecificData))
|
|
9193
9460
|
throw new Error("State is not a multisig transaction");
|
|
9194
9461
|
const r = i.typeSpecificData, s = r.pubkeys.map((f) => a.from(f, "hex"));
|
|
9195
9462
|
let o;
|
|
9196
9463
|
const c = ut.nameToNetwork(i.baseParams.networkName);
|
|
9197
|
-
r.existingPsbtBase64 ? o =
|
|
9464
|
+
r.existingPsbtBase64 ? o = R.fromBase64(r.existingPsbtBase64, { network: c }) : o = await this.importForSigning(t, {
|
|
9198
9465
|
signer: e
|
|
9199
9466
|
}).signPSBT();
|
|
9200
9467
|
const u = [];
|
|
@@ -9222,7 +9489,7 @@ class ur {
|
|
|
9222
9489
|
}
|
|
9223
9490
|
};
|
|
9224
9491
|
return {
|
|
9225
|
-
state:
|
|
9492
|
+
state: B.toBase64(p),
|
|
9226
9493
|
signed: h.signed,
|
|
9227
9494
|
final: h.final,
|
|
9228
9495
|
psbtBase64: d
|
|
@@ -9236,13 +9503,13 @@ class ur {
|
|
|
9236
9503
|
* @returns True if the public key has already signed
|
|
9237
9504
|
*/
|
|
9238
9505
|
static multiSigHasSigned(t, e) {
|
|
9239
|
-
const i =
|
|
9506
|
+
const i = B.fromBase64(t);
|
|
9240
9507
|
if (!et(i.typeSpecificData))
|
|
9241
9508
|
throw new Error("State is not a multisig transaction");
|
|
9242
9509
|
const r = i.typeSpecificData;
|
|
9243
9510
|
if (!r.existingPsbtBase64)
|
|
9244
9511
|
return !1;
|
|
9245
|
-
const s = ut.nameToNetwork(i.baseParams.networkName), o =
|
|
9512
|
+
const s = ut.nameToNetwork(i.baseParams.networkName), o = R.fromBase64(r.existingPsbtBase64, { network: s }), c = a.isBuffer(e) ? e : a.from(e, "hex");
|
|
9246
9513
|
return x.verifyIfSigned(o, c);
|
|
9247
9514
|
}
|
|
9248
9515
|
/**
|
|
@@ -9252,7 +9519,7 @@ class ur {
|
|
|
9252
9519
|
* @returns Object with signature count info
|
|
9253
9520
|
*/
|
|
9254
9521
|
static multiSigGetSignatureStatus(t) {
|
|
9255
|
-
const e =
|
|
9522
|
+
const e = B.fromBase64(t);
|
|
9256
9523
|
if (!et(e.typeSpecificData))
|
|
9257
9524
|
throw new Error("State is not a multisig transaction");
|
|
9258
9525
|
const i = e.typeSpecificData, r = i.minimumSignatures;
|
|
@@ -9263,7 +9530,7 @@ class ur {
|
|
|
9263
9530
|
isComplete: !1,
|
|
9264
9531
|
signers: []
|
|
9265
9532
|
};
|
|
9266
|
-
const s = ut.nameToNetwork(e.baseParams.networkName), o =
|
|
9533
|
+
const s = ut.nameToNetwork(e.baseParams.networkName), o = R.fromBase64(i.existingPsbtBase64, { network: s }), c = /* @__PURE__ */ new Set();
|
|
9267
9534
|
for (let h = i.originalInputCount; h < o.data.inputs.length; h++) {
|
|
9268
9535
|
const l = o.data.inputs[h];
|
|
9269
9536
|
if (l.tapScriptSig)
|
|
@@ -9295,13 +9562,13 @@ class ur {
|
|
|
9295
9562
|
* @returns Signed transaction hex ready for broadcast
|
|
9296
9563
|
*/
|
|
9297
9564
|
static multiSigFinalize(t) {
|
|
9298
|
-
const e =
|
|
9565
|
+
const e = B.fromBase64(t);
|
|
9299
9566
|
if (!et(e.typeSpecificData))
|
|
9300
9567
|
throw new Error("State is not a multisig transaction");
|
|
9301
9568
|
const i = e.typeSpecificData;
|
|
9302
9569
|
if (!i.existingPsbtBase64)
|
|
9303
9570
|
throw new Error("No PSBT found in state - transaction has not been signed");
|
|
9304
|
-
const r = ut.nameToNetwork(e.baseParams.networkName), s =
|
|
9571
|
+
const r = ut.nameToNetwork(e.baseParams.networkName), s = R.fromBase64(i.existingPsbtBase64, { network: r }), o = i.pubkeys.map((h) => a.from(h, "hex")), c = [];
|
|
9305
9572
|
for (let h = i.originalInputCount; h < s.data.inputs.length; h++)
|
|
9306
9573
|
c.push(o);
|
|
9307
9574
|
if (!x.attemptFinalizeInputs(
|
|
@@ -9321,7 +9588,7 @@ class ur {
|
|
|
9321
9588
|
* @returns PSBT in base64 format, or null if not yet built
|
|
9322
9589
|
*/
|
|
9323
9590
|
static multiSigGetPsbt(t) {
|
|
9324
|
-
const e =
|
|
9591
|
+
const e = B.fromBase64(t);
|
|
9325
9592
|
if (!et(e.typeSpecificData))
|
|
9326
9593
|
throw new Error("State is not a multisig transaction");
|
|
9327
9594
|
return e.typeSpecificData.existingPsbtBase64 || null;
|
|
@@ -9334,7 +9601,7 @@ class ur {
|
|
|
9334
9601
|
* @returns Updated state
|
|
9335
9602
|
*/
|
|
9336
9603
|
static multiSigUpdatePsbt(t, e) {
|
|
9337
|
-
const i =
|
|
9604
|
+
const i = B.fromBase64(t);
|
|
9338
9605
|
if (!et(i.typeSpecificData))
|
|
9339
9606
|
throw new Error("State is not a multisig transaction");
|
|
9340
9607
|
const r = {
|
|
@@ -9344,10 +9611,10 @@ class ur {
|
|
|
9344
9611
|
existingPsbtBase64: e
|
|
9345
9612
|
}
|
|
9346
9613
|
};
|
|
9347
|
-
return
|
|
9614
|
+
return B.toBase64(r);
|
|
9348
9615
|
}
|
|
9349
9616
|
}
|
|
9350
|
-
class
|
|
9617
|
+
class fr {
|
|
9351
9618
|
constructor(t) {
|
|
9352
9619
|
this.opnetAPIUrl = t, this.utxoPath = "address/utxos", this.rpc = "json-rpc";
|
|
9353
9620
|
}
|
|
@@ -9471,7 +9738,7 @@ class hr {
|
|
|
9471
9738
|
priorityFee: 0n,
|
|
9472
9739
|
gasSatFee: 330n,
|
|
9473
9740
|
mldsaSigner: null
|
|
9474
|
-
}, l = await new
|
|
9741
|
+
}, l = await new ri().createBTCTransfer(u), d = await this.broadcastTransaction(l.tx, !1);
|
|
9475
9742
|
return d || { error: "Could not broadcast transaction" };
|
|
9476
9743
|
}
|
|
9477
9744
|
/**
|
|
@@ -9558,8 +9825,8 @@ class hr {
|
|
|
9558
9825
|
return new UnwrapGeneration(result as UnwrappedGenerationParameters);
|
|
9559
9826
|
}*/
|
|
9560
9827
|
}
|
|
9561
|
-
var
|
|
9562
|
-
class
|
|
9828
|
+
var li = /* @__PURE__ */ ((n) => (n[n.UNWRAP = 0] = "UNWRAP", n))(li || {});
|
|
9829
|
+
class pr {
|
|
9563
9830
|
/**
|
|
9564
9831
|
* Generate a multi-sig address
|
|
9565
9832
|
* @param {Buffer[]} pubKeys - The public keys to use
|
|
@@ -9586,10 +9853,10 @@ class lr {
|
|
|
9586
9853
|
return o;
|
|
9587
9854
|
}
|
|
9588
9855
|
}
|
|
9589
|
-
var
|
|
9590
|
-
class
|
|
9856
|
+
var di = /* @__PURE__ */ ((n) => (n.UINT8 = "UINT8", n.UINT16 = "UINT16", n.UINT32 = "UINT32", n.UINT64 = "UINT64", n.UINT128 = "UINT128", n.UINT256 = "UINT256", n.INT8 = "INT8", n.INT16 = "INT16", n.INT32 = "INT32", n.INT64 = "INT64", n.INT128 = "INT128", n.BOOL = "BOOL", n.ADDRESS = "ADDRESS", n.EXTENDED_ADDRESS = "EXTENDED_ADDRESS", n.STRING = "STRING", n.BYTES4 = "BYTES4", n.BYTES32 = "BYTES32", n.BYTES = "BYTES", n.ADDRESS_UINT256_TUPLE = "ADDRESS_UINT256_TUPLE", n.EXTENDED_ADDRESS_UINT256_TUPLE = "EXTENDED_ADDRESS_UINT256_TUPLE", n.SCHNORR_SIGNATURE = "SCHNORR_SIGNATURE", n.ARRAY_OF_ADDRESSES = "ARRAY_OF_ADDRESSES", n.ARRAY_OF_EXTENDED_ADDRESSES = "ARRAY_OF_EXTENDED_ADDRESSES", n.ARRAY_OF_UINT256 = "ARRAY_OF_UINT256", n.ARRAY_OF_UINT128 = "ARRAY_OF_UINT128", n.ARRAY_OF_UINT64 = "ARRAY_OF_UINT64", n.ARRAY_OF_UINT32 = "ARRAY_OF_UINT32", n.ARRAY_OF_UINT16 = "ARRAY_OF_UINT16", n.ARRAY_OF_UINT8 = "ARRAY_OF_UINT8", n.ARRAY_OF_STRING = "ARRAY_OF_STRING", n.ARRAY_OF_BYTES = "ARRAY_OF_BYTES", n.ARRAY_OF_BUFFERS = "ARRAY_OF_BUFFERS", n))(di || {});
|
|
9857
|
+
class gr {
|
|
9591
9858
|
decodeData(t, e) {
|
|
9592
|
-
const i = new
|
|
9859
|
+
const i = new jt(t), r = [];
|
|
9593
9860
|
for (let s = 0; s < e.length; s++)
|
|
9594
9861
|
switch (e[s]) {
|
|
9595
9862
|
case "UINT8":
|
|
@@ -9622,12 +9889,33 @@ class dr {
|
|
|
9622
9889
|
case "UINT256":
|
|
9623
9890
|
r.push(i.readU256());
|
|
9624
9891
|
break;
|
|
9892
|
+
case "INT8":
|
|
9893
|
+
r.push(i.readI8());
|
|
9894
|
+
break;
|
|
9895
|
+
case "INT16":
|
|
9896
|
+
r.push(i.readI16());
|
|
9897
|
+
break;
|
|
9898
|
+
case "INT32":
|
|
9899
|
+
r.push(i.readI32());
|
|
9900
|
+
break;
|
|
9901
|
+
case "INT64":
|
|
9902
|
+
r.push(i.readI64());
|
|
9903
|
+
break;
|
|
9625
9904
|
case "INT128":
|
|
9626
9905
|
r.push(i.readI128());
|
|
9627
9906
|
break;
|
|
9907
|
+
case "EXTENDED_ADDRESS":
|
|
9908
|
+
r.push(i.readExtendedAddress());
|
|
9909
|
+
break;
|
|
9628
9910
|
case "ADDRESS_UINT256_TUPLE":
|
|
9629
9911
|
r.push(i.readAddressValueTuple());
|
|
9630
9912
|
break;
|
|
9913
|
+
case "EXTENDED_ADDRESS_UINT256_TUPLE":
|
|
9914
|
+
r.push(i.readExtendedAddressMapU256());
|
|
9915
|
+
break;
|
|
9916
|
+
case "SCHNORR_SIGNATURE":
|
|
9917
|
+
r.push(i.readSchnorrSignature());
|
|
9918
|
+
break;
|
|
9631
9919
|
case "BYTES":
|
|
9632
9920
|
r.push(i.readBytesWithLength());
|
|
9633
9921
|
break;
|
|
@@ -9637,6 +9925,9 @@ class dr {
|
|
|
9637
9925
|
case "ARRAY_OF_ADDRESSES":
|
|
9638
9926
|
r.push(i.readAddressArray());
|
|
9639
9927
|
break;
|
|
9928
|
+
case "ARRAY_OF_EXTENDED_ADDRESSES":
|
|
9929
|
+
r.push(i.readExtendedAddressArray());
|
|
9930
|
+
break;
|
|
9640
9931
|
case "ARRAY_OF_UINT256":
|
|
9641
9932
|
r.push(i.readU256Array());
|
|
9642
9933
|
break;
|
|
@@ -9681,64 +9972,10 @@ class dr {
|
|
|
9681
9972
|
return i;
|
|
9682
9973
|
}
|
|
9683
9974
|
sha256(t) {
|
|
9684
|
-
return new
|
|
9975
|
+
return new Ei.sha256().update(t).digest();
|
|
9685
9976
|
}
|
|
9686
9977
|
}
|
|
9687
|
-
class
|
|
9688
|
-
constructor(t) {
|
|
9689
|
-
if (this.items = new pt(), t)
|
|
9690
|
-
for (const [e, i] of t)
|
|
9691
|
-
this.set(e, i);
|
|
9692
|
-
}
|
|
9693
|
-
get size() {
|
|
9694
|
-
return this.items.size;
|
|
9695
|
-
}
|
|
9696
|
-
set(t, e) {
|
|
9697
|
-
const i = t.tweakedToBigInt();
|
|
9698
|
-
return this.items.set(i, e), this;
|
|
9699
|
-
}
|
|
9700
|
-
get(t) {
|
|
9701
|
-
return this.items.get(t.tweakedToBigInt());
|
|
9702
|
-
}
|
|
9703
|
-
has(t) {
|
|
9704
|
-
return this.items.has(t.tweakedToBigInt());
|
|
9705
|
-
}
|
|
9706
|
-
delete(t) {
|
|
9707
|
-
const e = t.tweakedToBigInt();
|
|
9708
|
-
return this.items.delete(e);
|
|
9709
|
-
}
|
|
9710
|
-
clear() {
|
|
9711
|
-
this.items.clear();
|
|
9712
|
-
}
|
|
9713
|
-
indexOf(t) {
|
|
9714
|
-
return this.items.indexOf(t.tweakedToBigInt());
|
|
9715
|
-
}
|
|
9716
|
-
/**
|
|
9717
|
-
* WARNING, THIS RETURN NEW COPY OF THE KEYS
|
|
9718
|
-
*/
|
|
9719
|
-
*entries() {
|
|
9720
|
-
for (const [t, e] of this.items.entries())
|
|
9721
|
-
yield [v.fromBigInt(t), e];
|
|
9722
|
-
}
|
|
9723
|
-
*keys() {
|
|
9724
|
-
for (const t of this.items.keys())
|
|
9725
|
-
yield v.fromBigInt(t);
|
|
9726
|
-
}
|
|
9727
|
-
*values() {
|
|
9728
|
-
for (const t of this.items.values())
|
|
9729
|
-
yield t;
|
|
9730
|
-
}
|
|
9731
|
-
forEach(t, e) {
|
|
9732
|
-
for (const [i, r] of this.items.entries()) {
|
|
9733
|
-
const s = v.fromBigInt(0n, i);
|
|
9734
|
-
t.call(e, r, s, this);
|
|
9735
|
-
}
|
|
9736
|
-
}
|
|
9737
|
-
*[Symbol.iterator]() {
|
|
9738
|
-
yield* this.entries();
|
|
9739
|
-
}
|
|
9740
|
-
}
|
|
9741
|
-
class ye {
|
|
9978
|
+
class Ee {
|
|
9742
9979
|
constructor(t = []) {
|
|
9743
9980
|
this.items = /* @__PURE__ */ new Set(), this.keys = [];
|
|
9744
9981
|
for (const e of t)
|
|
@@ -9759,7 +9996,7 @@ class ye {
|
|
|
9759
9996
|
this.items.delete(e) && (this.keys = this.keys.filter((i) => i.toBigInt() !== e));
|
|
9760
9997
|
}
|
|
9761
9998
|
clone() {
|
|
9762
|
-
return new
|
|
9999
|
+
return new Ee(this.keys);
|
|
9763
10000
|
}
|
|
9764
10001
|
clear() {
|
|
9765
10002
|
this.items.clear(), this.keys = [];
|
|
@@ -9774,16 +10011,16 @@ class ye {
|
|
|
9774
10011
|
yield* this.keys;
|
|
9775
10012
|
}
|
|
9776
10013
|
}
|
|
9777
|
-
class
|
|
10014
|
+
class Pe {
|
|
9778
10015
|
constructor(t) {
|
|
9779
|
-
this.compareFn = t, this.map = new
|
|
10016
|
+
this.compareFn = t, this.map = new yt(), this.#t = [];
|
|
9780
10017
|
}
|
|
9781
10018
|
#t;
|
|
9782
10019
|
get size() {
|
|
9783
10020
|
return this.map.size;
|
|
9784
10021
|
}
|
|
9785
10022
|
static fromMap(t, e) {
|
|
9786
|
-
const i = new
|
|
10023
|
+
const i = new Pe(e);
|
|
9787
10024
|
for (const [r, s] of t)
|
|
9788
10025
|
i.set(r, s);
|
|
9789
10026
|
return i;
|
|
@@ -9847,7 +10084,7 @@ class we {
|
|
|
9847
10084
|
yield [t, this.map.get(t)];
|
|
9848
10085
|
}
|
|
9849
10086
|
}
|
|
9850
|
-
class
|
|
10087
|
+
class Ae {
|
|
9851
10088
|
constructor(t) {
|
|
9852
10089
|
this.compareFn = t, this.elements = [];
|
|
9853
10090
|
}
|
|
@@ -9855,7 +10092,7 @@ class me {
|
|
|
9855
10092
|
return this.elements.length;
|
|
9856
10093
|
}
|
|
9857
10094
|
static fromSet(t, e) {
|
|
9858
|
-
const i = new
|
|
10095
|
+
const i = new Ae(e);
|
|
9859
10096
|
for (const r of t)
|
|
9860
10097
|
i.add(r);
|
|
9861
10098
|
return i;
|
|
@@ -9895,17 +10132,17 @@ class me {
|
|
|
9895
10132
|
return { found: !1, index: e };
|
|
9896
10133
|
}
|
|
9897
10134
|
}
|
|
9898
|
-
class
|
|
10135
|
+
class Sr {
|
|
9899
10136
|
constructor(t, e) {
|
|
9900
10137
|
this.type = t, this.data = e;
|
|
9901
10138
|
}
|
|
9902
10139
|
}
|
|
9903
|
-
class
|
|
10140
|
+
class Oe {
|
|
9904
10141
|
constructor() {
|
|
9905
10142
|
}
|
|
9906
10143
|
}
|
|
9907
|
-
var
|
|
9908
|
-
class
|
|
10144
|
+
var Pt = /* @__PURE__ */ ((n) => (n.Mainnet = "mainnet", n.Testnet = "testnet", n.Regtest = "regtest", n))(Pt || {}), fi = /* @__PURE__ */ ((n) => (n.BITCOIN_MAINNET = "BITCOIN_MAINNET", n.BITCOIN_TESTNET = "BITCOIN_TESTNET", n.BITCOIN_TESTNET4 = "BITCOIN_TESTNET4", n.BITCOIN_REGTEST = "BITCOIN_REGTEST", n.BITCOIN_SIGNET = "BITCOIN_SIGNET", n.FRACTAL_BITCOIN_MAINNET = "FRACTAL_BITCOIN_MAINNET", n.FRACTAL_BITCOIN_TESTNET = "FRACTAL_BITCOIN_TESTNET", n))(fi || {});
|
|
10145
|
+
class yr extends Oe {
|
|
9909
10146
|
constructor() {
|
|
9910
10147
|
if (super(), this.isInitialized = !1, !window)
|
|
9911
10148
|
throw new Error("UnisatSigner can only be used in a browser environment");
|
|
@@ -9951,14 +10188,14 @@ class gr extends be {
|
|
|
9951
10188
|
return;
|
|
9952
10189
|
const t = await this.unisat.getNetwork();
|
|
9953
10190
|
switch (t) {
|
|
9954
|
-
case
|
|
10191
|
+
case Pt.Mainnet:
|
|
9955
10192
|
this._network = I;
|
|
9956
10193
|
break;
|
|
9957
|
-
case
|
|
9958
|
-
this._network =
|
|
10194
|
+
case Pt.Testnet:
|
|
10195
|
+
this._network = Lt;
|
|
9959
10196
|
break;
|
|
9960
|
-
case
|
|
9961
|
-
this._network =
|
|
10197
|
+
case Pt.Regtest:
|
|
10198
|
+
this._network = Qt;
|
|
9962
10199
|
break;
|
|
9963
10200
|
default:
|
|
9964
10201
|
throw new Error(`Invalid network: ${t}`);
|
|
@@ -10003,19 +10240,19 @@ class gr extends be {
|
|
|
10003
10240
|
e.push(c);
|
|
10004
10241
|
const u = o.data.inputs.map((h, l) => {
|
|
10005
10242
|
let d = !1, p = !1;
|
|
10006
|
-
if (
|
|
10243
|
+
if (ye(h)) {
|
|
10007
10244
|
if (h.tapLeafScript && h.tapLeafScript.length > 0) {
|
|
10008
10245
|
for (const f of h.tapLeafScript)
|
|
10009
|
-
if (
|
|
10246
|
+
if (wr(this.publicKey, f.script)) {
|
|
10010
10247
|
d = !0, p = !1;
|
|
10011
10248
|
break;
|
|
10012
10249
|
}
|
|
10013
10250
|
}
|
|
10014
10251
|
if (!d && h.tapInternalKey) {
|
|
10015
|
-
const f = h.tapInternalKey, y =
|
|
10252
|
+
const f = h.tapInternalKey, y = O(this.publicKey);
|
|
10016
10253
|
f.equals(y) && (d = !0, p = !0);
|
|
10017
10254
|
}
|
|
10018
|
-
} else
|
|
10255
|
+
} else we(h, this.publicKey) && (d = !0, p = !1);
|
|
10019
10256
|
return d ? {
|
|
10020
10257
|
index: l,
|
|
10021
10258
|
publicKey: this.publicKey.toString("hex"),
|
|
@@ -10027,7 +10264,7 @@ class gr extends be {
|
|
|
10027
10264
|
toSignInputs: u
|
|
10028
10265
|
});
|
|
10029
10266
|
}
|
|
10030
|
-
const r = await this.unisat.signPsbt(e[0], i[0]), s =
|
|
10267
|
+
const r = await this.unisat.signPsbt(e[0], i[0]), s = R.fromHex(r);
|
|
10031
10268
|
t[0].combine(s);
|
|
10032
10269
|
}
|
|
10033
10270
|
hasAlreadySignedTapScriptSig(t) {
|
|
@@ -10072,7 +10309,7 @@ class gr extends be {
|
|
|
10072
10309
|
}
|
|
10073
10310
|
]).flat()
|
|
10074
10311
|
}, c = t.toHex(), u = await this.unisat.signPsbt(c, o);
|
|
10075
|
-
return
|
|
10312
|
+
return R.fromHex(u);
|
|
10076
10313
|
}
|
|
10077
10314
|
getNonDuplicateScriptSig(t, e) {
|
|
10078
10315
|
const i = [];
|
|
@@ -10081,15 +10318,15 @@ class gr extends be {
|
|
|
10081
10318
|
return i;
|
|
10082
10319
|
}
|
|
10083
10320
|
}
|
|
10084
|
-
function
|
|
10085
|
-
return
|
|
10321
|
+
function wr(n, t) {
|
|
10322
|
+
return mr(n, t) !== -1;
|
|
10086
10323
|
}
|
|
10087
|
-
function
|
|
10088
|
-
const e =
|
|
10324
|
+
function mr(n, t) {
|
|
10325
|
+
const e = gt(n), i = O(n), r = F(t);
|
|
10089
10326
|
if (r === null) throw new Error("Unknown script error");
|
|
10090
10327
|
return r.findIndex((s) => typeof s == "number" ? !1 : a.isBuffer(s) && (s.equals(n) || s.equals(e) || s.equals(i)));
|
|
10091
10328
|
}
|
|
10092
|
-
class
|
|
10329
|
+
class br extends Oe {
|
|
10093
10330
|
constructor() {
|
|
10094
10331
|
if (super(), this.isInitialized = !1, !window)
|
|
10095
10332
|
throw new Error("XverseSigner can only be used in a browser environment");
|
|
@@ -10134,7 +10371,7 @@ class wr extends be {
|
|
|
10134
10371
|
);
|
|
10135
10372
|
if (!e)
|
|
10136
10373
|
throw new Error("Payment address not found");
|
|
10137
|
-
const i = e.address.startsWith("tb") ?
|
|
10374
|
+
const i = e.address.startsWith("tb") ? Lt : e.address.startsWith("bc") ? I : null;
|
|
10138
10375
|
if (!i) throw new Error("Network not supported");
|
|
10139
10376
|
this._network = i, this._publicKey = a.from(e.publicKey, "hex"), this._p2wpkh = A.getP2WPKHAddress(this, this.network), this._p2tr = A.getTaprootAddress(this, this.network), this._addresses = [this._p2wpkh, this._p2tr], this.isInitialized = !0;
|
|
10140
10377
|
}
|
|
@@ -10187,19 +10424,19 @@ class wr extends be {
|
|
|
10187
10424
|
e.push(u);
|
|
10188
10425
|
const h = c.data.inputs.map((l, d) => {
|
|
10189
10426
|
let p = !1, f = !1;
|
|
10190
|
-
if (
|
|
10427
|
+
if (ye(l)) {
|
|
10191
10428
|
if (l.tapLeafScript && l.tapLeafScript.length > 0) {
|
|
10192
10429
|
for (const y of l.tapLeafScript)
|
|
10193
|
-
if (
|
|
10430
|
+
if (me(this.publicKey, y.script)) {
|
|
10194
10431
|
p = !0, f = !1;
|
|
10195
10432
|
break;
|
|
10196
10433
|
}
|
|
10197
10434
|
}
|
|
10198
10435
|
if (!p && l.tapInternalKey) {
|
|
10199
|
-
const y = l.tapInternalKey, S =
|
|
10436
|
+
const y = l.tapInternalKey, S = O(this.publicKey);
|
|
10200
10437
|
y.equals(S) && (p = !0, f = !0);
|
|
10201
10438
|
}
|
|
10202
|
-
} else
|
|
10439
|
+
} else we(l, this.publicKey) && (p = !0, f = !1);
|
|
10203
10440
|
return p ? {
|
|
10204
10441
|
index: d,
|
|
10205
10442
|
publicKey: this.publicKey.toString("hex"),
|
|
@@ -10218,7 +10455,7 @@ class wr extends be {
|
|
|
10218
10455
|
signInputs: r
|
|
10219
10456
|
});
|
|
10220
10457
|
if ("error" in s) throw new Error(s.error.message);
|
|
10221
|
-
const o =
|
|
10458
|
+
const o = R.fromBase64(s.result.psbt);
|
|
10222
10459
|
t[0].combine(o);
|
|
10223
10460
|
}
|
|
10224
10461
|
hasAlreadySignedTapScriptSig(t) {
|
|
@@ -10268,7 +10505,7 @@ class wr extends be {
|
|
|
10268
10505
|
signInputs: u
|
|
10269
10506
|
});
|
|
10270
10507
|
if ("error" in h) throw new Error(h.error.message);
|
|
10271
|
-
return
|
|
10508
|
+
return R.fromBase64(h.result.psbt);
|
|
10272
10509
|
}
|
|
10273
10510
|
getNonDuplicateScriptSig(t, e) {
|
|
10274
10511
|
const i = [];
|
|
@@ -10277,10 +10514,10 @@ class wr extends be {
|
|
|
10277
10514
|
return i;
|
|
10278
10515
|
}
|
|
10279
10516
|
}
|
|
10280
|
-
var
|
|
10281
|
-
class
|
|
10517
|
+
var pi = /* @__PURE__ */ ((n) => (n.ecdsa = "ecdsa", n.bip322 = "bip322-simple", n))(pi || {}), gi = /* @__PURE__ */ ((n) => (n.ecdsa = "ecdsa", n.schnorr = "schnorr", n))(gi || {}), Si = /* @__PURE__ */ ((n) => (n.mainnet = "mainnet", n.testnet = "testnet", n.signet = "Signet", n))(Si || {}), yi = /* @__PURE__ */ ((n) => (n.ECDSA = "ECDSA", n.BIP322 = "BIP322", n))(yi || {});
|
|
10518
|
+
class Yt {
|
|
10282
10519
|
constructor() {
|
|
10283
|
-
this._size = 0, this.capacity =
|
|
10520
|
+
this._size = 0, this.capacity = Yt.INITIAL_CAPACITY, this.#t = new Array(this.capacity), this.#e = new Array(this.capacity), this.deleted = new Array(this.capacity).fill(!1);
|
|
10284
10521
|
}
|
|
10285
10522
|
static {
|
|
10286
10523
|
this.INITIAL_CAPACITY = 16;
|
|
@@ -10296,7 +10533,7 @@ class Ht {
|
|
|
10296
10533
|
set(t, e) {
|
|
10297
10534
|
let i = !0;
|
|
10298
10535
|
const r = this.findInsertIndex(t);
|
|
10299
|
-
return (this.#t[r] === void 0 || this.deleted[r]) && (this._size++, i = !1), this.#t[r] = t, this.#e[r] = e, this.deleted[r] = !1, this._size > this.capacity *
|
|
10536
|
+
return (this.#t[r] === void 0 || this.deleted[r]) && (this._size++, i = !1), this.#t[r] = t, this.#e[r] = e, this.deleted[r] = !1, this._size > this.capacity * Yt.LOAD_FACTOR && this.resize(), i;
|
|
10300
10537
|
}
|
|
10301
10538
|
get(t) {
|
|
10302
10539
|
const e = this.findIndex(t);
|
|
@@ -10438,263 +10675,267 @@ class Ht {
|
|
|
10438
10675
|
t[i] !== void 0 && !this.deleted[i] && this.set(t[i], e[i]);
|
|
10439
10676
|
}
|
|
10440
10677
|
}
|
|
10441
|
-
const
|
|
10678
|
+
const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10442
10679
|
__proto__: null,
|
|
10443
|
-
ABICoder:
|
|
10444
|
-
ABIDataTypes:
|
|
10445
|
-
ADDRESS_BYTE_LENGTH:
|
|
10446
|
-
ANCHOR_SCRIPT:
|
|
10680
|
+
ABICoder: gr,
|
|
10681
|
+
ABIDataTypes: di,
|
|
10682
|
+
ADDRESS_BYTE_LENGTH: k,
|
|
10683
|
+
ANCHOR_SCRIPT: ue,
|
|
10447
10684
|
Address: v,
|
|
10448
|
-
AddressGenerator:
|
|
10449
|
-
AddressMap:
|
|
10450
|
-
AddressSet:
|
|
10685
|
+
AddressGenerator: fe,
|
|
10686
|
+
AddressMap: Ve,
|
|
10687
|
+
AddressSet: Ee,
|
|
10451
10688
|
AddressTypes: J,
|
|
10452
10689
|
AddressVerificator: H,
|
|
10453
|
-
BIPStandard:
|
|
10454
|
-
BOOLEAN_BYTE_LENGTH:
|
|
10455
|
-
BinaryReader:
|
|
10456
|
-
BinaryWriter:
|
|
10457
|
-
BitcoinUtils:
|
|
10690
|
+
BIPStandard: Et,
|
|
10691
|
+
BOOLEAN_BYTE_LENGTH: Ji,
|
|
10692
|
+
BinaryReader: jt,
|
|
10693
|
+
BinaryWriter: C,
|
|
10694
|
+
BitcoinUtils: D,
|
|
10458
10695
|
BufferHelper: X,
|
|
10459
|
-
CSVModes:
|
|
10460
|
-
CalldataGenerator:
|
|
10461
|
-
CancelTransaction:
|
|
10462
|
-
ChainId:
|
|
10463
|
-
ChallengeSolution:
|
|
10464
|
-
ChallengeSubmission:
|
|
10465
|
-
ChallengeVerification:
|
|
10466
|
-
Compressor:
|
|
10467
|
-
Consensus:
|
|
10468
|
-
ConsolidatedInteractionTransaction:
|
|
10469
|
-
ContractAddress:
|
|
10470
|
-
ContractBaseMetadata:
|
|
10471
|
-
CustomGenerator:
|
|
10472
|
-
CustomKeypair:
|
|
10473
|
-
CustomMap:
|
|
10474
|
-
CustomScriptTransaction:
|
|
10475
|
-
DeploymentGenerator:
|
|
10476
|
-
DeploymentTransaction:
|
|
10477
|
-
DeterministicMap:
|
|
10478
|
-
DeterministicSet:
|
|
10696
|
+
CSVModes: ei,
|
|
10697
|
+
CalldataGenerator: de,
|
|
10698
|
+
CancelTransaction: Ie,
|
|
10699
|
+
ChainId: Se,
|
|
10700
|
+
ChallengeSolution: he,
|
|
10701
|
+
ChallengeSubmission: hi,
|
|
10702
|
+
ChallengeVerification: ui,
|
|
10703
|
+
Compressor: W,
|
|
10704
|
+
Consensus: _t,
|
|
10705
|
+
ConsolidatedInteractionTransaction: ii,
|
|
10706
|
+
ContractAddress: oe,
|
|
10707
|
+
ContractBaseMetadata: or,
|
|
10708
|
+
CustomGenerator: qe,
|
|
10709
|
+
CustomKeypair: Oe,
|
|
10710
|
+
CustomMap: Yt,
|
|
10711
|
+
CustomScriptTransaction: qt,
|
|
10712
|
+
DeploymentGenerator: Vt,
|
|
10713
|
+
DeploymentTransaction: St,
|
|
10714
|
+
DeterministicMap: Pe,
|
|
10715
|
+
DeterministicSet: Ae,
|
|
10716
|
+
EXTENDED_ADDRESS_BYTE_LENGTH: ht,
|
|
10479
10717
|
EcKeyPair: A,
|
|
10480
10718
|
EpochValidator: ct,
|
|
10481
|
-
ExtendedAddressMap:
|
|
10482
|
-
FastMap:
|
|
10719
|
+
ExtendedAddressMap: ze,
|
|
10720
|
+
FastMap: yt,
|
|
10483
10721
|
FeaturePriority: Q,
|
|
10484
|
-
Features:
|
|
10485
|
-
FundingTransaction:
|
|
10722
|
+
Features: N,
|
|
10723
|
+
FundingTransaction: $t,
|
|
10486
10724
|
Generator: q,
|
|
10487
|
-
HashCommitmentGenerator:
|
|
10488
|
-
I128_BYTE_LENGTH:
|
|
10489
|
-
I16_BYTE_LENGTH:
|
|
10490
|
-
I256_BYTE_LENGTH:
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10725
|
+
HashCommitmentGenerator: P,
|
|
10726
|
+
I128_BYTE_LENGTH: Tt,
|
|
10727
|
+
I16_BYTE_LENGTH: xt,
|
|
10728
|
+
I256_BYTE_LENGTH: Zi,
|
|
10729
|
+
I32_BYTE_LENGTH: Bt,
|
|
10730
|
+
I64_BYTE_LENGTH: Ot,
|
|
10731
|
+
I8_BYTE_LENGTH: vt,
|
|
10732
|
+
InteractionTransaction: Xt,
|
|
10494
10733
|
InteractionTransactionP2WDA: j,
|
|
10495
|
-
LegacyCalldataGenerator:
|
|
10496
|
-
MINIMUM_AMOUNT_CA:
|
|
10734
|
+
LegacyCalldataGenerator: ir,
|
|
10735
|
+
MINIMUM_AMOUNT_CA: bt,
|
|
10497
10736
|
MINIMUM_AMOUNT_REWARD: V,
|
|
10498
|
-
MLDSAKeyPair:
|
|
10499
|
-
MLDSAPublicKeyMetadata:
|
|
10500
|
-
MLDSASecurityLevel:
|
|
10737
|
+
MLDSAKeyPair: E.MLDSAKeyPair,
|
|
10738
|
+
MLDSAPublicKeyMetadata: Qe,
|
|
10739
|
+
MLDSASecurityLevel: E.MLDSASecurityLevel,
|
|
10501
10740
|
MessageSigner: st,
|
|
10502
|
-
MessageType:
|
|
10503
|
-
Mnemonic:
|
|
10504
|
-
MnemonicStrength:
|
|
10505
|
-
MultiSignGenerator:
|
|
10741
|
+
MessageType: pi,
|
|
10742
|
+
Mnemonic: ge,
|
|
10743
|
+
MnemonicStrength: zt,
|
|
10744
|
+
MultiSignGenerator: kt,
|
|
10506
10745
|
MultiSignTransaction: x,
|
|
10507
|
-
NetEvent:
|
|
10508
|
-
OPNET_DEPLOYMENT_VERSION:
|
|
10509
|
-
OPNetConsensusConfig:
|
|
10510
|
-
OPNetLimitedProvider:
|
|
10511
|
-
OfflineTransactionManager:
|
|
10512
|
-
P2TR_MS:
|
|
10746
|
+
NetEvent: Sr,
|
|
10747
|
+
OPNET_DEPLOYMENT_VERSION: $e,
|
|
10748
|
+
OPNetConsensusConfig: Je,
|
|
10749
|
+
OPNetLimitedProvider: fr,
|
|
10750
|
+
OfflineTransactionManager: dr,
|
|
10751
|
+
P2TR_MS: pr,
|
|
10513
10752
|
P2WDADetector: z,
|
|
10514
|
-
P2WDAGenerator:
|
|
10515
|
-
PSBTTypes:
|
|
10516
|
-
QuantumBIP32API:
|
|
10517
|
-
QuantumBIP32Factory:
|
|
10518
|
-
QuantumBIP32Interface:
|
|
10519
|
-
QuantumDerivationPath:
|
|
10520
|
-
QuantumSigner:
|
|
10521
|
-
RoswellConsensus:
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
|
|
10528
|
-
|
|
10753
|
+
P2WDAGenerator: Ut,
|
|
10754
|
+
PSBTTypes: li,
|
|
10755
|
+
QuantumBIP32API: E.QuantumBIP32API,
|
|
10756
|
+
QuantumBIP32Factory: E.QuantumBIP32Factory,
|
|
10757
|
+
QuantumBIP32Interface: E.QuantumBIP32Interface,
|
|
10758
|
+
QuantumDerivationPath: E.QuantumDerivationPath,
|
|
10759
|
+
QuantumSigner: E.QuantumSigner,
|
|
10760
|
+
RoswellConsensus: Ze,
|
|
10761
|
+
SCHNORR_SIGNATURE_BYTE_LENGTH: lt,
|
|
10762
|
+
SELECTOR_BYTE_LENGTH: ji,
|
|
10763
|
+
SERIALIZATION_FORMAT_VERSION: Te,
|
|
10764
|
+
SERIALIZATION_MAGIC_BYTE: Nt,
|
|
10765
|
+
Secp256k1PointDeriver: He,
|
|
10766
|
+
SharedInteractionTransaction: be,
|
|
10767
|
+
SignatureType: gi,
|
|
10768
|
+
SigningProtocol: yi,
|
|
10529
10769
|
TapscriptVerificator: tt,
|
|
10530
10770
|
TimeLockGenerator: M,
|
|
10531
10771
|
TransactionBuilder: m,
|
|
10532
|
-
TransactionFactory:
|
|
10772
|
+
TransactionFactory: ri,
|
|
10533
10773
|
TransactionReconstructor: ut,
|
|
10534
|
-
TransactionSequence:
|
|
10535
|
-
TransactionSerializer:
|
|
10774
|
+
TransactionSequence: ti,
|
|
10775
|
+
TransactionSerializer: B,
|
|
10536
10776
|
TransactionStateCapture: $,
|
|
10537
10777
|
TransactionType: w,
|
|
10538
|
-
TweakedSigner:
|
|
10539
|
-
TweakedTransaction:
|
|
10540
|
-
U128_BYTE_LENGTH:
|
|
10541
|
-
U16_BYTE_LENGTH:
|
|
10542
|
-
U256_BYTE_LENGTH:
|
|
10543
|
-
U32_BYTE_LENGTH:
|
|
10544
|
-
U64_BYTE_LENGTH:
|
|
10545
|
-
U8_BYTE_LENGTH:
|
|
10546
|
-
UnisatChainType:
|
|
10547
|
-
UnisatSigner:
|
|
10778
|
+
TweakedSigner: pe,
|
|
10779
|
+
TweakedTransaction: Jt,
|
|
10780
|
+
U128_BYTE_LENGTH: It,
|
|
10781
|
+
U16_BYTE_LENGTH: ft,
|
|
10782
|
+
U256_BYTE_LENGTH: At,
|
|
10783
|
+
U32_BYTE_LENGTH: dt,
|
|
10784
|
+
U64_BYTE_LENGTH: Wt,
|
|
10785
|
+
U8_BYTE_LENGTH: Ht,
|
|
10786
|
+
UnisatChainType: fi,
|
|
10787
|
+
UnisatSigner: yr,
|
|
10548
10788
|
Wallet: Z,
|
|
10549
|
-
WalletNetworks:
|
|
10550
|
-
XverseNetwork:
|
|
10551
|
-
XverseSigner:
|
|
10552
|
-
buildBIPPath:
|
|
10553
|
-
createAddressRotation:
|
|
10554
|
-
createSignerMap:
|
|
10555
|
-
currentConsensus:
|
|
10556
|
-
currentConsensusConfig:
|
|
10557
|
-
disabledAddressRotation:
|
|
10558
|
-
getBIPDescription:
|
|
10559
|
-
getLevelFromPublicKeyLength:
|
|
10560
|
-
isCancelSpecificData:
|
|
10561
|
-
isCustomScriptSpecificData:
|
|
10562
|
-
isDeploymentSpecificData:
|
|
10563
|
-
isFundingSpecificData:
|
|
10564
|
-
isInteractionSpecificData:
|
|
10789
|
+
WalletNetworks: Pt,
|
|
10790
|
+
XverseNetwork: Si,
|
|
10791
|
+
XverseSigner: br,
|
|
10792
|
+
buildBIPPath: Ge,
|
|
10793
|
+
createAddressRotation: ar,
|
|
10794
|
+
createSignerMap: je,
|
|
10795
|
+
currentConsensus: Zt,
|
|
10796
|
+
currentConsensusConfig: ur,
|
|
10797
|
+
disabledAddressRotation: cr,
|
|
10798
|
+
getBIPDescription: sr,
|
|
10799
|
+
getLevelFromPublicKeyLength: ae,
|
|
10800
|
+
isCancelSpecificData: ci,
|
|
10801
|
+
isCustomScriptSpecificData: ai,
|
|
10802
|
+
isDeploymentSpecificData: ni,
|
|
10803
|
+
isFundingSpecificData: si,
|
|
10804
|
+
isInteractionSpecificData: oi,
|
|
10565
10805
|
isMultiSigSpecificData: et,
|
|
10566
|
-
isOPWallet:
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
}, Symbol.toStringTag, { value: "Module" })), Er = P.MLDSAKeyPair, Ar = P.MLDSASecurityLevel, Br = P.QuantumBIP32API, Or = P.QuantumBIP32Factory, vr = P.QuantumBIP32Interface, xr = P.QuantumDerivationPath, kr = P.QuantumSigner;
|
|
10806
|
+
isOPWallet: Ye,
|
|
10807
|
+
version: Vi,
|
|
10808
|
+
versionBuffer: Xe
|
|
10809
|
+
}, Symbol.toStringTag, { value: "Module" })), Or = E.MLDSAKeyPair, Br = E.MLDSASecurityLevel, xr = E.QuantumBIP32API, vr = E.QuantumBIP32Factory, kr = E.QuantumBIP32Interface, Ur = E.QuantumDerivationPath, Lr = E.QuantumSigner;
|
|
10571
10810
|
export {
|
|
10572
|
-
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10811
|
+
gr as ABICoder,
|
|
10812
|
+
di as ABIDataTypes,
|
|
10813
|
+
k as ADDRESS_BYTE_LENGTH,
|
|
10814
|
+
ue as ANCHOR_SCRIPT,
|
|
10576
10815
|
v as Address,
|
|
10577
|
-
|
|
10578
|
-
|
|
10579
|
-
|
|
10816
|
+
fe as AddressGenerator,
|
|
10817
|
+
Ve as AddressMap,
|
|
10818
|
+
Ee as AddressSet,
|
|
10580
10819
|
J as AddressTypes,
|
|
10581
10820
|
H as AddressVerificator,
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10821
|
+
Et as BIPStandard,
|
|
10822
|
+
Ji as BOOLEAN_BYTE_LENGTH,
|
|
10823
|
+
jt as BinaryReader,
|
|
10824
|
+
C as BinaryWriter,
|
|
10825
|
+
D as BitcoinUtils,
|
|
10587
10826
|
X as BufferHelper,
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
10827
|
+
ei as CSVModes,
|
|
10828
|
+
de as CalldataGenerator,
|
|
10829
|
+
Ie as CancelTransaction,
|
|
10830
|
+
Se as ChainId,
|
|
10831
|
+
he as ChallengeSolution,
|
|
10832
|
+
hi as ChallengeSubmission,
|
|
10833
|
+
ui as ChallengeVerification,
|
|
10834
|
+
W as Compressor,
|
|
10835
|
+
_t as Consensus,
|
|
10836
|
+
ii as ConsolidatedInteractionTransaction,
|
|
10837
|
+
oe as ContractAddress,
|
|
10838
|
+
or as ContractBaseMetadata,
|
|
10839
|
+
qe as CustomGenerator,
|
|
10840
|
+
Oe as CustomKeypair,
|
|
10841
|
+
Yt as CustomMap,
|
|
10842
|
+
qt as CustomScriptTransaction,
|
|
10843
|
+
Vt as DeploymentGenerator,
|
|
10844
|
+
St as DeploymentTransaction,
|
|
10845
|
+
Pe as DeterministicMap,
|
|
10846
|
+
Ae as DeterministicSet,
|
|
10847
|
+
ht as EXTENDED_ADDRESS_BYTE_LENGTH,
|
|
10608
10848
|
A as EcKeyPair,
|
|
10609
10849
|
ct as EpochValidator,
|
|
10610
|
-
|
|
10611
|
-
|
|
10850
|
+
ze as ExtendedAddressMap,
|
|
10851
|
+
yt as FastMap,
|
|
10612
10852
|
Q as FeaturePriority,
|
|
10613
|
-
|
|
10614
|
-
|
|
10853
|
+
N as Features,
|
|
10854
|
+
$t as FundingTransaction,
|
|
10615
10855
|
q as Generator,
|
|
10616
|
-
|
|
10617
|
-
|
|
10618
|
-
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10856
|
+
P as HashCommitmentGenerator,
|
|
10857
|
+
Tt as I128_BYTE_LENGTH,
|
|
10858
|
+
xt as I16_BYTE_LENGTH,
|
|
10859
|
+
Zi as I256_BYTE_LENGTH,
|
|
10860
|
+
Bt as I32_BYTE_LENGTH,
|
|
10861
|
+
Ot as I64_BYTE_LENGTH,
|
|
10862
|
+
vt as I8_BYTE_LENGTH,
|
|
10863
|
+
Xt as InteractionTransaction,
|
|
10623
10864
|
j as InteractionTransactionP2WDA,
|
|
10624
|
-
|
|
10625
|
-
|
|
10865
|
+
ir as LegacyCalldataGenerator,
|
|
10866
|
+
bt as MINIMUM_AMOUNT_CA,
|
|
10626
10867
|
V as MINIMUM_AMOUNT_REWARD,
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10868
|
+
Or as MLDSAKeyPair,
|
|
10869
|
+
Qe as MLDSAPublicKeyMetadata,
|
|
10870
|
+
Br as MLDSASecurityLevel,
|
|
10630
10871
|
st as MessageSigner,
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10872
|
+
pi as MessageType,
|
|
10873
|
+
ge as Mnemonic,
|
|
10874
|
+
zt as MnemonicStrength,
|
|
10875
|
+
kt as MultiSignGenerator,
|
|
10635
10876
|
x as MultiSignTransaction,
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10877
|
+
Sr as NetEvent,
|
|
10878
|
+
$e as OPNET_DEPLOYMENT_VERSION,
|
|
10879
|
+
Je as OPNetConsensusConfig,
|
|
10880
|
+
fr as OPNetLimitedProvider,
|
|
10881
|
+
dr as OfflineTransactionManager,
|
|
10882
|
+
pr as P2TR_MS,
|
|
10642
10883
|
z as P2WDADetector,
|
|
10643
|
-
|
|
10644
|
-
|
|
10645
|
-
|
|
10646
|
-
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
|
|
10657
|
-
|
|
10884
|
+
Ut as P2WDAGenerator,
|
|
10885
|
+
li as PSBTTypes,
|
|
10886
|
+
xr as QuantumBIP32API,
|
|
10887
|
+
vr as QuantumBIP32Factory,
|
|
10888
|
+
kr as QuantumBIP32Interface,
|
|
10889
|
+
Ur as QuantumDerivationPath,
|
|
10890
|
+
Lr as QuantumSigner,
|
|
10891
|
+
Ze as RoswellConsensus,
|
|
10892
|
+
lt as SCHNORR_SIGNATURE_BYTE_LENGTH,
|
|
10893
|
+
ji as SELECTOR_BYTE_LENGTH,
|
|
10894
|
+
Te as SERIALIZATION_FORMAT_VERSION,
|
|
10895
|
+
Nt as SERIALIZATION_MAGIC_BYTE,
|
|
10896
|
+
He as Secp256k1PointDeriver,
|
|
10897
|
+
be as SharedInteractionTransaction,
|
|
10898
|
+
gi as SignatureType,
|
|
10899
|
+
yi as SigningProtocol,
|
|
10658
10900
|
tt as TapscriptVerificator,
|
|
10659
10901
|
M as TimeLockGenerator,
|
|
10660
10902
|
m as TransactionBuilder,
|
|
10661
|
-
|
|
10903
|
+
ri as TransactionFactory,
|
|
10662
10904
|
ut as TransactionReconstructor,
|
|
10663
|
-
|
|
10664
|
-
|
|
10905
|
+
ti as TransactionSequence,
|
|
10906
|
+
B as TransactionSerializer,
|
|
10665
10907
|
$ as TransactionStateCapture,
|
|
10666
10908
|
w as TransactionType,
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10670
|
-
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10909
|
+
pe as TweakedSigner,
|
|
10910
|
+
Jt as TweakedTransaction,
|
|
10911
|
+
It as U128_BYTE_LENGTH,
|
|
10912
|
+
ft as U16_BYTE_LENGTH,
|
|
10913
|
+
At as U256_BYTE_LENGTH,
|
|
10914
|
+
dt as U32_BYTE_LENGTH,
|
|
10915
|
+
Wt as U64_BYTE_LENGTH,
|
|
10916
|
+
Ht as U8_BYTE_LENGTH,
|
|
10917
|
+
fi as UnisatChainType,
|
|
10918
|
+
yr as UnisatSigner,
|
|
10677
10919
|
Z as Wallet,
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10692
|
-
|
|
10693
|
-
|
|
10920
|
+
Pt as WalletNetworks,
|
|
10921
|
+
Si as XverseNetwork,
|
|
10922
|
+
br as XverseSigner,
|
|
10923
|
+
Ge as buildBIPPath,
|
|
10924
|
+
ar as createAddressRotation,
|
|
10925
|
+
je as createSignerMap,
|
|
10926
|
+
Zt as currentConsensus,
|
|
10927
|
+
ur as currentConsensusConfig,
|
|
10928
|
+
cr as disabledAddressRotation,
|
|
10929
|
+
sr as getBIPDescription,
|
|
10930
|
+
ae as getLevelFromPublicKeyLength,
|
|
10931
|
+
ci as isCancelSpecificData,
|
|
10932
|
+
ai as isCustomScriptSpecificData,
|
|
10933
|
+
ni as isDeploymentSpecificData,
|
|
10934
|
+
si as isFundingSpecificData,
|
|
10935
|
+
oi as isInteractionSpecificData,
|
|
10694
10936
|
et as isMultiSigSpecificData,
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
Me as versionBuffer
|
|
10937
|
+
Ye as isOPWallet,
|
|
10938
|
+
Ar as opnet,
|
|
10939
|
+
Vi as version,
|
|
10940
|
+
Xe as versionBuffer
|
|
10700
10941
|
};
|