@btc-vision/transaction 1.7.31 → 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/AUDIT/README.md +9 -0
- package/CHANGELOG.md +5 -0
- package/README.md +62 -18
- package/SECURITY.md +71 -0
- 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 +19 -0
- package/browser/index.js +1201 -874
- package/browser/keypair/Address.d.ts +4 -1
- package/browser/mnemonic/Mnemonic.d.ts +1 -1
- package/browser/noble-curves.js +1087 -1116
- package/browser/noble-hashes.js +25 -25
- package/browser/opnet.d.ts +1 -0
- package/browser/transaction/browser/WalletNetworks.d.ts +3 -3
- package/browser/transaction/browser/types/Unisat.d.ts +2 -2
- package/browser/utils/lengths.d.ts +3 -1
- package/browser/utils/types.d.ts +3 -0
- package/browser/vendors.js +950 -911
- 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 +19 -0
- package/build/deterministic/ExtendedAddressMap.js +87 -0
- package/build/keypair/Address.d.ts +4 -1
- package/build/keypair/Address.js +48 -13
- package/build/mnemonic/Mnemonic.d.ts +1 -1
- package/build/mnemonic/Mnemonic.js +2 -2
- package/build/opnet.d.ts +1 -0
- package/build/opnet.js +1 -0
- package/build/transaction/browser/WalletNetworks.d.ts +3 -3
- package/build/transaction/browser/WalletNetworks.js +3 -3
- package/build/transaction/browser/extensions/UnisatSigner.js +3 -3
- package/build/transaction/browser/types/Unisat.d.ts +2 -2
- 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 +13 -13
- 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 +122 -0
- package/src/keypair/Address.ts +79 -14
- package/src/mnemonic/Mnemonic.ts +2 -2
- package/src/opnet.ts +1 -0
- package/src/transaction/browser/WalletNetworks.ts +3 -3
- package/src/transaction/browser/extensions/UnisatSigner.ts +3 -3
- package/src/transaction/browser/types/Unisat.ts +2 -2
- 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 +26 -25
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;
|
|
@@ -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");
|
|
@@ -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,
|
|
@@ -1065,46 +1065,47 @@ class M {
|
|
|
1065
1065
|
]);
|
|
1066
1066
|
}
|
|
1067
1067
|
}
|
|
1068
|
-
class
|
|
1068
|
+
class v extends Uint8Array {
|
|
1069
1069
|
#t;
|
|
1070
1070
|
#e;
|
|
1071
|
-
#s;
|
|
1072
|
-
#i;
|
|
1073
|
-
#u;
|
|
1074
|
-
#r;
|
|
1075
1071
|
#n;
|
|
1072
|
+
#i;
|
|
1076
1073
|
#h;
|
|
1074
|
+
#r;
|
|
1075
|
+
#s;
|
|
1077
1076
|
#l;
|
|
1078
|
-
#
|
|
1077
|
+
#d;
|
|
1079
1078
|
#a;
|
|
1080
|
-
#
|
|
1079
|
+
#c;
|
|
1080
|
+
#u;
|
|
1081
1081
|
#p;
|
|
1082
|
+
#g;
|
|
1082
1083
|
// Lazy loading state - defers expensive EC operations until actually needed
|
|
1083
|
-
#
|
|
1084
|
-
#
|
|
1084
|
+
#f;
|
|
1085
|
+
#S = !1;
|
|
1085
1086
|
// After processing, this is 32-byte tweaked x-only (same as original behavior)
|
|
1086
|
-
#
|
|
1087
|
+
#o;
|
|
1087
1088
|
constructor(t, e) {
|
|
1088
|
-
if (super(
|
|
1089
|
+
if (super(k), !!t) {
|
|
1089
1090
|
if (e) {
|
|
1090
|
-
if (![
|
|
1091
|
+
if (![k, 33, 65].includes(e.length))
|
|
1091
1092
|
throw new Error(`Invalid public key length ${e.length}`);
|
|
1092
|
-
this.#
|
|
1093
|
+
this.#f = new Uint8Array(e.length), this.#f.set(e);
|
|
1093
1094
|
}
|
|
1094
1095
|
this.setMldsaKey(t);
|
|
1095
1096
|
}
|
|
1096
1097
|
}
|
|
1097
1098
|
get mldsaLevel() {
|
|
1098
|
-
return this.#
|
|
1099
|
+
return this.#g;
|
|
1099
1100
|
}
|
|
1100
1101
|
set mldsaLevel(t) {
|
|
1101
|
-
this.#
|
|
1102
|
+
this.#g = t;
|
|
1102
1103
|
}
|
|
1103
1104
|
get originalMDLSAPublicKey() {
|
|
1104
|
-
return this.#
|
|
1105
|
+
return this.#p;
|
|
1105
1106
|
}
|
|
1106
1107
|
set originalMDLSAPublicKey(t) {
|
|
1107
|
-
this.#
|
|
1108
|
+
this.#p = new Uint8Array(t);
|
|
1108
1109
|
}
|
|
1109
1110
|
/**
|
|
1110
1111
|
* If available, this will return the original public key associated with the address.
|
|
@@ -1114,26 +1115,26 @@ class k extends Uint8Array {
|
|
|
1114
1115
|
return this.ensureLegacyProcessed(), this.#i;
|
|
1115
1116
|
}
|
|
1116
1117
|
get mldsaPublicKey() {
|
|
1117
|
-
return this.#
|
|
1118
|
+
return this.#d;
|
|
1118
1119
|
}
|
|
1119
1120
|
/**
|
|
1120
1121
|
* Get the legacy public key (32-byte tweaked x-only after processing).
|
|
1121
1122
|
* Triggers lazy processing if not yet done.
|
|
1122
1123
|
*/
|
|
1123
1124
|
get legacyPublicKey() {
|
|
1124
|
-
return this.ensureLegacyProcessed(), this.#
|
|
1125
|
+
return this.ensureLegacyProcessed(), this.#o;
|
|
1125
1126
|
}
|
|
1126
1127
|
/**
|
|
1127
1128
|
* Get the key pair for the address
|
|
1128
1129
|
* @description This is only for internal use. Please use address.tweakedBytes instead.
|
|
1129
1130
|
*/
|
|
1130
1131
|
get keyPair() {
|
|
1131
|
-
if (this.ensureLegacyProcessed(), !this.#
|
|
1132
|
+
if (this.ensureLegacyProcessed(), !this.#h)
|
|
1132
1133
|
throw new Error("Legacy public key not set for address");
|
|
1133
|
-
return this.#
|
|
1134
|
+
return this.#h;
|
|
1134
1135
|
}
|
|
1135
1136
|
static dead() {
|
|
1136
|
-
return
|
|
1137
|
+
return v.fromString(
|
|
1137
1138
|
"0x0000000000000000000000000000000000000000000000000000000000000000",
|
|
1138
1139
|
// DEAD ADDRESS
|
|
1139
1140
|
"0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f"
|
|
@@ -1148,19 +1149,19 @@ class k extends Uint8Array {
|
|
|
1148
1149
|
static fromString(t, e) {
|
|
1149
1150
|
if (!t)
|
|
1150
1151
|
throw new Error("Invalid public key");
|
|
1151
|
-
if (t.startsWith("0x") && (t = t.slice(2)), !
|
|
1152
|
+
if (t.startsWith("0x") && (t = t.slice(2)), !D.isValidHex(t))
|
|
1152
1153
|
throw new Error(
|
|
1153
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.'
|
|
1154
1155
|
);
|
|
1155
1156
|
let i;
|
|
1156
1157
|
if (e) {
|
|
1157
|
-
if (e.startsWith("0x") && (e = e.slice(2)), !
|
|
1158
|
+
if (e.startsWith("0x") && (e = e.slice(2)), !D.isValidHex(e))
|
|
1158
1159
|
throw new Error(
|
|
1159
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.'
|
|
1160
1161
|
);
|
|
1161
1162
|
i = a.from(e, "hex");
|
|
1162
1163
|
}
|
|
1163
|
-
return new
|
|
1164
|
+
return new v(a.from(t, "hex"), i);
|
|
1164
1165
|
}
|
|
1165
1166
|
/**
|
|
1166
1167
|
* Create an address from a public key
|
|
@@ -1168,7 +1169,7 @@ class k extends Uint8Array {
|
|
|
1168
1169
|
* @param {ArrayLike<number>} bytes The public key
|
|
1169
1170
|
*/
|
|
1170
1171
|
static wrap(t) {
|
|
1171
|
-
return new
|
|
1172
|
+
return new v(t);
|
|
1172
1173
|
}
|
|
1173
1174
|
static uncompressedToCompressed(t) {
|
|
1174
1175
|
const e = Uint8Array.from(t), i = e.slice(1, 33), r = e.slice(33), s = a.alloc(33);
|
|
@@ -1182,6 +1183,7 @@ class k extends Uint8Array {
|
|
|
1182
1183
|
* This is the inverse operation of toBigInt().
|
|
1183
1184
|
*
|
|
1184
1185
|
* @param {bigint} value - The 256-bit unsigned integer to convert (0 to 2^256-1)
|
|
1186
|
+
* @param {bigint} [tweakedValue] - Optional tweaked public key as a 256-bit unsigned integer
|
|
1185
1187
|
* @returns {Address} A new Address instance containing the converted value
|
|
1186
1188
|
*
|
|
1187
1189
|
* @throws {RangeError} If the value is negative or exceeds 2^256-1
|
|
@@ -1193,9 +1195,9 @@ class k extends Uint8Array {
|
|
|
1193
1195
|
* console.log(address.toHex()); // 0x0000000000000000000000000000000000000000000000000000abc123...
|
|
1194
1196
|
* ```
|
|
1195
1197
|
*/
|
|
1196
|
-
static fromBigInt(t) {
|
|
1197
|
-
const
|
|
1198
|
-
return
|
|
1198
|
+
static fromBigInt(t, e) {
|
|
1199
|
+
const i = v.bigintToUint8Array(t), r = e !== void 0 ? v.bigintToUint8Array(e) : void 0;
|
|
1200
|
+
return new v(i, r);
|
|
1199
1201
|
}
|
|
1200
1202
|
/**
|
|
1201
1203
|
* Creates an Address instance from four 64-bit unsigned integers.
|
|
@@ -1225,7 +1227,11 @@ class k extends Uint8Array {
|
|
|
1225
1227
|
*/
|
|
1226
1228
|
static fromUint64Array(t, e, i, r) {
|
|
1227
1229
|
const s = new Uint8Array(32), o = new DataView(s.buffer);
|
|
1228
|
-
return o.setBigUint64(0, t, !1), o.setBigUint64(8, e, !1), o.setBigUint64(16, i, !1), o.setBigUint64(24, r, !1), new
|
|
1230
|
+
return o.setBigUint64(0, t, !1), o.setBigUint64(8, e, !1), o.setBigUint64(16, i, !1), o.setBigUint64(24, r, !1), new v(s);
|
|
1231
|
+
}
|
|
1232
|
+
static bigintToUint8Array(t) {
|
|
1233
|
+
const e = new Uint8Array(32), i = new DataView(e.buffer);
|
|
1234
|
+
return i.setBigUint64(0, t >> 192n & 0xffffffffffffffffn, !1), i.setBigUint64(8, t >> 128n & 0xffffffffffffffffn, !1), i.setBigUint64(16, t >> 64n & 0xffffffffffffffffn, !1), i.setBigUint64(24, t & 0xffffffffffffffffn, !1), e;
|
|
1229
1235
|
}
|
|
1230
1236
|
/**
|
|
1231
1237
|
* Converts the address to four 64-bit unsigned integers.
|
|
@@ -1246,22 +1252,22 @@ class k extends Uint8Array {
|
|
|
1246
1252
|
* ```
|
|
1247
1253
|
*/
|
|
1248
1254
|
toUint64Array() {
|
|
1249
|
-
if (this.#
|
|
1250
|
-
return this.#
|
|
1255
|
+
if (this.#u !== void 0)
|
|
1256
|
+
return this.#u;
|
|
1251
1257
|
const t = new DataView(this.buffer, this.byteOffset, 32);
|
|
1252
|
-
return this.#
|
|
1258
|
+
return this.#u = [
|
|
1253
1259
|
t.getBigUint64(0, !1),
|
|
1254
1260
|
t.getBigUint64(8, !1),
|
|
1255
1261
|
t.getBigUint64(16, !1),
|
|
1256
1262
|
t.getBigUint64(24, !1)
|
|
1257
|
-
], this.#
|
|
1263
|
+
], this.#u;
|
|
1258
1264
|
}
|
|
1259
1265
|
/**
|
|
1260
1266
|
* Check if the address is the dead address
|
|
1261
1267
|
* @returns {boolean}
|
|
1262
1268
|
*/
|
|
1263
1269
|
isDead() {
|
|
1264
|
-
for (let t = 0; t <
|
|
1270
|
+
for (let t = 0; t < k; t++)
|
|
1265
1271
|
if (this[t] !== 0)
|
|
1266
1272
|
return !1;
|
|
1267
1273
|
return !0;
|
|
@@ -1342,10 +1348,34 @@ class k extends Uint8Array {
|
|
|
1342
1348
|
* ```
|
|
1343
1349
|
*/
|
|
1344
1350
|
toBigInt() {
|
|
1345
|
-
if (this.#
|
|
1346
|
-
return this.#
|
|
1351
|
+
if (this.#a !== void 0)
|
|
1352
|
+
return this.#a;
|
|
1347
1353
|
const t = new DataView(this.buffer, this.byteOffset, 32);
|
|
1348
|
-
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
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Converts the tweaked public key to a BigInt representation.
|
|
1358
|
+
*
|
|
1359
|
+
* This method uses an optimized DataView approach to read the 32-byte address
|
|
1360
|
+
* as four 64-bit big-endian unsigned integers, then combines them using bitwise
|
|
1361
|
+
* operations. This is approximately 10-20x faster than string-based conversion.
|
|
1362
|
+
*
|
|
1363
|
+
* @returns {bigint} The address as a 256-bit unsigned integer
|
|
1364
|
+
*
|
|
1365
|
+
* @example
|
|
1366
|
+
* ```typescript
|
|
1367
|
+
* const address = Address.fromString('0x0123456789abcdef...', '0xtweaked...');
|
|
1368
|
+
* const bigIntValue = address.tweakedToBigInt();
|
|
1369
|
+
* console.log(bigIntValue); // 123456789...n
|
|
1370
|
+
* ```
|
|
1371
|
+
*/
|
|
1372
|
+
tweakedToBigInt() {
|
|
1373
|
+
if (!this.legacyPublicKey)
|
|
1374
|
+
throw new Error("Legacy public key not set");
|
|
1375
|
+
if (this.#c !== void 0)
|
|
1376
|
+
return this.#c;
|
|
1377
|
+
const t = new DataView(this.legacyPublicKey.buffer, this.byteOffset, 32);
|
|
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;
|
|
1349
1379
|
}
|
|
1350
1380
|
equals(t) {
|
|
1351
1381
|
const e = this;
|
|
@@ -1362,7 +1392,7 @@ class k extends Uint8Array {
|
|
|
1362
1392
|
*/
|
|
1363
1393
|
lessThan(t) {
|
|
1364
1394
|
const e = this;
|
|
1365
|
-
for (let i = 0; i <
|
|
1395
|
+
for (let i = 0; i < k; i++) {
|
|
1366
1396
|
const r = e[i], s = t[i];
|
|
1367
1397
|
if (r < s)
|
|
1368
1398
|
return !0;
|
|
@@ -1377,7 +1407,7 @@ class k extends Uint8Array {
|
|
|
1377
1407
|
*/
|
|
1378
1408
|
greaterThan(t) {
|
|
1379
1409
|
const e = this;
|
|
1380
|
-
for (let i = 0; i <
|
|
1410
|
+
for (let i = 0; i < k; i++) {
|
|
1381
1411
|
const r = e[i], s = t[i];
|
|
1382
1412
|
if (r > s)
|
|
1383
1413
|
return !0;
|
|
@@ -1449,14 +1479,14 @@ class k extends Uint8Array {
|
|
|
1449
1479
|
* @param {Network} network The network
|
|
1450
1480
|
*/
|
|
1451
1481
|
p2tr(t) {
|
|
1452
|
-
if (this.#t && this.#
|
|
1482
|
+
if (this.#t && this.#n === t)
|
|
1453
1483
|
return this.#t;
|
|
1454
1484
|
const e = this.legacyPublicKey;
|
|
1455
1485
|
if (!e)
|
|
1456
1486
|
throw new Error("Legacy public key not set");
|
|
1457
1487
|
const i = A.tweakedPubKeyBufferToAddress(e, t);
|
|
1458
1488
|
if (i)
|
|
1459
|
-
return this.#
|
|
1489
|
+
return this.#n = t, this.#t = i, i;
|
|
1460
1490
|
throw new Error("Legacy public key not set");
|
|
1461
1491
|
}
|
|
1462
1492
|
/**
|
|
@@ -1482,8 +1512,8 @@ class k extends Uint8Array {
|
|
|
1482
1512
|
* ```
|
|
1483
1513
|
*/
|
|
1484
1514
|
p2wda(t) {
|
|
1485
|
-
if (this.#
|
|
1486
|
-
return this.#
|
|
1515
|
+
if (this.#l && this.#n === t)
|
|
1516
|
+
return this.#l;
|
|
1487
1517
|
if (this.ensureLegacyProcessed(), !this.#i)
|
|
1488
1518
|
throw new Error("Cannot create P2WDA address: public key not set");
|
|
1489
1519
|
const e = a.from(this.#i);
|
|
@@ -1491,7 +1521,7 @@ class k extends Uint8Array {
|
|
|
1491
1521
|
throw new Error("P2WDA requires a compressed public key (33 bytes)");
|
|
1492
1522
|
try {
|
|
1493
1523
|
const i = z.generateP2WDAAddress(e, t);
|
|
1494
|
-
return this.#
|
|
1524
|
+
return this.#n = t, this.#l = i, {
|
|
1495
1525
|
address: i.address,
|
|
1496
1526
|
witnessScript: i.witnessScript
|
|
1497
1527
|
};
|
|
@@ -1551,38 +1581,52 @@ class k extends Uint8Array {
|
|
|
1551
1581
|
* @returns The P2OP address in bech32m format
|
|
1552
1582
|
*/
|
|
1553
1583
|
p2op(t) {
|
|
1554
|
-
if (this.#e && this.#
|
|
1584
|
+
if (this.#e && this.#n === t)
|
|
1555
1585
|
return this.#e;
|
|
1556
1586
|
const e = A.p2op(this, t);
|
|
1557
1587
|
if (e)
|
|
1558
|
-
return this.#
|
|
1588
|
+
return this.#n = t, this.#e = e, e;
|
|
1559
1589
|
throw new Error("ML-DSA public key not set");
|
|
1560
1590
|
}
|
|
1561
1591
|
toTweakedHybridPublicKeyHex() {
|
|
1562
|
-
if (this.ensureLegacyProcessed(), !this.#
|
|
1592
|
+
if (this.ensureLegacyProcessed(), this.ensureTweakedUncompressed(), !this.#s)
|
|
1563
1593
|
throw new Error("Legacy public key not set");
|
|
1564
|
-
return "0x" + this.#
|
|
1594
|
+
return "0x" + this.#s.toString("hex");
|
|
1565
1595
|
}
|
|
1566
1596
|
toTweakedHybridPublicKeyBuffer() {
|
|
1567
|
-
if (this.ensureLegacyProcessed(), !this.#
|
|
1597
|
+
if (this.ensureLegacyProcessed(), this.ensureTweakedUncompressed(), !this.#s)
|
|
1568
1598
|
throw new Error("Legacy public key not set");
|
|
1569
|
-
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
|
+
}
|
|
1570
1614
|
}
|
|
1571
1615
|
/**
|
|
1572
1616
|
* Sets the MLDSA key portion of the address.
|
|
1573
1617
|
* @param {ArrayLike<number>} mldsaPublicKey - The MLDSA public key or its hash
|
|
1574
1618
|
*/
|
|
1575
1619
|
setMldsaKey(t) {
|
|
1576
|
-
if (t.length ===
|
|
1577
|
-
const e = new Uint8Array(
|
|
1620
|
+
if (t.length === k) {
|
|
1621
|
+
const e = new Uint8Array(k);
|
|
1578
1622
|
e.set(t), super.set(e);
|
|
1579
1623
|
} else {
|
|
1580
1624
|
if (![1312, 1952, 2592].includes(t.length))
|
|
1581
1625
|
throw new Error(
|
|
1582
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.`
|
|
1583
1627
|
);
|
|
1584
|
-
this.#
|
|
1585
|
-
const i =
|
|
1628
|
+
this.#d = new Uint8Array(t.length), this.#d.set(t);
|
|
1629
|
+
const i = le(new Uint8Array(t)), r = new Uint8Array(k);
|
|
1586
1630
|
r.set(i), super.set(r);
|
|
1587
1631
|
}
|
|
1588
1632
|
}
|
|
@@ -1591,15 +1635,10 @@ class k extends Uint8Array {
|
|
|
1591
1635
|
* Does the EXACT same logic as the original set() method did for legacy keys.
|
|
1592
1636
|
*/
|
|
1593
1637
|
ensureLegacyProcessed() {
|
|
1594
|
-
if (this.#
|
|
1595
|
-
this.#
|
|
1596
|
-
const t = this.#
|
|
1597
|
-
|
|
1598
|
-
if (t.length === C) {
|
|
1599
|
-
const e = a.alloc(C);
|
|
1600
|
-
e.set(t), this.#n = te.generateHybridKeyFromHash(e), this.#c = t;
|
|
1601
|
-
} else
|
|
1602
|
-
this.autoFormat(t);
|
|
1638
|
+
if (this.#S) return;
|
|
1639
|
+
this.#S = !0;
|
|
1640
|
+
const t = this.#f;
|
|
1641
|
+
t && (t.length === k ? this.#o = t : this.autoFormat(t));
|
|
1603
1642
|
}
|
|
1604
1643
|
/**
|
|
1605
1644
|
* Processes a 33 or 65 byte public key, performing EC operations.
|
|
@@ -1607,16 +1646,16 @@ class k extends Uint8Array {
|
|
|
1607
1646
|
*/
|
|
1608
1647
|
autoFormat(t) {
|
|
1609
1648
|
const e = t[0];
|
|
1610
|
-
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t =
|
|
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);
|
|
1611
1650
|
const i = O(
|
|
1612
1651
|
A.tweakPublicKey(a.from(this.#i))
|
|
1613
1652
|
);
|
|
1614
|
-
this.#
|
|
1653
|
+
this.#s = oe.generateHybridKeyFromHash(i), this.#o = new Uint8Array(k), this.#o.set(i);
|
|
1615
1654
|
}
|
|
1616
1655
|
}
|
|
1617
|
-
class
|
|
1656
|
+
class yt {
|
|
1618
1657
|
constructor(t) {
|
|
1619
|
-
if (this._keys = [], this._values = {}, t instanceof
|
|
1658
|
+
if (this._keys = [], this._values = {}, t instanceof yt)
|
|
1620
1659
|
this.setAll(t);
|
|
1621
1660
|
else if (t)
|
|
1622
1661
|
for (const [e, i] of t)
|
|
@@ -1678,9 +1717,9 @@ class Ot {
|
|
|
1678
1717
|
yield [t, this._values[t]];
|
|
1679
1718
|
}
|
|
1680
1719
|
}
|
|
1681
|
-
class
|
|
1720
|
+
class Ve {
|
|
1682
1721
|
constructor(t) {
|
|
1683
|
-
if (this.items = new
|
|
1722
|
+
if (this.items = new yt(), t)
|
|
1684
1723
|
for (const [e, i] of t)
|
|
1685
1724
|
this.set(e, i);
|
|
1686
1725
|
}
|
|
@@ -1712,11 +1751,11 @@ class Fe {
|
|
|
1712
1751
|
*/
|
|
1713
1752
|
*entries() {
|
|
1714
1753
|
for (const [t, e] of this.items.entries())
|
|
1715
|
-
yield [
|
|
1754
|
+
yield [v.fromBigInt(t), e];
|
|
1716
1755
|
}
|
|
1717
1756
|
*keys() {
|
|
1718
1757
|
for (const t of this.items.keys())
|
|
1719
|
-
yield
|
|
1758
|
+
yield v.fromBigInt(t);
|
|
1720
1759
|
}
|
|
1721
1760
|
*values() {
|
|
1722
1761
|
for (const t of this.items.values())
|
|
@@ -1724,7 +1763,7 @@ class Fe {
|
|
|
1724
1763
|
}
|
|
1725
1764
|
forEach(t, e) {
|
|
1726
1765
|
for (const [i, r] of this.items.entries()) {
|
|
1727
|
-
const s =
|
|
1766
|
+
const s = v.fromBigInt(i);
|
|
1728
1767
|
t.call(e, r, s, this);
|
|
1729
1768
|
}
|
|
1730
1769
|
}
|
|
@@ -1732,7 +1771,70 @@ class Fe {
|
|
|
1732
1771
|
yield* this.entries();
|
|
1733
1772
|
}
|
|
1734
1773
|
}
|
|
1735
|
-
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 {
|
|
1736
1838
|
constructor(t) {
|
|
1737
1839
|
this.currentOffset = 0, this.buffer = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
1738
1840
|
}
|
|
@@ -1749,53 +1851,93 @@ class qt {
|
|
|
1749
1851
|
setBuffer(t) {
|
|
1750
1852
|
this.buffer = new DataView(t.buffer, t.byteOffset, t.byteLength), this.currentOffset = 0;
|
|
1751
1853
|
}
|
|
1854
|
+
get byteLength() {
|
|
1855
|
+
return this.buffer.byteLength;
|
|
1856
|
+
}
|
|
1752
1857
|
length() {
|
|
1753
1858
|
return this.buffer.byteLength;
|
|
1754
1859
|
}
|
|
1755
1860
|
bytesLeft() {
|
|
1756
1861
|
return this.buffer.byteLength - this.currentOffset;
|
|
1757
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 ------------------- //
|
|
1758
1900
|
/**
|
|
1759
1901
|
* Reads a single unsigned byte (u8).
|
|
1760
1902
|
*/
|
|
1761
1903
|
readU8() {
|
|
1762
|
-
this.verifyEnd(this.currentOffset +
|
|
1904
|
+
this.verifyEnd(this.currentOffset + Ht);
|
|
1763
1905
|
const t = this.buffer.getUint8(this.currentOffset);
|
|
1764
|
-
return this.currentOffset +=
|
|
1906
|
+
return this.currentOffset += Ht, t;
|
|
1765
1907
|
}
|
|
1766
1908
|
/**
|
|
1767
1909
|
* Reads an unsigned 16-bit integer. By default, big-endian.
|
|
1768
1910
|
* @param be - Endianness; true means big-endian (the default).
|
|
1769
1911
|
*/
|
|
1770
1912
|
readU16(t = !0) {
|
|
1771
|
-
this.verifyEnd(this.currentOffset +
|
|
1913
|
+
this.verifyEnd(this.currentOffset + ft);
|
|
1772
1914
|
const e = this.buffer.getUint16(this.currentOffset, !t);
|
|
1773
|
-
return this.currentOffset +=
|
|
1915
|
+
return this.currentOffset += ft, e;
|
|
1774
1916
|
}
|
|
1775
1917
|
/**
|
|
1776
1918
|
* Reads an unsigned 32-bit integer. By default, big-endian.
|
|
1777
1919
|
* @param be - Endianness; true means big-endian (the default).
|
|
1778
1920
|
*/
|
|
1779
1921
|
readU32(t = !0) {
|
|
1780
|
-
this.verifyEnd(this.currentOffset +
|
|
1922
|
+
this.verifyEnd(this.currentOffset + dt);
|
|
1781
1923
|
const e = this.buffer.getUint32(this.currentOffset, !t);
|
|
1782
|
-
return this.currentOffset +=
|
|
1924
|
+
return this.currentOffset += dt, e;
|
|
1783
1925
|
}
|
|
1784
1926
|
/**
|
|
1785
1927
|
* Reads an unsigned 64-bit integer. By default, big-endian.
|
|
1786
1928
|
* @param be - Endianness; true means big-endian (the default).
|
|
1787
1929
|
*/
|
|
1788
1930
|
readU64(t = !0) {
|
|
1789
|
-
this.verifyEnd(this.currentOffset +
|
|
1931
|
+
this.verifyEnd(this.currentOffset + Wt);
|
|
1790
1932
|
const e = this.buffer.getBigUint64(this.currentOffset, !t);
|
|
1791
|
-
return this.currentOffset +=
|
|
1933
|
+
return this.currentOffset += Wt, e;
|
|
1792
1934
|
}
|
|
1793
1935
|
/**
|
|
1794
1936
|
* Reads a 128-bit unsigned integer. By default, read big-endian.
|
|
1795
1937
|
* @param be - Endianness; true => big-endian (default).
|
|
1796
1938
|
*/
|
|
1797
1939
|
readU128(t = !0) {
|
|
1798
|
-
const e = this.readBytes(
|
|
1940
|
+
const e = this.readBytes(It);
|
|
1799
1941
|
let i = e;
|
|
1800
1942
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1801
1943
|
}
|
|
@@ -1804,7 +1946,7 @@ class qt {
|
|
|
1804
1946
|
* @param be - Endianness; true => big-endian (default).
|
|
1805
1947
|
*/
|
|
1806
1948
|
readU256(t = !0) {
|
|
1807
|
-
const e = this.readBytes(
|
|
1949
|
+
const e = this.readBytes(At);
|
|
1808
1950
|
let i = e;
|
|
1809
1951
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1810
1952
|
}
|
|
@@ -1813,7 +1955,7 @@ class qt {
|
|
|
1813
1955
|
* @param be - Endianness; true => big-endian (default).
|
|
1814
1956
|
*/
|
|
1815
1957
|
readI128(t = !0) {
|
|
1816
|
-
const e = this.readBytes(
|
|
1958
|
+
const e = this.readBytes(Tt);
|
|
1817
1959
|
let i = e;
|
|
1818
1960
|
t || (i = this.reverseBytes(e));
|
|
1819
1961
|
let r = BigInt("0x" + this.toHexString(i));
|
|
@@ -1868,11 +2010,47 @@ class qt {
|
|
|
1868
2010
|
return this.readString(e);
|
|
1869
2011
|
}
|
|
1870
2012
|
/**
|
|
1871
|
-
* Reads an address.
|
|
2013
|
+
* Reads an address (32 bytes MLDSA key hash only).
|
|
1872
2014
|
*/
|
|
1873
2015
|
readAddress() {
|
|
1874
|
-
const t = Array.from(this.readBytes(
|
|
1875
|
-
return new
|
|
2016
|
+
const t = Array.from(this.readBytes(k));
|
|
2017
|
+
return new v(t);
|
|
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 };
|
|
1876
2054
|
}
|
|
1877
2055
|
/**
|
|
1878
2056
|
* Reads bytes written as [u32 length][bytes].
|
|
@@ -1950,7 +2128,7 @@ class qt {
|
|
|
1950
2128
|
* Reads [u16 length][ (address, u256) pairs ].
|
|
1951
2129
|
*/
|
|
1952
2130
|
readAddressValueTuple(t = !0) {
|
|
1953
|
-
const e = this.readU16(t), i = new
|
|
2131
|
+
const e = this.readU16(t), i = new Ve();
|
|
1954
2132
|
for (let r = 0; r < e; r++) {
|
|
1955
2133
|
const s = this.readAddress(), o = this.readU256(t);
|
|
1956
2134
|
if (i.has(s))
|
|
@@ -1959,6 +2137,32 @@ class qt {
|
|
|
1959
2137
|
}
|
|
1960
2138
|
return i;
|
|
1961
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
|
+
}
|
|
1962
2166
|
// --------------------------------------------------- //
|
|
1963
2167
|
getOffset() {
|
|
1964
2168
|
return this.currentOffset;
|
|
@@ -1991,33 +2195,64 @@ class qt {
|
|
|
1991
2195
|
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1992
2196
|
}
|
|
1993
2197
|
}
|
|
1994
|
-
class
|
|
2198
|
+
class C {
|
|
1995
2199
|
constructor(t = 0) {
|
|
1996
2200
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(t);
|
|
1997
2201
|
}
|
|
1998
2202
|
static estimateArrayOfBufferLength(t) {
|
|
1999
2203
|
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2000
|
-
let e =
|
|
2204
|
+
let e = ft;
|
|
2001
2205
|
for (let i = 0; i < t.length; i++)
|
|
2002
|
-
e +=
|
|
2206
|
+
e += dt + t[i].length;
|
|
2003
2207
|
return e;
|
|
2004
2208
|
}
|
|
2005
2209
|
writeU8(t) {
|
|
2006
2210
|
if (t > 255) throw new Error("u8 value is too large.");
|
|
2007
|
-
this.allocSafe(
|
|
2211
|
+
this.allocSafe(Ht), this.buffer.setUint8(this.currentOffset++, t);
|
|
2008
2212
|
}
|
|
2009
2213
|
writeU16(t, e = !0) {
|
|
2010
2214
|
if (t > 65535) throw new Error("u16 value is too large.");
|
|
2011
|
-
this.allocSafe(
|
|
2215
|
+
this.allocSafe(ft), this.buffer.setUint16(this.currentOffset, t, !e), this.currentOffset += 2;
|
|
2012
2216
|
}
|
|
2013
2217
|
writeU32(t, e = !0) {
|
|
2014
2218
|
if (t > 4294967295) throw new Error("u32 value is too large.");
|
|
2015
|
-
this.allocSafe(
|
|
2219
|
+
this.allocSafe(dt), this.buffer.setUint32(this.currentOffset, t, !e), this.currentOffset += 4;
|
|
2016
2220
|
}
|
|
2017
2221
|
writeU64(t, e = !0) {
|
|
2018
2222
|
if (t > 18446744073709551615n) throw new Error("u64 value is too large.");
|
|
2019
|
-
this.allocSafe(
|
|
2223
|
+
this.allocSafe(Wt), this.buffer.setBigUint64(this.currentOffset, t, !e), this.currentOffset += 8;
|
|
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;
|
|
2020
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
|
+
// ---------------------------------------------------------------- //
|
|
2021
2256
|
writeSelector(t) {
|
|
2022
2257
|
this.writeU32(t, !0);
|
|
2023
2258
|
}
|
|
@@ -2027,9 +2262,9 @@ class D {
|
|
|
2027
2262
|
writeI128(t, e = !0) {
|
|
2028
2263
|
if (t > 170141183460469231731687303715884105727n || t < -170141183460469231731687303715884105728n)
|
|
2029
2264
|
throw new Error("i128 value is too large.");
|
|
2030
|
-
this.allocSafe(
|
|
2031
|
-
const i = X.valueToUint8Array(t,
|
|
2032
|
-
if (i.byteLength !==
|
|
2265
|
+
this.allocSafe(Tt);
|
|
2266
|
+
const i = X.valueToUint8Array(t, Tt);
|
|
2267
|
+
if (i.byteLength !== Tt)
|
|
2033
2268
|
throw new Error(`Invalid i128 value: ${t}`);
|
|
2034
2269
|
if (e)
|
|
2035
2270
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2041,9 +2276,9 @@ class D {
|
|
|
2041
2276
|
writeU256(t, e = !0) {
|
|
2042
2277
|
if (t > 115792089237316195423570985008687907853269984665640564039457584007913129639935n && t < 0n)
|
|
2043
2278
|
throw new Error("u256 value is too large or negative.");
|
|
2044
|
-
this.allocSafe(
|
|
2279
|
+
this.allocSafe(At);
|
|
2045
2280
|
const i = X.valueToUint8Array(t);
|
|
2046
|
-
if (i.byteLength !==
|
|
2281
|
+
if (i.byteLength !== At)
|
|
2047
2282
|
throw new Error(`Invalid u256 value: ${t}`);
|
|
2048
2283
|
if (e)
|
|
2049
2284
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2055,9 +2290,9 @@ class D {
|
|
|
2055
2290
|
writeU128(t, e = !0) {
|
|
2056
2291
|
if (t > 340282366920938463463374607431768211455n && t < 0n)
|
|
2057
2292
|
throw new Error("u128 value is too large or negative.");
|
|
2058
|
-
this.allocSafe(
|
|
2059
|
-
const i = X.valueToUint8Array(t,
|
|
2060
|
-
if (i.byteLength !==
|
|
2293
|
+
this.allocSafe(It);
|
|
2294
|
+
const i = X.valueToUint8Array(t, It);
|
|
2295
|
+
if (i.byteLength !== It)
|
|
2061
2296
|
throw new Error(`Invalid u128 value: ${t}`);
|
|
2062
2297
|
if (e)
|
|
2063
2298
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2077,11 +2312,51 @@ class D {
|
|
|
2077
2312
|
}
|
|
2078
2313
|
writeStringWithLength(t) {
|
|
2079
2314
|
const i = new TextEncoder().encode(t);
|
|
2080
|
-
this.allocSafe(
|
|
2315
|
+
this.allocSafe(dt + i.length), this.writeU32(i.length), this.writeBytes(i);
|
|
2081
2316
|
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Writes an address (32 bytes MLDSA key hash only).
|
|
2319
|
+
*/
|
|
2082
2320
|
writeAddress(t) {
|
|
2083
2321
|
this.verifyAddress(t), this.writeBytes(t);
|
|
2084
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
|
+
}
|
|
2085
2360
|
getBuffer(t = !0) {
|
|
2086
2361
|
const e = new Uint8Array(this.buffer.byteLength);
|
|
2087
2362
|
for (let i = 0; i < this.buffer.byteLength; i++)
|
|
@@ -2092,7 +2367,7 @@ class D {
|
|
|
2092
2367
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(4);
|
|
2093
2368
|
}
|
|
2094
2369
|
toBytesReader() {
|
|
2095
|
-
return new
|
|
2370
|
+
return new jt(this.getBuffer());
|
|
2096
2371
|
}
|
|
2097
2372
|
getOffset() {
|
|
2098
2373
|
return this.currentOffset;
|
|
@@ -2116,11 +2391,23 @@ class D {
|
|
|
2116
2391
|
this.writeAddress(s), this.writeU256(o, e);
|
|
2117
2392
|
}
|
|
2118
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
|
+
}
|
|
2119
2406
|
writeBytesWithLength(t) {
|
|
2120
2407
|
this.writeU32(t.length), this.writeBytes(t);
|
|
2121
2408
|
}
|
|
2122
2409
|
writeArrayOfBuffer(t, e = !0) {
|
|
2123
|
-
const i =
|
|
2410
|
+
const i = C.estimateArrayOfBufferLength(t);
|
|
2124
2411
|
this.allocSafe(i), this.writeU16(t.length, e);
|
|
2125
2412
|
for (let r = 0; r < t.length; r++)
|
|
2126
2413
|
this.writeU32(t[r].length, e), this.writeBytes(t[r]);
|
|
@@ -2131,6 +2418,16 @@ class D {
|
|
|
2131
2418
|
for (let e = 0; e < t.length; e++)
|
|
2132
2419
|
this.writeAddress(t[e]);
|
|
2133
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
|
+
}
|
|
2134
2431
|
writeU32Array(t, e = !0) {
|
|
2135
2432
|
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2136
2433
|
this.writeU16(t.length, e);
|
|
@@ -2180,9 +2477,9 @@ class D {
|
|
|
2180
2477
|
this.writeBytesWithLength(t[e]);
|
|
2181
2478
|
}
|
|
2182
2479
|
verifyAddress(t) {
|
|
2183
|
-
if (t.byteLength >
|
|
2480
|
+
if (t.byteLength > k)
|
|
2184
2481
|
throw new Error(
|
|
2185
|
-
`Address is too long ${t.byteLength} > ${
|
|
2482
|
+
`Address is too long ${t.byteLength} > ${k} bytes`
|
|
2186
2483
|
);
|
|
2187
2484
|
}
|
|
2188
2485
|
resize(t) {
|
|
@@ -2195,7 +2492,7 @@ class D {
|
|
|
2195
2492
|
return new DataView(new ArrayBuffer(t));
|
|
2196
2493
|
}
|
|
2197
2494
|
}
|
|
2198
|
-
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 || {});
|
|
2199
2496
|
class q {
|
|
2200
2497
|
constructor(t, e, i = I) {
|
|
2201
2498
|
this.network = I, this.senderPubKey = t, this.contractSaltPubKey = e, this.network = i, this.xSenderPubKey = O(t);
|
|
@@ -2214,7 +2511,7 @@ class q {
|
|
|
2214
2511
|
return i.writeUIntBE(e, 0, 3), a.from([this.senderPubKey[0], ...i]);
|
|
2215
2512
|
}
|
|
2216
2513
|
getHeader(t, e = []) {
|
|
2217
|
-
const i = new
|
|
2514
|
+
const i = new C(12);
|
|
2218
2515
|
return i.writeBytes(this.buildHeader(e)), i.writeU64(t), a.from(i.getBuffer());
|
|
2219
2516
|
}
|
|
2220
2517
|
/**
|
|
@@ -2236,24 +2533,24 @@ class q {
|
|
|
2236
2533
|
}
|
|
2237
2534
|
encodeFeature(t, e) {
|
|
2238
2535
|
switch (t.opcode) {
|
|
2239
|
-
case
|
|
2536
|
+
case N.ACCESS_LIST:
|
|
2240
2537
|
return this.encodeAccessListFeature(t, e);
|
|
2241
|
-
case
|
|
2538
|
+
case N.EPOCH_SUBMISSION:
|
|
2242
2539
|
return this.encodeChallengeSubmission(
|
|
2243
2540
|
t,
|
|
2244
2541
|
e
|
|
2245
2542
|
);
|
|
2246
|
-
case
|
|
2543
|
+
case N.MLDSA_LINK_PUBKEY:
|
|
2247
2544
|
return this.encodeLinkRequest(t, e);
|
|
2248
2545
|
default:
|
|
2249
2546
|
throw new Error(`Unknown feature type: ${t.opcode}`);
|
|
2250
2547
|
}
|
|
2251
2548
|
}
|
|
2252
2549
|
encodeAccessListFeature(t, e) {
|
|
2253
|
-
const i = new
|
|
2550
|
+
const i = new C();
|
|
2254
2551
|
i.writeU16(Object.keys(t.data).length);
|
|
2255
2552
|
for (const r in t.data) {
|
|
2256
|
-
const s =
|
|
2553
|
+
const s = v.fromString(r), o = t.data[r];
|
|
2257
2554
|
i.writeAddress(s), i.writeU32(o.length);
|
|
2258
2555
|
for (const c of o) {
|
|
2259
2556
|
const u = a.from(c, "base64");
|
|
@@ -2262,16 +2559,16 @@ class q {
|
|
|
2262
2559
|
i.writeBytes(u);
|
|
2263
2560
|
}
|
|
2264
2561
|
}
|
|
2265
|
-
e.writeBytesWithLength(
|
|
2562
|
+
e.writeBytesWithLength(W.compress(a.from(i.getBuffer())));
|
|
2266
2563
|
}
|
|
2267
2564
|
encodeChallengeSubmission(t, e) {
|
|
2268
2565
|
if ("verifySignature" in t.data && !t.data.verifySignature())
|
|
2269
2566
|
throw new Error("Invalid signature in challenge submission feature");
|
|
2270
|
-
const i = new
|
|
2567
|
+
const i = new C();
|
|
2271
2568
|
i.writeBytes(t.data.publicKey.toBuffer()), i.writeBytes(t.data.solution), t.data.graffiti && i.writeBytesWithLength(t.data.graffiti), e.writeBytesWithLength(i.getBuffer());
|
|
2272
2569
|
}
|
|
2273
2570
|
encodeLinkRequest(t, e) {
|
|
2274
|
-
const i = t.data, r = new
|
|
2571
|
+
const i = t.data, r = new C();
|
|
2275
2572
|
if (r.writeU8(i.level), r.writeBytes(i.hashedPublicKey), r.writeBoolean(i.verifyRequest), i.verifyRequest) {
|
|
2276
2573
|
if (!i.publicKey || !i.mldsaSignature)
|
|
2277
2574
|
throw new Error(
|
|
@@ -2284,7 +2581,7 @@ class q {
|
|
|
2284
2581
|
r.writeBytes(i.legacySignature), e.writeBytesWithLength(r.getBuffer());
|
|
2285
2582
|
}
|
|
2286
2583
|
}
|
|
2287
|
-
class
|
|
2584
|
+
class de extends q {
|
|
2288
2585
|
constructor(t, e, i = I) {
|
|
2289
2586
|
super(t, e, i);
|
|
2290
2587
|
}
|
|
@@ -2304,7 +2601,7 @@ class oe extends q {
|
|
|
2304
2601
|
throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
2305
2602
|
i = a.concat([i, s]);
|
|
2306
2603
|
}
|
|
2307
|
-
const r =
|
|
2604
|
+
const r = W.compress(i);
|
|
2308
2605
|
return r.byteLength >= i.byteLength ? i : r;
|
|
2309
2606
|
}
|
|
2310
2607
|
/**
|
|
@@ -2325,12 +2622,12 @@ class oe extends q {
|
|
|
2325
2622
|
if (s && s.length) {
|
|
2326
2623
|
const f = s.sort(
|
|
2327
2624
|
(S, b) => S.priority - b.priority
|
|
2328
|
-
),
|
|
2625
|
+
), y = new C();
|
|
2329
2626
|
for (let S = 0; S < f.length; S++) {
|
|
2330
2627
|
const b = f[S];
|
|
2331
|
-
c.push(b.opcode), this.encodeFeature(b,
|
|
2628
|
+
c.push(b.opcode), this.encodeFeature(b, y);
|
|
2332
2629
|
}
|
|
2333
|
-
u.push(...this.splitBufferIntoChunks(a.from(
|
|
2630
|
+
u.push(...this.splitBufferIntoChunks(a.from(y.getBuffer())));
|
|
2334
2631
|
}
|
|
2335
2632
|
let h = [
|
|
2336
2633
|
this.getHeader(r, c),
|
|
@@ -2349,7 +2646,7 @@ class oe extends q {
|
|
|
2349
2646
|
this.contractSaltPubKey,
|
|
2350
2647
|
g.OP_CHECKSIGVERIFY,
|
|
2351
2648
|
g.OP_HASH160,
|
|
2352
|
-
|
|
2649
|
+
gt(e),
|
|
2353
2650
|
g.OP_EQUALVERIFY,
|
|
2354
2651
|
g.OP_DEPTH,
|
|
2355
2652
|
g.OP_1,
|
|
@@ -2366,12 +2663,12 @@ class oe extends q {
|
|
|
2366
2663
|
g.OP_ENDIF
|
|
2367
2664
|
);
|
|
2368
2665
|
const l = h.flat(), d = L(l);
|
|
2369
|
-
if (!
|
|
2666
|
+
if (!F(d))
|
|
2370
2667
|
throw new Error("Failed to decompile script??");
|
|
2371
2668
|
return d;
|
|
2372
2669
|
}
|
|
2373
2670
|
}
|
|
2374
|
-
class
|
|
2671
|
+
class qe extends q {
|
|
2375
2672
|
constructor(t, e = I) {
|
|
2376
2673
|
super(t, void 0, e);
|
|
2377
2674
|
}
|
|
@@ -2383,13 +2680,13 @@ class Re extends q {
|
|
|
2383
2680
|
*/
|
|
2384
2681
|
compile(t) {
|
|
2385
2682
|
const e = t.flat(), i = L(e);
|
|
2386
|
-
if (!
|
|
2683
|
+
if (!F(i))
|
|
2387
2684
|
throw new Error("Failed to decompile script??");
|
|
2388
2685
|
return i;
|
|
2389
2686
|
}
|
|
2390
2687
|
}
|
|
2391
|
-
const
|
|
2392
|
-
class
|
|
2688
|
+
const $e = 0, Xe = a.from([$e]);
|
|
2689
|
+
class Vt extends q {
|
|
2393
2690
|
constructor(t, e, i = I) {
|
|
2394
2691
|
super(t, e, i);
|
|
2395
2692
|
}
|
|
@@ -2412,7 +2709,7 @@ class Ft extends q {
|
|
|
2412
2709
|
s,
|
|
2413
2710
|
o
|
|
2414
2711
|
), u = L(c);
|
|
2415
|
-
if (!
|
|
2712
|
+
if (!F(u))
|
|
2416
2713
|
throw new Error("Failed to decompile script??");
|
|
2417
2714
|
return u;
|
|
2418
2715
|
}
|
|
@@ -2421,10 +2718,10 @@ class Ft extends q {
|
|
|
2421
2718
|
const c = this.splitBufferIntoChunks(t), u = s ? this.splitBufferIntoChunks(s) : [], h = [], l = [];
|
|
2422
2719
|
if (o && o.length) {
|
|
2423
2720
|
const p = o.sort(
|
|
2424
|
-
(
|
|
2425
|
-
), f = new
|
|
2426
|
-
for (let
|
|
2427
|
-
const S = p[
|
|
2721
|
+
(y, S) => y.priority - S.priority
|
|
2722
|
+
), f = new C();
|
|
2723
|
+
for (let y = 0; y < p.length; y++) {
|
|
2724
|
+
const S = p[y];
|
|
2428
2725
|
h.push(S.opcode), this.encodeFeature(S, f);
|
|
2429
2726
|
}
|
|
2430
2727
|
l.push(...this.splitBufferIntoChunks(a.from(f.getBuffer())));
|
|
@@ -2464,7 +2761,7 @@ class Ft extends q {
|
|
|
2464
2761
|
].flat();
|
|
2465
2762
|
}
|
|
2466
2763
|
}
|
|
2467
|
-
class
|
|
2764
|
+
class P extends De {
|
|
2468
2765
|
constructor(t, e = I) {
|
|
2469
2766
|
if (super(), this.logColor = "#4a90d9", t.length !== 33)
|
|
2470
2767
|
throw new Error("Public key must be 33 bytes (compressed)");
|
|
@@ -2495,21 +2792,21 @@ class E extends ve {
|
|
|
2495
2792
|
this.WITNESS_FIXED_OVERHEAD = 112;
|
|
2496
2793
|
}
|
|
2497
2794
|
static {
|
|
2498
|
-
this.WITNESS_PER_CHUNK_OVERHEAD =
|
|
2795
|
+
this.WITNESS_PER_CHUNK_OVERHEAD = P.MAX_CHUNK_SIZE + 1 + P.BYTES_PER_COMMITMENT;
|
|
2499
2796
|
}
|
|
2500
2797
|
static {
|
|
2501
2798
|
this.MAX_CHUNKS_PER_OUTPUT = Math.floor(
|
|
2502
|
-
(
|
|
2799
|
+
(P.MAX_WITNESS_SIZE - P.WITNESS_FIXED_OVERHEAD) / P.WITNESS_PER_CHUNK_OVERHEAD
|
|
2503
2800
|
);
|
|
2504
2801
|
}
|
|
2505
2802
|
static {
|
|
2506
2803
|
this.INPUT_BASE_WEIGHT = 164;
|
|
2507
2804
|
}
|
|
2508
2805
|
static {
|
|
2509
|
-
this.INPUT_WITNESS_WEIGHT_MAX =
|
|
2806
|
+
this.INPUT_WITNESS_WEIGHT_MAX = P.MAX_WITNESS_SIZE;
|
|
2510
2807
|
}
|
|
2511
2808
|
static {
|
|
2512
|
-
this.WEIGHT_PER_INPUT =
|
|
2809
|
+
this.WEIGHT_PER_INPUT = P.INPUT_BASE_WEIGHT + P.INPUT_WITNESS_WEIGHT_MAX;
|
|
2513
2810
|
}
|
|
2514
2811
|
/**
|
|
2515
2812
|
* Calculate the maximum number of inputs per standard reveal transaction.
|
|
@@ -2520,8 +2817,8 @@ class E extends ve {
|
|
|
2520
2817
|
* @returns Maximum inputs per reveal tx (~38 with max chunks)
|
|
2521
2818
|
*/
|
|
2522
2819
|
static calculateMaxInputsPerTx() {
|
|
2523
|
-
const i =
|
|
2524
|
-
return Math.floor(i /
|
|
2820
|
+
const i = P.MAX_STANDARD_WEIGHT - 40 - 200;
|
|
2821
|
+
return Math.floor(i / P.WEIGHT_PER_INPUT);
|
|
2525
2822
|
}
|
|
2526
2823
|
/**
|
|
2527
2824
|
* Calculate maximum data per standard reveal transaction.
|
|
@@ -2529,7 +2826,7 @@ class E extends ve {
|
|
|
2529
2826
|
* @returns Maximum data in bytes (~300KB with batched chunks at 70 chunks/output)
|
|
2530
2827
|
*/
|
|
2531
2828
|
static calculateMaxDataPerTx() {
|
|
2532
|
-
return
|
|
2829
|
+
return P.calculateMaxInputsPerTx() * P.MAX_CHUNKS_PER_OUTPUT * P.MAX_CHUNK_SIZE;
|
|
2533
2830
|
}
|
|
2534
2831
|
/**
|
|
2535
2832
|
* Estimate the number of P2WSH outputs needed for a given data size.
|
|
@@ -2539,7 +2836,7 @@ class E extends ve {
|
|
|
2539
2836
|
*/
|
|
2540
2837
|
static estimateOutputCount(t) {
|
|
2541
2838
|
return Math.ceil(
|
|
2542
|
-
t / (
|
|
2839
|
+
t / (P.MAX_CHUNKS_PER_OUTPUT * P.MAX_CHUNK_SIZE)
|
|
2543
2840
|
);
|
|
2544
2841
|
}
|
|
2545
2842
|
/**
|
|
@@ -2549,7 +2846,7 @@ class E extends ve {
|
|
|
2549
2846
|
* @returns Number of 80-byte chunks needed
|
|
2550
2847
|
*/
|
|
2551
2848
|
static estimateChunkCount(t) {
|
|
2552
|
-
return Math.ceil(t /
|
|
2849
|
+
return Math.ceil(t / P.MAX_CHUNK_SIZE);
|
|
2553
2850
|
}
|
|
2554
2851
|
/**
|
|
2555
2852
|
* Validate that a witness script is a valid multi-hash committed script.
|
|
@@ -2561,7 +2858,7 @@ class E extends ve {
|
|
|
2561
2858
|
*/
|
|
2562
2859
|
static validateHashCommittedScript(t) {
|
|
2563
2860
|
try {
|
|
2564
|
-
const e =
|
|
2861
|
+
const e = F(t);
|
|
2565
2862
|
if (!e || e.length < 5)
|
|
2566
2863
|
return !1;
|
|
2567
2864
|
const i = e.length - 1;
|
|
@@ -2591,8 +2888,8 @@ class E extends ve {
|
|
|
2591
2888
|
*/
|
|
2592
2889
|
static extractDataHashes(t) {
|
|
2593
2890
|
try {
|
|
2594
|
-
const e =
|
|
2595
|
-
if (!e || !
|
|
2891
|
+
const e = F(t);
|
|
2892
|
+
if (!e || !P.validateHashCommittedScript(t))
|
|
2596
2893
|
return null;
|
|
2597
2894
|
const i = e.slice(0, -2), r = [];
|
|
2598
2895
|
for (let s = 0; s < i.length; s += 3)
|
|
@@ -2610,8 +2907,8 @@ class E extends ve {
|
|
|
2610
2907
|
*/
|
|
2611
2908
|
static extractPublicKey(t) {
|
|
2612
2909
|
try {
|
|
2613
|
-
const e =
|
|
2614
|
-
return !e || !
|
|
2910
|
+
const e = F(t);
|
|
2911
|
+
return !e || !P.validateHashCommittedScript(t) ? null : e[e.length - 2];
|
|
2615
2912
|
} catch {
|
|
2616
2913
|
return null;
|
|
2617
2914
|
}
|
|
@@ -2624,11 +2921,11 @@ class E extends ve {
|
|
|
2624
2921
|
* @returns true if all chunks match their commitments
|
|
2625
2922
|
*/
|
|
2626
2923
|
static verifyChunkCommitments(t, e) {
|
|
2627
|
-
const i =
|
|
2924
|
+
const i = P.extractDataHashes(e);
|
|
2628
2925
|
if (!i || i.length !== t.length)
|
|
2629
2926
|
return !1;
|
|
2630
2927
|
for (let r = 0; r < t.length; r++) {
|
|
2631
|
-
const s =
|
|
2928
|
+
const s = gt(t[r]);
|
|
2632
2929
|
if (!i[r].equals(s))
|
|
2633
2930
|
return !1;
|
|
2634
2931
|
}
|
|
@@ -2643,7 +2940,7 @@ class E extends ve {
|
|
|
2643
2940
|
* @returns Fee estimates
|
|
2644
2941
|
*/
|
|
2645
2942
|
static estimateFees(t, e, i = 0.7) {
|
|
2646
|
-
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;
|
|
2647
2944
|
return {
|
|
2648
2945
|
compressedSize: r,
|
|
2649
2946
|
outputCount: s,
|
|
@@ -2651,10 +2948,10 @@ class E extends ve {
|
|
|
2651
2948
|
setupVBytes: l,
|
|
2652
2949
|
revealVBytes: p,
|
|
2653
2950
|
setupFee: f,
|
|
2654
|
-
revealFee:
|
|
2951
|
+
revealFee: y,
|
|
2655
2952
|
totalFee: S,
|
|
2656
2953
|
outputsValue: b,
|
|
2657
|
-
totalCost:
|
|
2954
|
+
totalCost: K
|
|
2658
2955
|
};
|
|
2659
2956
|
}
|
|
2660
2957
|
/**
|
|
@@ -2662,7 +2959,7 @@ class E extends ve {
|
|
|
2662
2959
|
* HASH160 = RIPEMD160(SHA256(data))
|
|
2663
2960
|
*/
|
|
2664
2961
|
hashChunk(t) {
|
|
2665
|
-
return
|
|
2962
|
+
return gt(t);
|
|
2666
2963
|
}
|
|
2667
2964
|
/**
|
|
2668
2965
|
* Generate a hash-committed witness script for multiple data chunks.
|
|
@@ -2684,9 +2981,9 @@ class E extends ve {
|
|
|
2684
2981
|
generateWitnessScript(t) {
|
|
2685
2982
|
if (t.length === 0)
|
|
2686
2983
|
throw new Error("At least one data hash is required");
|
|
2687
|
-
if (t.length >
|
|
2984
|
+
if (t.length > P.MAX_CHUNKS_PER_OUTPUT)
|
|
2688
2985
|
throw new Error(
|
|
2689
|
-
`Too many chunks: ${t.length} exceeds limit of ${
|
|
2986
|
+
`Too many chunks: ${t.length} exceeds limit of ${P.MAX_CHUNKS_PER_OUTPUT}`
|
|
2690
2987
|
);
|
|
2691
2988
|
for (const i of t)
|
|
2692
2989
|
if (i.length !== 20)
|
|
@@ -2703,7 +3000,7 @@ class E extends ve {
|
|
|
2703
3000
|
* @returns P2WSH address info
|
|
2704
3001
|
*/
|
|
2705
3002
|
generateP2WSHAddress(t) {
|
|
2706
|
-
const e =
|
|
3003
|
+
const e = pt({
|
|
2707
3004
|
redeem: { output: t },
|
|
2708
3005
|
network: this.network
|
|
2709
3006
|
});
|
|
@@ -2725,10 +3022,10 @@ class E extends ve {
|
|
|
2725
3022
|
* @param maxChunkSize Maximum bytes per stack item (default: 80, P2WSH stack item limit)
|
|
2726
3023
|
* @returns Array of hash-committed P2WSH outputs
|
|
2727
3024
|
*/
|
|
2728
|
-
prepareChunks(t, e =
|
|
2729
|
-
if (e >
|
|
3025
|
+
prepareChunks(t, e = P.MAX_CHUNK_SIZE) {
|
|
3026
|
+
if (e > P.MAX_CHUNK_SIZE)
|
|
2730
3027
|
throw new Error(
|
|
2731
|
-
`Chunk size ${e} exceeds P2WSH stack item limit of ${
|
|
3028
|
+
`Chunk size ${e} exceeds P2WSH stack item limit of ${P.MAX_CHUNK_SIZE}`
|
|
2732
3029
|
);
|
|
2733
3030
|
if (t.length === 0)
|
|
2734
3031
|
throw new Error("Data cannot be empty");
|
|
@@ -2743,7 +3040,7 @@ class E extends ve {
|
|
|
2743
3040
|
for (; o < i.length; ) {
|
|
2744
3041
|
const u = i.slice(
|
|
2745
3042
|
o,
|
|
2746
|
-
o +
|
|
3043
|
+
o + P.MAX_CHUNKS_PER_OUTPUT
|
|
2747
3044
|
), h = u, l = h.map((f) => this.hashChunk(f)), d = this.generateWitnessScript(l), p = this.generateP2WSHAddress(d);
|
|
2748
3045
|
s.push({
|
|
2749
3046
|
address: p.address,
|
|
@@ -2760,7 +3057,7 @@ class E extends ve {
|
|
|
2760
3057
|
), s;
|
|
2761
3058
|
}
|
|
2762
3059
|
}
|
|
2763
|
-
class
|
|
3060
|
+
class ir extends q {
|
|
2764
3061
|
constructor(t, e = I) {
|
|
2765
3062
|
super(t, a.alloc(0), e);
|
|
2766
3063
|
}
|
|
@@ -2780,7 +3077,7 @@ class Ji extends q {
|
|
|
2780
3077
|
throw new Error(`Public key must be 33 bytes, got ${s.byteLength} bytes.`);
|
|
2781
3078
|
i = a.concat([i, s]);
|
|
2782
3079
|
}
|
|
2783
|
-
const r =
|
|
3080
|
+
const r = W.compress(i);
|
|
2784
3081
|
return r.byteLength >= i.byteLength ? i : r;
|
|
2785
3082
|
}
|
|
2786
3083
|
/**
|
|
@@ -2800,12 +3097,12 @@ class Ji extends q {
|
|
|
2800
3097
|
if (s && s.length) {
|
|
2801
3098
|
const f = s.sort(
|
|
2802
3099
|
(S, b) => S.priority - b.priority
|
|
2803
|
-
),
|
|
3100
|
+
), y = new C();
|
|
2804
3101
|
for (let S = 0; S < f.length; S++) {
|
|
2805
3102
|
const b = f[S];
|
|
2806
|
-
c.push(b.opcode), this.encodeFeature(b,
|
|
3103
|
+
c.push(b.opcode), this.encodeFeature(b, y);
|
|
2807
3104
|
}
|
|
2808
|
-
u.push(...this.splitBufferIntoChunks(a.from(
|
|
3105
|
+
u.push(...this.splitBufferIntoChunks(a.from(y.getBuffer())));
|
|
2809
3106
|
}
|
|
2810
3107
|
let h = [
|
|
2811
3108
|
this.getHeader(r, c),
|
|
@@ -2836,12 +3133,12 @@ class Ji extends q {
|
|
|
2836
3133
|
g.OP_ENDIF
|
|
2837
3134
|
);
|
|
2838
3135
|
const l = h.flat(), d = L(l);
|
|
2839
|
-
if (!
|
|
3136
|
+
if (!F(d))
|
|
2840
3137
|
throw new Error("Failed to decompile script??");
|
|
2841
3138
|
return d;
|
|
2842
3139
|
}
|
|
2843
3140
|
}
|
|
2844
|
-
class
|
|
3141
|
+
class kt {
|
|
2845
3142
|
static {
|
|
2846
3143
|
this.MAXIMUM_SUPPORTED_SIGNATURE = 255;
|
|
2847
3144
|
}
|
|
@@ -2850,13 +3147,13 @@ class Pt {
|
|
|
2850
3147
|
throw new Error("Minimum signatures must be greater than 1");
|
|
2851
3148
|
if (t.length < e)
|
|
2852
3149
|
throw new Error("The amount of public keys is lower than the minimum required");
|
|
2853
|
-
if (e >
|
|
3150
|
+
if (e > kt.MAXIMUM_SUPPORTED_SIGNATURE)
|
|
2854
3151
|
throw new Error(
|
|
2855
|
-
`The maximum amount of signatures is ${
|
|
3152
|
+
`The maximum amount of signatures is ${kt.MAXIMUM_SUPPORTED_SIGNATURE}`
|
|
2856
3153
|
);
|
|
2857
3154
|
const r = a.alloc(1);
|
|
2858
3155
|
r.writeUInt8(e), t = t.filter(
|
|
2859
|
-
(d, p, f) => p === f.findIndex((
|
|
3156
|
+
(d, p, f) => p === f.findIndex((y) => d.equals(y))
|
|
2860
3157
|
), t = t.sort((d, p) => d.compare(p));
|
|
2861
3158
|
let s = !1;
|
|
2862
3159
|
const o = t.map((d) => {
|
|
@@ -2879,12 +3176,12 @@ class Pt {
|
|
|
2879
3176
|
g.OP_NUMEQUAL
|
|
2880
3177
|
// Use NUMEQUALVERIFY to ensure the correct number of signatures
|
|
2881
3178
|
].flat(), h = L(u);
|
|
2882
|
-
if (!
|
|
3179
|
+
if (!F(h))
|
|
2883
3180
|
throw new Error("Failed to decompile script.");
|
|
2884
3181
|
return h;
|
|
2885
3182
|
}
|
|
2886
3183
|
}
|
|
2887
|
-
class
|
|
3184
|
+
class Ut extends q {
|
|
2888
3185
|
static {
|
|
2889
3186
|
this.P2WDA_VERSION = 1;
|
|
2890
3187
|
}
|
|
@@ -2924,8 +3221,8 @@ class Et extends q {
|
|
|
2924
3221
|
throw new Error("Contract salt public key not set");
|
|
2925
3222
|
if (e.length !== 32)
|
|
2926
3223
|
throw new Error("Contract secret must be exactly 32 bytes");
|
|
2927
|
-
const o = new
|
|
2928
|
-
o.writeU8(
|
|
3224
|
+
const o = new C();
|
|
3225
|
+
o.writeU8(Ut.P2WDA_VERSION);
|
|
2929
3226
|
const c = s.sort((u, h) => u.priority - h.priority);
|
|
2930
3227
|
return o.writeBytes(
|
|
2931
3228
|
this.getHeader(
|
|
@@ -2953,23 +3250,23 @@ class Et extends q {
|
|
|
2953
3250
|
}
|
|
2954
3251
|
}
|
|
2955
3252
|
ot(G);
|
|
2956
|
-
class
|
|
3253
|
+
class fe {
|
|
2957
3254
|
// Generate a valid SegWit address from random bytes
|
|
2958
3255
|
static generatePKSH(t, e) {
|
|
2959
3256
|
if (t.length !== 32) throw new Error("Invalid hash length");
|
|
2960
|
-
const i =
|
|
3257
|
+
const i = Bi(t);
|
|
2961
3258
|
return this.toSegwitAddress(i, e);
|
|
2962
3259
|
}
|
|
2963
3260
|
// Generate a valid Taproot address from a public key
|
|
2964
3261
|
static generateTaprootAddress(t, e) {
|
|
2965
3262
|
if (t.length !== 32) throw new Error("Invalid public key length");
|
|
2966
|
-
const i =
|
|
2967
|
-
return i.unshift(1),
|
|
3263
|
+
const i = Rt.bech32m.toWords(t);
|
|
3264
|
+
return i.unshift(1), Rt.bech32m.encode(e.bech32, i);
|
|
2968
3265
|
}
|
|
2969
3266
|
// Convert a hash to a SegWit address
|
|
2970
3267
|
static toSegwitAddress(t, e) {
|
|
2971
|
-
const i =
|
|
2972
|
-
return i.unshift(0),
|
|
3268
|
+
const i = Rt.bech32.toWords(t);
|
|
3269
|
+
return i.unshift(0), Rt.bech32.encode(e.bech32, i);
|
|
2973
3270
|
}
|
|
2974
3271
|
}
|
|
2975
3272
|
class tt {
|
|
@@ -2977,7 +3274,7 @@ class tt {
|
|
|
2977
3274
|
this.TAP_SCRIPT_VERSION = 192;
|
|
2978
3275
|
}
|
|
2979
3276
|
static getContractAddress(t) {
|
|
2980
|
-
const e = t.network || I, r = new
|
|
3277
|
+
const e = t.network || I, r = new Vt(
|
|
2981
3278
|
t.deployerPubKey,
|
|
2982
3279
|
O(t.contractSaltPubKey),
|
|
2983
3280
|
e
|
|
@@ -3004,7 +3301,7 @@ class tt {
|
|
|
3004
3301
|
return tt.generateAddressFromScript(t, o);
|
|
3005
3302
|
}
|
|
3006
3303
|
static verifyControlBlock(t, e) {
|
|
3007
|
-
const i = t.network || I, s = new
|
|
3304
|
+
const i = t.network || I, s = new Vt(
|
|
3008
3305
|
t.deployerPubKey,
|
|
3009
3306
|
O(t.contractSaltPubKey),
|
|
3010
3307
|
i
|
|
@@ -3052,7 +3349,7 @@ class tt {
|
|
|
3052
3349
|
}
|
|
3053
3350
|
}
|
|
3054
3351
|
ot(G);
|
|
3055
|
-
class
|
|
3352
|
+
class pe {
|
|
3056
3353
|
/**
|
|
3057
3354
|
* Tweak a signer
|
|
3058
3355
|
* @param {Signer} signer - The signer to tweak
|
|
@@ -3063,22 +3360,22 @@ class ce {
|
|
|
3063
3360
|
let i = t.privateKey;
|
|
3064
3361
|
if (!i)
|
|
3065
3362
|
throw new Error("Private key is required for tweaking signer!");
|
|
3066
|
-
t.publicKey[0] === 3 && (i =
|
|
3067
|
-
const r =
|
|
3363
|
+
t.publicKey[0] === 3 && (i = Mt.privateNegate(i));
|
|
3364
|
+
const r = Mt.privateAdd(
|
|
3068
3365
|
i,
|
|
3069
|
-
|
|
3366
|
+
xi(O(a.from(t.publicKey)), e.tweakHash)
|
|
3070
3367
|
);
|
|
3071
3368
|
if (!r)
|
|
3072
3369
|
throw new Error("Invalid tweaked private key!");
|
|
3073
3370
|
return A.fromPrivateKey(a.from(r), e.network);
|
|
3074
3371
|
}
|
|
3075
3372
|
}
|
|
3076
|
-
function
|
|
3373
|
+
function Ye(n) {
|
|
3077
3374
|
return typeof n == "object" && n !== null && "web3" in n && typeof n.web3 == "object" && "getMLDSAPublicKey" in n.web3 && "signMLDSAMessage" in n.web3;
|
|
3078
3375
|
}
|
|
3079
|
-
class
|
|
3376
|
+
class rr {
|
|
3080
3377
|
sha256(t) {
|
|
3081
|
-
return
|
|
3378
|
+
return Fe(a.from(t));
|
|
3082
3379
|
}
|
|
3083
3380
|
/**
|
|
3084
3381
|
* Attempts to sign a message using OP_WALLET if available in browser environment.
|
|
@@ -3206,7 +3503,7 @@ class tr {
|
|
|
3206
3503
|
* @returns {SignedMessage} The Schnorr signature.
|
|
3207
3504
|
*/
|
|
3208
3505
|
tweakAndSignMessage(t, e, i) {
|
|
3209
|
-
const r =
|
|
3506
|
+
const r = pe.tweakSigner(t, { network: i });
|
|
3210
3507
|
return this.signMessage(r, e);
|
|
3211
3508
|
}
|
|
3212
3509
|
/**
|
|
@@ -3221,7 +3518,7 @@ class tr {
|
|
|
3221
3518
|
throw new Error("Private key not found in keypair.");
|
|
3222
3519
|
const i = this.sha256(e);
|
|
3223
3520
|
return {
|
|
3224
|
-
signature:
|
|
3521
|
+
signature: Mt.signSchnorr(i, t.privateKey),
|
|
3225
3522
|
message: i
|
|
3226
3523
|
};
|
|
3227
3524
|
}
|
|
@@ -3237,7 +3534,7 @@ class tr {
|
|
|
3237
3534
|
if (typeof e == "string" && (e = a.from(e, "utf-8")), i.length !== 64)
|
|
3238
3535
|
throw new Error("Invalid signature length.");
|
|
3239
3536
|
const r = this.sha256(e);
|
|
3240
|
-
return
|
|
3537
|
+
return Mt.verifySchnorr(r, O(a.from(t)), i);
|
|
3241
3538
|
}
|
|
3242
3539
|
/**
|
|
3243
3540
|
* Tweak the public key and verify a signature.
|
|
@@ -3292,10 +3589,10 @@ class tr {
|
|
|
3292
3589
|
if (typeof window > "u")
|
|
3293
3590
|
return null;
|
|
3294
3591
|
const t = window;
|
|
3295
|
-
return !t.opnet || !
|
|
3592
|
+
return !t.opnet || !Ye(t.opnet) ? null : t.opnet;
|
|
3296
3593
|
}
|
|
3297
3594
|
}
|
|
3298
|
-
const st = new
|
|
3595
|
+
const st = new rr();
|
|
3299
3596
|
ot(G);
|
|
3300
3597
|
class Z {
|
|
3301
3598
|
/**
|
|
@@ -3308,16 +3605,16 @@ class Z {
|
|
|
3308
3605
|
* @param chainCode - Optional chain code for BIP32 derivation (32 bytes)
|
|
3309
3606
|
* @throws {Error} If the private keys are invalid
|
|
3310
3607
|
*/
|
|
3311
|
-
constructor(t, e, i = I, r =
|
|
3608
|
+
constructor(t, e, i = I, r = E.MLDSASecurityLevel.LEVEL2, s) {
|
|
3312
3609
|
this.network = i, this._securityLevel = r;
|
|
3313
3610
|
const o = t.startsWith("0x") ? t.replace("0x", "") : t;
|
|
3314
|
-
|
|
3611
|
+
D.isValidHex(o) ? this._keypair = A.fromPrivateKey(
|
|
3315
3612
|
a.from(o, "hex"),
|
|
3316
3613
|
this.network
|
|
3317
3614
|
) : this._keypair = A.fromWIF(o, this.network);
|
|
3318
3615
|
const c = e.startsWith("0x") ? e.replace("0x", "") : e;
|
|
3319
|
-
if (
|
|
3320
|
-
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;
|
|
3321
3618
|
let f;
|
|
3322
3619
|
if (u.length === l)
|
|
3323
3620
|
f = u;
|
|
@@ -3329,15 +3626,15 @@ class Z {
|
|
|
3329
3626
|
);
|
|
3330
3627
|
if (s && s.length !== 32)
|
|
3331
3628
|
throw new Error("Chain code must be 32 bytes");
|
|
3332
|
-
this._chainCode = s || a.alloc(32), this._mldsaKeypair =
|
|
3629
|
+
this._chainCode = s || a.alloc(32), this._mldsaKeypair = E.QuantumBIP32Factory.fromPrivateKey(
|
|
3333
3630
|
f,
|
|
3334
3631
|
this._chainCode,
|
|
3335
3632
|
this.network,
|
|
3336
3633
|
r
|
|
3337
3634
|
);
|
|
3338
3635
|
} else
|
|
3339
|
-
this._mldsaKeypair =
|
|
3340
|
-
this._bufferPubKey = this._keypair.publicKey, this._address = new
|
|
3636
|
+
this._mldsaKeypair = E.QuantumBIP32Factory.fromBase58(c), this._chainCode = a.from(this._mldsaKeypair.chainCode), this._securityLevel = this._mldsaKeypair.securityLevel;
|
|
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();
|
|
3341
3638
|
}
|
|
3342
3639
|
/**
|
|
3343
3640
|
* Get the address for the wallet
|
|
@@ -3464,7 +3761,7 @@ class Z {
|
|
|
3464
3761
|
* @param chainCode - Optional chain code for BIP32 derivation
|
|
3465
3762
|
* @returns A Wallet instance
|
|
3466
3763
|
*/
|
|
3467
|
-
static fromWif(t, e, i = I, r =
|
|
3764
|
+
static fromWif(t, e, i = I, r = E.MLDSASecurityLevel.LEVEL2, s) {
|
|
3468
3765
|
return new Z(t, e, i, r, s);
|
|
3469
3766
|
}
|
|
3470
3767
|
/**
|
|
@@ -3474,7 +3771,7 @@ class Z {
|
|
|
3474
3771
|
* @param securityLevel - The ML-DSA security level (default: LEVEL2/44)
|
|
3475
3772
|
* @returns A new Wallet instance with randomly generated keys
|
|
3476
3773
|
*/
|
|
3477
|
-
static generate(t = I, e =
|
|
3774
|
+
static generate(t = I, e = E.MLDSASecurityLevel.LEVEL2) {
|
|
3478
3775
|
const i = A.generateWallet(t, e);
|
|
3479
3776
|
if (!i.quantumPrivateKey)
|
|
3480
3777
|
throw new Error("Failed to generate quantum keys");
|
|
@@ -3495,7 +3792,7 @@ class Z {
|
|
|
3495
3792
|
* @param chainCode - Optional chain code for BIP32 derivation
|
|
3496
3793
|
* @returns A Wallet instance
|
|
3497
3794
|
*/
|
|
3498
|
-
static fromPrivateKeys(t, e, i = I, r =
|
|
3795
|
+
static fromPrivateKeys(t, e, i = I, r = E.MLDSASecurityLevel.LEVEL2, s) {
|
|
3499
3796
|
return new Z(
|
|
3500
3797
|
t,
|
|
3501
3798
|
e,
|
|
@@ -3567,8 +3864,8 @@ class Z {
|
|
|
3567
3864
|
);
|
|
3568
3865
|
}
|
|
3569
3866
|
}
|
|
3570
|
-
var
|
|
3571
|
-
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) {
|
|
3572
3869
|
switch (n) {
|
|
3573
3870
|
case 44:
|
|
3574
3871
|
return "BIP44: Legacy addresses (P2PKH), widely used by Unisat and other wallets";
|
|
@@ -3582,12 +3879,12 @@ function er(n) {
|
|
|
3582
3879
|
return "Unknown BIP standard";
|
|
3583
3880
|
}
|
|
3584
3881
|
}
|
|
3585
|
-
function
|
|
3882
|
+
function Ge(n, t, e, i, r) {
|
|
3586
3883
|
return `m/${n}'/${t}'/${e}'/${i}/${r}`;
|
|
3587
3884
|
}
|
|
3588
3885
|
ot(G);
|
|
3589
|
-
const
|
|
3590
|
-
class
|
|
3886
|
+
const nr = E.BIP32Factory(G);
|
|
3887
|
+
class ge {
|
|
3591
3888
|
/**
|
|
3592
3889
|
* Create a new Mnemonic instance from an existing phrase
|
|
3593
3890
|
*
|
|
@@ -3597,10 +3894,10 @@ class ue {
|
|
|
3597
3894
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
3598
3895
|
* @throws {Error} If the mnemonic phrase is invalid
|
|
3599
3896
|
*/
|
|
3600
|
-
constructor(t, e = "", i = I, r =
|
|
3601
|
-
if (!
|
|
3897
|
+
constructor(t, e = "", i = I, r = E.MLDSASecurityLevel.LEVEL2) {
|
|
3898
|
+
if (!wt.validateMnemonic(t))
|
|
3602
3899
|
throw new Error("Invalid mnemonic phrase");
|
|
3603
|
-
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(
|
|
3604
3901
|
this._seed,
|
|
3605
3902
|
this._network,
|
|
3606
3903
|
this._securityLevel
|
|
@@ -3646,8 +3943,8 @@ class ue {
|
|
|
3646
3943
|
* @param strength - The entropy strength in bits (default: 256 for 24 words)
|
|
3647
3944
|
* @returns A new random mnemonic phrase
|
|
3648
3945
|
*/
|
|
3649
|
-
static generatePhrase(t =
|
|
3650
|
-
return
|
|
3946
|
+
static generatePhrase(t = zt.MAXIMUM) {
|
|
3947
|
+
return wt.generateMnemonic(t);
|
|
3651
3948
|
}
|
|
3652
3949
|
/**
|
|
3653
3950
|
* Generate a new Mnemonic instance with a random phrase
|
|
@@ -3658,9 +3955,9 @@ class ue {
|
|
|
3658
3955
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
3659
3956
|
* @returns A new Mnemonic instance
|
|
3660
3957
|
*/
|
|
3661
|
-
static generate(t =
|
|
3662
|
-
const s =
|
|
3663
|
-
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);
|
|
3664
3961
|
}
|
|
3665
3962
|
/**
|
|
3666
3963
|
* Validate a mnemonic phrase
|
|
@@ -3669,7 +3966,7 @@ class ue {
|
|
|
3669
3966
|
* @returns True if the phrase is valid, false otherwise
|
|
3670
3967
|
*/
|
|
3671
3968
|
static validate(t) {
|
|
3672
|
-
return
|
|
3969
|
+
return wt.validateMnemonic(t);
|
|
3673
3970
|
}
|
|
3674
3971
|
/**
|
|
3675
3972
|
* Derive a wallet at a specific index using BIP360 (quantum) and configurable BIP standard (classical) paths
|
|
@@ -3695,7 +3992,7 @@ class ue {
|
|
|
3695
3992
|
* const wallet3 = mnemonic.derive(0, 0, false, BIPStandard.BIP86);
|
|
3696
3993
|
* ```
|
|
3697
3994
|
*/
|
|
3698
|
-
derive(t = 0, e = 0, i = !1, r =
|
|
3995
|
+
derive(t = 0, e = 0, i = !1, r = Et.BIP84) {
|
|
3699
3996
|
const s = this.buildClassicalPath(e, t, i, r), o = this._classicalRoot.derivePath(s);
|
|
3700
3997
|
if (!o.privateKey)
|
|
3701
3998
|
throw new Error(`Failed to derive classical private key at index ${t}`);
|
|
@@ -3725,7 +4022,7 @@ class ue {
|
|
|
3725
4022
|
* @param isChange - Whether this is a change address (default: false)
|
|
3726
4023
|
* @returns A Wallet instance with both classical and quantum keys
|
|
3727
4024
|
*/
|
|
3728
|
-
|
|
4025
|
+
deriveOPWallet(t = J.P2TR, e = 0, i = 0, r = !1) {
|
|
3729
4026
|
let s;
|
|
3730
4027
|
switch (t) {
|
|
3731
4028
|
case J.P2PKH:
|
|
@@ -3770,7 +4067,7 @@ class ue {
|
|
|
3770
4067
|
deriveMultipleUnisat(t = J.P2TR, e = 5, i = 0, r = 0, s = !1) {
|
|
3771
4068
|
const o = [];
|
|
3772
4069
|
for (let c = 0; c < e; c++)
|
|
3773
|
-
o.push(this.
|
|
4070
|
+
o.push(this.deriveOPWallet(t, i + c, r, s));
|
|
3774
4071
|
return o;
|
|
3775
4072
|
}
|
|
3776
4073
|
/**
|
|
@@ -3783,7 +4080,7 @@ class ue {
|
|
|
3783
4080
|
* @param bipStandard - The BIP standard to use for classical derivation (default: BIP84)
|
|
3784
4081
|
* @returns An array of Wallet instances
|
|
3785
4082
|
*/
|
|
3786
|
-
deriveMultiple(t, e = 0, i = 0, r = !1, s =
|
|
4083
|
+
deriveMultiple(t, e = 0, i = 0, r = !1, s = Et.BIP84) {
|
|
3787
4084
|
const o = [];
|
|
3788
4085
|
for (let c = 0; c < t; c++)
|
|
3789
4086
|
o.push(this.derive(e + c, i, r, s));
|
|
@@ -3835,9 +4132,9 @@ class ue {
|
|
|
3835
4132
|
* @param bipStandard - The BIP standard to use (default: BIP84)
|
|
3836
4133
|
* @returns The derivation path string
|
|
3837
4134
|
*/
|
|
3838
|
-
buildClassicalPath(t, e, i, r =
|
|
4135
|
+
buildClassicalPath(t, e, i, r = Et.BIP84) {
|
|
3839
4136
|
const s = this.getCoinType();
|
|
3840
|
-
return
|
|
4137
|
+
return Ge(r, s, t, i ? 1 : 0, e);
|
|
3841
4138
|
}
|
|
3842
4139
|
/**
|
|
3843
4140
|
* Build a quantum derivation path (BIP360)
|
|
@@ -3856,23 +4153,23 @@ class ue {
|
|
|
3856
4153
|
* @returns The coin type (0 for mainnet, 1 for testnet/regtest)
|
|
3857
4154
|
*/
|
|
3858
4155
|
getCoinType() {
|
|
3859
|
-
return this._network.bech32 ===
|
|
4156
|
+
return this._network.bech32 === Lt.bech32 || this._network.bech32 === Qt.bech32 ? 1 : 0;
|
|
3860
4157
|
}
|
|
3861
4158
|
}
|
|
3862
|
-
var
|
|
3863
|
-
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) {
|
|
3864
4161
|
switch (n) {
|
|
3865
4162
|
case 1312:
|
|
3866
|
-
return
|
|
4163
|
+
return E.MLDSASecurityLevel.LEVEL2;
|
|
3867
4164
|
case 1952:
|
|
3868
|
-
return
|
|
4165
|
+
return E.MLDSASecurityLevel.LEVEL3;
|
|
3869
4166
|
case 2592:
|
|
3870
|
-
return
|
|
4167
|
+
return E.MLDSASecurityLevel.LEVEL5;
|
|
3871
4168
|
default:
|
|
3872
4169
|
throw new Error(`Invalid MLDSA public key length: ${n}`);
|
|
3873
4170
|
}
|
|
3874
4171
|
}
|
|
3875
|
-
class
|
|
4172
|
+
class or {
|
|
3876
4173
|
constructor(t = I) {
|
|
3877
4174
|
this.network = t;
|
|
3878
4175
|
}
|
|
@@ -3890,25 +4187,25 @@ class rr {
|
|
|
3890
4187
|
return this.address;
|
|
3891
4188
|
}
|
|
3892
4189
|
}
|
|
3893
|
-
var
|
|
3894
|
-
function
|
|
4190
|
+
var Se = /* @__PURE__ */ ((n) => (n[n.Bitcoin = 0] = "Bitcoin", n[n.Fractal = 1] = "Fractal", n))(Se || {});
|
|
4191
|
+
function je(n) {
|
|
3895
4192
|
return new Map(n);
|
|
3896
4193
|
}
|
|
3897
|
-
function
|
|
4194
|
+
function ar(n) {
|
|
3898
4195
|
return {
|
|
3899
4196
|
enabled: !0,
|
|
3900
|
-
signerMap: n instanceof Map ? n :
|
|
4197
|
+
signerMap: n instanceof Map ? n : je(n)
|
|
3901
4198
|
};
|
|
3902
4199
|
}
|
|
3903
|
-
function
|
|
4200
|
+
function cr() {
|
|
3904
4201
|
return {
|
|
3905
4202
|
enabled: !1,
|
|
3906
4203
|
signerMap: /* @__PURE__ */ new Map()
|
|
3907
4204
|
};
|
|
3908
4205
|
}
|
|
3909
|
-
var
|
|
3910
|
-
const
|
|
3911
|
-
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,
|
|
3912
4209
|
CONSENSUS_NAME: "Roswell",
|
|
3913
4210
|
// The block height at which this consensus was enabled.
|
|
3914
4211
|
ENABLED_AT_BLOCK: 0n
|
|
@@ -3924,17 +4221,17 @@ const qe = {
|
|
|
3924
4221
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES: 250n,
|
|
3925
4222
|
// Equivalent to 56500 satoshis, calculated from UNWRAP_CONSOLIDATION_PREPAID_FEES.
|
|
3926
4223
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT: 56500n,
|
|
3927
|
-
},
|
|
3928
|
-
[
|
|
3929
|
-
},
|
|
3930
|
-
function
|
|
4224
|
+
}, Je = {
|
|
4225
|
+
[_t.Roswell]: Ze
|
|
4226
|
+
}, Zt = _t.Roswell, ur = Je[Zt];
|
|
4227
|
+
function ce(n) {
|
|
3931
4228
|
let t = a.allocUnsafe(0);
|
|
3932
4229
|
function e(o) {
|
|
3933
4230
|
t = a.concat([t, a.from(o)]);
|
|
3934
4231
|
}
|
|
3935
4232
|
function i(o) {
|
|
3936
|
-
const c = t.length, u =
|
|
3937
|
-
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);
|
|
3938
4235
|
}
|
|
3939
4236
|
function r(o) {
|
|
3940
4237
|
i(o.length), e(o);
|
|
@@ -3944,23 +4241,23 @@ function ie(n) {
|
|
|
3944
4241
|
}
|
|
3945
4242
|
return s(n), t;
|
|
3946
4243
|
}
|
|
3947
|
-
function
|
|
3948
|
-
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));
|
|
3949
4246
|
}
|
|
3950
|
-
function
|
|
4247
|
+
function hr(n) {
|
|
3951
4248
|
return n.redeemScript ? n.redeemScript : n.witnessScript ? n.witnessScript : n.witnessUtxo ? n.witnessUtxo.script : (n.nonWitnessUtxo, null);
|
|
3952
4249
|
}
|
|
3953
|
-
function
|
|
4250
|
+
function we(n, t) {
|
|
3954
4251
|
if (n.nonWitnessUtxo && !n.redeemScript && !n.witnessScript && !n.witnessUtxo || n.redeemScript)
|
|
3955
4252
|
return !0;
|
|
3956
|
-
const e =
|
|
3957
|
-
return e ?
|
|
4253
|
+
const e = hr(n);
|
|
4254
|
+
return e ? me(t, e) : !1;
|
|
3958
4255
|
}
|
|
3959
|
-
function
|
|
3960
|
-
return
|
|
4256
|
+
function me(n, t) {
|
|
4257
|
+
return vi(n, t) !== -1;
|
|
3961
4258
|
}
|
|
3962
|
-
var
|
|
3963
|
-
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 {
|
|
3964
4261
|
constructor(t) {
|
|
3965
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) => {
|
|
3966
4263
|
const u = this.inputs[e];
|
|
@@ -3985,11 +4282,11 @@ class Xt extends ve {
|
|
|
3985
4282
|
const d = [i.partialSig[0].signature, i.witnessScript];
|
|
3986
4283
|
return {
|
|
3987
4284
|
finalScriptSig: void 0,
|
|
3988
|
-
finalScriptWitness:
|
|
4285
|
+
finalScriptWitness: ce(d)
|
|
3989
4286
|
};
|
|
3990
4287
|
}
|
|
3991
4288
|
}
|
|
3992
|
-
return
|
|
4289
|
+
return Me(
|
|
3993
4290
|
e,
|
|
3994
4291
|
i,
|
|
3995
4292
|
r,
|
|
@@ -4030,7 +4327,7 @@ class Xt extends ve {
|
|
|
4030
4327
|
return e += c, u;
|
|
4031
4328
|
}
|
|
4032
4329
|
function r() {
|
|
4033
|
-
const c =
|
|
4330
|
+
const c = Ti(t, e);
|
|
4034
4331
|
return e += c.bytes, c.numberValue || 0;
|
|
4035
4332
|
}
|
|
4036
4333
|
function s() {
|
|
@@ -4058,8 +4355,8 @@ class Xt extends ve {
|
|
|
4058
4355
|
* @returns {bigint} - The estimated transaction fees
|
|
4059
4356
|
*/
|
|
4060
4357
|
static preEstimateTaprootTransactionFees(t, e, i, r, s, o, c = 32n, u = 139n) {
|
|
4061
|
-
const h = 10n, l = 41n, d = 68n, p = 1n, f = h + l * e + d * i,
|
|
4062
|
-
return (f * 3n + (f +
|
|
4358
|
+
const h = 10n, l = 41n, d = 68n, p = 1n, f = h + l * e + d * i, y = e * p + r * s + c * e + u * e + o;
|
|
4359
|
+
return (f * 3n + (f + y)) / 4n * t;
|
|
4063
4360
|
}
|
|
4064
4361
|
static signInput(t, e, i, r, s) {
|
|
4065
4362
|
s && s[0] && (e.sighashType = s[0]), t.signInput(i, r, s.length ? s : void 0);
|
|
@@ -4207,7 +4504,7 @@ class Xt extends ve {
|
|
|
4207
4504
|
return {
|
|
4208
4505
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4209
4506
|
network: this.network,
|
|
4210
|
-
name:
|
|
4507
|
+
name: U.P2TR
|
|
4211
4508
|
};
|
|
4212
4509
|
}
|
|
4213
4510
|
/**
|
|
@@ -4219,7 +4516,7 @@ class Xt extends ve {
|
|
|
4219
4516
|
return {
|
|
4220
4517
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4221
4518
|
network: this.network,
|
|
4222
|
-
name:
|
|
4519
|
+
name: U.P2TR
|
|
4223
4520
|
};
|
|
4224
4521
|
}
|
|
4225
4522
|
/**
|
|
@@ -4243,7 +4540,7 @@ class Xt extends ve {
|
|
|
4243
4540
|
async signInput(t, e, i, r, s = !1, o = !1) {
|
|
4244
4541
|
if (this.anchorInputIndices.has(i)) return;
|
|
4245
4542
|
const c = r.publicKey;
|
|
4246
|
-
let u =
|
|
4543
|
+
let u = ye(e);
|
|
4247
4544
|
s && (u = !u);
|
|
4248
4545
|
let h = !1, l = !1;
|
|
4249
4546
|
if (u)
|
|
@@ -4254,7 +4551,7 @@ class Xt extends ve {
|
|
|
4254
4551
|
`Failed to sign Taproot script path input ${i} (reverse: ${s}): ${d.message}`
|
|
4255
4552
|
), l = !0;
|
|
4256
4553
|
}
|
|
4257
|
-
else if (s ||
|
|
4554
|
+
else if (s || we(e, c))
|
|
4258
4555
|
try {
|
|
4259
4556
|
await this.signNonTaprootInput(r, t, i), h = !0;
|
|
4260
4557
|
} catch (d) {
|
|
@@ -4343,49 +4640,49 @@ class Xt extends ve {
|
|
|
4343
4640
|
network: this.network
|
|
4344
4641
|
};
|
|
4345
4642
|
if (t && (i.tweakHash = this.getTweakerHash()), "privateKey" in e)
|
|
4346
|
-
return
|
|
4643
|
+
return pe.tweakSigner(e, i);
|
|
4347
4644
|
}
|
|
4348
4645
|
generateP2SHRedeemScript(t) {
|
|
4349
|
-
const e =
|
|
4646
|
+
const e = pt({
|
|
4350
4647
|
redeem: { output: t },
|
|
4351
4648
|
network: this.network
|
|
4352
4649
|
});
|
|
4353
|
-
return
|
|
4650
|
+
return mt({
|
|
4354
4651
|
redeem: e,
|
|
4355
4652
|
network: this.network
|
|
4356
4653
|
}).output;
|
|
4357
4654
|
}
|
|
4358
4655
|
generateP2SHRedeemScriptLegacy(t) {
|
|
4359
|
-
const e =
|
|
4656
|
+
const e = gt(this.signer.publicKey), i = L([
|
|
4360
4657
|
g.OP_DUP,
|
|
4361
4658
|
g.OP_HASH160,
|
|
4362
4659
|
e,
|
|
4363
4660
|
g.OP_EQUALVERIFY,
|
|
4364
4661
|
g.OP_CHECKSIG
|
|
4365
|
-
]), r =
|
|
4662
|
+
]), r = gt(i), s = L([
|
|
4366
4663
|
g.OP_HASH160,
|
|
4367
4664
|
r,
|
|
4368
4665
|
g.OP_EQUAL
|
|
4369
|
-
]), o =
|
|
4666
|
+
]), o = pt({
|
|
4370
4667
|
redeem: { output: i },
|
|
4371
4668
|
// Use the custom redeem script
|
|
4372
4669
|
network: this.network
|
|
4373
|
-
}), c =
|
|
4670
|
+
}), c = mt({
|
|
4374
4671
|
redeem: o,
|
|
4375
4672
|
// The P2WSH is wrapped inside the P2SH
|
|
4376
4673
|
network: this.network
|
|
4377
4674
|
});
|
|
4378
|
-
if (
|
|
4675
|
+
if (Ce(s, this.network) === t && c.redeem && c.redeem.output)
|
|
4379
4676
|
return {
|
|
4380
4677
|
redeemScript: i,
|
|
4381
4678
|
outputScript: c.redeem.output
|
|
4382
4679
|
};
|
|
4383
4680
|
}
|
|
4384
4681
|
generateP2SHP2PKHRedeemScript(t, e) {
|
|
4385
|
-
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({
|
|
4386
4683
|
pubkey: r,
|
|
4387
4684
|
network: this.network
|
|
4388
|
-
}), o =
|
|
4685
|
+
}), o = mt({
|
|
4389
4686
|
redeem: s,
|
|
4390
4687
|
network: this.network
|
|
4391
4688
|
}), c = o.address;
|
|
@@ -4415,14 +4712,14 @@ class Xt extends ve {
|
|
|
4415
4712
|
script: r
|
|
4416
4713
|
}
|
|
4417
4714
|
};
|
|
4418
|
-
if (
|
|
4715
|
+
if (ki(r))
|
|
4419
4716
|
if (t.nonWitnessUtxo)
|
|
4420
4717
|
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4421
4718
|
else
|
|
4422
4719
|
throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");
|
|
4423
|
-
else if (!(
|
|
4720
|
+
else if (!(ve(r) || Ui(r))) if (ke(r))
|
|
4424
4721
|
this.processP2WSHInput(t, s, e);
|
|
4425
|
-
else if (
|
|
4722
|
+
else if (Li(r)) {
|
|
4426
4723
|
let o;
|
|
4427
4724
|
if (t.redeemScript)
|
|
4428
4725
|
o = T.isBuffer(t.redeemScript) ? t.redeemScript : T.from(t.redeemScript, "hex");
|
|
@@ -4440,22 +4737,22 @@ class Xt extends ve {
|
|
|
4440
4737
|
o = h.redeemScript;
|
|
4441
4738
|
}
|
|
4442
4739
|
s.redeemScript = o;
|
|
4443
|
-
const c =
|
|
4740
|
+
const c = mt({ redeem: { output: s.redeemScript } });
|
|
4444
4741
|
if (!c.redeem)
|
|
4445
4742
|
throw new Error("Failed to extract redeem script from P2SH UTXO");
|
|
4446
4743
|
const u = c.redeem.output;
|
|
4447
4744
|
if (!u)
|
|
4448
4745
|
throw new Error("Failed to extract redeem output from P2SH UTXO");
|
|
4449
|
-
t.nonWitnessUtxo && (s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex")),
|
|
4450
|
-
} 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)) {
|
|
4451
4748
|
if (this.sighashTypes) {
|
|
4452
|
-
const o =
|
|
4749
|
+
const o = Jt.calculateSignHash(this.sighashTypes);
|
|
4453
4750
|
o && (s.sighashType = o);
|
|
4454
4751
|
}
|
|
4455
4752
|
this.addressRotationEnabled ? s.tapInternalKey = this.internalPubKeyToXOnlyForInput(e) : (this.tweakSigner(), s.tapInternalKey = this.internalPubKeyToXOnly());
|
|
4456
|
-
} else if (
|
|
4753
|
+
} else if (_i(r))
|
|
4457
4754
|
this.anchorInputIndices.add(e), s.isPayToAnchor = !0;
|
|
4458
|
-
else if (
|
|
4755
|
+
else if (Ki(r) || Di(r))
|
|
4459
4756
|
if (t.nonWitnessUtxo)
|
|
4460
4757
|
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4461
4758
|
else
|
|
@@ -4468,9 +4765,9 @@ class Xt extends ve {
|
|
|
4468
4765
|
if (!t.witnessScript)
|
|
4469
4766
|
throw new Error("Missing witnessScript for P2WSH UTXO");
|
|
4470
4767
|
e.witnessScript = T.isBuffer(t.witnessScript) ? t.witnessScript : T.from(t.witnessScript, "hex");
|
|
4471
|
-
const r =
|
|
4768
|
+
const r = F(e.witnessScript);
|
|
4472
4769
|
if (r && this.isCSVScript(r)) {
|
|
4473
|
-
const s =
|
|
4770
|
+
const s = F(e.witnessScript);
|
|
4474
4771
|
if (s && this.isCSVScript(s)) {
|
|
4475
4772
|
this.csvInputIndices.add(i);
|
|
4476
4773
|
const o = this.extractCSVBlocks(s);
|
|
@@ -4507,7 +4804,7 @@ class Xt extends ve {
|
|
|
4507
4804
|
);
|
|
4508
4805
|
return {
|
|
4509
4806
|
finalScriptSig: void 0,
|
|
4510
|
-
finalScriptWitness:
|
|
4807
|
+
finalScriptWitness: ce(i)
|
|
4511
4808
|
};
|
|
4512
4809
|
}
|
|
4513
4810
|
async signInputsWalletBased(t) {
|
|
@@ -4536,7 +4833,7 @@ class Xt extends ve {
|
|
|
4536
4833
|
if (t[e] === g.OP_CHECKSEQUENCEVERIFY && e > 0) {
|
|
4537
4834
|
const i = t[e - 1];
|
|
4538
4835
|
if (T.isBuffer(i))
|
|
4539
|
-
return
|
|
4836
|
+
return Re.decode(i);
|
|
4540
4837
|
if (typeof i == "number") {
|
|
4541
4838
|
if (i === g.OP_0 || i === g.OP_FALSE)
|
|
4542
4839
|
return 0;
|
|
@@ -4569,7 +4866,7 @@ class Xt extends ve {
|
|
|
4569
4866
|
isTaprootScriptSpend(t, e) {
|
|
4570
4867
|
if (t.tapLeafScript && t.tapLeafScript.length > 0) {
|
|
4571
4868
|
for (const i of t.tapLeafScript)
|
|
4572
|
-
if (
|
|
4869
|
+
if (me(e, i.script))
|
|
4573
4870
|
return !0;
|
|
4574
4871
|
}
|
|
4575
4872
|
return !1;
|
|
@@ -4588,22 +4885,22 @@ class Xt extends ve {
|
|
|
4588
4885
|
"signInput" in t ? await t.signInput(e, i) : e.signInput(i, t);
|
|
4589
4886
|
}
|
|
4590
4887
|
}
|
|
4591
|
-
function
|
|
4888
|
+
function ee(n, t) {
|
|
4592
4889
|
return JSON.stringify(n) === JSON.stringify(t);
|
|
4593
4890
|
}
|
|
4594
|
-
function
|
|
4595
|
-
if (
|
|
4891
|
+
function lr(n) {
|
|
4892
|
+
if (ee(n, I))
|
|
4596
4893
|
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
4597
|
-
if (
|
|
4894
|
+
if (ee(n, Lt))
|
|
4598
4895
|
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
4599
|
-
if (
|
|
4896
|
+
if (ee(n, Qt))
|
|
4600
4897
|
return "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";
|
|
4601
4898
|
throw new Error("Unsupported network for chain ID retrieval");
|
|
4602
4899
|
}
|
|
4603
|
-
function
|
|
4604
|
-
return Uint8Array.from(a.from(
|
|
4900
|
+
function _e(n) {
|
|
4901
|
+
return Uint8Array.from(a.from(lr(n), "hex"));
|
|
4605
4902
|
}
|
|
4606
|
-
const
|
|
4903
|
+
const Ke = Uint8Array.from(
|
|
4607
4904
|
a.from(
|
|
4608
4905
|
"e784995a412d773988c4b8e333d7b39dfb3cabf118d0d645411a916ca2407939",
|
|
4609
4906
|
// sha256("OP_NET")
|
|
@@ -4611,12 +4908,12 @@ const xe = Uint8Array.from(
|
|
|
4611
4908
|
)
|
|
4612
4909
|
);
|
|
4613
4910
|
ot(G);
|
|
4614
|
-
const V = 330n,
|
|
4615
|
-
class m extends
|
|
4911
|
+
const V = 330n, bt = 297n, ue = a.from("51024e73", "hex");
|
|
4912
|
+
class m extends Jt {
|
|
4616
4913
|
constructor(t) {
|
|
4617
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)
|
|
4618
4915
|
throw new Error("Vout value is less than the value to send");
|
|
4619
|
-
this.transaction = new
|
|
4916
|
+
this.transaction = new R({
|
|
4620
4917
|
network: this.network,
|
|
4621
4918
|
version: this.txVersion
|
|
4622
4919
|
});
|
|
@@ -4634,7 +4931,7 @@ class m extends Xt {
|
|
|
4634
4931
|
* @returns {Buffer}
|
|
4635
4932
|
*/
|
|
4636
4933
|
static witnessStackToScriptWitness(t) {
|
|
4637
|
-
return
|
|
4934
|
+
return ce(t);
|
|
4638
4935
|
}
|
|
4639
4936
|
addOPReturn(t) {
|
|
4640
4937
|
const e = L([g.OP_RETURN, t]);
|
|
@@ -4646,7 +4943,7 @@ class m extends Xt {
|
|
|
4646
4943
|
addAnchor() {
|
|
4647
4944
|
this.addOutput({
|
|
4648
4945
|
value: 0,
|
|
4649
|
-
script:
|
|
4946
|
+
script: ue
|
|
4650
4947
|
});
|
|
4651
4948
|
}
|
|
4652
4949
|
async getFundingTransactionParameters() {
|
|
@@ -4752,7 +5049,7 @@ class m extends Xt {
|
|
|
4752
5049
|
throw new Error("Output value is 0 and no script provided");
|
|
4753
5050
|
if (i.script.length < 2)
|
|
4754
5051
|
throw new Error("Output script is too short");
|
|
4755
|
-
if (i.script[0] !== g.OP_RETURN && !i.script.equals(
|
|
5052
|
+
if (i.script[0] !== g.OP_RETURN && !i.script.equals(ue))
|
|
4756
5053
|
throw new Error(
|
|
4757
5054
|
"Output script must start with OP_RETURN or be an ANCHOR when value is 0"
|
|
4758
5055
|
);
|
|
@@ -4792,7 +5089,7 @@ class m extends Xt {
|
|
|
4792
5089
|
*/
|
|
4793
5090
|
async estimateTransactionFees() {
|
|
4794
5091
|
await Promise.resolve();
|
|
4795
|
-
const t = new
|
|
5092
|
+
const t = new R({ network: this.network }), e = this.getInputs(), i = this.getOutputs();
|
|
4796
5093
|
t.addInputs(e), t.addOutputs(i);
|
|
4797
5094
|
const r = a.alloc(64, 0), s = a.alloc(72, 0), o = a.alloc(33, 2), c = (p, f) => {
|
|
4798
5095
|
if (f.isPayToAnchor || this.anchorInputIndices.has(p))
|
|
@@ -4802,7 +5099,7 @@ class m extends Xt {
|
|
|
4802
5099
|
};
|
|
4803
5100
|
if (f.witnessScript && z.isP2WDAWitnessScript(f.witnessScript)) {
|
|
4804
5101
|
const S = [];
|
|
4805
|
-
for (let
|
|
5102
|
+
for (let K = 0; K < 10; K++)
|
|
4806
5103
|
S.push(a.alloc(0));
|
|
4807
5104
|
const b = a.alloc(72, 0);
|
|
4808
5105
|
return {
|
|
@@ -4814,7 +5111,7 @@ class m extends Xt {
|
|
|
4814
5111
|
};
|
|
4815
5112
|
}
|
|
4816
5113
|
if (p === 0 && this.tapLeafScript) {
|
|
4817
|
-
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);
|
|
4818
5115
|
return {
|
|
4819
5116
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4820
5117
|
S,
|
|
@@ -4823,7 +5120,7 @@ class m extends Xt {
|
|
|
4823
5120
|
r,
|
|
4824
5121
|
// Second Schnorr signature
|
|
4825
5122
|
b,
|
|
4826
|
-
|
|
5123
|
+
K
|
|
4827
5124
|
])
|
|
4828
5125
|
};
|
|
4829
5126
|
}
|
|
@@ -4855,16 +5152,16 @@ class m extends Xt {
|
|
|
4855
5152
|
}
|
|
4856
5153
|
const S = it.script.decompile(f.witnessScript);
|
|
4857
5154
|
if (S && S.length >= 4) {
|
|
4858
|
-
const b = S[0],
|
|
4859
|
-
if (typeof b == "number" && b >= g.OP_1 &&
|
|
4860
|
-
const
|
|
4861
|
-
for (let
|
|
4862
|
-
|
|
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);
|
|
4863
5160
|
return {
|
|
4864
5161
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4865
5162
|
a.alloc(0),
|
|
4866
5163
|
// OP_0 due to multisig bug
|
|
4867
|
-
...
|
|
5164
|
+
...Dt,
|
|
4868
5165
|
f.witnessScript
|
|
4869
5166
|
])
|
|
4870
5167
|
};
|
|
@@ -4892,12 +5189,12 @@ class m extends Xt {
|
|
|
4892
5189
|
finalScriptSig: it.script.compile([s, f.redeemScript]),
|
|
4893
5190
|
finalScriptWitness: void 0
|
|
4894
5191
|
};
|
|
4895
|
-
const
|
|
4896
|
-
return
|
|
5192
|
+
const y = f.witnessUtxo?.script;
|
|
5193
|
+
return y ? f.tapInternalKey ? {
|
|
4897
5194
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4898
5195
|
r
|
|
4899
5196
|
])
|
|
4900
|
-
} :
|
|
5197
|
+
} : y.length === 22 && y[0] === g.OP_0 ? {
|
|
4901
5198
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4902
5199
|
s,
|
|
4903
5200
|
o
|
|
@@ -4907,10 +5204,10 @@ class m extends Xt {
|
|
|
4907
5204
|
s,
|
|
4908
5205
|
o
|
|
4909
5206
|
])
|
|
4910
|
-
} :
|
|
5207
|
+
} : Me(
|
|
4911
5208
|
p,
|
|
4912
5209
|
f,
|
|
4913
|
-
|
|
5210
|
+
y,
|
|
4914
5211
|
!0,
|
|
4915
5212
|
!!f.redeemScript,
|
|
4916
5213
|
!!f.witnessScript
|
|
@@ -4919,7 +5216,7 @@ class m extends Xt {
|
|
|
4919
5216
|
try {
|
|
4920
5217
|
for (let p = 0; p < t.data.inputs.length; p++) {
|
|
4921
5218
|
const f = e[p];
|
|
4922
|
-
f && t.finalizeInput(p, (
|
|
5219
|
+
f && t.finalizeInput(p, (y) => c(y, f));
|
|
4923
5220
|
}
|
|
4924
5221
|
} catch (p) {
|
|
4925
5222
|
this.warn(`Could not finalize dummy tx: ${p.message}`);
|
|
@@ -4930,10 +5227,10 @@ class m extends Xt {
|
|
|
4930
5227
|
), d;
|
|
4931
5228
|
}
|
|
4932
5229
|
async rebuildFromBase64(t) {
|
|
4933
|
-
return this.transaction =
|
|
5230
|
+
return this.transaction = R.fromBase64(t, {
|
|
4934
5231
|
network: this.network,
|
|
4935
5232
|
version: this.txVersion
|
|
4936
|
-
}), this.signed = !1, this.sighashTypes = [
|
|
5233
|
+
}), this.signed = !1, this.sighashTypes = [ne.SIGHASH_ANYONECANPAY, ne.SIGHASH_ALL], await this.signPSBT();
|
|
4937
5234
|
}
|
|
4938
5235
|
setPSBT(t) {
|
|
4939
5236
|
this.transaction = t;
|
|
@@ -5040,8 +5337,8 @@ class m extends Xt {
|
|
|
5040
5337
|
const t = O(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5041
5338
|
if (e.length !== 33)
|
|
5042
5339
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5043
|
-
const i =
|
|
5044
|
-
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);
|
|
5045
5342
|
const s = r.getBuffer(), o = st.signMessage(this.tweakedSigner, s);
|
|
5046
5343
|
if (!st.verifySignature(t, s, o.signature))
|
|
5047
5344
|
throw new Error("Could not verify generated legacy signature for MLDSA link request");
|
|
@@ -5055,11 +5352,11 @@ class m extends Xt {
|
|
|
5055
5352
|
const t = O(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5056
5353
|
if (e.length !== 33)
|
|
5057
5354
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5058
|
-
const i =
|
|
5059
|
-
if (r !==
|
|
5355
|
+
const i = _e(this.network), r = ae(this.mldsaSigner.publicKey.length);
|
|
5356
|
+
if (r !== E.MLDSASecurityLevel.LEVEL2)
|
|
5060
5357
|
throw new Error("Only MLDSA level 2 is supported for link requests");
|
|
5061
|
-
const s = new
|
|
5062
|
-
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);
|
|
5063
5360
|
const o = s.getBuffer(), c = st.signMLDSAMessage(this.mldsaSigner, o);
|
|
5064
5361
|
if (!st.verifyMLDSASignature(
|
|
5065
5362
|
this.mldsaSigner,
|
|
@@ -5075,12 +5372,12 @@ class m extends Xt {
|
|
|
5075
5372
|
t.revealMLDSAPublicKey && (s = this.generateMLDSASignature());
|
|
5076
5373
|
const o = {
|
|
5077
5374
|
priority: Q.MLDSA_LINK_PUBKEY,
|
|
5078
|
-
opcode:
|
|
5375
|
+
opcode: N.MLDSA_LINK_PUBKEY,
|
|
5079
5376
|
data: {
|
|
5080
5377
|
verifyRequest: !!t.revealMLDSAPublicKey,
|
|
5081
5378
|
publicKey: i.publicKey,
|
|
5082
5379
|
hashedPublicKey: this.hashedPublicKey,
|
|
5083
|
-
level:
|
|
5380
|
+
level: ae(i.publicKey.length),
|
|
5084
5381
|
legacySignature: r,
|
|
5085
5382
|
mldsaSignature: s
|
|
5086
5383
|
}
|
|
@@ -5187,13 +5484,13 @@ class m extends Xt {
|
|
|
5187
5484
|
addFeeToOutput(t, e, i, r) {
|
|
5188
5485
|
if (r) {
|
|
5189
5486
|
let s;
|
|
5190
|
-
t > V +
|
|
5487
|
+
t > V + bt ? s = bt : s = t, this.addOutput(
|
|
5191
5488
|
{
|
|
5192
5489
|
value: Number(s),
|
|
5193
5490
|
address: e
|
|
5194
5491
|
},
|
|
5195
5492
|
!0
|
|
5196
|
-
), s ===
|
|
5493
|
+
), s === bt && t - bt > V && this.addOutput(
|
|
5197
5494
|
{
|
|
5198
5495
|
value: Number(t - s),
|
|
5199
5496
|
address: i.address
|
|
@@ -5339,9 +5636,9 @@ class m extends Xt {
|
|
|
5339
5636
|
return !1;
|
|
5340
5637
|
}
|
|
5341
5638
|
}
|
|
5342
|
-
class
|
|
5639
|
+
class qt extends m {
|
|
5343
5640
|
constructor(t) {
|
|
5344
|
-
if (super(t), this.type =
|
|
5641
|
+
if (super(t), this.type = w.CUSTOM_CODE, this.tapLeafScript = null, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5345
5642
|
if (!this.tapLeafScript)
|
|
5346
5643
|
throw new Error("Tap leaf script is required");
|
|
5347
5644
|
const s = this.getScriptSolution(i).concat(this.tapLeafScript.script).concat(this.tapLeafScript.controlBlock);
|
|
@@ -5354,7 +5651,7 @@ class Wt extends m {
|
|
|
5354
5651
|
};
|
|
5355
5652
|
}, !t.script) throw new Error("Bitcoin script is required");
|
|
5356
5653
|
if (!t.witnesses) throw new Error("Witness(es) are required");
|
|
5357
|
-
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);
|
|
5358
5655
|
}
|
|
5359
5656
|
/**
|
|
5360
5657
|
* @description Get the contract address (PKSH)
|
|
@@ -5438,7 +5735,7 @@ class Wt extends m {
|
|
|
5438
5735
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5439
5736
|
network: this.network,
|
|
5440
5737
|
scriptTree: this.scriptTree,
|
|
5441
|
-
name:
|
|
5738
|
+
name: U.P2TR
|
|
5442
5739
|
};
|
|
5443
5740
|
}
|
|
5444
5741
|
/**
|
|
@@ -5456,7 +5753,7 @@ class Wt extends m {
|
|
|
5456
5753
|
network: this.network,
|
|
5457
5754
|
scriptTree: this.scriptTree,
|
|
5458
5755
|
redeem: t,
|
|
5459
|
-
name:
|
|
5756
|
+
name: U.P2TR
|
|
5460
5757
|
};
|
|
5461
5758
|
}
|
|
5462
5759
|
getScriptSolution(t) {
|
|
@@ -5489,12 +5786,12 @@ class Wt extends m {
|
|
|
5489
5786
|
*/
|
|
5490
5787
|
generateRedeemScripts() {
|
|
5491
5788
|
this.targetScriptRedeem = {
|
|
5492
|
-
name:
|
|
5789
|
+
name: U.P2TR,
|
|
5493
5790
|
//pubkeys: this.getPubKeys(),
|
|
5494
5791
|
output: this.compiledTargetScript,
|
|
5495
5792
|
redeemVersion: 192
|
|
5496
5793
|
}, this.leftOverFundsScriptRedeem = {
|
|
5497
|
-
name:
|
|
5794
|
+
name: U.P2TR,
|
|
5498
5795
|
//pubkeys: this.getPubKeys(),
|
|
5499
5796
|
output: this.getLeafScript(),
|
|
5500
5797
|
redeemVersion: 192
|
|
@@ -5524,7 +5821,7 @@ class Wt extends m {
|
|
|
5524
5821
|
];
|
|
5525
5822
|
}
|
|
5526
5823
|
}
|
|
5527
|
-
class
|
|
5824
|
+
class be extends m {
|
|
5528
5825
|
constructor(t) {
|
|
5529
5826
|
if (super(t), this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5530
5827
|
if (!this.tapLeafScript)
|
|
@@ -5542,7 +5839,7 @@ class pe extends m {
|
|
|
5542
5839
|
this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.disableAutoRefund = t.disableAutoRefund || !1, this.epochChallenge = M.generateTimeLockAddress(
|
|
5543
5840
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
5544
5841
|
this.network
|
|
5545
|
-
), this.calldata =
|
|
5842
|
+
), this.calldata = W.compress(t.calldata), this.randomBytes = t.randomBytes || D.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.calldataGenerator = new de(
|
|
5546
5843
|
a.from(this.signer.publicKey),
|
|
5547
5844
|
this.scriptSignerXOnlyPubKey(),
|
|
5548
5845
|
this.network
|
|
@@ -5631,7 +5928,7 @@ class pe extends m {
|
|
|
5631
5928
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5632
5929
|
network: this.network,
|
|
5633
5930
|
scriptTree: this.scriptTree,
|
|
5634
|
-
name:
|
|
5931
|
+
name: U.P2TR
|
|
5635
5932
|
};
|
|
5636
5933
|
}
|
|
5637
5934
|
generateTapData() {
|
|
@@ -5645,7 +5942,7 @@ class pe extends m {
|
|
|
5645
5942
|
network: this.network,
|
|
5646
5943
|
scriptTree: this.scriptTree,
|
|
5647
5944
|
redeem: t,
|
|
5648
|
-
name:
|
|
5945
|
+
name: U.P2TR
|
|
5649
5946
|
};
|
|
5650
5947
|
}
|
|
5651
5948
|
/**
|
|
@@ -5745,19 +6042,19 @@ class pe extends m {
|
|
|
5745
6042
|
*/
|
|
5746
6043
|
generateRedeemScripts() {
|
|
5747
6044
|
this.targetScriptRedeem = {
|
|
5748
|
-
name:
|
|
6045
|
+
name: U.P2TR,
|
|
5749
6046
|
output: this.compiledTargetScript,
|
|
5750
6047
|
redeemVersion: 192
|
|
5751
6048
|
}, this.leftOverFundsScriptRedeem = {
|
|
5752
|
-
name:
|
|
6049
|
+
name: U.P2TR,
|
|
5753
6050
|
output: this.LOCK_LEAF_SCRIPT,
|
|
5754
6051
|
redeemVersion: 192
|
|
5755
6052
|
};
|
|
5756
6053
|
}
|
|
5757
6054
|
}
|
|
5758
|
-
class
|
|
6055
|
+
class St extends m {
|
|
5759
6056
|
constructor(t) {
|
|
5760
|
-
if (super(t), this.type =
|
|
6057
|
+
if (super(t), this.type = w.DEPLOYMENT, this.tapLeafScript = null, this.deploymentVersion = 0, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5761
6058
|
if (!this.tapLeafScript)
|
|
5762
6059
|
throw new Error("Tap leaf script is required");
|
|
5763
6060
|
if (!i.tapScriptSig)
|
|
@@ -5772,11 +6069,11 @@ class ft extends m {
|
|
|
5772
6069
|
};
|
|
5773
6070
|
}, !this.hashedPublicKey)
|
|
5774
6071
|
throw new Error("MLDSA signer must be defined to deploy a contract.");
|
|
5775
|
-
if (this.bytecode =
|
|
5776
|
-
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(
|
|
5777
6074
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
5778
6075
|
this.network
|
|
5779
|
-
), 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(
|
|
5780
6077
|
a.from(this.signer.publicKey),
|
|
5781
6078
|
this.contractSignerXOnlyPubKey(),
|
|
5782
6079
|
this.network
|
|
@@ -5796,7 +6093,7 @@ class ft extends m {
|
|
|
5796
6093
|
this.calldata,
|
|
5797
6094
|
this.generateFeatures(t)
|
|
5798
6095
|
);
|
|
5799
|
-
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + this.contractSeed.toString("hex"), this._contractAddress = new
|
|
6096
|
+
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + this.contractSeed.toString("hex"), this._contractAddress = new v(this.contractSeed);
|
|
5800
6097
|
}
|
|
5801
6098
|
static {
|
|
5802
6099
|
this.MAXIMUM_CONTRACT_SIZE = 128 * 1024;
|
|
@@ -5916,7 +6213,7 @@ class ft extends m {
|
|
|
5916
6213
|
*/
|
|
5917
6214
|
generateScriptAddress() {
|
|
5918
6215
|
return {
|
|
5919
|
-
name:
|
|
6216
|
+
name: U.P2TR,
|
|
5920
6217
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5921
6218
|
network: this.network,
|
|
5922
6219
|
scriptTree: this.scriptTree
|
|
@@ -5933,7 +6230,7 @@ class ft extends m {
|
|
|
5933
6230
|
if (!this.scriptTree)
|
|
5934
6231
|
throw new Error("Script tree is required");
|
|
5935
6232
|
return {
|
|
5936
|
-
name:
|
|
6233
|
+
name: U.P2TR,
|
|
5937
6234
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5938
6235
|
network: this.network,
|
|
5939
6236
|
scriptTree: this.scriptTree,
|
|
@@ -5944,7 +6241,7 @@ class ft extends m {
|
|
|
5944
6241
|
const e = [], i = t.challenge.getSubmission();
|
|
5945
6242
|
if (i && e.push({
|
|
5946
6243
|
priority: Q.MLDSA_LINK_PUBKEY,
|
|
5947
|
-
opcode:
|
|
6244
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
5948
6245
|
data: i
|
|
5949
6246
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
5950
6247
|
throw new Error(
|
|
@@ -5953,12 +6250,12 @@ class ft extends m {
|
|
|
5953
6250
|
return t.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(t, e), e;
|
|
5954
6251
|
}
|
|
5955
6252
|
verifyCalldata() {
|
|
5956
|
-
if (this.calldata && this.calldata.length >
|
|
6253
|
+
if (this.calldata && this.calldata.length > be.MAXIMUM_CALLDATA_SIZE)
|
|
5957
6254
|
throw new Error("Calldata size overflow.");
|
|
5958
6255
|
}
|
|
5959
6256
|
verifyBytecode() {
|
|
5960
6257
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
5961
|
-
if (this.bytecode.length >
|
|
6258
|
+
if (this.bytecode.length > St.MAXIMUM_CONTRACT_SIZE)
|
|
5962
6259
|
throw new Error("Contract size overflow.");
|
|
5963
6260
|
}
|
|
5964
6261
|
/**
|
|
@@ -5985,12 +6282,12 @@ class ft extends m {
|
|
|
5985
6282
|
*/
|
|
5986
6283
|
generateRedeemScripts() {
|
|
5987
6284
|
this.targetScriptRedeem = {
|
|
5988
|
-
name:
|
|
6285
|
+
name: U.P2TR,
|
|
5989
6286
|
//pubkeys: this.getPubKeys(),
|
|
5990
6287
|
output: this.compiledTargetScript,
|
|
5991
6288
|
redeemVersion: 192
|
|
5992
6289
|
}, this.leftOverFundsScriptRedeem = {
|
|
5993
|
-
name:
|
|
6290
|
+
name: U.P2TR,
|
|
5994
6291
|
//pubkeys: this.getPubKeys(),
|
|
5995
6292
|
output: this.getLeafScript(),
|
|
5996
6293
|
redeemVersion: 192
|
|
@@ -6022,9 +6319,9 @@ class ft extends m {
|
|
|
6022
6319
|
];
|
|
6023
6320
|
}
|
|
6024
6321
|
}
|
|
6025
|
-
class
|
|
6322
|
+
class $t extends m {
|
|
6026
6323
|
constructor(t) {
|
|
6027
|
-
super(t), this.type =
|
|
6324
|
+
super(t), this.type = w.FUNDING, this.amount = t.amount, this.splitInputsInto = t.splitInputsInto ?? 1, this.internalInit();
|
|
6028
6325
|
}
|
|
6029
6326
|
async buildTransaction() {
|
|
6030
6327
|
if (!this.to)
|
|
@@ -6065,9 +6362,9 @@ class Mt extends m {
|
|
|
6065
6362
|
return this.signer;
|
|
6066
6363
|
}
|
|
6067
6364
|
}
|
|
6068
|
-
class
|
|
6365
|
+
class Xt extends be {
|
|
6069
6366
|
constructor(t) {
|
|
6070
|
-
if (super(t), this.type =
|
|
6367
|
+
if (super(t), this.type = w.INTERACTION, this.tapLeafScript = null, !t.contract)
|
|
6071
6368
|
throw new Error("parameters.contract is required for interaction transaction.");
|
|
6072
6369
|
if (this.contractSecret = a.from(t.contract.replace("0x", ""), "hex"), this.contractSecret.length !== 32)
|
|
6073
6370
|
throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
@@ -6092,13 +6389,13 @@ class Nt extends pe {
|
|
|
6092
6389
|
const e = [];
|
|
6093
6390
|
t.loadedStorage && e.push({
|
|
6094
6391
|
priority: Q.ACCESS_LIST,
|
|
6095
|
-
opcode:
|
|
6392
|
+
opcode: N.ACCESS_LIST,
|
|
6096
6393
|
data: t.loadedStorage
|
|
6097
6394
|
});
|
|
6098
6395
|
const i = t.challenge.getSubmission();
|
|
6099
6396
|
if (i && e.push({
|
|
6100
6397
|
priority: Q.EPOCH_SUBMISSION,
|
|
6101
|
-
opcode:
|
|
6398
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
6102
6399
|
data: i
|
|
6103
6400
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
6104
6401
|
throw new Error(
|
|
@@ -6109,7 +6406,7 @@ class Nt extends pe {
|
|
|
6109
6406
|
}
|
|
6110
6407
|
class j extends m {
|
|
6111
6408
|
constructor(t) {
|
|
6112
|
-
if (super(t), this.type =
|
|
6409
|
+
if (super(t), this.type = w.INTERACTION, this.p2wdaInputIndices = /* @__PURE__ */ new Set(), this.compiledOperationData = null, !t.to)
|
|
6113
6410
|
throw new Error("Contract address (to) is required");
|
|
6114
6411
|
if (!t.contract)
|
|
6115
6412
|
throw new Error("Contract secret is required");
|
|
@@ -6117,7 +6414,7 @@ class j extends m {
|
|
|
6117
6414
|
throw new Error("Calldata is required");
|
|
6118
6415
|
if (!t.challenge)
|
|
6119
6416
|
throw new Error("Challenge solution is required");
|
|
6120
|
-
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(
|
|
6121
6418
|
T.from(this.signer.publicKey),
|
|
6122
6419
|
this.scriptSignerXOnlyPubKey(),
|
|
6123
6420
|
this.network
|
|
@@ -6197,13 +6494,13 @@ class j extends m {
|
|
|
6197
6494
|
const e = [];
|
|
6198
6495
|
t.loadedStorage && e.push({
|
|
6199
6496
|
priority: Q.ACCESS_LIST,
|
|
6200
|
-
opcode:
|
|
6497
|
+
opcode: N.ACCESS_LIST,
|
|
6201
6498
|
data: t.loadedStorage
|
|
6202
6499
|
});
|
|
6203
6500
|
const i = t.challenge.getSubmission();
|
|
6204
6501
|
return i && e.push({
|
|
6205
6502
|
priority: Q.EPOCH_SUBMISSION,
|
|
6206
|
-
opcode:
|
|
6503
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
6207
6504
|
data: i
|
|
6208
6505
|
}), e;
|
|
6209
6506
|
}
|
|
@@ -6239,7 +6536,7 @@ class j extends m {
|
|
|
6239
6536
|
if (!this.compiledOperationData)
|
|
6240
6537
|
throw new Error("Operation data not compiled");
|
|
6241
6538
|
const t = this.compiledOperationData.length;
|
|
6242
|
-
if (!
|
|
6539
|
+
if (!Ut.validateWitnessSize(t)) {
|
|
6243
6540
|
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(
|
|
6244
6541
|
r / j.MAX_BYTES_PER_WITNESS
|
|
6245
6542
|
);
|
|
@@ -6262,7 +6559,7 @@ class j extends m {
|
|
|
6262
6559
|
const i = e.partialSig[0].signature, r = T.concat([i, this.compiledOperationData]), s = st.signMessage(
|
|
6263
6560
|
this.signer,
|
|
6264
6561
|
r
|
|
6265
|
-
), 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);
|
|
6266
6563
|
if (h.length > j.MAX_WITNESS_FIELDS)
|
|
6267
6564
|
throw new Error(
|
|
6268
6565
|
`Compressed data needs ${h.length} witness fields, max is ${j.MAX_WITNESS_FIELDS}`
|
|
@@ -6291,7 +6588,7 @@ class j extends m {
|
|
|
6291
6588
|
return e;
|
|
6292
6589
|
}
|
|
6293
6590
|
}
|
|
6294
|
-
class
|
|
6591
|
+
class Ie extends m {
|
|
6295
6592
|
constructor(t) {
|
|
6296
6593
|
super({
|
|
6297
6594
|
...t,
|
|
@@ -6299,7 +6596,7 @@ class ge extends m {
|
|
|
6299
6596
|
isCancellation: !0,
|
|
6300
6597
|
priorityFee: 1n,
|
|
6301
6598
|
calldata: a.alloc(0)
|
|
6302
|
-
}), this.type =
|
|
6599
|
+
}), this.type = w.CANCEL, this.tapLeafScript = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
6303
6600
|
if (!this.tapLeafScript)
|
|
6304
6601
|
throw new Error("Tap leaf script is required");
|
|
6305
6602
|
if (!i.tapScriptSig || i.tapScriptSig.length === 0)
|
|
@@ -6361,7 +6658,7 @@ class ge extends m {
|
|
|
6361
6658
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
6362
6659
|
network: this.network,
|
|
6363
6660
|
scriptTree: this.scriptTree,
|
|
6364
|
-
name:
|
|
6661
|
+
name: U.P2TR
|
|
6365
6662
|
};
|
|
6366
6663
|
}
|
|
6367
6664
|
/**
|
|
@@ -6388,7 +6685,7 @@ class ge extends m {
|
|
|
6388
6685
|
network: this.network,
|
|
6389
6686
|
scriptTree: this.scriptTree,
|
|
6390
6687
|
redeem: t,
|
|
6391
|
-
name:
|
|
6688
|
+
name: U.P2TR
|
|
6392
6689
|
};
|
|
6393
6690
|
}
|
|
6394
6691
|
async signInputs(t) {
|
|
@@ -6447,15 +6744,15 @@ class ge extends m {
|
|
|
6447
6744
|
*/
|
|
6448
6745
|
generateLeftoverFundsRedeem() {
|
|
6449
6746
|
this.leftOverFundsScriptRedeem = {
|
|
6450
|
-
name:
|
|
6747
|
+
name: U.P2TR,
|
|
6451
6748
|
output: this.LOCK_LEAF_SCRIPT,
|
|
6452
6749
|
redeemVersion: 192
|
|
6453
6750
|
};
|
|
6454
6751
|
}
|
|
6455
6752
|
}
|
|
6456
|
-
class
|
|
6753
|
+
class ii extends m {
|
|
6457
6754
|
constructor(t) {
|
|
6458
|
-
if (super(t), this.type =
|
|
6755
|
+
if (super(t), this.type = w.INTERACTION, this.cachedValuePerOutput = null, !t.to)
|
|
6459
6756
|
throw new Error("Contract address (to) is required");
|
|
6460
6757
|
if (!t.contract)
|
|
6461
6758
|
throw new Error("Contract secret (contract) is required");
|
|
@@ -6463,12 +6760,12 @@ class Ge extends m {
|
|
|
6463
6760
|
throw new Error("Calldata is required");
|
|
6464
6761
|
if (!t.challenge)
|
|
6465
6762
|
throw new Error("Challenge solution is required");
|
|
6466
|
-
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)
|
|
6467
6764
|
throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
6468
|
-
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(
|
|
6469
6766
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
6470
6767
|
this.network
|
|
6471
|
-
), this.calldataGenerator = new
|
|
6768
|
+
), this.calldataGenerator = new de(
|
|
6472
6769
|
T.from(this.signer.publicKey),
|
|
6473
6770
|
O(T.from(this.scriptSigner.publicKey)),
|
|
6474
6771
|
this.network
|
|
@@ -6487,7 +6784,7 @@ class Ge extends m {
|
|
|
6487
6784
|
this.priorityFee,
|
|
6488
6785
|
this.generateFeatures(t)
|
|
6489
6786
|
);
|
|
6490
|
-
this.hashCommitmentGenerator = new
|
|
6787
|
+
this.hashCommitmentGenerator = new P(
|
|
6491
6788
|
T.from(this.signer.publicKey),
|
|
6492
6789
|
this.network
|
|
6493
6790
|
), this.commitmentOutputs = this.hashCommitmentGenerator.prepareChunks(
|
|
@@ -6577,7 +6874,7 @@ class Ge extends m {
|
|
|
6577
6874
|
* @param setupTxId The transaction ID of the setup transaction
|
|
6578
6875
|
*/
|
|
6579
6876
|
buildRevealTransaction(t) {
|
|
6580
|
-
const e = new
|
|
6877
|
+
const e = new R({ network: this.network }), i = this.calculateValuePerOutput();
|
|
6581
6878
|
for (let p = 0; p < this.commitmentOutputs.length; p++) {
|
|
6582
6879
|
const f = this.commitmentOutputs[p];
|
|
6583
6880
|
e.addInput({
|
|
@@ -6607,7 +6904,7 @@ class Ge extends m {
|
|
|
6607
6904
|
e.signInput(p, this.signer);
|
|
6608
6905
|
for (let p = 0; p < this.commitmentOutputs.length; p++) {
|
|
6609
6906
|
const f = this.commitmentOutputs[p];
|
|
6610
|
-
e.finalizeInput(p, (
|
|
6907
|
+
e.finalizeInput(p, (y, S) => this.finalizeCommitmentInput(S, f));
|
|
6611
6908
|
}
|
|
6612
6909
|
const l = e.extractTransaction(), d = {
|
|
6613
6910
|
txHex: l.toHex(),
|
|
@@ -6686,14 +6983,14 @@ class Ge extends m {
|
|
|
6686
6983
|
calculateValuePerOutput() {
|
|
6687
6984
|
if (this.cachedValuePerOutput !== null)
|
|
6688
6985
|
return this.cachedValuePerOutput;
|
|
6689
|
-
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;
|
|
6690
6987
|
return this.cachedValuePerOutput = c > u ? c : u, this.cachedValuePerOutput;
|
|
6691
6988
|
}
|
|
6692
6989
|
/**
|
|
6693
6990
|
* Get refund address.
|
|
6694
6991
|
*/
|
|
6695
6992
|
getRefundAddress() {
|
|
6696
|
-
return this.from ? this.from :
|
|
6993
|
+
return this.from ? this.from : fe.generatePKSH(this.signer.publicKey, this.network);
|
|
6697
6994
|
}
|
|
6698
6995
|
/**
|
|
6699
6996
|
* Generate features (same as InteractionTransaction).
|
|
@@ -6702,13 +6999,13 @@ class Ge extends m {
|
|
|
6702
6999
|
const e = [];
|
|
6703
7000
|
t.loadedStorage && e.push({
|
|
6704
7001
|
priority: Q.ACCESS_LIST,
|
|
6705
|
-
opcode:
|
|
7002
|
+
opcode: N.ACCESS_LIST,
|
|
6706
7003
|
data: t.loadedStorage
|
|
6707
7004
|
});
|
|
6708
7005
|
const i = t.challenge.getSubmission();
|
|
6709
7006
|
if (i && e.push({
|
|
6710
7007
|
priority: Q.EPOCH_SUBMISSION,
|
|
6711
|
-
opcode:
|
|
7008
|
+
opcode: N.EPOCH_SUBMISSION,
|
|
6712
7009
|
data: i
|
|
6713
7010
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
6714
7011
|
throw new Error(
|
|
@@ -6720,16 +7017,16 @@ class Ge extends m {
|
|
|
6720
7017
|
* Validate output count is within standard tx limits.
|
|
6721
7018
|
*/
|
|
6722
7019
|
validateOutputCount() {
|
|
6723
|
-
const t =
|
|
7020
|
+
const t = P.calculateMaxInputsPerTx();
|
|
6724
7021
|
if (this.commitmentOutputs.length > t) {
|
|
6725
|
-
const e =
|
|
7022
|
+
const e = P.calculateMaxDataPerTx();
|
|
6726
7023
|
throw new Error(
|
|
6727
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.`
|
|
6728
7025
|
);
|
|
6729
7026
|
}
|
|
6730
7027
|
}
|
|
6731
7028
|
}
|
|
6732
|
-
class
|
|
7029
|
+
class ri {
|
|
6733
7030
|
constructor() {
|
|
6734
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;
|
|
6735
7032
|
}
|
|
@@ -6750,7 +7047,7 @@ class Qe {
|
|
|
6750
7047
|
return e;
|
|
6751
7048
|
if (!("signer" in t))
|
|
6752
7049
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6753
|
-
const r = await new
|
|
7050
|
+
const r = await new Ie(t).signTransaction();
|
|
6754
7051
|
return {
|
|
6755
7052
|
transaction: r.toHex(),
|
|
6756
7053
|
nextUTXOs: this.getUTXOAsTransaction(r, t.from, 0),
|
|
@@ -6773,10 +7070,10 @@ class Qe {
|
|
|
6773
7070
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6774
7071
|
const e = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: i, estimatedAmount: r, challenge: s } = await this.iterateFundingAmount(
|
|
6775
7072
|
{ ...t, optionalInputs: e },
|
|
6776
|
-
|
|
7073
|
+
qt,
|
|
6777
7074
|
async (p) => {
|
|
6778
|
-
const f = await p.estimateTransactionFees(),
|
|
6779
|
-
return f +
|
|
7075
|
+
const f = await p.estimateTransactionFees(), y = this.getPriorityFee(t), S = p.getOptionalOutputValue();
|
|
7076
|
+
return f + y + S;
|
|
6780
7077
|
},
|
|
6781
7078
|
"CustomScript"
|
|
6782
7079
|
), o = await i.getFundingTransactionParameters();
|
|
@@ -6804,7 +7101,7 @@ class Qe {
|
|
|
6804
7101
|
estimatedFees: i.estimatedFees,
|
|
6805
7102
|
compiledTargetScript: i.exportCompiledTargetScript(),
|
|
6806
7103
|
optionalInputs: e
|
|
6807
|
-
}, d = await new
|
|
7104
|
+
}, d = await new qt(h).signTransaction();
|
|
6808
7105
|
return [
|
|
6809
7106
|
u.tx.toHex(),
|
|
6810
7107
|
d.toHex(),
|
|
@@ -6833,10 +7130,10 @@ class Qe {
|
|
|
6833
7130
|
return this.signP2WDAInteraction(t);
|
|
6834
7131
|
const r = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: s, estimatedAmount: o, challenge: c } = await this.iterateFundingAmount(
|
|
6835
7132
|
{ ...t, optionalInputs: r },
|
|
6836
|
-
|
|
7133
|
+
Xt,
|
|
6837
7134
|
async (S) => {
|
|
6838
|
-
const b = await S.estimateTransactionFees(),
|
|
6839
|
-
return b +
|
|
7135
|
+
const b = await S.estimateTransactionFees(), K = S.getTotalOutputValue();
|
|
7136
|
+
return b + K;
|
|
6840
7137
|
},
|
|
6841
7138
|
"Interaction"
|
|
6842
7139
|
);
|
|
@@ -6872,11 +7169,11 @@ class Qe {
|
|
|
6872
7169
|
nonWitnessUtxo: l.tx.toBuffer(),
|
|
6873
7170
|
estimatedFees: s.estimatedFees,
|
|
6874
7171
|
optionalInputs: r
|
|
6875
|
-
}, f = new
|
|
7172
|
+
}, f = new Xt(p), y = await f.signTransaction();
|
|
6876
7173
|
return {
|
|
6877
7174
|
interactionAddress: s.getScriptAddress(),
|
|
6878
7175
|
fundingTransaction: l.tx.toHex(),
|
|
6879
|
-
interactionTransaction:
|
|
7176
|
+
interactionTransaction: y.toHex(),
|
|
6880
7177
|
estimatedFees: f.transactionFee,
|
|
6881
7178
|
nextUTXOs: this.getUTXOAsTransaction(
|
|
6882
7179
|
l.tx,
|
|
@@ -6916,7 +7213,7 @@ class Qe {
|
|
|
6916
7213
|
throw new Error('Field "signer" not provided.');
|
|
6917
7214
|
if (!t.challenge)
|
|
6918
7215
|
throw new Error('Field "challenge" not provided.');
|
|
6919
|
-
const e = this.parseOptionalInputs(t.optionalInputs), i = new
|
|
7216
|
+
const e = this.parseOptionalInputs(t.optionalInputs), i = new ii({
|
|
6920
7217
|
...t,
|
|
6921
7218
|
optionalInputs: e
|
|
6922
7219
|
}), r = await i.build();
|
|
@@ -6946,10 +7243,10 @@ class Qe {
|
|
|
6946
7243
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6947
7244
|
const i = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: o } = await this.iterateFundingAmount(
|
|
6948
7245
|
{ ...t, optionalInputs: i },
|
|
6949
|
-
|
|
6950
|
-
async (
|
|
6951
|
-
const
|
|
6952
|
-
return
|
|
7246
|
+
St,
|
|
7247
|
+
async (Kt) => {
|
|
7248
|
+
const Dt = await Kt.estimateTransactionFees(), Ct = this.getPriorityFee(t), wi = Kt.getOptionalOutputValue();
|
|
7249
|
+
return Dt + Ct + wi;
|
|
6953
7250
|
},
|
|
6954
7251
|
"Deployment"
|
|
6955
7252
|
);
|
|
@@ -6965,7 +7262,7 @@ class Qe {
|
|
|
6965
7262
|
if (!u)
|
|
6966
7263
|
throw new Error("Could not sign funding transaction.");
|
|
6967
7264
|
c.estimatedFees = u.estimatedFees;
|
|
6968
|
-
const l = await new
|
|
7265
|
+
const l = await new $t({
|
|
6969
7266
|
...c,
|
|
6970
7267
|
optionalInputs: [],
|
|
6971
7268
|
optionalOutputs: []
|
|
@@ -6989,7 +7286,7 @@ class Qe {
|
|
|
6989
7286
|
nonWitnessUtxo: l.toBuffer(),
|
|
6990
7287
|
estimatedFees: r.estimatedFees,
|
|
6991
7288
|
optionalInputs: i
|
|
6992
|
-
},
|
|
7289
|
+
}, y = new St(f), S = await y.signTransaction(), b = l.outs[1], K = {
|
|
6993
7290
|
transactionId: l.getId(),
|
|
6994
7291
|
outputIndex: 1,
|
|
6995
7292
|
scriptPubKey: {
|
|
@@ -7000,9 +7297,9 @@ class Qe {
|
|
|
7000
7297
|
};
|
|
7001
7298
|
return {
|
|
7002
7299
|
transaction: [l.toHex(), S.toHex()],
|
|
7003
|
-
contractAddress:
|
|
7004
|
-
contractPubKey:
|
|
7005
|
-
utxos: [
|
|
7300
|
+
contractAddress: y.getContractAddress(),
|
|
7301
|
+
contractPubKey: y.contractPubKey,
|
|
7302
|
+
utxos: [K],
|
|
7006
7303
|
challenge: o.toRaw(),
|
|
7007
7304
|
inputUtxos: t.utxos
|
|
7008
7305
|
};
|
|
@@ -7137,7 +7434,7 @@ class Qe {
|
|
|
7137
7434
|
*/
|
|
7138
7435
|
async createFundTransaction(t) {
|
|
7139
7436
|
if (!t.to) throw new Error('Field "to" not provided.');
|
|
7140
|
-
const e = new
|
|
7437
|
+
const e = new $t(t), i = await e.signTransaction();
|
|
7141
7438
|
if (!i)
|
|
7142
7439
|
throw new Error("Could not sign funding transaction.");
|
|
7143
7440
|
return {
|
|
@@ -7169,7 +7466,7 @@ class Qe {
|
|
|
7169
7466
|
*/
|
|
7170
7467
|
writePSBTHeader(t, e) {
|
|
7171
7468
|
const i = a.from(e, "base64"), r = a.alloc(2);
|
|
7172
|
-
return r.writeUInt8(t, 0), r.writeUInt8(
|
|
7469
|
+
return r.writeUInt8(t, 0), r.writeUInt8(Zt, 1), a.concat([r, i]).toString("hex");
|
|
7173
7470
|
}
|
|
7174
7471
|
/**
|
|
7175
7472
|
* Sign a P2WDA interaction transaction
|
|
@@ -7237,11 +7534,11 @@ class Qe {
|
|
|
7237
7534
|
* @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge: IChallengeSolution | null}>} - The final transaction and estimated amount
|
|
7238
7535
|
*/
|
|
7239
7536
|
async iterateFundingAmount(t, e, i, r) {
|
|
7240
|
-
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);
|
|
7241
7538
|
let c = this.INITIAL_FUNDING_ESTIMATE, u = 0n, h = 0, l = null, d = null;
|
|
7242
7539
|
for (; h < this.MAX_ITERATIONS && c !== u; ) {
|
|
7243
7540
|
u = c;
|
|
7244
|
-
const p = new
|
|
7541
|
+
const p = new ne();
|
|
7245
7542
|
p.addOutput(this.P2TR_SCRIPT, Number(c));
|
|
7246
7543
|
const f = {
|
|
7247
7544
|
transactionId: a.alloc(32, 0).toString("hex"),
|
|
@@ -7253,25 +7550,25 @@ class Qe {
|
|
|
7253
7550
|
value: c,
|
|
7254
7551
|
nonWitnessUtxo: p.toBuffer()
|
|
7255
7552
|
};
|
|
7256
|
-
let
|
|
7257
|
-
"challenge" in t && t.challenge ?
|
|
7553
|
+
let y;
|
|
7554
|
+
"challenge" in t && t.challenge ? y = {
|
|
7258
7555
|
...t,
|
|
7259
7556
|
utxos: [f],
|
|
7260
7557
|
randomBytes: s,
|
|
7261
7558
|
challenge: d ?? t.challenge
|
|
7262
|
-
} :
|
|
7559
|
+
} : y = {
|
|
7263
7560
|
...t,
|
|
7264
7561
|
utxos: [f],
|
|
7265
7562
|
randomBytes: s
|
|
7266
7563
|
};
|
|
7267
|
-
const S = new e(
|
|
7564
|
+
const S = new e(y);
|
|
7268
7565
|
try {
|
|
7269
7566
|
await S.generateTransactionMinimalSignatures(), c = await i(S);
|
|
7270
7567
|
} catch (b) {
|
|
7271
7568
|
if (b instanceof Error) {
|
|
7272
|
-
const
|
|
7273
|
-
if (
|
|
7274
|
-
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(
|
|
7275
7572
|
`${r}: Caught insufficient funds, updating to ${c}`
|
|
7276
7573
|
);
|
|
7277
7574
|
else
|
|
@@ -7323,11 +7620,11 @@ class x extends m {
|
|
|
7323
7620
|
if (super({
|
|
7324
7621
|
...t,
|
|
7325
7622
|
signer: A.fromPrivateKey(
|
|
7326
|
-
|
|
7623
|
+
Fe(a.from("aaaaaaaa", "utf-8"))
|
|
7327
7624
|
),
|
|
7328
7625
|
priorityFee: 0n,
|
|
7329
7626
|
gasSatFee: 0n
|
|
7330
|
-
}), this.type =
|
|
7627
|
+
}), this.type = w.MULTI_SIG, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.originalInputCount = 0, this.sighashTypes = x.signHashTypesArray, this.customFinalizer = (e, i) => {
|
|
7331
7628
|
if (!this.tapLeafScript)
|
|
7332
7629
|
throw new Error("Tap leaf script is required");
|
|
7333
7630
|
const s = this.getScriptSolution(i).concat(this.tapLeafScript.script).concat(this.tapLeafScript.controlBlock);
|
|
@@ -7336,7 +7633,7 @@ class x extends m {
|
|
|
7336
7633
|
};
|
|
7337
7634
|
}, !t.pubkeys)
|
|
7338
7635
|
throw new Error("Pubkeys are required");
|
|
7339
|
-
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(
|
|
7340
7637
|
t.pubkeys,
|
|
7341
7638
|
this.minimumSignatures
|
|
7342
7639
|
), this.scriptTree = this.getScriptTree(), this.internalInit();
|
|
@@ -7366,7 +7663,7 @@ class x extends m {
|
|
|
7366
7663
|
* @returns {MultiSignTransaction} The multisig transaction
|
|
7367
7664
|
*/
|
|
7368
7665
|
static fromBase64(t) {
|
|
7369
|
-
const e =
|
|
7666
|
+
const e = R.fromBase64(t.psbt, { network: t.network });
|
|
7370
7667
|
return new x({
|
|
7371
7668
|
...t,
|
|
7372
7669
|
psbt: e
|
|
@@ -7427,7 +7724,7 @@ class x extends m {
|
|
|
7427
7724
|
});
|
|
7428
7725
|
u.tapScriptSig = (u.tapScriptSig || []).concat(h);
|
|
7429
7726
|
}
|
|
7430
|
-
|
|
7727
|
+
Reflect.deleteProperty(u, "finalScriptWitness");
|
|
7431
7728
|
const l = x.signHashTypesArray ? [x.calculateSignHash(x.signHashTypesArray)] : [];
|
|
7432
7729
|
try {
|
|
7433
7730
|
x.signInput(t, u, c, e, l), s = !0;
|
|
@@ -7519,7 +7816,7 @@ class x extends m {
|
|
|
7519
7816
|
u
|
|
7520
7817
|
);
|
|
7521
7818
|
}
|
|
7522
|
-
|
|
7819
|
+
Reflect.deleteProperty(c, "finalScriptWitness"), t.finalizeInput(
|
|
7523
7820
|
o,
|
|
7524
7821
|
(h, l) => x.partialFinalizer(
|
|
7525
7822
|
h,
|
|
@@ -7627,7 +7924,7 @@ class x extends m {
|
|
|
7627
7924
|
//this.internalPubKeyToXOnly(),
|
|
7628
7925
|
network: this.network,
|
|
7629
7926
|
scriptTree: this.scriptTree,
|
|
7630
|
-
name:
|
|
7927
|
+
name: U.P2TR
|
|
7631
7928
|
};
|
|
7632
7929
|
}
|
|
7633
7930
|
generateTapData() {
|
|
@@ -7642,7 +7939,7 @@ class x extends m {
|
|
|
7642
7939
|
network: this.network,
|
|
7643
7940
|
scriptTree: this.scriptTree,
|
|
7644
7941
|
redeem: t,
|
|
7645
|
-
name:
|
|
7942
|
+
name: U.P2TR
|
|
7646
7943
|
};
|
|
7647
7944
|
}
|
|
7648
7945
|
/**
|
|
@@ -7699,34 +7996,34 @@ class x extends m {
|
|
|
7699
7996
|
*/
|
|
7700
7997
|
generateRedeemScripts() {
|
|
7701
7998
|
this.targetScriptRedeem = {
|
|
7702
|
-
name:
|
|
7999
|
+
name: U.P2TR,
|
|
7703
8000
|
output: this.compiledTargetScript,
|
|
7704
8001
|
redeemVersion: 192
|
|
7705
8002
|
}, this.leftOverFundsScriptRedeem = {
|
|
7706
|
-
name:
|
|
8003
|
+
name: U.P2TR,
|
|
7707
8004
|
output: x.LOCK_LEAF_SCRIPT,
|
|
7708
8005
|
redeemVersion: 192
|
|
7709
8006
|
};
|
|
7710
8007
|
}
|
|
7711
8008
|
}
|
|
7712
|
-
const
|
|
7713
|
-
function
|
|
7714
|
-
return n.type ===
|
|
8009
|
+
const Te = 1, Nt = 66;
|
|
8010
|
+
function si(n) {
|
|
8011
|
+
return n.type === w.FUNDING;
|
|
7715
8012
|
}
|
|
7716
|
-
function
|
|
7717
|
-
return n.type ===
|
|
8013
|
+
function ni(n) {
|
|
8014
|
+
return n.type === w.DEPLOYMENT;
|
|
7718
8015
|
}
|
|
7719
|
-
function
|
|
7720
|
-
return n.type ===
|
|
8016
|
+
function oi(n) {
|
|
8017
|
+
return n.type === w.INTERACTION;
|
|
7721
8018
|
}
|
|
7722
8019
|
function et(n) {
|
|
7723
|
-
return n.type ===
|
|
8020
|
+
return n.type === w.MULTI_SIG;
|
|
7724
8021
|
}
|
|
7725
|
-
function
|
|
7726
|
-
return n.type ===
|
|
8022
|
+
function ai(n) {
|
|
8023
|
+
return n.type === w.CUSTOM_CODE;
|
|
7727
8024
|
}
|
|
7728
|
-
function
|
|
7729
|
-
return n.type ===
|
|
8025
|
+
function ci(n) {
|
|
8026
|
+
return n.type === w.CANCEL;
|
|
7730
8027
|
}
|
|
7731
8028
|
class B {
|
|
7732
8029
|
/**
|
|
@@ -7735,7 +8032,7 @@ class B {
|
|
|
7735
8032
|
* @returns Buffer containing serialized state with checksum
|
|
7736
8033
|
*/
|
|
7737
8034
|
static serialize(t) {
|
|
7738
|
-
const e = new
|
|
8035
|
+
const e = new C();
|
|
7739
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);
|
|
7740
8037
|
const i = a.from(e.getBuffer()), r = this.calculateChecksum(i);
|
|
7741
8038
|
return a.concat([i, r]);
|
|
@@ -7752,10 +8049,10 @@ class B {
|
|
|
7752
8049
|
const e = t.subarray(-32), i = t.subarray(0, -32), r = this.calculateChecksum(i);
|
|
7753
8050
|
if (!e.equals(r))
|
|
7754
8051
|
throw new Error("Invalid checksum - data may be corrupted");
|
|
7755
|
-
const s = new
|
|
7756
|
-
if (o.formatVersion >
|
|
8052
|
+
const s = new jt(i), o = this.readHeader(s);
|
|
8053
|
+
if (o.formatVersion > Te)
|
|
7757
8054
|
throw new Error(`Unsupported format version: ${o.formatVersion}`);
|
|
7758
|
-
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),
|
|
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);
|
|
7759
8056
|
return {
|
|
7760
8057
|
header: o,
|
|
7761
8058
|
baseParams: c,
|
|
@@ -7765,7 +8062,7 @@ class B {
|
|
|
7765
8062
|
addressRotationEnabled: d,
|
|
7766
8063
|
signerMappings: p,
|
|
7767
8064
|
typeSpecificData: f,
|
|
7768
|
-
precomputedData:
|
|
8065
|
+
precomputedData: y
|
|
7769
8066
|
};
|
|
7770
8067
|
}
|
|
7771
8068
|
/**
|
|
@@ -7801,13 +8098,13 @@ class B {
|
|
|
7801
8098
|
return this.deserialize(a.from(t, "hex"));
|
|
7802
8099
|
}
|
|
7803
8100
|
static writeHeader(t, e) {
|
|
7804
|
-
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));
|
|
7805
8102
|
}
|
|
7806
8103
|
static readHeader(t) {
|
|
7807
8104
|
const e = t.readU8();
|
|
7808
|
-
if (e !==
|
|
8105
|
+
if (e !== Nt)
|
|
7809
8106
|
throw new Error(
|
|
7810
|
-
`Invalid magic byte: expected 0x${
|
|
8107
|
+
`Invalid magic byte: expected 0x${Nt.toString(16)}, got 0x${e.toString(16)}`
|
|
7811
8108
|
);
|
|
7812
8109
|
return {
|
|
7813
8110
|
formatVersion: t.readU8(),
|
|
@@ -7900,22 +8197,22 @@ class B {
|
|
|
7900
8197
|
}
|
|
7901
8198
|
static writeTypeSpecificData(t, e) {
|
|
7902
8199
|
switch (e.type) {
|
|
7903
|
-
case
|
|
8200
|
+
case w.FUNDING:
|
|
7904
8201
|
this.writeFundingData(t, e);
|
|
7905
8202
|
break;
|
|
7906
|
-
case
|
|
8203
|
+
case w.DEPLOYMENT:
|
|
7907
8204
|
this.writeDeploymentData(t, e);
|
|
7908
8205
|
break;
|
|
7909
|
-
case
|
|
8206
|
+
case w.INTERACTION:
|
|
7910
8207
|
this.writeInteractionData(t, e);
|
|
7911
8208
|
break;
|
|
7912
|
-
case
|
|
8209
|
+
case w.MULTI_SIG:
|
|
7913
8210
|
this.writeMultiSigData(t, e);
|
|
7914
8211
|
break;
|
|
7915
|
-
case
|
|
8212
|
+
case w.CUSTOM_CODE:
|
|
7916
8213
|
this.writeCustomScriptData(t, e);
|
|
7917
8214
|
break;
|
|
7918
|
-
case
|
|
8215
|
+
case w.CANCEL:
|
|
7919
8216
|
this.writeCancelData(t, e);
|
|
7920
8217
|
break;
|
|
7921
8218
|
default:
|
|
@@ -7924,17 +8221,17 @@ class B {
|
|
|
7924
8221
|
}
|
|
7925
8222
|
static readTypeSpecificData(t, e) {
|
|
7926
8223
|
switch (e) {
|
|
7927
|
-
case
|
|
8224
|
+
case w.FUNDING:
|
|
7928
8225
|
return this.readFundingData(t);
|
|
7929
|
-
case
|
|
8226
|
+
case w.DEPLOYMENT:
|
|
7930
8227
|
return this.readDeploymentData(t);
|
|
7931
|
-
case
|
|
8228
|
+
case w.INTERACTION:
|
|
7932
8229
|
return this.readInteractionData(t);
|
|
7933
|
-
case
|
|
8230
|
+
case w.MULTI_SIG:
|
|
7934
8231
|
return this.readMultiSigData(t);
|
|
7935
|
-
case
|
|
8232
|
+
case w.CUSTOM_CODE:
|
|
7936
8233
|
return this.readCustomScriptData(t);
|
|
7937
|
-
case
|
|
8234
|
+
case w.CANCEL:
|
|
7938
8235
|
return this.readCancelData(t);
|
|
7939
8236
|
default:
|
|
7940
8237
|
throw new Error(`Unsupported transaction type: ${e}`);
|
|
@@ -7946,7 +8243,7 @@ class B {
|
|
|
7946
8243
|
}
|
|
7947
8244
|
static readFundingData(t) {
|
|
7948
8245
|
return {
|
|
7949
|
-
type:
|
|
8246
|
+
type: w.FUNDING,
|
|
7950
8247
|
amount: t.readU64().toString(),
|
|
7951
8248
|
splitInputsInto: t.readU16()
|
|
7952
8249
|
};
|
|
@@ -7958,7 +8255,7 @@ class B {
|
|
|
7958
8255
|
static readDeploymentData(t) {
|
|
7959
8256
|
const e = a.from(t.readBytesWithLength()).toString("hex"), r = t.readBoolean() ? a.from(t.readBytesWithLength()).toString("hex") : void 0, s = this.readChallenge(t), o = t.readBoolean(), c = t.readBoolean(), h = t.readBoolean() ? a.from(t.readBytesWithLength()).toString("hex") : void 0;
|
|
7960
8257
|
return {
|
|
7961
|
-
type:
|
|
8258
|
+
type: w.DEPLOYMENT,
|
|
7962
8259
|
bytecode: e,
|
|
7963
8260
|
calldata: r,
|
|
7964
8261
|
challenge: s,
|
|
@@ -7974,7 +8271,7 @@ class B {
|
|
|
7974
8271
|
static readInteractionData(t) {
|
|
7975
8272
|
const e = a.from(t.readBytesWithLength()).toString("hex"), r = t.readBoolean() ? t.readStringWithLength() : void 0, s = this.readChallenge(t), c = t.readBoolean() ? this.readLoadedStorage(t) : void 0, u = t.readBoolean(), h = t.readBoolean(), l = t.readBoolean(), d = t.readBoolean(), f = t.readBoolean() ? a.from(t.readBytesWithLength()).toString("hex") : void 0;
|
|
7976
8273
|
return {
|
|
7977
|
-
type:
|
|
8274
|
+
type: w.INTERACTION,
|
|
7978
8275
|
calldata: e,
|
|
7979
8276
|
contract: r,
|
|
7980
8277
|
challenge: s,
|
|
@@ -7999,7 +8296,7 @@ class B {
|
|
|
7999
8296
|
i.push(a.from(t.readBytesWithLength()).toString("hex"));
|
|
8000
8297
|
const r = t.readU8(), s = t.readStringWithLength(), o = t.readU64().toString(), c = t.readStringWithLength(), u = t.readU16(), l = t.readBoolean() ? t.readStringWithLength() : void 0;
|
|
8001
8298
|
return {
|
|
8002
|
-
type:
|
|
8299
|
+
type: w.MULTI_SIG,
|
|
8003
8300
|
pubkeys: i,
|
|
8004
8301
|
minimumSignatures: r,
|
|
8005
8302
|
receiver: s,
|
|
@@ -8031,7 +8328,7 @@ class B {
|
|
|
8031
8328
|
s.push(a.from(t.readBytesWithLength()).toString("hex"));
|
|
8032
8329
|
const c = t.readBoolean() ? a.from(t.readBytesWithLength()).toString("hex") : void 0;
|
|
8033
8330
|
return {
|
|
8034
|
-
type:
|
|
8331
|
+
type: w.CUSTOM_CODE,
|
|
8035
8332
|
scriptElements: i,
|
|
8036
8333
|
witnesses: s,
|
|
8037
8334
|
annex: c
|
|
@@ -8052,7 +8349,7 @@ class B {
|
|
|
8052
8349
|
}
|
|
8053
8350
|
static readCancelData(t) {
|
|
8054
8351
|
return {
|
|
8055
|
-
type:
|
|
8352
|
+
type: w.CANCEL,
|
|
8056
8353
|
compiledTargetScript: a.from(t.readBytesWithLength()).toString("hex")
|
|
8057
8354
|
};
|
|
8058
8355
|
}
|
|
@@ -8076,13 +8373,13 @@ class B {
|
|
|
8076
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();
|
|
8077
8374
|
let d;
|
|
8078
8375
|
if (l) {
|
|
8079
|
-
const p = t.readStringWithLength(), f = t.readStringWithLength(),
|
|
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");
|
|
8080
8377
|
d = {
|
|
8081
8378
|
mldsaPublicKey: p,
|
|
8082
8379
|
legacyPublicKey: f,
|
|
8083
|
-
solution:
|
|
8380
|
+
solution: y,
|
|
8084
8381
|
graffiti: b,
|
|
8085
|
-
signature:
|
|
8382
|
+
signature: K
|
|
8086
8383
|
};
|
|
8087
8384
|
}
|
|
8088
8385
|
return {
|
|
@@ -8142,8 +8439,8 @@ class B {
|
|
|
8142
8439
|
* Calculate double SHA256 checksum (Bitcoin standard)
|
|
8143
8440
|
*/
|
|
8144
8441
|
static calculateChecksum(t) {
|
|
8145
|
-
const e =
|
|
8146
|
-
return
|
|
8442
|
+
const e = ie("sha256").update(t).digest();
|
|
8443
|
+
return ie("sha256").update(e).digest();
|
|
8147
8444
|
}
|
|
8148
8445
|
static networkNameToU8(t) {
|
|
8149
8446
|
switch (t) {
|
|
@@ -8177,7 +8474,7 @@ class $ {
|
|
|
8177
8474
|
static fromFunding(t, e) {
|
|
8178
8475
|
return this.captureState({
|
|
8179
8476
|
params: t,
|
|
8180
|
-
type:
|
|
8477
|
+
type: w.FUNDING,
|
|
8181
8478
|
precomputed: e
|
|
8182
8479
|
});
|
|
8183
8480
|
}
|
|
@@ -8187,7 +8484,7 @@ class $ {
|
|
|
8187
8484
|
static fromDeployment(t, e) {
|
|
8188
8485
|
return this.captureState({
|
|
8189
8486
|
params: t,
|
|
8190
|
-
type:
|
|
8487
|
+
type: w.DEPLOYMENT,
|
|
8191
8488
|
precomputed: e
|
|
8192
8489
|
});
|
|
8193
8490
|
}
|
|
@@ -8197,7 +8494,7 @@ class $ {
|
|
|
8197
8494
|
static fromInteraction(t, e) {
|
|
8198
8495
|
return this.captureState({
|
|
8199
8496
|
params: t,
|
|
8200
|
-
type:
|
|
8497
|
+
type: w.INTERACTION,
|
|
8201
8498
|
precomputed: e
|
|
8202
8499
|
});
|
|
8203
8500
|
}
|
|
@@ -8207,7 +8504,7 @@ class $ {
|
|
|
8207
8504
|
static fromMultiSig(t, e) {
|
|
8208
8505
|
return this.captureState({
|
|
8209
8506
|
params: t,
|
|
8210
|
-
type:
|
|
8507
|
+
type: w.MULTI_SIG,
|
|
8211
8508
|
precomputed: e
|
|
8212
8509
|
});
|
|
8213
8510
|
}
|
|
@@ -8217,7 +8514,7 @@ class $ {
|
|
|
8217
8514
|
static fromCustomScript(t, e) {
|
|
8218
8515
|
return this.captureState({
|
|
8219
8516
|
params: t,
|
|
8220
|
-
type:
|
|
8517
|
+
type: w.CUSTOM_CODE,
|
|
8221
8518
|
precomputed: e
|
|
8222
8519
|
});
|
|
8223
8520
|
}
|
|
@@ -8227,7 +8524,7 @@ class $ {
|
|
|
8227
8524
|
static fromCancel(t, e) {
|
|
8228
8525
|
return this.captureState({
|
|
8229
8526
|
params: t,
|
|
8230
|
-
type:
|
|
8527
|
+
type: w.CANCEL,
|
|
8231
8528
|
precomputed: e
|
|
8232
8529
|
});
|
|
8233
8530
|
}
|
|
@@ -8253,8 +8550,8 @@ class $ {
|
|
|
8253
8550
|
*/
|
|
8254
8551
|
static createHeader(t, e, i) {
|
|
8255
8552
|
return {
|
|
8256
|
-
formatVersion:
|
|
8257
|
-
consensusVersion:
|
|
8553
|
+
formatVersion: Te,
|
|
8554
|
+
consensusVersion: Zt,
|
|
8258
8555
|
transactionType: t,
|
|
8259
8556
|
chainId: i ?? this.networkToChainId(e),
|
|
8260
8557
|
timestamp: Date.now()
|
|
@@ -8308,17 +8605,17 @@ class $ {
|
|
|
8308
8605
|
*/
|
|
8309
8606
|
static extractTypeSpecificData(t, e) {
|
|
8310
8607
|
switch (t) {
|
|
8311
|
-
case
|
|
8608
|
+
case w.FUNDING:
|
|
8312
8609
|
return this.extractFundingData(e);
|
|
8313
|
-
case
|
|
8610
|
+
case w.DEPLOYMENT:
|
|
8314
8611
|
return this.extractDeploymentData(e);
|
|
8315
|
-
case
|
|
8612
|
+
case w.INTERACTION:
|
|
8316
8613
|
return this.extractInteractionData(e);
|
|
8317
|
-
case
|
|
8614
|
+
case w.MULTI_SIG:
|
|
8318
8615
|
return this.extractMultiSigData(e);
|
|
8319
|
-
case
|
|
8616
|
+
case w.CUSTOM_CODE:
|
|
8320
8617
|
return this.extractCustomScriptData(e);
|
|
8321
|
-
case
|
|
8618
|
+
case w.CANCEL:
|
|
8322
8619
|
return this.extractCancelData(e);
|
|
8323
8620
|
default:
|
|
8324
8621
|
throw new Error(`Unsupported transaction type: ${t}`);
|
|
@@ -8326,14 +8623,14 @@ class $ {
|
|
|
8326
8623
|
}
|
|
8327
8624
|
static extractFundingData(t) {
|
|
8328
8625
|
return {
|
|
8329
|
-
type:
|
|
8626
|
+
type: w.FUNDING,
|
|
8330
8627
|
amount: t.amount.toString(),
|
|
8331
8628
|
splitInputsInto: t.splitInputsInto ?? 1
|
|
8332
8629
|
};
|
|
8333
8630
|
}
|
|
8334
8631
|
static extractDeploymentData(t) {
|
|
8335
8632
|
return {
|
|
8336
|
-
type:
|
|
8633
|
+
type: w.DEPLOYMENT,
|
|
8337
8634
|
bytecode: t.bytecode.toString("hex"),
|
|
8338
8635
|
calldata: t.calldata?.toString("hex"),
|
|
8339
8636
|
challenge: t.challenge.toRaw(),
|
|
@@ -8343,7 +8640,7 @@ class $ {
|
|
|
8343
8640
|
}
|
|
8344
8641
|
static extractInteractionData(t) {
|
|
8345
8642
|
return {
|
|
8346
|
-
type:
|
|
8643
|
+
type: w.INTERACTION,
|
|
8347
8644
|
calldata: t.calldata.toString("hex"),
|
|
8348
8645
|
contract: t.contract,
|
|
8349
8646
|
challenge: t.challenge.toRaw(),
|
|
@@ -8356,7 +8653,7 @@ class $ {
|
|
|
8356
8653
|
}
|
|
8357
8654
|
static extractMultiSigData(t) {
|
|
8358
8655
|
return {
|
|
8359
|
-
type:
|
|
8656
|
+
type: w.MULTI_SIG,
|
|
8360
8657
|
pubkeys: (t.pubkeys || []).map((e) => e.toString("hex")),
|
|
8361
8658
|
minimumSignatures: t.minimumSignatures || 0,
|
|
8362
8659
|
receiver: t.receiver || "",
|
|
@@ -8377,7 +8674,7 @@ class $ {
|
|
|
8377
8674
|
}
|
|
8378
8675
|
);
|
|
8379
8676
|
return {
|
|
8380
|
-
type:
|
|
8677
|
+
type: w.CUSTOM_CODE,
|
|
8381
8678
|
scriptElements: e,
|
|
8382
8679
|
witnesses: (t.witnesses || []).map((i) => i.toString("hex")),
|
|
8383
8680
|
annex: t.annex?.toString("hex")
|
|
@@ -8386,7 +8683,7 @@ class $ {
|
|
|
8386
8683
|
static extractCancelData(t) {
|
|
8387
8684
|
const e = t.compiledTargetScript, i = e ? a.isBuffer(e) ? e.toString("hex") : e : "";
|
|
8388
8685
|
return {
|
|
8389
|
-
type:
|
|
8686
|
+
type: w.CANCEL,
|
|
8390
8687
|
compiledTargetScript: i
|
|
8391
8688
|
};
|
|
8392
8689
|
}
|
|
@@ -8441,10 +8738,10 @@ class $ {
|
|
|
8441
8738
|
* Convert network to chain ID
|
|
8442
8739
|
*/
|
|
8443
8740
|
static networkToChainId(t) {
|
|
8444
|
-
return
|
|
8741
|
+
return Se.Bitcoin;
|
|
8445
8742
|
}
|
|
8446
8743
|
}
|
|
8447
|
-
function
|
|
8744
|
+
function _(n) {
|
|
8448
8745
|
return a.from(n.replace("0x", ""), "hex");
|
|
8449
8746
|
}
|
|
8450
8747
|
class ct {
|
|
@@ -8467,7 +8764,7 @@ class ct {
|
|
|
8467
8764
|
* Calculate SHA-1 hash
|
|
8468
8765
|
*/
|
|
8469
8766
|
static sha1(t) {
|
|
8470
|
-
return
|
|
8767
|
+
return Ci(a.isBuffer(t) ? t : a.from(t));
|
|
8471
8768
|
}
|
|
8472
8769
|
/**
|
|
8473
8770
|
* Calculate mining preimage
|
|
@@ -8533,17 +8830,17 @@ class ct {
|
|
|
8533
8830
|
*/
|
|
8534
8831
|
static validateEpochWinner(t) {
|
|
8535
8832
|
try {
|
|
8536
|
-
const e = BigInt(t.epochNumber), i =
|
|
8833
|
+
const e = BigInt(t.epochNumber), i = v.fromString(
|
|
8537
8834
|
t.mldsaPublicKey,
|
|
8538
8835
|
t.legacyPublicKey
|
|
8539
|
-
), r =
|
|
8540
|
-
epochHash:
|
|
8541
|
-
epochRoot:
|
|
8542
|
-
targetHash:
|
|
8543
|
-
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),
|
|
8544
8841
|
startBlock: BigInt(t.verification.startBlock),
|
|
8545
8842
|
endBlock: BigInt(t.verification.endBlock),
|
|
8546
|
-
proofs: Object.freeze(t.verification.proofs.map((
|
|
8843
|
+
proofs: Object.freeze(t.verification.proofs.map((y) => _(y)))
|
|
8547
8844
|
}, u = this.calculatePreimage(
|
|
8548
8845
|
c.targetChecksum,
|
|
8549
8846
|
i.toBuffer(),
|
|
@@ -8588,17 +8885,17 @@ class ct {
|
|
|
8588
8885
|
};
|
|
8589
8886
|
}
|
|
8590
8887
|
}
|
|
8591
|
-
class
|
|
8888
|
+
class ui {
|
|
8592
8889
|
constructor(t) {
|
|
8593
|
-
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)));
|
|
8594
8891
|
}
|
|
8595
8892
|
}
|
|
8596
|
-
class
|
|
8893
|
+
class hi {
|
|
8597
8894
|
constructor(t, e) {
|
|
8598
|
-
this.epochNumber = e, this.publicKey =
|
|
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);
|
|
8599
8896
|
}
|
|
8600
8897
|
verifySignature() {
|
|
8601
|
-
const t = new
|
|
8898
|
+
const t = new C();
|
|
8602
8899
|
t.writeAddress(this.publicKey), t.writeU64(this.epochNumber), t.writeBytes(this.solution), this.graffiti && t.writeBytes(this.graffiti);
|
|
8603
8900
|
const e = t.getBuffer();
|
|
8604
8901
|
return st.verifySignature(
|
|
@@ -8608,9 +8905,9 @@ class ri {
|
|
|
8608
8905
|
);
|
|
8609
8906
|
}
|
|
8610
8907
|
}
|
|
8611
|
-
class
|
|
8908
|
+
class he {
|
|
8612
8909
|
constructor(t) {
|
|
8613
|
-
this.epochNumber = BigInt(t.epochNumber), this.publicKey =
|
|
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;
|
|
8614
8911
|
}
|
|
8615
8912
|
/**
|
|
8616
8913
|
* Static method to validate from raw data directly
|
|
@@ -8737,17 +9034,17 @@ class ut {
|
|
|
8737
9034
|
estimatedFees: t.precomputedData.estimatedFees ? BigInt(t.precomputedData.estimatedFees) : void 0,
|
|
8738
9035
|
compiledTargetScript: t.precomputedData.compiledTargetScript ? a.from(t.precomputedData.compiledTargetScript, "hex") : void 0
|
|
8739
9036
|
}, p = t.typeSpecificData;
|
|
8740
|
-
if (
|
|
9037
|
+
if (si(p))
|
|
8741
9038
|
return this.reconstructFunding(d, p);
|
|
8742
|
-
if (
|
|
9039
|
+
if (ni(p))
|
|
8743
9040
|
return this.reconstructDeployment(d, p, t);
|
|
8744
|
-
if (
|
|
9041
|
+
if (oi(p))
|
|
8745
9042
|
return this.reconstructInteraction(d, p, t);
|
|
8746
9043
|
if (et(p))
|
|
8747
9044
|
return this.reconstructMultiSig(d, p);
|
|
8748
|
-
if (
|
|
9045
|
+
if (ai(p))
|
|
8749
9046
|
return this.reconstructCustomScript(d, p, t);
|
|
8750
|
-
if (
|
|
9047
|
+
if (ci(p))
|
|
8751
9048
|
return this.reconstructCancel(d, p);
|
|
8752
9049
|
throw new Error(`Unsupported transaction type: ${t.header.transactionType}`);
|
|
8753
9050
|
}
|
|
@@ -8760,13 +9057,13 @@ class ut {
|
|
|
8760
9057
|
amount: BigInt(e.amount),
|
|
8761
9058
|
splitInputsInto: e.splitInputsInto
|
|
8762
9059
|
};
|
|
8763
|
-
return new
|
|
9060
|
+
return new $t(i);
|
|
8764
9061
|
}
|
|
8765
9062
|
/**
|
|
8766
9063
|
* Reconstruct a DeploymentTransaction
|
|
8767
9064
|
*/
|
|
8768
9065
|
static reconstructDeployment(t, e, i) {
|
|
8769
|
-
const r = new
|
|
9066
|
+
const r = new he(e.challenge), s = {
|
|
8770
9067
|
...t,
|
|
8771
9068
|
bytecode: a.from(e.bytecode, "hex"),
|
|
8772
9069
|
calldata: e.calldata ? a.from(e.calldata, "hex") : void 0,
|
|
@@ -8775,13 +9072,13 @@ class ut {
|
|
|
8775
9072
|
revealMLDSAPublicKey: e.revealMLDSAPublicKey,
|
|
8776
9073
|
linkMLDSAPublicKeyToAddress: e.linkMLDSAPublicKeyToAddress
|
|
8777
9074
|
};
|
|
8778
|
-
return new
|
|
9075
|
+
return new St(s);
|
|
8779
9076
|
}
|
|
8780
9077
|
/**
|
|
8781
9078
|
* Reconstruct an InteractionTransaction
|
|
8782
9079
|
*/
|
|
8783
9080
|
static reconstructInteraction(t, e, i) {
|
|
8784
|
-
const r = new
|
|
9081
|
+
const r = new he(e.challenge);
|
|
8785
9082
|
if (!t.to)
|
|
8786
9083
|
throw new Error('InteractionTransaction requires a "to" address');
|
|
8787
9084
|
const s = {
|
|
@@ -8797,7 +9094,7 @@ class ut {
|
|
|
8797
9094
|
revealMLDSAPublicKey: e.revealMLDSAPublicKey,
|
|
8798
9095
|
linkMLDSAPublicKeyToAddress: e.linkMLDSAPublicKeyToAddress
|
|
8799
9096
|
};
|
|
8800
|
-
return new
|
|
9097
|
+
return new Xt(s);
|
|
8801
9098
|
}
|
|
8802
9099
|
/**
|
|
8803
9100
|
* Reconstruct a MultiSignTransaction
|
|
@@ -8851,7 +9148,7 @@ class ut {
|
|
|
8851
9148
|
annex: o,
|
|
8852
9149
|
randomBytes: i.precomputedData.randomBytes ? a.from(i.precomputedData.randomBytes, "hex") : void 0
|
|
8853
9150
|
};
|
|
8854
|
-
return new
|
|
9151
|
+
return new qt(c);
|
|
8855
9152
|
}
|
|
8856
9153
|
/**
|
|
8857
9154
|
* Reconstruct a CancelTransaction
|
|
@@ -8861,7 +9158,7 @@ class ut {
|
|
|
8861
9158
|
...t,
|
|
8862
9159
|
compiledTargetScript: a.from(e.compiledTargetScript, "hex")
|
|
8863
9160
|
};
|
|
8864
|
-
return new
|
|
9161
|
+
return new Ie(i);
|
|
8865
9162
|
}
|
|
8866
9163
|
/**
|
|
8867
9164
|
* Build address rotation config from options
|
|
@@ -8924,15 +9221,15 @@ class ut {
|
|
|
8924
9221
|
case "mainnet":
|
|
8925
9222
|
return I;
|
|
8926
9223
|
case "testnet":
|
|
8927
|
-
return
|
|
9224
|
+
return Lt;
|
|
8928
9225
|
case "regtest":
|
|
8929
|
-
return
|
|
9226
|
+
return Qt;
|
|
8930
9227
|
default:
|
|
8931
9228
|
throw new Error(`Unknown network: ${t}`);
|
|
8932
9229
|
}
|
|
8933
9230
|
}
|
|
8934
9231
|
}
|
|
8935
|
-
class
|
|
9232
|
+
class dr {
|
|
8936
9233
|
/**
|
|
8937
9234
|
* Export a FundingTransaction for offline signing
|
|
8938
9235
|
* @param params - Funding transaction parameters
|
|
@@ -9005,19 +9302,19 @@ class ur {
|
|
|
9005
9302
|
const r = t.type;
|
|
9006
9303
|
let s;
|
|
9007
9304
|
switch (r) {
|
|
9008
|
-
case
|
|
9305
|
+
case w.FUNDING:
|
|
9009
9306
|
s = $.fromFunding(
|
|
9010
9307
|
e,
|
|
9011
9308
|
i
|
|
9012
9309
|
);
|
|
9013
9310
|
break;
|
|
9014
|
-
case
|
|
9311
|
+
case w.DEPLOYMENT:
|
|
9015
9312
|
s = $.fromDeployment(
|
|
9016
9313
|
e,
|
|
9017
9314
|
i
|
|
9018
9315
|
);
|
|
9019
9316
|
break;
|
|
9020
|
-
case
|
|
9317
|
+
case w.INTERACTION:
|
|
9021
9318
|
s = $.fromInteraction(
|
|
9022
9319
|
e,
|
|
9023
9320
|
i
|
|
@@ -9164,7 +9461,7 @@ class ur {
|
|
|
9164
9461
|
const r = i.typeSpecificData, s = r.pubkeys.map((f) => a.from(f, "hex"));
|
|
9165
9462
|
let o;
|
|
9166
9463
|
const c = ut.nameToNetwork(i.baseParams.networkName);
|
|
9167
|
-
r.existingPsbtBase64 ? o =
|
|
9464
|
+
r.existingPsbtBase64 ? o = R.fromBase64(r.existingPsbtBase64, { network: c }) : o = await this.importForSigning(t, {
|
|
9168
9465
|
signer: e
|
|
9169
9466
|
}).signPSBT();
|
|
9170
9467
|
const u = [];
|
|
@@ -9212,7 +9509,7 @@ class ur {
|
|
|
9212
9509
|
const r = i.typeSpecificData;
|
|
9213
9510
|
if (!r.existingPsbtBase64)
|
|
9214
9511
|
return !1;
|
|
9215
|
-
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");
|
|
9216
9513
|
return x.verifyIfSigned(o, c);
|
|
9217
9514
|
}
|
|
9218
9515
|
/**
|
|
@@ -9233,7 +9530,7 @@ class ur {
|
|
|
9233
9530
|
isComplete: !1,
|
|
9234
9531
|
signers: []
|
|
9235
9532
|
};
|
|
9236
|
-
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();
|
|
9237
9534
|
for (let h = i.originalInputCount; h < o.data.inputs.length; h++) {
|
|
9238
9535
|
const l = o.data.inputs[h];
|
|
9239
9536
|
if (l.tapScriptSig)
|
|
@@ -9271,7 +9568,7 @@ class ur {
|
|
|
9271
9568
|
const i = e.typeSpecificData;
|
|
9272
9569
|
if (!i.existingPsbtBase64)
|
|
9273
9570
|
throw new Error("No PSBT found in state - transaction has not been signed");
|
|
9274
|
-
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 = [];
|
|
9275
9572
|
for (let h = i.originalInputCount; h < s.data.inputs.length; h++)
|
|
9276
9573
|
c.push(o);
|
|
9277
9574
|
if (!x.attemptFinalizeInputs(
|
|
@@ -9317,7 +9614,7 @@ class ur {
|
|
|
9317
9614
|
return B.toBase64(r);
|
|
9318
9615
|
}
|
|
9319
9616
|
}
|
|
9320
|
-
class
|
|
9617
|
+
class fr {
|
|
9321
9618
|
constructor(t) {
|
|
9322
9619
|
this.opnetAPIUrl = t, this.utxoPath = "address/utxos", this.rpc = "json-rpc";
|
|
9323
9620
|
}
|
|
@@ -9340,7 +9637,7 @@ class hr {
|
|
|
9340
9637
|
const s = await r.json(), o = s.raw ?? [], c = t.usePendingUTXO ? [...s.confirmed, ...s.pending] : s.confirmed, u = [];
|
|
9341
9638
|
for (const f of c)
|
|
9342
9639
|
s.spentTransactions.some(
|
|
9343
|
-
(
|
|
9640
|
+
(y) => y.transactionId === f.transactionId && y.outputIndex === f.outputIndex
|
|
9344
9641
|
) || u.push(f);
|
|
9345
9642
|
if (u.length === 0)
|
|
9346
9643
|
throw new Error("No UTXO found");
|
|
@@ -9351,8 +9648,8 @@ class hr {
|
|
|
9351
9648
|
let d = 0n;
|
|
9352
9649
|
const p = t.requestedAmount;
|
|
9353
9650
|
for (const f of h) {
|
|
9354
|
-
const
|
|
9355
|
-
if (
|
|
9651
|
+
const y = BigInt(f.value);
|
|
9652
|
+
if (y <= 0n)
|
|
9356
9653
|
continue;
|
|
9357
9654
|
const S = f.raw;
|
|
9358
9655
|
if (S == null)
|
|
@@ -9364,10 +9661,10 @@ class hr {
|
|
|
9364
9661
|
throw new Error(
|
|
9365
9662
|
`Invalid raw index ${S} - not found in raw transactions array`
|
|
9366
9663
|
);
|
|
9367
|
-
if (d +=
|
|
9664
|
+
if (d += y, l.push({
|
|
9368
9665
|
transactionId: f.transactionId,
|
|
9369
9666
|
outputIndex: f.outputIndex,
|
|
9370
|
-
value:
|
|
9667
|
+
value: y,
|
|
9371
9668
|
scriptPubKey: f.scriptPubKey,
|
|
9372
9669
|
nonWitnessUtxo: a.from(b, "base64")
|
|
9373
9670
|
}), d > p)
|
|
@@ -9441,7 +9738,7 @@ class hr {
|
|
|
9441
9738
|
priorityFee: 0n,
|
|
9442
9739
|
gasSatFee: 330n,
|
|
9443
9740
|
mldsaSigner: null
|
|
9444
|
-
}, l = await new
|
|
9741
|
+
}, l = await new ri().createBTCTransfer(u), d = await this.broadcastTransaction(l.tx, !1);
|
|
9445
9742
|
return d || { error: "Could not broadcast transaction" };
|
|
9446
9743
|
}
|
|
9447
9744
|
/**
|
|
@@ -9528,8 +9825,8 @@ class hr {
|
|
|
9528
9825
|
return new UnwrapGeneration(result as UnwrappedGenerationParameters);
|
|
9529
9826
|
}*/
|
|
9530
9827
|
}
|
|
9531
|
-
var
|
|
9532
|
-
class
|
|
9828
|
+
var li = /* @__PURE__ */ ((n) => (n[n.UNWRAP = 0] = "UNWRAP", n))(li || {});
|
|
9829
|
+
class pr {
|
|
9533
9830
|
/**
|
|
9534
9831
|
* Generate a multi-sig address
|
|
9535
9832
|
* @param {Buffer[]} pubKeys - The public keys to use
|
|
@@ -9556,10 +9853,10 @@ class lr {
|
|
|
9556
9853
|
return o;
|
|
9557
9854
|
}
|
|
9558
9855
|
}
|
|
9559
|
-
var
|
|
9560
|
-
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 {
|
|
9561
9858
|
decodeData(t, e) {
|
|
9562
|
-
const i = new
|
|
9859
|
+
const i = new jt(t), r = [];
|
|
9563
9860
|
for (let s = 0; s < e.length; s++)
|
|
9564
9861
|
switch (e[s]) {
|
|
9565
9862
|
case "UINT8":
|
|
@@ -9592,12 +9889,33 @@ class dr {
|
|
|
9592
9889
|
case "UINT256":
|
|
9593
9890
|
r.push(i.readU256());
|
|
9594
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;
|
|
9595
9904
|
case "INT128":
|
|
9596
9905
|
r.push(i.readI128());
|
|
9597
9906
|
break;
|
|
9907
|
+
case "EXTENDED_ADDRESS":
|
|
9908
|
+
r.push(i.readExtendedAddress());
|
|
9909
|
+
break;
|
|
9598
9910
|
case "ADDRESS_UINT256_TUPLE":
|
|
9599
9911
|
r.push(i.readAddressValueTuple());
|
|
9600
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;
|
|
9601
9919
|
case "BYTES":
|
|
9602
9920
|
r.push(i.readBytesWithLength());
|
|
9603
9921
|
break;
|
|
@@ -9607,6 +9925,9 @@ class dr {
|
|
|
9607
9925
|
case "ARRAY_OF_ADDRESSES":
|
|
9608
9926
|
r.push(i.readAddressArray());
|
|
9609
9927
|
break;
|
|
9928
|
+
case "ARRAY_OF_EXTENDED_ADDRESSES":
|
|
9929
|
+
r.push(i.readExtendedAddressArray());
|
|
9930
|
+
break;
|
|
9610
9931
|
case "ARRAY_OF_UINT256":
|
|
9611
9932
|
r.push(i.readU256Array());
|
|
9612
9933
|
break;
|
|
@@ -9651,10 +9972,10 @@ class dr {
|
|
|
9651
9972
|
return i;
|
|
9652
9973
|
}
|
|
9653
9974
|
sha256(t) {
|
|
9654
|
-
return new
|
|
9975
|
+
return new Ei.sha256().update(t).digest();
|
|
9655
9976
|
}
|
|
9656
9977
|
}
|
|
9657
|
-
class
|
|
9978
|
+
class Ee {
|
|
9658
9979
|
constructor(t = []) {
|
|
9659
9980
|
this.items = /* @__PURE__ */ new Set(), this.keys = [];
|
|
9660
9981
|
for (const e of t)
|
|
@@ -9675,7 +9996,7 @@ class we {
|
|
|
9675
9996
|
this.items.delete(e) && (this.keys = this.keys.filter((i) => i.toBigInt() !== e));
|
|
9676
9997
|
}
|
|
9677
9998
|
clone() {
|
|
9678
|
-
return new
|
|
9999
|
+
return new Ee(this.keys);
|
|
9679
10000
|
}
|
|
9680
10001
|
clear() {
|
|
9681
10002
|
this.items.clear(), this.keys = [];
|
|
@@ -9690,16 +10011,16 @@ class we {
|
|
|
9690
10011
|
yield* this.keys;
|
|
9691
10012
|
}
|
|
9692
10013
|
}
|
|
9693
|
-
class
|
|
10014
|
+
class Pe {
|
|
9694
10015
|
constructor(t) {
|
|
9695
|
-
this.compareFn = t, this.map = new
|
|
10016
|
+
this.compareFn = t, this.map = new yt(), this.#t = [];
|
|
9696
10017
|
}
|
|
9697
10018
|
#t;
|
|
9698
10019
|
get size() {
|
|
9699
10020
|
return this.map.size;
|
|
9700
10021
|
}
|
|
9701
10022
|
static fromMap(t, e) {
|
|
9702
|
-
const i = new
|
|
10023
|
+
const i = new Pe(e);
|
|
9703
10024
|
for (const [r, s] of t)
|
|
9704
10025
|
i.set(r, s);
|
|
9705
10026
|
return i;
|
|
@@ -9763,7 +10084,7 @@ class ye {
|
|
|
9763
10084
|
yield [t, this.map.get(t)];
|
|
9764
10085
|
}
|
|
9765
10086
|
}
|
|
9766
|
-
class
|
|
10087
|
+
class Ae {
|
|
9767
10088
|
constructor(t) {
|
|
9768
10089
|
this.compareFn = t, this.elements = [];
|
|
9769
10090
|
}
|
|
@@ -9771,7 +10092,7 @@ class me {
|
|
|
9771
10092
|
return this.elements.length;
|
|
9772
10093
|
}
|
|
9773
10094
|
static fromSet(t, e) {
|
|
9774
|
-
const i = new
|
|
10095
|
+
const i = new Ae(e);
|
|
9775
10096
|
for (const r of t)
|
|
9776
10097
|
i.add(r);
|
|
9777
10098
|
return i;
|
|
@@ -9811,17 +10132,17 @@ class me {
|
|
|
9811
10132
|
return { found: !1, index: e };
|
|
9812
10133
|
}
|
|
9813
10134
|
}
|
|
9814
|
-
class
|
|
10135
|
+
class Sr {
|
|
9815
10136
|
constructor(t, e) {
|
|
9816
10137
|
this.type = t, this.data = e;
|
|
9817
10138
|
}
|
|
9818
10139
|
}
|
|
9819
|
-
class
|
|
10140
|
+
class Oe {
|
|
9820
10141
|
constructor() {
|
|
9821
10142
|
}
|
|
9822
10143
|
}
|
|
9823
|
-
var
|
|
9824
|
-
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 {
|
|
9825
10146
|
constructor() {
|
|
9826
10147
|
if (super(), this.isInitialized = !1, !window)
|
|
9827
10148
|
throw new Error("UnisatSigner can only be used in a browser environment");
|
|
@@ -9867,14 +10188,14 @@ class pr extends be {
|
|
|
9867
10188
|
return;
|
|
9868
10189
|
const t = await this.unisat.getNetwork();
|
|
9869
10190
|
switch (t) {
|
|
9870
|
-
case
|
|
10191
|
+
case Pt.Mainnet:
|
|
9871
10192
|
this._network = I;
|
|
9872
10193
|
break;
|
|
9873
|
-
case
|
|
9874
|
-
this._network =
|
|
10194
|
+
case Pt.Testnet:
|
|
10195
|
+
this._network = Lt;
|
|
9875
10196
|
break;
|
|
9876
|
-
case
|
|
9877
|
-
this._network =
|
|
10197
|
+
case Pt.Regtest:
|
|
10198
|
+
this._network = Qt;
|
|
9878
10199
|
break;
|
|
9879
10200
|
default:
|
|
9880
10201
|
throw new Error(`Invalid network: ${t}`);
|
|
@@ -9919,19 +10240,19 @@ class pr extends be {
|
|
|
9919
10240
|
e.push(c);
|
|
9920
10241
|
const u = o.data.inputs.map((h, l) => {
|
|
9921
10242
|
let d = !1, p = !1;
|
|
9922
|
-
if (
|
|
10243
|
+
if (ye(h)) {
|
|
9923
10244
|
if (h.tapLeafScript && h.tapLeafScript.length > 0) {
|
|
9924
10245
|
for (const f of h.tapLeafScript)
|
|
9925
|
-
if (
|
|
10246
|
+
if (wr(this.publicKey, f.script)) {
|
|
9926
10247
|
d = !0, p = !1;
|
|
9927
10248
|
break;
|
|
9928
10249
|
}
|
|
9929
10250
|
}
|
|
9930
10251
|
if (!d && h.tapInternalKey) {
|
|
9931
|
-
const f = h.tapInternalKey,
|
|
9932
|
-
f.equals(
|
|
10252
|
+
const f = h.tapInternalKey, y = O(this.publicKey);
|
|
10253
|
+
f.equals(y) && (d = !0, p = !0);
|
|
9933
10254
|
}
|
|
9934
|
-
} else
|
|
10255
|
+
} else we(h, this.publicKey) && (d = !0, p = !1);
|
|
9935
10256
|
return d ? {
|
|
9936
10257
|
index: l,
|
|
9937
10258
|
publicKey: this.publicKey.toString("hex"),
|
|
@@ -9943,7 +10264,7 @@ class pr extends be {
|
|
|
9943
10264
|
toSignInputs: u
|
|
9944
10265
|
});
|
|
9945
10266
|
}
|
|
9946
|
-
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);
|
|
9947
10268
|
t[0].combine(s);
|
|
9948
10269
|
}
|
|
9949
10270
|
hasAlreadySignedTapScriptSig(t) {
|
|
@@ -9988,7 +10309,7 @@ class pr extends be {
|
|
|
9988
10309
|
}
|
|
9989
10310
|
]).flat()
|
|
9990
10311
|
}, c = t.toHex(), u = await this.unisat.signPsbt(c, o);
|
|
9991
|
-
return
|
|
10312
|
+
return R.fromHex(u);
|
|
9992
10313
|
}
|
|
9993
10314
|
getNonDuplicateScriptSig(t, e) {
|
|
9994
10315
|
const i = [];
|
|
@@ -9997,15 +10318,15 @@ class pr extends be {
|
|
|
9997
10318
|
return i;
|
|
9998
10319
|
}
|
|
9999
10320
|
}
|
|
10000
|
-
function
|
|
10001
|
-
return
|
|
10321
|
+
function wr(n, t) {
|
|
10322
|
+
return mr(n, t) !== -1;
|
|
10002
10323
|
}
|
|
10003
|
-
function
|
|
10004
|
-
const e =
|
|
10324
|
+
function mr(n, t) {
|
|
10325
|
+
const e = gt(n), i = O(n), r = F(t);
|
|
10005
10326
|
if (r === null) throw new Error("Unknown script error");
|
|
10006
10327
|
return r.findIndex((s) => typeof s == "number" ? !1 : a.isBuffer(s) && (s.equals(n) || s.equals(e) || s.equals(i)));
|
|
10007
10328
|
}
|
|
10008
|
-
class
|
|
10329
|
+
class br extends Oe {
|
|
10009
10330
|
constructor() {
|
|
10010
10331
|
if (super(), this.isInitialized = !1, !window)
|
|
10011
10332
|
throw new Error("XverseSigner can only be used in a browser environment");
|
|
@@ -10050,7 +10371,7 @@ class wr extends be {
|
|
|
10050
10371
|
);
|
|
10051
10372
|
if (!e)
|
|
10052
10373
|
throw new Error("Payment address not found");
|
|
10053
|
-
const i = e.address.startsWith("tb") ?
|
|
10374
|
+
const i = e.address.startsWith("tb") ? Lt : e.address.startsWith("bc") ? I : null;
|
|
10054
10375
|
if (!i) throw new Error("Network not supported");
|
|
10055
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;
|
|
10056
10377
|
}
|
|
@@ -10103,19 +10424,19 @@ class wr extends be {
|
|
|
10103
10424
|
e.push(u);
|
|
10104
10425
|
const h = c.data.inputs.map((l, d) => {
|
|
10105
10426
|
let p = !1, f = !1;
|
|
10106
|
-
if (
|
|
10427
|
+
if (ye(l)) {
|
|
10107
10428
|
if (l.tapLeafScript && l.tapLeafScript.length > 0) {
|
|
10108
|
-
for (const
|
|
10109
|
-
if (
|
|
10429
|
+
for (const y of l.tapLeafScript)
|
|
10430
|
+
if (me(this.publicKey, y.script)) {
|
|
10110
10431
|
p = !0, f = !1;
|
|
10111
10432
|
break;
|
|
10112
10433
|
}
|
|
10113
10434
|
}
|
|
10114
10435
|
if (!p && l.tapInternalKey) {
|
|
10115
|
-
const
|
|
10116
|
-
|
|
10436
|
+
const y = l.tapInternalKey, S = O(this.publicKey);
|
|
10437
|
+
y.equals(S) && (p = !0, f = !0);
|
|
10117
10438
|
}
|
|
10118
|
-
} else
|
|
10439
|
+
} else we(l, this.publicKey) && (p = !0, f = !1);
|
|
10119
10440
|
return p ? {
|
|
10120
10441
|
index: d,
|
|
10121
10442
|
publicKey: this.publicKey.toString("hex"),
|
|
@@ -10134,7 +10455,7 @@ class wr extends be {
|
|
|
10134
10455
|
signInputs: r
|
|
10135
10456
|
});
|
|
10136
10457
|
if ("error" in s) throw new Error(s.error.message);
|
|
10137
|
-
const o =
|
|
10458
|
+
const o = R.fromBase64(s.result.psbt);
|
|
10138
10459
|
t[0].combine(o);
|
|
10139
10460
|
}
|
|
10140
10461
|
hasAlreadySignedTapScriptSig(t) {
|
|
@@ -10184,7 +10505,7 @@ class wr extends be {
|
|
|
10184
10505
|
signInputs: u
|
|
10185
10506
|
});
|
|
10186
10507
|
if ("error" in h) throw new Error(h.error.message);
|
|
10187
|
-
return
|
|
10508
|
+
return R.fromBase64(h.result.psbt);
|
|
10188
10509
|
}
|
|
10189
10510
|
getNonDuplicateScriptSig(t, e) {
|
|
10190
10511
|
const i = [];
|
|
@@ -10193,10 +10514,10 @@ class wr extends be {
|
|
|
10193
10514
|
return i;
|
|
10194
10515
|
}
|
|
10195
10516
|
}
|
|
10196
|
-
var
|
|
10197
|
-
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 {
|
|
10198
10519
|
constructor() {
|
|
10199
|
-
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);
|
|
10200
10521
|
}
|
|
10201
10522
|
static {
|
|
10202
10523
|
this.INITIAL_CAPACITY = 16;
|
|
@@ -10212,7 +10533,7 @@ class Ht {
|
|
|
10212
10533
|
set(t, e) {
|
|
10213
10534
|
let i = !0;
|
|
10214
10535
|
const r = this.findInsertIndex(t);
|
|
10215
|
-
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;
|
|
10216
10537
|
}
|
|
10217
10538
|
get(t) {
|
|
10218
10539
|
const e = this.findIndex(t);
|
|
@@ -10354,261 +10675,267 @@ class Ht {
|
|
|
10354
10675
|
t[i] !== void 0 && !this.deleted[i] && this.set(t[i], e[i]);
|
|
10355
10676
|
}
|
|
10356
10677
|
}
|
|
10357
|
-
const
|
|
10678
|
+
const Ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10358
10679
|
__proto__: null,
|
|
10359
|
-
ABICoder:
|
|
10360
|
-
ABIDataTypes:
|
|
10361
|
-
ADDRESS_BYTE_LENGTH:
|
|
10362
|
-
ANCHOR_SCRIPT:
|
|
10363
|
-
Address:
|
|
10364
|
-
AddressGenerator:
|
|
10365
|
-
AddressMap:
|
|
10366
|
-
AddressSet:
|
|
10680
|
+
ABICoder: gr,
|
|
10681
|
+
ABIDataTypes: di,
|
|
10682
|
+
ADDRESS_BYTE_LENGTH: k,
|
|
10683
|
+
ANCHOR_SCRIPT: ue,
|
|
10684
|
+
Address: v,
|
|
10685
|
+
AddressGenerator: fe,
|
|
10686
|
+
AddressMap: Ve,
|
|
10687
|
+
AddressSet: Ee,
|
|
10367
10688
|
AddressTypes: J,
|
|
10368
10689
|
AddressVerificator: H,
|
|
10369
|
-
BIPStandard:
|
|
10370
|
-
BOOLEAN_BYTE_LENGTH:
|
|
10371
|
-
BinaryReader:
|
|
10372
|
-
BinaryWriter:
|
|
10373
|
-
BitcoinUtils:
|
|
10690
|
+
BIPStandard: Et,
|
|
10691
|
+
BOOLEAN_BYTE_LENGTH: Ji,
|
|
10692
|
+
BinaryReader: jt,
|
|
10693
|
+
BinaryWriter: C,
|
|
10694
|
+
BitcoinUtils: D,
|
|
10374
10695
|
BufferHelper: X,
|
|
10375
|
-
CSVModes:
|
|
10376
|
-
CalldataGenerator:
|
|
10377
|
-
CancelTransaction:
|
|
10378
|
-
ChainId:
|
|
10379
|
-
ChallengeSolution:
|
|
10380
|
-
ChallengeSubmission:
|
|
10381
|
-
ChallengeVerification:
|
|
10382
|
-
Compressor:
|
|
10383
|
-
Consensus:
|
|
10384
|
-
ConsolidatedInteractionTransaction:
|
|
10385
|
-
ContractAddress:
|
|
10386
|
-
ContractBaseMetadata:
|
|
10387
|
-
CustomGenerator:
|
|
10388
|
-
CustomKeypair:
|
|
10389
|
-
CustomMap:
|
|
10390
|
-
CustomScriptTransaction:
|
|
10391
|
-
DeploymentGenerator:
|
|
10392
|
-
DeploymentTransaction:
|
|
10393
|
-
DeterministicMap:
|
|
10394
|
-
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,
|
|
10395
10717
|
EcKeyPair: A,
|
|
10396
10718
|
EpochValidator: ct,
|
|
10397
|
-
|
|
10719
|
+
ExtendedAddressMap: ze,
|
|
10720
|
+
FastMap: yt,
|
|
10398
10721
|
FeaturePriority: Q,
|
|
10399
|
-
Features:
|
|
10400
|
-
FundingTransaction:
|
|
10722
|
+
Features: N,
|
|
10723
|
+
FundingTransaction: $t,
|
|
10401
10724
|
Generator: q,
|
|
10402
|
-
HashCommitmentGenerator:
|
|
10403
|
-
I128_BYTE_LENGTH:
|
|
10404
|
-
I16_BYTE_LENGTH:
|
|
10405
|
-
I256_BYTE_LENGTH:
|
|
10406
|
-
|
|
10407
|
-
|
|
10408
|
-
|
|
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,
|
|
10409
10733
|
InteractionTransactionP2WDA: j,
|
|
10410
|
-
LegacyCalldataGenerator:
|
|
10411
|
-
MINIMUM_AMOUNT_CA:
|
|
10734
|
+
LegacyCalldataGenerator: ir,
|
|
10735
|
+
MINIMUM_AMOUNT_CA: bt,
|
|
10412
10736
|
MINIMUM_AMOUNT_REWARD: V,
|
|
10413
|
-
MLDSAKeyPair:
|
|
10414
|
-
MLDSAPublicKeyMetadata:
|
|
10415
|
-
MLDSASecurityLevel:
|
|
10737
|
+
MLDSAKeyPair: E.MLDSAKeyPair,
|
|
10738
|
+
MLDSAPublicKeyMetadata: Qe,
|
|
10739
|
+
MLDSASecurityLevel: E.MLDSASecurityLevel,
|
|
10416
10740
|
MessageSigner: st,
|
|
10417
|
-
MessageType:
|
|
10418
|
-
Mnemonic:
|
|
10419
|
-
MnemonicStrength:
|
|
10420
|
-
MultiSignGenerator:
|
|
10741
|
+
MessageType: pi,
|
|
10742
|
+
Mnemonic: ge,
|
|
10743
|
+
MnemonicStrength: zt,
|
|
10744
|
+
MultiSignGenerator: kt,
|
|
10421
10745
|
MultiSignTransaction: x,
|
|
10422
|
-
NetEvent:
|
|
10423
|
-
OPNET_DEPLOYMENT_VERSION:
|
|
10424
|
-
OPNetConsensusConfig:
|
|
10425
|
-
OPNetLimitedProvider:
|
|
10426
|
-
OfflineTransactionManager:
|
|
10427
|
-
P2TR_MS:
|
|
10746
|
+
NetEvent: Sr,
|
|
10747
|
+
OPNET_DEPLOYMENT_VERSION: $e,
|
|
10748
|
+
OPNetConsensusConfig: Je,
|
|
10749
|
+
OPNetLimitedProvider: fr,
|
|
10750
|
+
OfflineTransactionManager: dr,
|
|
10751
|
+
P2TR_MS: pr,
|
|
10428
10752
|
P2WDADetector: z,
|
|
10429
|
-
P2WDAGenerator:
|
|
10430
|
-
PSBTTypes:
|
|
10431
|
-
QuantumBIP32API:
|
|
10432
|
-
QuantumBIP32Factory:
|
|
10433
|
-
QuantumBIP32Interface:
|
|
10434
|
-
QuantumDerivationPath:
|
|
10435
|
-
QuantumSigner:
|
|
10436
|
-
RoswellConsensus:
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10442
|
-
|
|
10443
|
-
|
|
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,
|
|
10444
10769
|
TapscriptVerificator: tt,
|
|
10445
10770
|
TimeLockGenerator: M,
|
|
10446
10771
|
TransactionBuilder: m,
|
|
10447
|
-
TransactionFactory:
|
|
10772
|
+
TransactionFactory: ri,
|
|
10448
10773
|
TransactionReconstructor: ut,
|
|
10449
|
-
TransactionSequence:
|
|
10774
|
+
TransactionSequence: ti,
|
|
10450
10775
|
TransactionSerializer: B,
|
|
10451
10776
|
TransactionStateCapture: $,
|
|
10452
|
-
TransactionType:
|
|
10453
|
-
TweakedSigner:
|
|
10454
|
-
TweakedTransaction:
|
|
10455
|
-
U128_BYTE_LENGTH:
|
|
10456
|
-
U16_BYTE_LENGTH:
|
|
10457
|
-
U256_BYTE_LENGTH:
|
|
10458
|
-
U32_BYTE_LENGTH:
|
|
10459
|
-
U64_BYTE_LENGTH:
|
|
10460
|
-
U8_BYTE_LENGTH:
|
|
10461
|
-
UnisatChainType:
|
|
10462
|
-
UnisatSigner:
|
|
10777
|
+
TransactionType: w,
|
|
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,
|
|
10463
10788
|
Wallet: Z,
|
|
10464
|
-
WalletNetworks:
|
|
10465
|
-
XverseNetwork:
|
|
10466
|
-
XverseSigner:
|
|
10467
|
-
buildBIPPath:
|
|
10468
|
-
createAddressRotation:
|
|
10469
|
-
createSignerMap:
|
|
10470
|
-
currentConsensus:
|
|
10471
|
-
currentConsensusConfig:
|
|
10472
|
-
disabledAddressRotation:
|
|
10473
|
-
getBIPDescription:
|
|
10474
|
-
getLevelFromPublicKeyLength:
|
|
10475
|
-
isCancelSpecificData:
|
|
10476
|
-
isCustomScriptSpecificData:
|
|
10477
|
-
isDeploymentSpecificData:
|
|
10478
|
-
isFundingSpecificData:
|
|
10479
|
-
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,
|
|
10480
10805
|
isMultiSigSpecificData: et,
|
|
10481
|
-
isOPWallet:
|
|
10482
|
-
|
|
10483
|
-
|
|
10484
|
-
|
|
10485
|
-
}, Symbol.toStringTag, { value: "Module" })), Pr = P.MLDSAKeyPair, Er = P.MLDSASecurityLevel, Ar = P.QuantumBIP32API, Or = P.QuantumBIP32Factory, Br = P.QuantumBIP32Interface, xr = P.QuantumDerivationPath, vr = 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;
|
|
10486
10810
|
export {
|
|
10487
|
-
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10811
|
+
gr as ABICoder,
|
|
10812
|
+
di as ABIDataTypes,
|
|
10813
|
+
k as ADDRESS_BYTE_LENGTH,
|
|
10814
|
+
ue as ANCHOR_SCRIPT,
|
|
10815
|
+
v as Address,
|
|
10816
|
+
fe as AddressGenerator,
|
|
10817
|
+
Ve as AddressMap,
|
|
10818
|
+
Ee as AddressSet,
|
|
10495
10819
|
J as AddressTypes,
|
|
10496
10820
|
H as AddressVerificator,
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10821
|
+
Et as BIPStandard,
|
|
10822
|
+
Ji as BOOLEAN_BYTE_LENGTH,
|
|
10823
|
+
jt as BinaryReader,
|
|
10824
|
+
C as BinaryWriter,
|
|
10825
|
+
D as BitcoinUtils,
|
|
10502
10826
|
X as BufferHelper,
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
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,
|
|
10523
10848
|
A as EcKeyPair,
|
|
10524
10849
|
ct as EpochValidator,
|
|
10525
|
-
|
|
10850
|
+
ze as ExtendedAddressMap,
|
|
10851
|
+
yt as FastMap,
|
|
10526
10852
|
Q as FeaturePriority,
|
|
10527
|
-
|
|
10528
|
-
|
|
10853
|
+
N as Features,
|
|
10854
|
+
$t as FundingTransaction,
|
|
10529
10855
|
q as Generator,
|
|
10530
|
-
|
|
10531
|
-
|
|
10532
|
-
|
|
10533
|
-
|
|
10534
|
-
|
|
10535
|
-
|
|
10536
|
-
|
|
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,
|
|
10537
10864
|
j as InteractionTransactionP2WDA,
|
|
10538
|
-
|
|
10539
|
-
|
|
10865
|
+
ir as LegacyCalldataGenerator,
|
|
10866
|
+
bt as MINIMUM_AMOUNT_CA,
|
|
10540
10867
|
V as MINIMUM_AMOUNT_REWARD,
|
|
10541
|
-
|
|
10542
|
-
|
|
10543
|
-
|
|
10868
|
+
Or as MLDSAKeyPair,
|
|
10869
|
+
Qe as MLDSAPublicKeyMetadata,
|
|
10870
|
+
Br as MLDSASecurityLevel,
|
|
10544
10871
|
st as MessageSigner,
|
|
10545
|
-
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
|
|
10872
|
+
pi as MessageType,
|
|
10873
|
+
ge as Mnemonic,
|
|
10874
|
+
zt as MnemonicStrength,
|
|
10875
|
+
kt as MultiSignGenerator,
|
|
10549
10876
|
x as MultiSignTransaction,
|
|
10550
|
-
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
10554
|
-
|
|
10555
|
-
|
|
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,
|
|
10556
10883
|
z as P2WDADetector,
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
|
|
10569
|
-
|
|
10570
|
-
|
|
10571
|
-
|
|
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,
|
|
10572
10900
|
tt as TapscriptVerificator,
|
|
10573
10901
|
M as TimeLockGenerator,
|
|
10574
10902
|
m as TransactionBuilder,
|
|
10575
|
-
|
|
10903
|
+
ri as TransactionFactory,
|
|
10576
10904
|
ut as TransactionReconstructor,
|
|
10577
|
-
|
|
10905
|
+
ti as TransactionSequence,
|
|
10578
10906
|
B as TransactionSerializer,
|
|
10579
10907
|
$ as TransactionStateCapture,
|
|
10580
|
-
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10908
|
+
w as TransactionType,
|
|
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,
|
|
10591
10919
|
Z as Wallet,
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
|
|
10600
|
-
|
|
10601
|
-
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
|
|
10607
|
-
|
|
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,
|
|
10608
10936
|
et as isMultiSigSpecificData,
|
|
10609
|
-
|
|
10610
|
-
|
|
10611
|
-
|
|
10612
|
-
|
|
10613
|
-
Me as versionBuffer
|
|
10937
|
+
Ye as isOPWallet,
|
|
10938
|
+
Ar as opnet,
|
|
10939
|
+
Vi as version,
|
|
10940
|
+
Xe as versionBuffer
|
|
10614
10941
|
};
|