@btc-vision/transaction 1.7.31 → 1.8.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AUDIT/README.md +9 -0
- package/CHANGELOG.md +5 -0
- package/README.md +62 -18
- package/SECURITY.md +71 -0
- package/browser/deterministic/ExtendedAddressMap.d.ts +17 -0
- package/browser/index.js +448 -362
- package/browser/keypair/Address.d.ts +3 -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/vendors.js +950 -911
- package/build/deterministic/ExtendedAddressMap.d.ts +17 -0
- package/build/deterministic/ExtendedAddressMap.js +60 -0
- package/build/keypair/Address.d.ts +3 -1
- package/build/keypair/Address.js +30 -10
- 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/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/deterministic/ExtendedAddressMap.ts +83 -0
- package/src/keypair/Address.ts +53 -9
- 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/test/derivePath.test.ts +30 -29
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as a, f as Vt, g as Ie, h as P, j as G, s as di, k as Qt, a as T, L as
|
|
2
|
-
import { i as ot, b as I, p as
|
|
3
|
-
import { s as ki, m as Li,
|
|
4
|
-
import { A as _i,
|
|
1
|
+
import { B as a, f as Vt, g as Ie, h as P, j as G, s as di, k as Qt, a as T, L as xe, d as Lt, l as Kt, m as gt, c as fi, e as pi, b as gi, n as Si } from "./vendors.js";
|
|
2
|
+
import { i as ot, b as I, p as yi, a as lt, c as jt, t as B, d as rt, e as it, f as L, g as ke, h as Zt, j as St, k as Te, l as wi, o as g, m as R, n as Ut, q as Yt, r as Le, s as mi, u as Y, v as dt, w as bi, x as Ii, y as Ue, z as Bt, A as zt, B as _e, C as Ti, D as Ke, P as k, E as Pi, F as Pe, G as Ei, H as Ee, I as Ai, J as Bi, K as Oi, L as vi, M as F, T as Jt, N as xi } from "./btc-vision-bitcoin.js";
|
|
3
|
+
import { s as ki, m as Li, e as Ui } from "./noble-curves.js";
|
|
4
|
+
import { A as _i, z as ne, y as Ki, v as Ci } from "./noble-hashes.js";
|
|
5
5
|
const Di = "1.7.31";
|
|
6
6
|
function Fi(n, t = {}) {
|
|
7
7
|
return a.from(Vt.gzip(n, { level: t.level || 6 }));
|
|
@@ -50,9 +50,9 @@ ot(G);
|
|
|
50
50
|
const Ce = typeof Ie == "function" ? Ie : P.BIP32Factory;
|
|
51
51
|
if (!Ce)
|
|
52
52
|
throw new Error("Failed to load BIP32 library");
|
|
53
|
-
const at = ki.Point, Ni = at.Fn.ORDER, Hi = _i("TapTweak"),
|
|
53
|
+
const at = ki.Point, Ni = at.Fn.ORDER, Hi = _i("TapTweak"), Be = ne(Hi);
|
|
54
54
|
function Vi(n) {
|
|
55
|
-
return ne(Ci(
|
|
55
|
+
return ne(Ci(Be, Be, n));
|
|
56
56
|
}
|
|
57
57
|
class A {
|
|
58
58
|
static {
|
|
@@ -106,7 +106,7 @@ 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 = yi({
|
|
110
110
|
m: e,
|
|
111
111
|
pubkeys: r,
|
|
112
112
|
network: i
|
|
@@ -152,7 +152,7 @@ class A {
|
|
|
152
152
|
static tweakedPubKeyToAddress(t, e) {
|
|
153
153
|
t.startsWith("0x") && (t = t.slice(2));
|
|
154
154
|
let i = a.from(t, "hex");
|
|
155
|
-
return i.length !== 32 && (i =
|
|
155
|
+
return i.length !== 32 && (i = B(i)), A.tweakedPubKeyBufferToAddress(i, e);
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* Get the address of a tweaked public key
|
|
@@ -289,7 +289,7 @@ class A {
|
|
|
289
289
|
* @returns {string} - The legacy address
|
|
290
290
|
*/
|
|
291
291
|
static getLegacySegwitAddress(t, e = I) {
|
|
292
|
-
const i =
|
|
292
|
+
const i = St({
|
|
293
293
|
redeem: jt({ pubkey: a.from(t.publicKey), network: e }),
|
|
294
294
|
network: e
|
|
295
295
|
});
|
|
@@ -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 = wi({ pubkey: a.from(t.publicKey), network: e });
|
|
332
332
|
if (!i.output)
|
|
333
333
|
throw new Error("Failed to generate wallet");
|
|
334
334
|
return "0x" + i.output.toString("hex");
|
|
@@ -360,7 +360,7 @@ class A {
|
|
|
360
360
|
*/
|
|
361
361
|
static getTaprootAddress(t, e = I) {
|
|
362
362
|
const { address: i } = rt({
|
|
363
|
-
internalPubkey:
|
|
363
|
+
internalPubkey: B(a.from(t.publicKey)),
|
|
364
364
|
network: e
|
|
365
365
|
});
|
|
366
366
|
if (!i)
|
|
@@ -394,7 +394,7 @@ class A {
|
|
|
394
394
|
return this.ECPair.fromPrivateKey(a.from(r), { network: e });
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
const C = 32, zi = 4,
|
|
397
|
+
const C = 32, zi = 4, Tt = 32, wt = 16, Ct = 8, ht = 4, Pt = 2, Dt = 1, qi = 32, mt = 16, $i = 8, Xi = 4, Yi = 2, Gi = 1, Qi = 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 = Tt) {
|
|
430
430
|
const i = t.toString(16).padStart(e * 2, "0");
|
|
431
431
|
return X.hexToUint8Array(i);
|
|
432
432
|
}
|
|
@@ -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
1071
|
#s;
|
|
1072
1072
|
#i;
|
|
1073
|
-
#
|
|
1073
|
+
#h;
|
|
1074
1074
|
#r;
|
|
1075
1075
|
#n;
|
|
1076
|
-
#h;
|
|
1077
1076
|
#l;
|
|
1077
|
+
#d;
|
|
1078
1078
|
#o;
|
|
1079
1079
|
#a;
|
|
1080
|
-
#
|
|
1080
|
+
#c;
|
|
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
|
+
#u;
|
|
1087
1088
|
constructor(t, e) {
|
|
1088
1089
|
if (super(C), !!t) {
|
|
1089
1090
|
if (e) {
|
|
1090
1091
|
if (![C, 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.#u;
|
|
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"
|
|
@@ -1160,7 +1161,7 @@ class k extends Uint8Array {
|
|
|
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 ? 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,15 +1252,15 @@ class k extends Uint8Array {
|
|
|
1246
1252
|
* ```
|
|
1247
1253
|
*/
|
|
1248
1254
|
toUint64Array() {
|
|
1249
|
-
if (this.#
|
|
1250
|
-
return this.#
|
|
1255
|
+
if (this.#c !== void 0)
|
|
1256
|
+
return this.#c;
|
|
1251
1257
|
const t = new DataView(this.buffer, this.byteOffset, 32);
|
|
1252
|
-
return this.#
|
|
1258
|
+
return this.#c = [
|
|
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.#c;
|
|
1258
1264
|
}
|
|
1259
1265
|
/**
|
|
1260
1266
|
* Check if the address is the dead address
|
|
@@ -1347,6 +1353,30 @@ class k extends Uint8Array {
|
|
|
1347
1353
|
const t = new DataView(this.buffer, this.byteOffset, 32);
|
|
1348
1354
|
return this.#o = t.getBigUint64(0, !1) << 192n | t.getBigUint64(8, !1) << 128n | t.getBigUint64(16, !1) << 64n | t.getBigUint64(24, !1), this.#o;
|
|
1349
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.#a !== void 0)
|
|
1376
|
+
return this.#a;
|
|
1377
|
+
const t = new DataView(this.legacyPublicKey.buffer, this.byteOffset, 32);
|
|
1378
|
+
return this.#a = t.getBigUint64(0, !1) << 192n | t.getBigUint64(8, !1) << 128n | t.getBigUint64(16, !1) << 64n | t.getBigUint64(24, !1), this.#a;
|
|
1379
|
+
}
|
|
1350
1380
|
equals(t) {
|
|
1351
1381
|
const e = this;
|
|
1352
1382
|
if (t.length !== e.length)
|
|
@@ -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.#s === 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.#s = t, this.#
|
|
1524
|
+
return this.#s = t, this.#l = i, {
|
|
1495
1525
|
address: i.address,
|
|
1496
1526
|
witnessScript: i.witnessScript
|
|
1497
1527
|
};
|
|
@@ -1581,7 +1611,7 @@ class k extends Uint8Array {
|
|
|
1581
1611
|
throw new Error(
|
|
1582
1612
|
`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
1613
|
);
|
|
1584
|
-
this.#
|
|
1614
|
+
this.#d = new Uint8Array(t.length), this.#d.set(t);
|
|
1585
1615
|
const i = ne(new Uint8Array(t)), r = new Uint8Array(C);
|
|
1586
1616
|
r.set(i), super.set(r);
|
|
1587
1617
|
}
|
|
@@ -1591,13 +1621,13 @@ class k extends Uint8Array {
|
|
|
1591
1621
|
* Does the EXACT same logic as the original set() method did for legacy keys.
|
|
1592
1622
|
*/
|
|
1593
1623
|
ensureLegacyProcessed() {
|
|
1594
|
-
if (this.#
|
|
1595
|
-
this.#
|
|
1596
|
-
const t = this.#
|
|
1624
|
+
if (this.#S) return;
|
|
1625
|
+
this.#S = !0;
|
|
1626
|
+
const t = this.#f;
|
|
1597
1627
|
if (t)
|
|
1598
1628
|
if (t.length === C) {
|
|
1599
1629
|
const e = a.alloc(C);
|
|
1600
|
-
e.set(t), this.#n = te.generateHybridKeyFromHash(e), this.#
|
|
1630
|
+
e.set(t), this.#n = te.generateHybridKeyFromHash(e), this.#u = t;
|
|
1601
1631
|
} else
|
|
1602
1632
|
this.autoFormat(t);
|
|
1603
1633
|
}
|
|
@@ -1607,16 +1637,16 @@ class k extends Uint8Array {
|
|
|
1607
1637
|
*/
|
|
1608
1638
|
autoFormat(t) {
|
|
1609
1639
|
const e = t[0];
|
|
1610
|
-
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t =
|
|
1611
|
-
const i =
|
|
1640
|
+
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t = v.uncompressedToCompressed(t)), this.#i = Uint8Array.from(t), this.#h = A.fromPublicKey(this.#i), this.#r = mi(this.#i);
|
|
1641
|
+
const i = B(
|
|
1612
1642
|
A.tweakPublicKey(a.from(this.#i))
|
|
1613
1643
|
);
|
|
1614
|
-
this.#n = te.generateHybridKeyFromHash(i), this.#
|
|
1644
|
+
this.#n = te.generateHybridKeyFromHash(i), this.#u = new Uint8Array(C), this.#u.set(i);
|
|
1615
1645
|
}
|
|
1616
1646
|
}
|
|
1617
|
-
class
|
|
1647
|
+
class pt {
|
|
1618
1648
|
constructor(t) {
|
|
1619
|
-
if (this._keys = [], this._values = {}, t instanceof
|
|
1649
|
+
if (this._keys = [], this._values = {}, t instanceof pt)
|
|
1620
1650
|
this.setAll(t);
|
|
1621
1651
|
else if (t)
|
|
1622
1652
|
for (const [e, i] of t)
|
|
@@ -1680,7 +1710,7 @@ class Ot {
|
|
|
1680
1710
|
}
|
|
1681
1711
|
class Fe {
|
|
1682
1712
|
constructor(t) {
|
|
1683
|
-
if (this.items = new
|
|
1713
|
+
if (this.items = new pt(), t)
|
|
1684
1714
|
for (const [e, i] of t)
|
|
1685
1715
|
this.set(e, i);
|
|
1686
1716
|
}
|
|
@@ -1712,11 +1742,11 @@ class Fe {
|
|
|
1712
1742
|
*/
|
|
1713
1743
|
*entries() {
|
|
1714
1744
|
for (const [t, e] of this.items.entries())
|
|
1715
|
-
yield [
|
|
1745
|
+
yield [v.fromBigInt(t), e];
|
|
1716
1746
|
}
|
|
1717
1747
|
*keys() {
|
|
1718
1748
|
for (const t of this.items.keys())
|
|
1719
|
-
yield
|
|
1749
|
+
yield v.fromBigInt(t);
|
|
1720
1750
|
}
|
|
1721
1751
|
*values() {
|
|
1722
1752
|
for (const t of this.items.values())
|
|
@@ -1724,7 +1754,7 @@ class Fe {
|
|
|
1724
1754
|
}
|
|
1725
1755
|
forEach(t, e) {
|
|
1726
1756
|
for (const [i, r] of this.items.entries()) {
|
|
1727
|
-
const s =
|
|
1757
|
+
const s = v.fromBigInt(i);
|
|
1728
1758
|
t.call(e, r, s, this);
|
|
1729
1759
|
}
|
|
1730
1760
|
}
|
|
@@ -1768,9 +1798,9 @@ class qt {
|
|
|
1768
1798
|
* @param be - Endianness; true means big-endian (the default).
|
|
1769
1799
|
*/
|
|
1770
1800
|
readU16(t = !0) {
|
|
1771
|
-
this.verifyEnd(this.currentOffset +
|
|
1801
|
+
this.verifyEnd(this.currentOffset + Pt);
|
|
1772
1802
|
const e = this.buffer.getUint16(this.currentOffset, !t);
|
|
1773
|
-
return this.currentOffset +=
|
|
1803
|
+
return this.currentOffset += Pt, e;
|
|
1774
1804
|
}
|
|
1775
1805
|
/**
|
|
1776
1806
|
* Reads an unsigned 32-bit integer. By default, big-endian.
|
|
@@ -1804,7 +1834,7 @@ class qt {
|
|
|
1804
1834
|
* @param be - Endianness; true => big-endian (default).
|
|
1805
1835
|
*/
|
|
1806
1836
|
readU256(t = !0) {
|
|
1807
|
-
const e = this.readBytes(
|
|
1837
|
+
const e = this.readBytes(Tt);
|
|
1808
1838
|
let i = e;
|
|
1809
1839
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1810
1840
|
}
|
|
@@ -1813,7 +1843,7 @@ class qt {
|
|
|
1813
1843
|
* @param be - Endianness; true => big-endian (default).
|
|
1814
1844
|
*/
|
|
1815
1845
|
readI128(t = !0) {
|
|
1816
|
-
const e = this.readBytes(
|
|
1846
|
+
const e = this.readBytes(mt);
|
|
1817
1847
|
let i = e;
|
|
1818
1848
|
t || (i = this.reverseBytes(e));
|
|
1819
1849
|
let r = BigInt("0x" + this.toHexString(i));
|
|
@@ -1872,7 +1902,7 @@ class qt {
|
|
|
1872
1902
|
*/
|
|
1873
1903
|
readAddress() {
|
|
1874
1904
|
const t = Array.from(this.readBytes(C));
|
|
1875
|
-
return new
|
|
1905
|
+
return new v(t);
|
|
1876
1906
|
}
|
|
1877
1907
|
/**
|
|
1878
1908
|
* Reads bytes written as [u32 length][bytes].
|
|
@@ -1997,7 +2027,7 @@ class D {
|
|
|
1997
2027
|
}
|
|
1998
2028
|
static estimateArrayOfBufferLength(t) {
|
|
1999
2029
|
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2000
|
-
let e =
|
|
2030
|
+
let e = Pt;
|
|
2001
2031
|
for (let i = 0; i < t.length; i++)
|
|
2002
2032
|
e += ht + t[i].length;
|
|
2003
2033
|
return e;
|
|
@@ -2008,7 +2038,7 @@ class D {
|
|
|
2008
2038
|
}
|
|
2009
2039
|
writeU16(t, e = !0) {
|
|
2010
2040
|
if (t > 65535) throw new Error("u16 value is too large.");
|
|
2011
|
-
this.allocSafe(
|
|
2041
|
+
this.allocSafe(Pt), this.buffer.setUint16(this.currentOffset, t, !e), this.currentOffset += 2;
|
|
2012
2042
|
}
|
|
2013
2043
|
writeU32(t, e = !0) {
|
|
2014
2044
|
if (t > 4294967295) throw new Error("u32 value is too large.");
|
|
@@ -2027,9 +2057,9 @@ class D {
|
|
|
2027
2057
|
writeI128(t, e = !0) {
|
|
2028
2058
|
if (t > 170141183460469231731687303715884105727n || t < -170141183460469231731687303715884105728n)
|
|
2029
2059
|
throw new Error("i128 value is too large.");
|
|
2030
|
-
this.allocSafe(
|
|
2031
|
-
const i = X.valueToUint8Array(t,
|
|
2032
|
-
if (i.byteLength !==
|
|
2060
|
+
this.allocSafe(mt);
|
|
2061
|
+
const i = X.valueToUint8Array(t, mt);
|
|
2062
|
+
if (i.byteLength !== mt)
|
|
2033
2063
|
throw new Error(`Invalid i128 value: ${t}`);
|
|
2034
2064
|
if (e)
|
|
2035
2065
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2041,9 +2071,9 @@ class D {
|
|
|
2041
2071
|
writeU256(t, e = !0) {
|
|
2042
2072
|
if (t > 115792089237316195423570985008687907853269984665640564039457584007913129639935n && t < 0n)
|
|
2043
2073
|
throw new Error("u256 value is too large or negative.");
|
|
2044
|
-
this.allocSafe(
|
|
2074
|
+
this.allocSafe(Tt);
|
|
2045
2075
|
const i = X.valueToUint8Array(t);
|
|
2046
|
-
if (i.byteLength !==
|
|
2076
|
+
if (i.byteLength !== Tt)
|
|
2047
2077
|
throw new Error(`Invalid u256 value: ${t}`);
|
|
2048
2078
|
if (e)
|
|
2049
2079
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2198,7 +2228,7 @@ class D {
|
|
|
2198
2228
|
var W = /* @__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))(W || {}), 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
2229
|
class q {
|
|
2200
2230
|
constructor(t, e, i = I) {
|
|
2201
|
-
this.network = I, this.senderPubKey = t, this.contractSaltPubKey = e, this.network = i, this.xSenderPubKey =
|
|
2231
|
+
this.network = I, this.senderPubKey = t, this.contractSaltPubKey = e, this.network = i, this.xSenderPubKey = B(t);
|
|
2202
2232
|
}
|
|
2203
2233
|
static {
|
|
2204
2234
|
this.DATA_CHUNK_SIZE = 512;
|
|
@@ -2253,7 +2283,7 @@ class q {
|
|
|
2253
2283
|
const i = new D();
|
|
2254
2284
|
i.writeU16(Object.keys(t.data).length);
|
|
2255
2285
|
for (const r in t.data) {
|
|
2256
|
-
const s =
|
|
2286
|
+
const s = v.fromString(r), o = t.data[r];
|
|
2257
2287
|
i.writeAddress(s), i.writeU32(o.length);
|
|
2258
2288
|
for (const c of o) {
|
|
2259
2289
|
const u = a.from(c, "base64");
|
|
@@ -2325,12 +2355,12 @@ class oe extends q {
|
|
|
2325
2355
|
if (s && s.length) {
|
|
2326
2356
|
const f = s.sort(
|
|
2327
2357
|
(S, b) => S.priority - b.priority
|
|
2328
|
-
),
|
|
2358
|
+
), y = new D();
|
|
2329
2359
|
for (let S = 0; S < f.length; S++) {
|
|
2330
2360
|
const b = f[S];
|
|
2331
|
-
c.push(b.opcode), this.encodeFeature(b,
|
|
2361
|
+
c.push(b.opcode), this.encodeFeature(b, y);
|
|
2332
2362
|
}
|
|
2333
|
-
u.push(...this.splitBufferIntoChunks(a.from(
|
|
2363
|
+
u.push(...this.splitBufferIntoChunks(a.from(y.getBuffer())));
|
|
2334
2364
|
}
|
|
2335
2365
|
let h = [
|
|
2336
2366
|
this.getHeader(r, c),
|
|
@@ -2421,10 +2451,10 @@ class Ft extends q {
|
|
|
2421
2451
|
const c = this.splitBufferIntoChunks(t), u = s ? this.splitBufferIntoChunks(s) : [], h = [], l = [];
|
|
2422
2452
|
if (o && o.length) {
|
|
2423
2453
|
const p = o.sort(
|
|
2424
|
-
(
|
|
2454
|
+
(y, S) => y.priority - S.priority
|
|
2425
2455
|
), f = new D();
|
|
2426
|
-
for (let
|
|
2427
|
-
const S = p[
|
|
2456
|
+
for (let y = 0; y < p.length; y++) {
|
|
2457
|
+
const S = p[y];
|
|
2428
2458
|
h.push(S.opcode), this.encodeFeature(S, f);
|
|
2429
2459
|
}
|
|
2430
2460
|
l.push(...this.splitBufferIntoChunks(a.from(f.getBuffer())));
|
|
@@ -2464,7 +2494,7 @@ class Ft extends q {
|
|
|
2464
2494
|
].flat();
|
|
2465
2495
|
}
|
|
2466
2496
|
}
|
|
2467
|
-
class E extends
|
|
2497
|
+
class E extends xe {
|
|
2468
2498
|
constructor(t, e = I) {
|
|
2469
2499
|
if (super(), this.logColor = "#4a90d9", t.length !== 33)
|
|
2470
2500
|
throw new Error("Public key must be 33 bytes (compressed)");
|
|
@@ -2643,7 +2673,7 @@ class E extends ve {
|
|
|
2643
2673
|
* @returns Fee estimates
|
|
2644
2674
|
*/
|
|
2645
2675
|
static estimateFees(t, e, i = 0.7) {
|
|
2646
|
-
const r = Math.ceil(t * i), s = E.estimateOutputCount(r), o = E.estimateChunkCount(r), c = 116, u = s * 43 + 43, l = 11 + c + u, d = 40 + s * E.WEIGHT_PER_INPUT + 200, p = Math.ceil(d / 4), f = BigInt(Math.ceil(l * e)),
|
|
2676
|
+
const r = Math.ceil(t * i), s = E.estimateOutputCount(r), o = E.estimateChunkCount(r), c = 116, u = s * 43 + 43, l = 11 + c + u, d = 40 + s * E.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) * E.MIN_OUTPUT_VALUE, _ = S + b;
|
|
2647
2677
|
return {
|
|
2648
2678
|
compressedSize: r,
|
|
2649
2679
|
outputCount: s,
|
|
@@ -2651,7 +2681,7 @@ class E extends ve {
|
|
|
2651
2681
|
setupVBytes: l,
|
|
2652
2682
|
revealVBytes: p,
|
|
2653
2683
|
setupFee: f,
|
|
2654
|
-
revealFee:
|
|
2684
|
+
revealFee: y,
|
|
2655
2685
|
totalFee: S,
|
|
2656
2686
|
outputsValue: b,
|
|
2657
2687
|
totalCost: _
|
|
@@ -2800,12 +2830,12 @@ class Ji extends q {
|
|
|
2800
2830
|
if (s && s.length) {
|
|
2801
2831
|
const f = s.sort(
|
|
2802
2832
|
(S, b) => S.priority - b.priority
|
|
2803
|
-
),
|
|
2833
|
+
), y = new D();
|
|
2804
2834
|
for (let S = 0; S < f.length; S++) {
|
|
2805
2835
|
const b = f[S];
|
|
2806
|
-
c.push(b.opcode), this.encodeFeature(b,
|
|
2836
|
+
c.push(b.opcode), this.encodeFeature(b, y);
|
|
2807
2837
|
}
|
|
2808
|
-
u.push(...this.splitBufferIntoChunks(a.from(
|
|
2838
|
+
u.push(...this.splitBufferIntoChunks(a.from(y.getBuffer())));
|
|
2809
2839
|
}
|
|
2810
2840
|
let h = [
|
|
2811
2841
|
this.getHeader(r, c),
|
|
@@ -2841,7 +2871,7 @@ class Ji extends q {
|
|
|
2841
2871
|
return d;
|
|
2842
2872
|
}
|
|
2843
2873
|
}
|
|
2844
|
-
class
|
|
2874
|
+
class Et {
|
|
2845
2875
|
static {
|
|
2846
2876
|
this.MAXIMUM_SUPPORTED_SIGNATURE = 255;
|
|
2847
2877
|
}
|
|
@@ -2850,17 +2880,17 @@ class Pt {
|
|
|
2850
2880
|
throw new Error("Minimum signatures must be greater than 1");
|
|
2851
2881
|
if (t.length < e)
|
|
2852
2882
|
throw new Error("The amount of public keys is lower than the minimum required");
|
|
2853
|
-
if (e >
|
|
2883
|
+
if (e > Et.MAXIMUM_SUPPORTED_SIGNATURE)
|
|
2854
2884
|
throw new Error(
|
|
2855
|
-
`The maximum amount of signatures is ${
|
|
2885
|
+
`The maximum amount of signatures is ${Et.MAXIMUM_SUPPORTED_SIGNATURE}`
|
|
2856
2886
|
);
|
|
2857
2887
|
const r = a.alloc(1);
|
|
2858
2888
|
r.writeUInt8(e), t = t.filter(
|
|
2859
|
-
(d, p, f) => p === f.findIndex((
|
|
2889
|
+
(d, p, f) => p === f.findIndex((y) => d.equals(y))
|
|
2860
2890
|
), t = t.sort((d, p) => d.compare(p));
|
|
2861
2891
|
let s = !1;
|
|
2862
2892
|
const o = t.map((d) => {
|
|
2863
|
-
const p =
|
|
2893
|
+
const p = B(d);
|
|
2864
2894
|
return i && !s && (s = i.equals(p)), p;
|
|
2865
2895
|
});
|
|
2866
2896
|
i && !s && o.push(i);
|
|
@@ -2884,7 +2914,7 @@ class Pt {
|
|
|
2884
2914
|
return h;
|
|
2885
2915
|
}
|
|
2886
2916
|
}
|
|
2887
|
-
class
|
|
2917
|
+
class At extends q {
|
|
2888
2918
|
static {
|
|
2889
2919
|
this.P2WDA_VERSION = 1;
|
|
2890
2920
|
}
|
|
@@ -2925,7 +2955,7 @@ class Et extends q {
|
|
|
2925
2955
|
if (e.length !== 32)
|
|
2926
2956
|
throw new Error("Contract secret must be exactly 32 bytes");
|
|
2927
2957
|
const o = new D();
|
|
2928
|
-
o.writeU8(
|
|
2958
|
+
o.writeU8(At.P2WDA_VERSION);
|
|
2929
2959
|
const c = s.sort((u, h) => u.priority - h.priority);
|
|
2930
2960
|
return o.writeBytes(
|
|
2931
2961
|
this.getHeader(
|
|
@@ -2979,7 +3009,7 @@ class tt {
|
|
|
2979
3009
|
static getContractAddress(t) {
|
|
2980
3010
|
const e = t.network || I, r = new Ft(
|
|
2981
3011
|
t.deployerPubKey,
|
|
2982
|
-
|
|
3012
|
+
B(t.contractSaltPubKey),
|
|
2983
3013
|
e
|
|
2984
3014
|
).compile(
|
|
2985
3015
|
t.bytecode,
|
|
@@ -2989,7 +3019,7 @@ class tt {
|
|
|
2989
3019
|
t.calldata,
|
|
2990
3020
|
t.features
|
|
2991
3021
|
), s = L([
|
|
2992
|
-
|
|
3022
|
+
B(t.deployerPubKey),
|
|
2993
3023
|
g.OP_CHECKSIG
|
|
2994
3024
|
]), o = [
|
|
2995
3025
|
{
|
|
@@ -3006,7 +3036,7 @@ class tt {
|
|
|
3006
3036
|
static verifyControlBlock(t, e) {
|
|
3007
3037
|
const i = t.network || I, s = new Ft(
|
|
3008
3038
|
t.deployerPubKey,
|
|
3009
|
-
|
|
3039
|
+
B(t.contractSaltPubKey),
|
|
3010
3040
|
i
|
|
3011
3041
|
).compile(
|
|
3012
3042
|
t.bytecode,
|
|
@@ -3016,7 +3046,7 @@ class tt {
|
|
|
3016
3046
|
t.calldata,
|
|
3017
3047
|
t.features
|
|
3018
3048
|
), o = L([
|
|
3019
|
-
|
|
3049
|
+
B(t.deployerPubKey),
|
|
3020
3050
|
g.OP_CHECKSIG
|
|
3021
3051
|
]), c = [
|
|
3022
3052
|
{
|
|
@@ -3028,7 +3058,7 @@ class tt {
|
|
|
3028
3058
|
version: tt.TAP_SCRIPT_VERSION
|
|
3029
3059
|
}
|
|
3030
3060
|
], h = rt({
|
|
3031
|
-
internalPubkey:
|
|
3061
|
+
internalPubkey: B(t.deployerPubKey),
|
|
3032
3062
|
network: i,
|
|
3033
3063
|
scriptTree: c,
|
|
3034
3064
|
redeem: {
|
|
@@ -3044,7 +3074,7 @@ class tt {
|
|
|
3044
3074
|
}
|
|
3045
3075
|
static generateAddressFromScript(t, e) {
|
|
3046
3076
|
const i = t.network || I, r = {
|
|
3047
|
-
internalPubkey:
|
|
3077
|
+
internalPubkey: B(t.deployerPubKey),
|
|
3048
3078
|
network: i,
|
|
3049
3079
|
scriptTree: e
|
|
3050
3080
|
};
|
|
@@ -3066,7 +3096,7 @@ class ce {
|
|
|
3066
3096
|
t.publicKey[0] === 3 && (i = Kt.privateNegate(i));
|
|
3067
3097
|
const r = Kt.privateAdd(
|
|
3068
3098
|
i,
|
|
3069
|
-
Ii(
|
|
3099
|
+
Ii(B(a.from(t.publicKey)), e.tweakHash)
|
|
3070
3100
|
);
|
|
3071
3101
|
if (!r)
|
|
3072
3102
|
throw new Error("Invalid tweaked private key!");
|
|
@@ -3237,7 +3267,7 @@ class tr {
|
|
|
3237
3267
|
if (typeof e == "string" && (e = a.from(e, "utf-8")), i.length !== 64)
|
|
3238
3268
|
throw new Error("Invalid signature length.");
|
|
3239
3269
|
const r = this.sha256(e);
|
|
3240
|
-
return Kt.verifySchnorr(r,
|
|
3270
|
+
return Kt.verifySchnorr(r, B(a.from(t)), i);
|
|
3241
3271
|
}
|
|
3242
3272
|
/**
|
|
3243
3273
|
* Tweak the public key and verify a signature.
|
|
@@ -3337,7 +3367,7 @@ class Z {
|
|
|
3337
3367
|
);
|
|
3338
3368
|
} else
|
|
3339
3369
|
this._mldsaKeypair = P.QuantumBIP32Factory.fromBase58(c), this._chainCode = a.from(this._mldsaKeypair.chainCode), this._securityLevel = this._mldsaKeypair.securityLevel;
|
|
3340
|
-
this._bufferPubKey = this._keypair.publicKey, this._address = new
|
|
3370
|
+
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
3371
|
}
|
|
3342
3372
|
/**
|
|
3343
3373
|
* Get the address for the wallet
|
|
@@ -3452,7 +3482,7 @@ class Z {
|
|
|
3452
3482
|
*/
|
|
3453
3483
|
get xOnly() {
|
|
3454
3484
|
if (!this.keypair) throw new Error("Keypair not set");
|
|
3455
|
-
return
|
|
3485
|
+
return B(this._bufferPubKey);
|
|
3456
3486
|
}
|
|
3457
3487
|
/**
|
|
3458
3488
|
* Create a wallet from WIF strings
|
|
@@ -3567,7 +3597,7 @@ class Z {
|
|
|
3567
3597
|
);
|
|
3568
3598
|
}
|
|
3569
3599
|
}
|
|
3570
|
-
var Rt = /* @__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))(Rt || {}),
|
|
3600
|
+
var Rt = /* @__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))(Rt || {}), bt = /* @__PURE__ */ ((n) => (n[n.BIP44 = 44] = "BIP44", n[n.BIP49 = 49] = "BIP49", n[n.BIP84 = 84] = "BIP84", n[n.BIP86 = 86] = "BIP86", n))(bt || {});
|
|
3571
3601
|
function er(n) {
|
|
3572
3602
|
switch (n) {
|
|
3573
3603
|
case 44:
|
|
@@ -3598,9 +3628,9 @@ class ue {
|
|
|
3598
3628
|
* @throws {Error} If the mnemonic phrase is invalid
|
|
3599
3629
|
*/
|
|
3600
3630
|
constructor(t, e = "", i = I, r = P.MLDSASecurityLevel.LEVEL2) {
|
|
3601
|
-
if (!
|
|
3631
|
+
if (!gt.validateMnemonic(t))
|
|
3602
3632
|
throw new Error("Invalid mnemonic phrase");
|
|
3603
|
-
this._phrase = t, this._passphrase = e, this._network = i, this._securityLevel = r, this._seed =
|
|
3633
|
+
this._phrase = t, this._passphrase = e, this._network = i, this._securityLevel = r, this._seed = gt.mnemonicToSeedSync(this._phrase, this._passphrase), this._classicalRoot = ir.fromSeed(this._seed, this._network), this._quantumRoot = P.QuantumBIP32Factory.fromSeed(
|
|
3604
3634
|
this._seed,
|
|
3605
3635
|
this._network,
|
|
3606
3636
|
this._securityLevel
|
|
@@ -3647,7 +3677,7 @@ class ue {
|
|
|
3647
3677
|
* @returns A new random mnemonic phrase
|
|
3648
3678
|
*/
|
|
3649
3679
|
static generatePhrase(t = Rt.MAXIMUM) {
|
|
3650
|
-
return
|
|
3680
|
+
return gt.generateMnemonic(t);
|
|
3651
3681
|
}
|
|
3652
3682
|
/**
|
|
3653
3683
|
* Generate a new Mnemonic instance with a random phrase
|
|
@@ -3659,7 +3689,7 @@ class ue {
|
|
|
3659
3689
|
* @returns A new Mnemonic instance
|
|
3660
3690
|
*/
|
|
3661
3691
|
static generate(t = Rt.MAXIMUM, e = "", i = I, r = P.MLDSASecurityLevel.LEVEL2) {
|
|
3662
|
-
const s =
|
|
3692
|
+
const s = gt.generateMnemonic(t);
|
|
3663
3693
|
return new ue(s, e, i, r);
|
|
3664
3694
|
}
|
|
3665
3695
|
/**
|
|
@@ -3669,7 +3699,7 @@ class ue {
|
|
|
3669
3699
|
* @returns True if the phrase is valid, false otherwise
|
|
3670
3700
|
*/
|
|
3671
3701
|
static validate(t) {
|
|
3672
|
-
return
|
|
3702
|
+
return gt.validateMnemonic(t);
|
|
3673
3703
|
}
|
|
3674
3704
|
/**
|
|
3675
3705
|
* Derive a wallet at a specific index using BIP360 (quantum) and configurable BIP standard (classical) paths
|
|
@@ -3695,7 +3725,7 @@ class ue {
|
|
|
3695
3725
|
* const wallet3 = mnemonic.derive(0, 0, false, BIPStandard.BIP86);
|
|
3696
3726
|
* ```
|
|
3697
3727
|
*/
|
|
3698
|
-
derive(t = 0, e = 0, i = !1, r =
|
|
3728
|
+
derive(t = 0, e = 0, i = !1, r = bt.BIP84) {
|
|
3699
3729
|
const s = this.buildClassicalPath(e, t, i, r), o = this._classicalRoot.derivePath(s);
|
|
3700
3730
|
if (!o.privateKey)
|
|
3701
3731
|
throw new Error(`Failed to derive classical private key at index ${t}`);
|
|
@@ -3725,7 +3755,7 @@ class ue {
|
|
|
3725
3755
|
* @param isChange - Whether this is a change address (default: false)
|
|
3726
3756
|
* @returns A Wallet instance with both classical and quantum keys
|
|
3727
3757
|
*/
|
|
3728
|
-
|
|
3758
|
+
deriveOPWallet(t = J.P2TR, e = 0, i = 0, r = !1) {
|
|
3729
3759
|
let s;
|
|
3730
3760
|
switch (t) {
|
|
3731
3761
|
case J.P2PKH:
|
|
@@ -3770,7 +3800,7 @@ class ue {
|
|
|
3770
3800
|
deriveMultipleUnisat(t = J.P2TR, e = 5, i = 0, r = 0, s = !1) {
|
|
3771
3801
|
const o = [];
|
|
3772
3802
|
for (let c = 0; c < e; c++)
|
|
3773
|
-
o.push(this.
|
|
3803
|
+
o.push(this.deriveOPWallet(t, i + c, r, s));
|
|
3774
3804
|
return o;
|
|
3775
3805
|
}
|
|
3776
3806
|
/**
|
|
@@ -3783,7 +3813,7 @@ class ue {
|
|
|
3783
3813
|
* @param bipStandard - The BIP standard to use for classical derivation (default: BIP84)
|
|
3784
3814
|
* @returns An array of Wallet instances
|
|
3785
3815
|
*/
|
|
3786
|
-
deriveMultiple(t, e = 0, i = 0, r = !1, s =
|
|
3816
|
+
deriveMultiple(t, e = 0, i = 0, r = !1, s = bt.BIP84) {
|
|
3787
3817
|
const o = [];
|
|
3788
3818
|
for (let c = 0; c < t; c++)
|
|
3789
3819
|
o.push(this.derive(e + c, i, r, s));
|
|
@@ -3835,7 +3865,7 @@ class ue {
|
|
|
3835
3865
|
* @param bipStandard - The BIP standard to use (default: BIP84)
|
|
3836
3866
|
* @returns The derivation path string
|
|
3837
3867
|
*/
|
|
3838
|
-
buildClassicalPath(t, e, i, r =
|
|
3868
|
+
buildClassicalPath(t, e, i, r = bt.BIP84) {
|
|
3839
3869
|
const s = this.getCoinType();
|
|
3840
3870
|
return He(r, s, t, i ? 1 : 0, e);
|
|
3841
3871
|
}
|
|
@@ -3856,7 +3886,7 @@ class ue {
|
|
|
3856
3886
|
* @returns The coin type (0 for mainnet, 1 for testnet/regtest)
|
|
3857
3887
|
*/
|
|
3858
3888
|
getCoinType() {
|
|
3859
|
-
return this._network.bech32 ===
|
|
3889
|
+
return this._network.bech32 === Bt.bech32 || this._network.bech32 === zt.bech32 ? 1 : 0;
|
|
3860
3890
|
}
|
|
3861
3891
|
}
|
|
3862
3892
|
var Ve = /* @__PURE__ */ ((n) => (n[n.MLDSA44 = 1312] = "MLDSA44", n[n.MLDSA65 = 1952] = "MLDSA65", n[n.MLDSA87 = 2592] = "MLDSA87", n))(Ve || {});
|
|
@@ -3906,9 +3936,9 @@ function nr() {
|
|
|
3906
3936
|
signerMap: /* @__PURE__ */ new Map()
|
|
3907
3937
|
};
|
|
3908
3938
|
}
|
|
3909
|
-
var
|
|
3939
|
+
var w = /* @__PURE__ */ ((n) => (n[n.GENERIC = 0] = "GENERIC", n[n.FUNDING = 1] = "FUNDING", n[n.DEPLOYMENT = 2] = "DEPLOYMENT", n[n.INTERACTION = 3] = "INTERACTION", n[n.MULTI_SIG = 4] = "MULTI_SIG", n[n.CUSTOM_CODE = 5] = "CUSTOM_CODE", n[n.CANCEL = 6] = "CANCEL", n[n.CONSOLIDATED_SETUP = 7] = "CONSOLIDATED_SETUP", n[n.CONSOLIDATED_REVEAL = 8] = "CONSOLIDATED_REVEAL", n))(w || {}), Ot = /* @__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))(Ot || {});
|
|
3910
3940
|
const qe = {
|
|
3911
|
-
CONSENSUS:
|
|
3941
|
+
CONSENSUS: Ot.Roswell,
|
|
3912
3942
|
CONSENSUS_NAME: "Roswell",
|
|
3913
3943
|
// The block height at which this consensus was enabled.
|
|
3914
3944
|
ENABLED_AT_BLOCK: 0n
|
|
@@ -3925,8 +3955,8 @@ const qe = {
|
|
|
3925
3955
|
// Equivalent to 56500 satoshis, calculated from UNWRAP_CONSOLIDATION_PREPAID_FEES.
|
|
3926
3956
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT: 56500n,
|
|
3927
3957
|
}, $e = {
|
|
3928
|
-
[
|
|
3929
|
-
}, $t =
|
|
3958
|
+
[Ot.Roswell]: qe
|
|
3959
|
+
}, $t = Ot.Roswell, or = $e[$t];
|
|
3930
3960
|
function ie(n) {
|
|
3931
3961
|
let t = a.allocUnsafe(0);
|
|
3932
3962
|
function e(o) {
|
|
@@ -3960,7 +3990,7 @@ function fe(n, t) {
|
|
|
3960
3990
|
return Ti(n, t) !== -1;
|
|
3961
3991
|
}
|
|
3962
3992
|
var Xe = /* @__PURE__ */ ((n) => (n[n.REPLACE_BY_FEE = 4294967293] = "REPLACE_BY_FEE", n[n.FINAL = 4294967295] = "FINAL", n))(Xe || {}), Ye = /* @__PURE__ */ ((n) => (n[n.BLOCKS = 0] = "BLOCKS", n[n.TIMESTAMPS = 1] = "TIMESTAMPS", n))(Ye || {});
|
|
3963
|
-
class Xt extends
|
|
3993
|
+
class Xt extends xe {
|
|
3964
3994
|
constructor(t) {
|
|
3965
3995
|
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
3996
|
const u = this.inputs[e];
|
|
@@ -4058,8 +4088,8 @@ class Xt extends ve {
|
|
|
4058
4088
|
* @returns {bigint} - The estimated transaction fees
|
|
4059
4089
|
*/
|
|
4060
4090
|
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 +
|
|
4091
|
+
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;
|
|
4092
|
+
return (f * 3n + (f + y)) / 4n * t;
|
|
4063
4093
|
}
|
|
4064
4094
|
static signInput(t, e, i, r, s) {
|
|
4065
4095
|
s && s[0] && (e.sighashType = s[0]), t.signInput(i, r, s.length ? s : void 0);
|
|
@@ -4186,7 +4216,7 @@ class Xt extends ve {
|
|
|
4186
4216
|
*/
|
|
4187
4217
|
internalPubKeyToXOnlyForInput(t) {
|
|
4188
4218
|
const e = this.getSignerForInput(t);
|
|
4189
|
-
return
|
|
4219
|
+
return B(T.from(e.publicKey));
|
|
4190
4220
|
}
|
|
4191
4221
|
/**
|
|
4192
4222
|
* Get the tweaked signer for a specific input.
|
|
@@ -4207,7 +4237,7 @@ class Xt extends ve {
|
|
|
4207
4237
|
return {
|
|
4208
4238
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4209
4239
|
network: this.network,
|
|
4210
|
-
name:
|
|
4240
|
+
name: k.P2TR
|
|
4211
4241
|
};
|
|
4212
4242
|
}
|
|
4213
4243
|
/**
|
|
@@ -4219,7 +4249,7 @@ class Xt extends ve {
|
|
|
4219
4249
|
return {
|
|
4220
4250
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
4221
4251
|
network: this.network,
|
|
4222
|
-
name:
|
|
4252
|
+
name: k.P2TR
|
|
4223
4253
|
};
|
|
4224
4254
|
}
|
|
4225
4255
|
/**
|
|
@@ -4317,7 +4347,7 @@ class Xt extends ve {
|
|
|
4317
4347
|
* @returns {Buffer}
|
|
4318
4348
|
*/
|
|
4319
4349
|
internalPubKeyToXOnly() {
|
|
4320
|
-
return
|
|
4350
|
+
return B(T.from(this.signer.publicKey));
|
|
4321
4351
|
}
|
|
4322
4352
|
/**
|
|
4323
4353
|
* Internal init.
|
|
@@ -4350,7 +4380,7 @@ class Xt extends ve {
|
|
|
4350
4380
|
redeem: { output: t },
|
|
4351
4381
|
network: this.network
|
|
4352
4382
|
});
|
|
4353
|
-
return
|
|
4383
|
+
return St({
|
|
4354
4384
|
redeem: e,
|
|
4355
4385
|
network: this.network
|
|
4356
4386
|
}).output;
|
|
@@ -4370,7 +4400,7 @@ class Xt extends ve {
|
|
|
4370
4400
|
redeem: { output: i },
|
|
4371
4401
|
// Use the custom redeem script
|
|
4372
4402
|
network: this.network
|
|
4373
|
-
}), c =
|
|
4403
|
+
}), c = St({
|
|
4374
4404
|
redeem: o,
|
|
4375
4405
|
// The P2WSH is wrapped inside the P2SH
|
|
4376
4406
|
network: this.network
|
|
@@ -4385,7 +4415,7 @@ class Xt extends ve {
|
|
|
4385
4415
|
const i = this.addressRotationEnabled && e !== void 0 ? this.getSignerForInput(e) : this.signer, r = T.isBuffer(i.publicKey) ? i.publicKey : T.from(i.publicKey, "hex"), s = jt({
|
|
4386
4416
|
pubkey: r,
|
|
4387
4417
|
network: this.network
|
|
4388
|
-
}), o =
|
|
4418
|
+
}), o = St({
|
|
4389
4419
|
redeem: s,
|
|
4390
4420
|
network: this.network
|
|
4391
4421
|
}), c = o.address;
|
|
@@ -4440,7 +4470,7 @@ class Xt extends ve {
|
|
|
4440
4470
|
o = h.redeemScript;
|
|
4441
4471
|
}
|
|
4442
4472
|
s.redeemScript = o;
|
|
4443
|
-
const c =
|
|
4473
|
+
const c = St({ redeem: { output: s.redeemScript } });
|
|
4444
4474
|
if (!c.redeem)
|
|
4445
4475
|
throw new Error("Failed to extract redeem script from P2SH UTXO");
|
|
4446
4476
|
const u = c.redeem.output;
|
|
@@ -4453,9 +4483,9 @@ class Xt extends ve {
|
|
|
4453
4483
|
o && (s.sighashType = o);
|
|
4454
4484
|
}
|
|
4455
4485
|
this.addressRotationEnabled ? s.tapInternalKey = this.internalPubKeyToXOnlyForInput(e) : (this.tweakSigner(), s.tapInternalKey = this.internalPubKeyToXOnly());
|
|
4456
|
-
} else if (
|
|
4486
|
+
} else if (Bi(r))
|
|
4457
4487
|
this.anchorInputIndices.add(e), s.isPayToAnchor = !0;
|
|
4458
|
-
else if (
|
|
4488
|
+
else if (Oi(r) || vi(r))
|
|
4459
4489
|
if (t.nonWitnessUtxo)
|
|
4460
4490
|
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4461
4491
|
else
|
|
@@ -4594,16 +4624,16 @@ function Gt(n, t) {
|
|
|
4594
4624
|
function cr(n) {
|
|
4595
4625
|
if (Gt(n, I))
|
|
4596
4626
|
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
4597
|
-
if (Gt(n,
|
|
4627
|
+
if (Gt(n, Bt))
|
|
4598
4628
|
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
4599
4629
|
if (Gt(n, zt))
|
|
4600
4630
|
return "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";
|
|
4601
4631
|
throw new Error("Unsupported network for chain ID retrieval");
|
|
4602
4632
|
}
|
|
4603
|
-
function
|
|
4633
|
+
function Oe(n) {
|
|
4604
4634
|
return Uint8Array.from(a.from(cr(n), "hex"));
|
|
4605
4635
|
}
|
|
4606
|
-
const
|
|
4636
|
+
const ve = Uint8Array.from(
|
|
4607
4637
|
a.from(
|
|
4608
4638
|
"e784995a412d773988c4b8e333d7b39dfb3cabf118d0d645411a916ca2407939",
|
|
4609
4639
|
// sha256("OP_NET")
|
|
@@ -4611,7 +4641,7 @@ const xe = Uint8Array.from(
|
|
|
4611
4641
|
)
|
|
4612
4642
|
);
|
|
4613
4643
|
ot(G);
|
|
4614
|
-
const V = 330n,
|
|
4644
|
+
const V = 330n, yt = 297n, re = a.from("51024e73", "hex");
|
|
4615
4645
|
class m extends Xt {
|
|
4616
4646
|
constructor(t) {
|
|
4617
4647
|
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)
|
|
@@ -4857,14 +4887,14 @@ class m extends Xt {
|
|
|
4857
4887
|
if (S && S.length >= 4) {
|
|
4858
4888
|
const b = S[0], _ = S[S.length - 1];
|
|
4859
4889
|
if (typeof b == "number" && b >= g.OP_1 && _ === g.OP_CHECKMULTISIG) {
|
|
4860
|
-
const
|
|
4861
|
-
for (let kt = 0; kt <
|
|
4862
|
-
|
|
4890
|
+
const vt = b - g.OP_1 + 1, xt = [];
|
|
4891
|
+
for (let kt = 0; kt < vt; kt++)
|
|
4892
|
+
xt.push(s);
|
|
4863
4893
|
return {
|
|
4864
4894
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4865
4895
|
a.alloc(0),
|
|
4866
4896
|
// OP_0 due to multisig bug
|
|
4867
|
-
...
|
|
4897
|
+
...xt,
|
|
4868
4898
|
f.witnessScript
|
|
4869
4899
|
])
|
|
4870
4900
|
};
|
|
@@ -4892,12 +4922,12 @@ class m extends Xt {
|
|
|
4892
4922
|
finalScriptSig: it.script.compile([s, f.redeemScript]),
|
|
4893
4923
|
finalScriptWitness: void 0
|
|
4894
4924
|
};
|
|
4895
|
-
const
|
|
4896
|
-
return
|
|
4925
|
+
const y = f.witnessUtxo?.script;
|
|
4926
|
+
return y ? f.tapInternalKey ? {
|
|
4897
4927
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4898
4928
|
r
|
|
4899
4929
|
])
|
|
4900
|
-
} :
|
|
4930
|
+
} : y.length === 22 && y[0] === g.OP_0 ? {
|
|
4901
4931
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4902
4932
|
s,
|
|
4903
4933
|
o
|
|
@@ -4910,7 +4940,7 @@ class m extends Xt {
|
|
|
4910
4940
|
} : Ke(
|
|
4911
4941
|
p,
|
|
4912
4942
|
f,
|
|
4913
|
-
|
|
4943
|
+
y,
|
|
4914
4944
|
!0,
|
|
4915
4945
|
!!f.redeemScript,
|
|
4916
4946
|
!!f.witnessScript
|
|
@@ -4919,7 +4949,7 @@ class m extends Xt {
|
|
|
4919
4949
|
try {
|
|
4920
4950
|
for (let p = 0; p < t.data.inputs.length; p++) {
|
|
4921
4951
|
const f = e[p];
|
|
4922
|
-
f && t.finalizeInput(p, (
|
|
4952
|
+
f && t.finalizeInput(p, (y) => c(y, f));
|
|
4923
4953
|
}
|
|
4924
4954
|
} catch (p) {
|
|
4925
4955
|
this.warn(`Could not finalize dummy tx: ${p.message}`);
|
|
@@ -5014,7 +5044,7 @@ class m extends Xt {
|
|
|
5014
5044
|
);
|
|
5015
5045
|
}
|
|
5016
5046
|
defineLockScript() {
|
|
5017
|
-
return L([
|
|
5047
|
+
return L([B(a.from(this.signer.publicKey)), g.OP_CHECKSIG]);
|
|
5018
5048
|
}
|
|
5019
5049
|
/**
|
|
5020
5050
|
* @description Adds the value to the output
|
|
@@ -5037,11 +5067,11 @@ class m extends Xt {
|
|
|
5037
5067
|
generateLegacySignature() {
|
|
5038
5068
|
if (this.tweakSigner(), !this.tweakedSigner)
|
|
5039
5069
|
throw new Error("Tweaked signer is not defined");
|
|
5040
|
-
const t =
|
|
5070
|
+
const t = B(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5041
5071
|
if (e.length !== 33)
|
|
5042
5072
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5043
|
-
const i =
|
|
5044
|
-
r.writeU8(P.MLDSASecurityLevel.LEVEL2), r.writeBytes(this.hashedPublicKey), r.writeBytes(t), r.writeBytes(e), r.writeBytes(
|
|
5073
|
+
const i = Oe(this.network), r = new D();
|
|
5074
|
+
r.writeU8(P.MLDSASecurityLevel.LEVEL2), r.writeBytes(this.hashedPublicKey), r.writeBytes(t), r.writeBytes(e), r.writeBytes(ve), r.writeBytes(i);
|
|
5045
5075
|
const s = r.getBuffer(), o = st.signMessage(this.tweakedSigner, s);
|
|
5046
5076
|
if (!st.verifySignature(t, s, o.signature))
|
|
5047
5077
|
throw new Error("Could not verify generated legacy signature for MLDSA link request");
|
|
@@ -5052,14 +5082,14 @@ class m extends Xt {
|
|
|
5052
5082
|
throw new Error("MLDSA signer is not defined");
|
|
5053
5083
|
if (this.tweakSigner(), !this.tweakedSigner)
|
|
5054
5084
|
throw new Error("Tweaked signer is not defined");
|
|
5055
|
-
const t =
|
|
5085
|
+
const t = B(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5056
5086
|
if (e.length !== 33)
|
|
5057
5087
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5058
|
-
const i =
|
|
5088
|
+
const i = Oe(this.network), r = ee(this.mldsaSigner.publicKey.length);
|
|
5059
5089
|
if (r !== P.MLDSASecurityLevel.LEVEL2)
|
|
5060
5090
|
throw new Error("Only MLDSA level 2 is supported for link requests");
|
|
5061
5091
|
const s = new D();
|
|
5062
|
-
s.writeU8(r), s.writeBytes(this.hashedPublicKey), s.writeBytes(this.mldsaSigner.publicKey), s.writeBytes(t), s.writeBytes(e), s.writeBytes(
|
|
5092
|
+
s.writeU8(r), s.writeBytes(this.hashedPublicKey), s.writeBytes(this.mldsaSigner.publicKey), s.writeBytes(t), s.writeBytes(e), s.writeBytes(ve), s.writeBytes(i);
|
|
5063
5093
|
const o = s.getBuffer(), c = st.signMLDSAMessage(this.mldsaSigner, o);
|
|
5064
5094
|
if (!st.verifyMLDSASignature(
|
|
5065
5095
|
this.mldsaSigner,
|
|
@@ -5187,13 +5217,13 @@ class m extends Xt {
|
|
|
5187
5217
|
addFeeToOutput(t, e, i, r) {
|
|
5188
5218
|
if (r) {
|
|
5189
5219
|
let s;
|
|
5190
|
-
t > V +
|
|
5220
|
+
t > V + yt ? s = yt : s = t, this.addOutput(
|
|
5191
5221
|
{
|
|
5192
5222
|
value: Number(s),
|
|
5193
5223
|
address: e
|
|
5194
5224
|
},
|
|
5195
5225
|
!0
|
|
5196
|
-
), s ===
|
|
5226
|
+
), s === yt && t - yt > V && this.addOutput(
|
|
5197
5227
|
{
|
|
5198
5228
|
value: Number(t - s),
|
|
5199
5229
|
address: i.address
|
|
@@ -5341,7 +5371,7 @@ class m extends Xt {
|
|
|
5341
5371
|
}
|
|
5342
5372
|
class Wt extends m {
|
|
5343
5373
|
constructor(t) {
|
|
5344
|
-
if (super(t), this.type =
|
|
5374
|
+
if (super(t), this.type = w.CUSTOM_CODE, this.tapLeafScript = null, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5345
5375
|
if (!this.tapLeafScript)
|
|
5346
5376
|
throw new Error("Tap leaf script is required");
|
|
5347
5377
|
const s = this.getScriptSolution(i).concat(this.tapLeafScript.script).concat(this.tapLeafScript.controlBlock);
|
|
@@ -5383,7 +5413,7 @@ class Wt extends m {
|
|
|
5383
5413
|
* @protected
|
|
5384
5414
|
*/
|
|
5385
5415
|
contractSignerXOnlyPubKey() {
|
|
5386
|
-
return
|
|
5416
|
+
return B(a.from(this.contractSigner.publicKey));
|
|
5387
5417
|
}
|
|
5388
5418
|
/**
|
|
5389
5419
|
* Build the transaction
|
|
@@ -5438,7 +5468,7 @@ class Wt extends m {
|
|
|
5438
5468
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5439
5469
|
network: this.network,
|
|
5440
5470
|
scriptTree: this.scriptTree,
|
|
5441
|
-
name:
|
|
5471
|
+
name: k.P2TR
|
|
5442
5472
|
};
|
|
5443
5473
|
}
|
|
5444
5474
|
/**
|
|
@@ -5456,7 +5486,7 @@ class Wt extends m {
|
|
|
5456
5486
|
network: this.network,
|
|
5457
5487
|
scriptTree: this.scriptTree,
|
|
5458
5488
|
redeem: t,
|
|
5459
|
-
name:
|
|
5489
|
+
name: k.P2TR
|
|
5460
5490
|
};
|
|
5461
5491
|
}
|
|
5462
5492
|
getScriptSolution(t) {
|
|
@@ -5489,12 +5519,12 @@ class Wt extends m {
|
|
|
5489
5519
|
*/
|
|
5490
5520
|
generateRedeemScripts() {
|
|
5491
5521
|
this.targetScriptRedeem = {
|
|
5492
|
-
name:
|
|
5522
|
+
name: k.P2TR,
|
|
5493
5523
|
//pubkeys: this.getPubKeys(),
|
|
5494
5524
|
output: this.compiledTargetScript,
|
|
5495
5525
|
redeemVersion: 192
|
|
5496
5526
|
}, this.leftOverFundsScriptRedeem = {
|
|
5497
|
-
name:
|
|
5527
|
+
name: k.P2TR,
|
|
5498
5528
|
//pubkeys: this.getPubKeys(),
|
|
5499
5529
|
output: this.getLeafScript(),
|
|
5500
5530
|
redeemVersion: 192
|
|
@@ -5580,7 +5610,7 @@ class pe extends m {
|
|
|
5580
5610
|
* @returns {Buffer} The internal pubkey as an x-only key
|
|
5581
5611
|
*/
|
|
5582
5612
|
scriptSignerXOnlyPubKey() {
|
|
5583
|
-
return
|
|
5613
|
+
return B(a.from(this.scriptSigner.publicKey));
|
|
5584
5614
|
}
|
|
5585
5615
|
/**
|
|
5586
5616
|
* Generate a key pair from the seed
|
|
@@ -5631,7 +5661,7 @@ class pe extends m {
|
|
|
5631
5661
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5632
5662
|
network: this.network,
|
|
5633
5663
|
scriptTree: this.scriptTree,
|
|
5634
|
-
name:
|
|
5664
|
+
name: k.P2TR
|
|
5635
5665
|
};
|
|
5636
5666
|
}
|
|
5637
5667
|
generateTapData() {
|
|
@@ -5645,7 +5675,7 @@ class pe extends m {
|
|
|
5645
5675
|
network: this.network,
|
|
5646
5676
|
scriptTree: this.scriptTree,
|
|
5647
5677
|
redeem: t,
|
|
5648
|
-
name:
|
|
5678
|
+
name: k.P2TR
|
|
5649
5679
|
};
|
|
5650
5680
|
}
|
|
5651
5681
|
/**
|
|
@@ -5745,11 +5775,11 @@ class pe extends m {
|
|
|
5745
5775
|
*/
|
|
5746
5776
|
generateRedeemScripts() {
|
|
5747
5777
|
this.targetScriptRedeem = {
|
|
5748
|
-
name:
|
|
5778
|
+
name: k.P2TR,
|
|
5749
5779
|
output: this.compiledTargetScript,
|
|
5750
5780
|
redeemVersion: 192
|
|
5751
5781
|
}, this.leftOverFundsScriptRedeem = {
|
|
5752
|
-
name:
|
|
5782
|
+
name: k.P2TR,
|
|
5753
5783
|
output: this.LOCK_LEAF_SCRIPT,
|
|
5754
5784
|
redeemVersion: 192
|
|
5755
5785
|
};
|
|
@@ -5757,7 +5787,7 @@ class pe extends m {
|
|
|
5757
5787
|
}
|
|
5758
5788
|
class ft extends m {
|
|
5759
5789
|
constructor(t) {
|
|
5760
|
-
if (super(t), this.type =
|
|
5790
|
+
if (super(t), this.type = w.DEPLOYMENT, this.tapLeafScript = null, this.deploymentVersion = 0, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5761
5791
|
if (!this.tapLeafScript)
|
|
5762
5792
|
throw new Error("Tap leaf script is required");
|
|
5763
5793
|
if (!i.tapScriptSig)
|
|
@@ -5796,7 +5826,7 @@ class ft extends m {
|
|
|
5796
5826
|
this.calldata,
|
|
5797
5827
|
this.generateFeatures(t)
|
|
5798
5828
|
);
|
|
5799
|
-
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + this.contractSeed.toString("hex"), this._contractAddress = new
|
|
5829
|
+
this.scriptTree = this.getScriptTree(), this.internalInit(), this._contractPubKey = "0x" + this.contractSeed.toString("hex"), this._contractAddress = new v(this.contractSeed);
|
|
5800
5830
|
}
|
|
5801
5831
|
static {
|
|
5802
5832
|
this.MAXIMUM_CONTRACT_SIZE = 128 * 1024;
|
|
@@ -5848,7 +5878,7 @@ class ft extends m {
|
|
|
5848
5878
|
* @protected
|
|
5849
5879
|
*/
|
|
5850
5880
|
contractSignerXOnlyPubKey() {
|
|
5851
|
-
return
|
|
5881
|
+
return B(a.from(this.contractSigner.publicKey));
|
|
5852
5882
|
}
|
|
5853
5883
|
/**
|
|
5854
5884
|
* Build the transaction
|
|
@@ -5916,7 +5946,7 @@ class ft extends m {
|
|
|
5916
5946
|
*/
|
|
5917
5947
|
generateScriptAddress() {
|
|
5918
5948
|
return {
|
|
5919
|
-
name:
|
|
5949
|
+
name: k.P2TR,
|
|
5920
5950
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5921
5951
|
network: this.network,
|
|
5922
5952
|
scriptTree: this.scriptTree
|
|
@@ -5933,7 +5963,7 @@ class ft extends m {
|
|
|
5933
5963
|
if (!this.scriptTree)
|
|
5934
5964
|
throw new Error("Script tree is required");
|
|
5935
5965
|
return {
|
|
5936
|
-
name:
|
|
5966
|
+
name: k.P2TR,
|
|
5937
5967
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
5938
5968
|
network: this.network,
|
|
5939
5969
|
scriptTree: this.scriptTree,
|
|
@@ -5985,12 +6015,12 @@ class ft extends m {
|
|
|
5985
6015
|
*/
|
|
5986
6016
|
generateRedeemScripts() {
|
|
5987
6017
|
this.targetScriptRedeem = {
|
|
5988
|
-
name:
|
|
6018
|
+
name: k.P2TR,
|
|
5989
6019
|
//pubkeys: this.getPubKeys(),
|
|
5990
6020
|
output: this.compiledTargetScript,
|
|
5991
6021
|
redeemVersion: 192
|
|
5992
6022
|
}, this.leftOverFundsScriptRedeem = {
|
|
5993
|
-
name:
|
|
6023
|
+
name: k.P2TR,
|
|
5994
6024
|
//pubkeys: this.getPubKeys(),
|
|
5995
6025
|
output: this.getLeafScript(),
|
|
5996
6026
|
redeemVersion: 192
|
|
@@ -6024,7 +6054,7 @@ class ft extends m {
|
|
|
6024
6054
|
}
|
|
6025
6055
|
class Mt extends m {
|
|
6026
6056
|
constructor(t) {
|
|
6027
|
-
super(t), this.type =
|
|
6057
|
+
super(t), this.type = w.FUNDING, this.amount = t.amount, this.splitInputsInto = t.splitInputsInto ?? 1, this.internalInit();
|
|
6028
6058
|
}
|
|
6029
6059
|
async buildTransaction() {
|
|
6030
6060
|
if (!this.to)
|
|
@@ -6067,7 +6097,7 @@ class Mt extends m {
|
|
|
6067
6097
|
}
|
|
6068
6098
|
class Nt extends pe {
|
|
6069
6099
|
constructor(t) {
|
|
6070
|
-
if (super(t), this.type =
|
|
6100
|
+
if (super(t), this.type = w.INTERACTION, this.tapLeafScript = null, !t.contract)
|
|
6071
6101
|
throw new Error("parameters.contract is required for interaction transaction.");
|
|
6072
6102
|
if (this.contractSecret = a.from(t.contract.replace("0x", ""), "hex"), this.contractSecret.length !== 32)
|
|
6073
6103
|
throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
@@ -6109,7 +6139,7 @@ class Nt extends pe {
|
|
|
6109
6139
|
}
|
|
6110
6140
|
class j extends m {
|
|
6111
6141
|
constructor(t) {
|
|
6112
|
-
if (super(t), this.type =
|
|
6142
|
+
if (super(t), this.type = w.INTERACTION, this.p2wdaInputIndices = /* @__PURE__ */ new Set(), this.compiledOperationData = null, !t.to)
|
|
6113
6143
|
throw new Error("Contract address (to) is required");
|
|
6114
6144
|
if (!t.contract)
|
|
6115
6145
|
throw new Error("Contract secret is required");
|
|
@@ -6117,7 +6147,7 @@ class j extends m {
|
|
|
6117
6147
|
throw new Error("Calldata is required");
|
|
6118
6148
|
if (!t.challenge)
|
|
6119
6149
|
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 = N.compress(t.calldata), this.challenge = t.challenge, this.randomBytes = t.randomBytes || K.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.p2wdaGenerator = new
|
|
6150
|
+
if (this.disableAutoRefund = t.disableAutoRefund || !1, this.contractAddress = t.to, this.contractSecret = T.from(t.contract.replace("0x", ""), "hex"), this.calldata = N.compress(t.calldata), this.challenge = t.challenge, this.randomBytes = t.randomBytes || K.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.p2wdaGenerator = new At(
|
|
6121
6151
|
T.from(this.signer.publicKey),
|
|
6122
6152
|
this.scriptSignerXOnlyPubKey(),
|
|
6123
6153
|
this.network
|
|
@@ -6217,7 +6247,7 @@ class j extends m {
|
|
|
6217
6247
|
* Get script signer x-only pubkey (same as SharedInteractionTransaction)
|
|
6218
6248
|
*/
|
|
6219
6249
|
scriptSignerXOnlyPubKey() {
|
|
6220
|
-
return
|
|
6250
|
+
return B(T.from(this.scriptSigner.publicKey));
|
|
6221
6251
|
}
|
|
6222
6252
|
/**
|
|
6223
6253
|
* Validate that input 0 is P2WDA
|
|
@@ -6239,7 +6269,7 @@ class j extends m {
|
|
|
6239
6269
|
if (!this.compiledOperationData)
|
|
6240
6270
|
throw new Error("Operation data not compiled");
|
|
6241
6271
|
const t = this.compiledOperationData.length;
|
|
6242
|
-
if (!
|
|
6272
|
+
if (!At.validateWitnessSize(t)) {
|
|
6243
6273
|
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(
|
|
6244
6274
|
r / j.MAX_BYTES_PER_WITNESS
|
|
6245
6275
|
);
|
|
@@ -6299,7 +6329,7 @@ class ge extends m {
|
|
|
6299
6329
|
isCancellation: !0,
|
|
6300
6330
|
priorityFee: 1n,
|
|
6301
6331
|
calldata: a.alloc(0)
|
|
6302
|
-
}), this.type =
|
|
6332
|
+
}), this.type = w.CANCEL, this.tapLeafScript = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
6303
6333
|
if (!this.tapLeafScript)
|
|
6304
6334
|
throw new Error("Tap leaf script is required");
|
|
6305
6335
|
if (!i.tapScriptSig || i.tapScriptSig.length === 0)
|
|
@@ -6361,7 +6391,7 @@ class ge extends m {
|
|
|
6361
6391
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
6362
6392
|
network: this.network,
|
|
6363
6393
|
scriptTree: this.scriptTree,
|
|
6364
|
-
name:
|
|
6394
|
+
name: k.P2TR
|
|
6365
6395
|
};
|
|
6366
6396
|
}
|
|
6367
6397
|
/**
|
|
@@ -6388,7 +6418,7 @@ class ge extends m {
|
|
|
6388
6418
|
network: this.network,
|
|
6389
6419
|
scriptTree: this.scriptTree,
|
|
6390
6420
|
redeem: t,
|
|
6391
|
-
name:
|
|
6421
|
+
name: k.P2TR
|
|
6392
6422
|
};
|
|
6393
6423
|
}
|
|
6394
6424
|
async signInputs(t) {
|
|
@@ -6447,7 +6477,7 @@ class ge extends m {
|
|
|
6447
6477
|
*/
|
|
6448
6478
|
generateLeftoverFundsRedeem() {
|
|
6449
6479
|
this.leftOverFundsScriptRedeem = {
|
|
6450
|
-
name:
|
|
6480
|
+
name: k.P2TR,
|
|
6451
6481
|
output: this.LOCK_LEAF_SCRIPT,
|
|
6452
6482
|
redeemVersion: 192
|
|
6453
6483
|
};
|
|
@@ -6455,7 +6485,7 @@ class ge extends m {
|
|
|
6455
6485
|
}
|
|
6456
6486
|
class Ge extends m {
|
|
6457
6487
|
constructor(t) {
|
|
6458
|
-
if (super(t), this.type =
|
|
6488
|
+
if (super(t), this.type = w.INTERACTION, this.cachedValuePerOutput = null, !t.to)
|
|
6459
6489
|
throw new Error("Contract address (to) is required");
|
|
6460
6490
|
if (!t.contract)
|
|
6461
6491
|
throw new Error("Contract secret (contract) is required");
|
|
@@ -6470,7 +6500,7 @@ class Ge extends m {
|
|
|
6470
6500
|
this.network
|
|
6471
6501
|
), this.calldataGenerator = new oe(
|
|
6472
6502
|
T.from(this.signer.publicKey),
|
|
6473
|
-
|
|
6503
|
+
B(T.from(this.scriptSigner.publicKey)),
|
|
6474
6504
|
this.network
|
|
6475
6505
|
), t.compiledTargetScript)
|
|
6476
6506
|
if (T.isBuffer(t.compiledTargetScript))
|
|
@@ -6607,7 +6637,7 @@ class Ge extends m {
|
|
|
6607
6637
|
e.signInput(p, this.signer);
|
|
6608
6638
|
for (let p = 0; p < this.commitmentOutputs.length; p++) {
|
|
6609
6639
|
const f = this.commitmentOutputs[p];
|
|
6610
|
-
e.finalizeInput(p, (
|
|
6640
|
+
e.finalizeInput(p, (y, S) => this.finalizeCommitmentInput(S, f));
|
|
6611
6641
|
}
|
|
6612
6642
|
const l = e.extractTransaction(), d = {
|
|
6613
6643
|
txHex: l.toHex(),
|
|
@@ -6775,8 +6805,8 @@ class Qe {
|
|
|
6775
6805
|
{ ...t, optionalInputs: e },
|
|
6776
6806
|
Wt,
|
|
6777
6807
|
async (p) => {
|
|
6778
|
-
const f = await p.estimateTransactionFees(),
|
|
6779
|
-
return f +
|
|
6808
|
+
const f = await p.estimateTransactionFees(), y = this.getPriorityFee(t), S = p.getOptionalOutputValue();
|
|
6809
|
+
return f + y + S;
|
|
6780
6810
|
},
|
|
6781
6811
|
"CustomScript"
|
|
6782
6812
|
), o = await i.getFundingTransactionParameters();
|
|
@@ -6872,11 +6902,11 @@ class Qe {
|
|
|
6872
6902
|
nonWitnessUtxo: l.tx.toBuffer(),
|
|
6873
6903
|
estimatedFees: s.estimatedFees,
|
|
6874
6904
|
optionalInputs: r
|
|
6875
|
-
}, f = new Nt(p),
|
|
6905
|
+
}, f = new Nt(p), y = await f.signTransaction();
|
|
6876
6906
|
return {
|
|
6877
6907
|
interactionAddress: s.getScriptAddress(),
|
|
6878
6908
|
fundingTransaction: l.tx.toHex(),
|
|
6879
|
-
interactionTransaction:
|
|
6909
|
+
interactionTransaction: y.toHex(),
|
|
6880
6910
|
estimatedFees: f.transactionFee,
|
|
6881
6911
|
nextUTXOs: this.getUTXOAsTransaction(
|
|
6882
6912
|
l.tx,
|
|
@@ -6947,9 +6977,9 @@ class Qe {
|
|
|
6947
6977
|
const i = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: o } = await this.iterateFundingAmount(
|
|
6948
6978
|
{ ...t, optionalInputs: i },
|
|
6949
6979
|
ft,
|
|
6950
|
-
async (
|
|
6951
|
-
const
|
|
6952
|
-
return
|
|
6980
|
+
async (vt) => {
|
|
6981
|
+
const xt = await vt.estimateTransactionFees(), kt = this.getPriorityFee(t), li = vt.getOptionalOutputValue();
|
|
6982
|
+
return xt + kt + li;
|
|
6953
6983
|
},
|
|
6954
6984
|
"Deployment"
|
|
6955
6985
|
);
|
|
@@ -6989,7 +7019,7 @@ class Qe {
|
|
|
6989
7019
|
nonWitnessUtxo: l.toBuffer(),
|
|
6990
7020
|
estimatedFees: r.estimatedFees,
|
|
6991
7021
|
optionalInputs: i
|
|
6992
|
-
},
|
|
7022
|
+
}, y = new ft(f), S = await y.signTransaction(), b = l.outs[1], _ = {
|
|
6993
7023
|
transactionId: l.getId(),
|
|
6994
7024
|
outputIndex: 1,
|
|
6995
7025
|
scriptPubKey: {
|
|
@@ -7000,8 +7030,8 @@ class Qe {
|
|
|
7000
7030
|
};
|
|
7001
7031
|
return {
|
|
7002
7032
|
transaction: [l.toHex(), S.toHex()],
|
|
7003
|
-
contractAddress:
|
|
7004
|
-
contractPubKey:
|
|
7033
|
+
contractAddress: y.getContractAddress(),
|
|
7034
|
+
contractPubKey: y.contractPubKey,
|
|
7005
7035
|
utxos: [_],
|
|
7006
7036
|
challenge: o.toRaw(),
|
|
7007
7037
|
inputUtxos: t.utxos
|
|
@@ -7237,7 +7267,7 @@ class Qe {
|
|
|
7237
7267
|
* @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge: IChallengeSolution | null}>} - The final transaction and estimated amount
|
|
7238
7268
|
*/
|
|
7239
7269
|
async iterateFundingAmount(t, e, i, r) {
|
|
7240
|
-
const s = "randomBytes" in t ? t.randomBytes ?? K.rndBytes() : K.rndBytes(), o =
|
|
7270
|
+
const s = "randomBytes" in t ? t.randomBytes ?? K.rndBytes() : K.rndBytes(), o = v.dead().p2tr(t.network);
|
|
7241
7271
|
let c = this.INITIAL_FUNDING_ESTIMATE, u = 0n, h = 0, l = null, d = null;
|
|
7242
7272
|
for (; h < this.MAX_ITERATIONS && c !== u; ) {
|
|
7243
7273
|
u = c;
|
|
@@ -7253,18 +7283,18 @@ class Qe {
|
|
|
7253
7283
|
value: c,
|
|
7254
7284
|
nonWitnessUtxo: p.toBuffer()
|
|
7255
7285
|
};
|
|
7256
|
-
let
|
|
7257
|
-
"challenge" in t && t.challenge ?
|
|
7286
|
+
let y;
|
|
7287
|
+
"challenge" in t && t.challenge ? y = {
|
|
7258
7288
|
...t,
|
|
7259
7289
|
utxos: [f],
|
|
7260
7290
|
randomBytes: s,
|
|
7261
7291
|
challenge: d ?? t.challenge
|
|
7262
|
-
} :
|
|
7292
|
+
} : y = {
|
|
7263
7293
|
...t,
|
|
7264
7294
|
utxos: [f],
|
|
7265
7295
|
randomBytes: s
|
|
7266
7296
|
};
|
|
7267
|
-
const S = new e(
|
|
7297
|
+
const S = new e(y);
|
|
7268
7298
|
try {
|
|
7269
7299
|
await S.generateTransactionMinimalSignatures(), c = await i(S);
|
|
7270
7300
|
} catch (b) {
|
|
@@ -7327,7 +7357,7 @@ class x extends m {
|
|
|
7327
7357
|
),
|
|
7328
7358
|
priorityFee: 0n,
|
|
7329
7359
|
gasSatFee: 0n
|
|
7330
|
-
}), this.type =
|
|
7360
|
+
}), this.type = w.MULTI_SIG, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.originalInputCount = 0, this.sighashTypes = x.signHashTypesArray, this.customFinalizer = (e, i) => {
|
|
7331
7361
|
if (!this.tapLeafScript)
|
|
7332
7362
|
throw new Error("Tap leaf script is required");
|
|
7333
7363
|
const s = this.getScriptSolution(i).concat(this.tapLeafScript.script).concat(this.tapLeafScript.controlBlock);
|
|
@@ -7336,7 +7366,7 @@ class x extends m {
|
|
|
7336
7366
|
};
|
|
7337
7367
|
}, !t.pubkeys)
|
|
7338
7368
|
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 =
|
|
7369
|
+
t.psbt && (this.log("Using provided PSBT."), this.transaction = t.psbt, this.originalInputCount = this.transaction.data.inputs.length), this.refundVault = t.refundVault, this.requestedAmount = t.requestedAmount, this.receiver = t.receiver, this.publicKeys = t.pubkeys, this.minimumSignatures = t.minimumSignatures, this.compiledTargetScript = Et.compile(
|
|
7340
7370
|
t.pubkeys,
|
|
7341
7371
|
this.minimumSignatures
|
|
7342
7372
|
), this.scriptTree = this.getScriptTree(), this.internalInit();
|
|
@@ -7406,7 +7436,7 @@ class x extends m {
|
|
|
7406
7436
|
let s = !1, o = !0;
|
|
7407
7437
|
for (let c = i; c < t.data.inputs.length; c++) {
|
|
7408
7438
|
const u = t.data.inputs[c];
|
|
7409
|
-
u.tapInternalKey || (u.tapInternalKey =
|
|
7439
|
+
u.tapInternalKey || (u.tapInternalKey = B(x.numsPoint));
|
|
7410
7440
|
const h = [];
|
|
7411
7441
|
if (u.finalScriptWitness) {
|
|
7412
7442
|
const d = m.readScriptWitnessToWitnessStack(
|
|
@@ -7457,7 +7487,7 @@ class x extends m {
|
|
|
7457
7487
|
for (const u of r) {
|
|
7458
7488
|
let h = !1;
|
|
7459
7489
|
for (const l of e.tapScriptSig)
|
|
7460
|
-
l.pubkey.equals(
|
|
7490
|
+
l.pubkey.equals(B(u)) && (o.push(l.signature), h = !0);
|
|
7461
7491
|
h || o.push(a.alloc(0));
|
|
7462
7492
|
}
|
|
7463
7493
|
o = o.reverse();
|
|
@@ -7496,7 +7526,7 @@ class x extends m {
|
|
|
7496
7526
|
for (let o = e; o < t.data.inputs.length; o++)
|
|
7497
7527
|
try {
|
|
7498
7528
|
const c = t.data.inputs[o];
|
|
7499
|
-
c.tapInternalKey || (c.tapInternalKey =
|
|
7529
|
+
c.tapInternalKey || (c.tapInternalKey = B(x.numsPoint));
|
|
7500
7530
|
const u = [];
|
|
7501
7531
|
if (c.finalScriptWitness) {
|
|
7502
7532
|
const h = m.readScriptWitnessToWitnessStack(
|
|
@@ -7623,11 +7653,11 @@ class x extends m {
|
|
|
7623
7653
|
}
|
|
7624
7654
|
generateScriptAddress() {
|
|
7625
7655
|
return {
|
|
7626
|
-
internalPubkey:
|
|
7656
|
+
internalPubkey: B(x.numsPoint),
|
|
7627
7657
|
//this.internalPubKeyToXOnly(),
|
|
7628
7658
|
network: this.network,
|
|
7629
7659
|
scriptTree: this.scriptTree,
|
|
7630
|
-
name:
|
|
7660
|
+
name: k.P2TR
|
|
7631
7661
|
};
|
|
7632
7662
|
}
|
|
7633
7663
|
generateTapData() {
|
|
@@ -7637,12 +7667,12 @@ class x extends m {
|
|
|
7637
7667
|
if (!this.scriptTree)
|
|
7638
7668
|
throw new Error("Script tree is required");
|
|
7639
7669
|
return {
|
|
7640
|
-
internalPubkey:
|
|
7670
|
+
internalPubkey: B(x.numsPoint),
|
|
7641
7671
|
//this.internalPubKeyToXOnly(),
|
|
7642
7672
|
network: this.network,
|
|
7643
7673
|
scriptTree: this.scriptTree,
|
|
7644
7674
|
redeem: t,
|
|
7645
|
-
name:
|
|
7675
|
+
name: k.P2TR
|
|
7646
7676
|
};
|
|
7647
7677
|
}
|
|
7648
7678
|
/**
|
|
@@ -7699,11 +7729,11 @@ class x extends m {
|
|
|
7699
7729
|
*/
|
|
7700
7730
|
generateRedeemScripts() {
|
|
7701
7731
|
this.targetScriptRedeem = {
|
|
7702
|
-
name:
|
|
7732
|
+
name: k.P2TR,
|
|
7703
7733
|
output: this.compiledTargetScript,
|
|
7704
7734
|
redeemVersion: 192
|
|
7705
7735
|
}, this.leftOverFundsScriptRedeem = {
|
|
7706
|
-
name:
|
|
7736
|
+
name: k.P2TR,
|
|
7707
7737
|
output: x.LOCK_LEAF_SCRIPT,
|
|
7708
7738
|
redeemVersion: 192
|
|
7709
7739
|
};
|
|
@@ -7711,24 +7741,24 @@ class x extends m {
|
|
|
7711
7741
|
}
|
|
7712
7742
|
const Se = 1, _t = 66;
|
|
7713
7743
|
function je(n) {
|
|
7714
|
-
return n.type ===
|
|
7744
|
+
return n.type === w.FUNDING;
|
|
7715
7745
|
}
|
|
7716
7746
|
function Ze(n) {
|
|
7717
|
-
return n.type ===
|
|
7747
|
+
return n.type === w.DEPLOYMENT;
|
|
7718
7748
|
}
|
|
7719
7749
|
function Je(n) {
|
|
7720
|
-
return n.type ===
|
|
7750
|
+
return n.type === w.INTERACTION;
|
|
7721
7751
|
}
|
|
7722
7752
|
function et(n) {
|
|
7723
|
-
return n.type ===
|
|
7753
|
+
return n.type === w.MULTI_SIG;
|
|
7724
7754
|
}
|
|
7725
7755
|
function ti(n) {
|
|
7726
|
-
return n.type ===
|
|
7756
|
+
return n.type === w.CUSTOM_CODE;
|
|
7727
7757
|
}
|
|
7728
7758
|
function ei(n) {
|
|
7729
|
-
return n.type ===
|
|
7759
|
+
return n.type === w.CANCEL;
|
|
7730
7760
|
}
|
|
7731
|
-
class
|
|
7761
|
+
class O {
|
|
7732
7762
|
/**
|
|
7733
7763
|
* Serialize transaction state to binary format
|
|
7734
7764
|
* @param state - The transaction state to serialize
|
|
@@ -7755,7 +7785,7 @@ class B {
|
|
|
7755
7785
|
const s = new qt(i), o = this.readHeader(s);
|
|
7756
7786
|
if (o.formatVersion > Se)
|
|
7757
7787
|
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),
|
|
7788
|
+
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
7789
|
return {
|
|
7760
7790
|
header: o,
|
|
7761
7791
|
baseParams: c,
|
|
@@ -7765,7 +7795,7 @@ class B {
|
|
|
7765
7795
|
addressRotationEnabled: d,
|
|
7766
7796
|
signerMappings: p,
|
|
7767
7797
|
typeSpecificData: f,
|
|
7768
|
-
precomputedData:
|
|
7798
|
+
precomputedData: y
|
|
7769
7799
|
};
|
|
7770
7800
|
}
|
|
7771
7801
|
/**
|
|
@@ -7900,22 +7930,22 @@ class B {
|
|
|
7900
7930
|
}
|
|
7901
7931
|
static writeTypeSpecificData(t, e) {
|
|
7902
7932
|
switch (e.type) {
|
|
7903
|
-
case
|
|
7933
|
+
case w.FUNDING:
|
|
7904
7934
|
this.writeFundingData(t, e);
|
|
7905
7935
|
break;
|
|
7906
|
-
case
|
|
7936
|
+
case w.DEPLOYMENT:
|
|
7907
7937
|
this.writeDeploymentData(t, e);
|
|
7908
7938
|
break;
|
|
7909
|
-
case
|
|
7939
|
+
case w.INTERACTION:
|
|
7910
7940
|
this.writeInteractionData(t, e);
|
|
7911
7941
|
break;
|
|
7912
|
-
case
|
|
7942
|
+
case w.MULTI_SIG:
|
|
7913
7943
|
this.writeMultiSigData(t, e);
|
|
7914
7944
|
break;
|
|
7915
|
-
case
|
|
7945
|
+
case w.CUSTOM_CODE:
|
|
7916
7946
|
this.writeCustomScriptData(t, e);
|
|
7917
7947
|
break;
|
|
7918
|
-
case
|
|
7948
|
+
case w.CANCEL:
|
|
7919
7949
|
this.writeCancelData(t, e);
|
|
7920
7950
|
break;
|
|
7921
7951
|
default:
|
|
@@ -7924,17 +7954,17 @@ class B {
|
|
|
7924
7954
|
}
|
|
7925
7955
|
static readTypeSpecificData(t, e) {
|
|
7926
7956
|
switch (e) {
|
|
7927
|
-
case
|
|
7957
|
+
case w.FUNDING:
|
|
7928
7958
|
return this.readFundingData(t);
|
|
7929
|
-
case
|
|
7959
|
+
case w.DEPLOYMENT:
|
|
7930
7960
|
return this.readDeploymentData(t);
|
|
7931
|
-
case
|
|
7961
|
+
case w.INTERACTION:
|
|
7932
7962
|
return this.readInteractionData(t);
|
|
7933
|
-
case
|
|
7963
|
+
case w.MULTI_SIG:
|
|
7934
7964
|
return this.readMultiSigData(t);
|
|
7935
|
-
case
|
|
7965
|
+
case w.CUSTOM_CODE:
|
|
7936
7966
|
return this.readCustomScriptData(t);
|
|
7937
|
-
case
|
|
7967
|
+
case w.CANCEL:
|
|
7938
7968
|
return this.readCancelData(t);
|
|
7939
7969
|
default:
|
|
7940
7970
|
throw new Error(`Unsupported transaction type: ${e}`);
|
|
@@ -7946,7 +7976,7 @@ class B {
|
|
|
7946
7976
|
}
|
|
7947
7977
|
static readFundingData(t) {
|
|
7948
7978
|
return {
|
|
7949
|
-
type:
|
|
7979
|
+
type: w.FUNDING,
|
|
7950
7980
|
amount: t.readU64().toString(),
|
|
7951
7981
|
splitInputsInto: t.readU16()
|
|
7952
7982
|
};
|
|
@@ -7958,7 +7988,7 @@ class B {
|
|
|
7958
7988
|
static readDeploymentData(t) {
|
|
7959
7989
|
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
7990
|
return {
|
|
7961
|
-
type:
|
|
7991
|
+
type: w.DEPLOYMENT,
|
|
7962
7992
|
bytecode: e,
|
|
7963
7993
|
calldata: r,
|
|
7964
7994
|
challenge: s,
|
|
@@ -7974,7 +8004,7 @@ class B {
|
|
|
7974
8004
|
static readInteractionData(t) {
|
|
7975
8005
|
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
8006
|
return {
|
|
7977
|
-
type:
|
|
8007
|
+
type: w.INTERACTION,
|
|
7978
8008
|
calldata: e,
|
|
7979
8009
|
contract: r,
|
|
7980
8010
|
challenge: s,
|
|
@@ -7999,7 +8029,7 @@ class B {
|
|
|
7999
8029
|
i.push(a.from(t.readBytesWithLength()).toString("hex"));
|
|
8000
8030
|
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
8031
|
return {
|
|
8002
|
-
type:
|
|
8032
|
+
type: w.MULTI_SIG,
|
|
8003
8033
|
pubkeys: i,
|
|
8004
8034
|
minimumSignatures: r,
|
|
8005
8035
|
receiver: s,
|
|
@@ -8031,7 +8061,7 @@ class B {
|
|
|
8031
8061
|
s.push(a.from(t.readBytesWithLength()).toString("hex"));
|
|
8032
8062
|
const c = t.readBoolean() ? a.from(t.readBytesWithLength()).toString("hex") : void 0;
|
|
8033
8063
|
return {
|
|
8034
|
-
type:
|
|
8064
|
+
type: w.CUSTOM_CODE,
|
|
8035
8065
|
scriptElements: i,
|
|
8036
8066
|
witnesses: s,
|
|
8037
8067
|
annex: c
|
|
@@ -8052,7 +8082,7 @@ class B {
|
|
|
8052
8082
|
}
|
|
8053
8083
|
static readCancelData(t) {
|
|
8054
8084
|
return {
|
|
8055
|
-
type:
|
|
8085
|
+
type: w.CANCEL,
|
|
8056
8086
|
compiledTargetScript: a.from(t.readBytesWithLength()).toString("hex")
|
|
8057
8087
|
};
|
|
8058
8088
|
}
|
|
@@ -8076,11 +8106,11 @@ class B {
|
|
|
8076
8106
|
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
8107
|
let d;
|
|
8078
8108
|
if (l) {
|
|
8079
|
-
const p = t.readStringWithLength(), f = t.readStringWithLength(),
|
|
8109
|
+
const p = t.readStringWithLength(), f = t.readStringWithLength(), y = "0x" + a.from(t.readBytesWithLength()).toString("hex"), b = t.readBoolean() ? "0x" + a.from(t.readBytesWithLength()).toString("hex") : void 0, _ = "0x" + a.from(t.readBytesWithLength()).toString("hex");
|
|
8080
8110
|
d = {
|
|
8081
8111
|
mldsaPublicKey: p,
|
|
8082
8112
|
legacyPublicKey: f,
|
|
8083
|
-
solution:
|
|
8113
|
+
solution: y,
|
|
8084
8114
|
graffiti: b,
|
|
8085
8115
|
signature: _
|
|
8086
8116
|
};
|
|
@@ -8177,7 +8207,7 @@ class $ {
|
|
|
8177
8207
|
static fromFunding(t, e) {
|
|
8178
8208
|
return this.captureState({
|
|
8179
8209
|
params: t,
|
|
8180
|
-
type:
|
|
8210
|
+
type: w.FUNDING,
|
|
8181
8211
|
precomputed: e
|
|
8182
8212
|
});
|
|
8183
8213
|
}
|
|
@@ -8187,7 +8217,7 @@ class $ {
|
|
|
8187
8217
|
static fromDeployment(t, e) {
|
|
8188
8218
|
return this.captureState({
|
|
8189
8219
|
params: t,
|
|
8190
|
-
type:
|
|
8220
|
+
type: w.DEPLOYMENT,
|
|
8191
8221
|
precomputed: e
|
|
8192
8222
|
});
|
|
8193
8223
|
}
|
|
@@ -8197,7 +8227,7 @@ class $ {
|
|
|
8197
8227
|
static fromInteraction(t, e) {
|
|
8198
8228
|
return this.captureState({
|
|
8199
8229
|
params: t,
|
|
8200
|
-
type:
|
|
8230
|
+
type: w.INTERACTION,
|
|
8201
8231
|
precomputed: e
|
|
8202
8232
|
});
|
|
8203
8233
|
}
|
|
@@ -8207,7 +8237,7 @@ class $ {
|
|
|
8207
8237
|
static fromMultiSig(t, e) {
|
|
8208
8238
|
return this.captureState({
|
|
8209
8239
|
params: t,
|
|
8210
|
-
type:
|
|
8240
|
+
type: w.MULTI_SIG,
|
|
8211
8241
|
precomputed: e
|
|
8212
8242
|
});
|
|
8213
8243
|
}
|
|
@@ -8217,7 +8247,7 @@ class $ {
|
|
|
8217
8247
|
static fromCustomScript(t, e) {
|
|
8218
8248
|
return this.captureState({
|
|
8219
8249
|
params: t,
|
|
8220
|
-
type:
|
|
8250
|
+
type: w.CUSTOM_CODE,
|
|
8221
8251
|
precomputed: e
|
|
8222
8252
|
});
|
|
8223
8253
|
}
|
|
@@ -8227,7 +8257,7 @@ class $ {
|
|
|
8227
8257
|
static fromCancel(t, e) {
|
|
8228
8258
|
return this.captureState({
|
|
8229
8259
|
params: t,
|
|
8230
|
-
type:
|
|
8260
|
+
type: w.CANCEL,
|
|
8231
8261
|
precomputed: e
|
|
8232
8262
|
});
|
|
8233
8263
|
}
|
|
@@ -8308,17 +8338,17 @@ class $ {
|
|
|
8308
8338
|
*/
|
|
8309
8339
|
static extractTypeSpecificData(t, e) {
|
|
8310
8340
|
switch (t) {
|
|
8311
|
-
case
|
|
8341
|
+
case w.FUNDING:
|
|
8312
8342
|
return this.extractFundingData(e);
|
|
8313
|
-
case
|
|
8343
|
+
case w.DEPLOYMENT:
|
|
8314
8344
|
return this.extractDeploymentData(e);
|
|
8315
|
-
case
|
|
8345
|
+
case w.INTERACTION:
|
|
8316
8346
|
return this.extractInteractionData(e);
|
|
8317
|
-
case
|
|
8347
|
+
case w.MULTI_SIG:
|
|
8318
8348
|
return this.extractMultiSigData(e);
|
|
8319
|
-
case
|
|
8349
|
+
case w.CUSTOM_CODE:
|
|
8320
8350
|
return this.extractCustomScriptData(e);
|
|
8321
|
-
case
|
|
8351
|
+
case w.CANCEL:
|
|
8322
8352
|
return this.extractCancelData(e);
|
|
8323
8353
|
default:
|
|
8324
8354
|
throw new Error(`Unsupported transaction type: ${t}`);
|
|
@@ -8326,14 +8356,14 @@ class $ {
|
|
|
8326
8356
|
}
|
|
8327
8357
|
static extractFundingData(t) {
|
|
8328
8358
|
return {
|
|
8329
|
-
type:
|
|
8359
|
+
type: w.FUNDING,
|
|
8330
8360
|
amount: t.amount.toString(),
|
|
8331
8361
|
splitInputsInto: t.splitInputsInto ?? 1
|
|
8332
8362
|
};
|
|
8333
8363
|
}
|
|
8334
8364
|
static extractDeploymentData(t) {
|
|
8335
8365
|
return {
|
|
8336
|
-
type:
|
|
8366
|
+
type: w.DEPLOYMENT,
|
|
8337
8367
|
bytecode: t.bytecode.toString("hex"),
|
|
8338
8368
|
calldata: t.calldata?.toString("hex"),
|
|
8339
8369
|
challenge: t.challenge.toRaw(),
|
|
@@ -8343,7 +8373,7 @@ class $ {
|
|
|
8343
8373
|
}
|
|
8344
8374
|
static extractInteractionData(t) {
|
|
8345
8375
|
return {
|
|
8346
|
-
type:
|
|
8376
|
+
type: w.INTERACTION,
|
|
8347
8377
|
calldata: t.calldata.toString("hex"),
|
|
8348
8378
|
contract: t.contract,
|
|
8349
8379
|
challenge: t.challenge.toRaw(),
|
|
@@ -8356,7 +8386,7 @@ class $ {
|
|
|
8356
8386
|
}
|
|
8357
8387
|
static extractMultiSigData(t) {
|
|
8358
8388
|
return {
|
|
8359
|
-
type:
|
|
8389
|
+
type: w.MULTI_SIG,
|
|
8360
8390
|
pubkeys: (t.pubkeys || []).map((e) => e.toString("hex")),
|
|
8361
8391
|
minimumSignatures: t.minimumSignatures || 0,
|
|
8362
8392
|
receiver: t.receiver || "",
|
|
@@ -8377,7 +8407,7 @@ class $ {
|
|
|
8377
8407
|
}
|
|
8378
8408
|
);
|
|
8379
8409
|
return {
|
|
8380
|
-
type:
|
|
8410
|
+
type: w.CUSTOM_CODE,
|
|
8381
8411
|
scriptElements: e,
|
|
8382
8412
|
witnesses: (t.witnesses || []).map((i) => i.toString("hex")),
|
|
8383
8413
|
annex: t.annex?.toString("hex")
|
|
@@ -8386,7 +8416,7 @@ class $ {
|
|
|
8386
8416
|
static extractCancelData(t) {
|
|
8387
8417
|
const e = t.compiledTargetScript, i = e ? a.isBuffer(e) ? e.toString("hex") : e : "";
|
|
8388
8418
|
return {
|
|
8389
|
-
type:
|
|
8419
|
+
type: w.CANCEL,
|
|
8390
8420
|
compiledTargetScript: i
|
|
8391
8421
|
};
|
|
8392
8422
|
}
|
|
@@ -8467,7 +8497,7 @@ class ct {
|
|
|
8467
8497
|
* Calculate SHA-1 hash
|
|
8468
8498
|
*/
|
|
8469
8499
|
static sha1(t) {
|
|
8470
|
-
return
|
|
8500
|
+
return xi(a.isBuffer(t) ? t : a.from(t));
|
|
8471
8501
|
}
|
|
8472
8502
|
/**
|
|
8473
8503
|
* Calculate mining preimage
|
|
@@ -8533,7 +8563,7 @@ class ct {
|
|
|
8533
8563
|
*/
|
|
8534
8564
|
static validateEpochWinner(t) {
|
|
8535
8565
|
try {
|
|
8536
|
-
const e = BigInt(t.epochNumber), i =
|
|
8566
|
+
const e = BigInt(t.epochNumber), i = v.fromString(
|
|
8537
8567
|
t.mldsaPublicKey,
|
|
8538
8568
|
t.legacyPublicKey
|
|
8539
8569
|
), r = U(t.solution), s = U(t.salt), o = t.difficulty, c = {
|
|
@@ -8543,7 +8573,7 @@ class ct {
|
|
|
8543
8573
|
targetChecksum: U(t.verification.targetChecksum),
|
|
8544
8574
|
startBlock: BigInt(t.verification.startBlock),
|
|
8545
8575
|
endBlock: BigInt(t.verification.endBlock),
|
|
8546
|
-
proofs: Object.freeze(t.verification.proofs.map((
|
|
8576
|
+
proofs: Object.freeze(t.verification.proofs.map((y) => U(y)))
|
|
8547
8577
|
}, u = this.calculatePreimage(
|
|
8548
8578
|
c.targetChecksum,
|
|
8549
8579
|
i.toBuffer(),
|
|
@@ -8595,7 +8625,7 @@ class ii {
|
|
|
8595
8625
|
}
|
|
8596
8626
|
class ri {
|
|
8597
8627
|
constructor(t, e) {
|
|
8598
|
-
this.epochNumber = e, this.publicKey =
|
|
8628
|
+
this.epochNumber = e, this.publicKey = v.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution = U(t.solution), this.graffiti = t.graffiti ? U(t.graffiti) : void 0, this.signature = U(t.signature);
|
|
8599
8629
|
}
|
|
8600
8630
|
verifySignature() {
|
|
8601
8631
|
const t = new D();
|
|
@@ -8610,7 +8640,7 @@ class ri {
|
|
|
8610
8640
|
}
|
|
8611
8641
|
class se {
|
|
8612
8642
|
constructor(t) {
|
|
8613
|
-
this.epochNumber = BigInt(t.epochNumber), this.publicKey =
|
|
8643
|
+
this.epochNumber = BigInt(t.epochNumber), this.publicKey = v.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution = U(t.solution), this.salt = U(t.salt), this.graffiti = U(t.graffiti), this.difficulty = t.difficulty, this.verification = new ii(t.verification), this.submission = t.submission ? new ri(t.submission, this.epochNumber + 2n) : t.submission;
|
|
8614
8644
|
}
|
|
8615
8645
|
/**
|
|
8616
8646
|
* Static method to validate from raw data directly
|
|
@@ -8924,7 +8954,7 @@ class ut {
|
|
|
8924
8954
|
case "mainnet":
|
|
8925
8955
|
return I;
|
|
8926
8956
|
case "testnet":
|
|
8927
|
-
return
|
|
8957
|
+
return Bt;
|
|
8928
8958
|
case "regtest":
|
|
8929
8959
|
return zt;
|
|
8930
8960
|
default:
|
|
@@ -8941,7 +8971,7 @@ class ur {
|
|
|
8941
8971
|
*/
|
|
8942
8972
|
static exportFunding(t, e) {
|
|
8943
8973
|
const i = $.fromFunding(t, e);
|
|
8944
|
-
return
|
|
8974
|
+
return O.toBase64(i);
|
|
8945
8975
|
}
|
|
8946
8976
|
/**
|
|
8947
8977
|
* Export a DeploymentTransaction for offline signing
|
|
@@ -8951,7 +8981,7 @@ class ur {
|
|
|
8951
8981
|
*/
|
|
8952
8982
|
static exportDeployment(t, e) {
|
|
8953
8983
|
const i = $.fromDeployment(t, e);
|
|
8954
|
-
return
|
|
8984
|
+
return O.toBase64(i);
|
|
8955
8985
|
}
|
|
8956
8986
|
/**
|
|
8957
8987
|
* Export an InteractionTransaction for offline signing
|
|
@@ -8961,7 +8991,7 @@ class ur {
|
|
|
8961
8991
|
*/
|
|
8962
8992
|
static exportInteraction(t, e) {
|
|
8963
8993
|
const i = $.fromInteraction(t, e);
|
|
8964
|
-
return
|
|
8994
|
+
return O.toBase64(i);
|
|
8965
8995
|
}
|
|
8966
8996
|
/**
|
|
8967
8997
|
* Export a MultiSignTransaction for offline signing
|
|
@@ -8971,7 +9001,7 @@ class ur {
|
|
|
8971
9001
|
*/
|
|
8972
9002
|
static exportMultiSig(t, e) {
|
|
8973
9003
|
const i = $.fromMultiSig(t, e);
|
|
8974
|
-
return
|
|
9004
|
+
return O.toBase64(i);
|
|
8975
9005
|
}
|
|
8976
9006
|
/**
|
|
8977
9007
|
* Export a CustomScriptTransaction for offline signing
|
|
@@ -8981,7 +9011,7 @@ class ur {
|
|
|
8981
9011
|
*/
|
|
8982
9012
|
static exportCustomScript(t, e) {
|
|
8983
9013
|
const i = $.fromCustomScript(t, e);
|
|
8984
|
-
return
|
|
9014
|
+
return O.toBase64(i);
|
|
8985
9015
|
}
|
|
8986
9016
|
/**
|
|
8987
9017
|
* Export a CancelTransaction for offline signing
|
|
@@ -8991,7 +9021,7 @@ class ur {
|
|
|
8991
9021
|
*/
|
|
8992
9022
|
static exportCancel(t, e) {
|
|
8993
9023
|
const i = $.fromCancel(t, e);
|
|
8994
|
-
return
|
|
9024
|
+
return O.toBase64(i);
|
|
8995
9025
|
}
|
|
8996
9026
|
/**
|
|
8997
9027
|
* Export transaction state from a builder instance.
|
|
@@ -9005,19 +9035,19 @@ class ur {
|
|
|
9005
9035
|
const r = t.type;
|
|
9006
9036
|
let s;
|
|
9007
9037
|
switch (r) {
|
|
9008
|
-
case
|
|
9038
|
+
case w.FUNDING:
|
|
9009
9039
|
s = $.fromFunding(
|
|
9010
9040
|
e,
|
|
9011
9041
|
i
|
|
9012
9042
|
);
|
|
9013
9043
|
break;
|
|
9014
|
-
case
|
|
9044
|
+
case w.DEPLOYMENT:
|
|
9015
9045
|
s = $.fromDeployment(
|
|
9016
9046
|
e,
|
|
9017
9047
|
i
|
|
9018
9048
|
);
|
|
9019
9049
|
break;
|
|
9020
|
-
case
|
|
9050
|
+
case w.INTERACTION:
|
|
9021
9051
|
s = $.fromInteraction(
|
|
9022
9052
|
e,
|
|
9023
9053
|
i
|
|
@@ -9026,7 +9056,7 @@ class ur {
|
|
|
9026
9056
|
default:
|
|
9027
9057
|
throw new Error(`Unsupported transaction type for export: ${r}`);
|
|
9028
9058
|
}
|
|
9029
|
-
return
|
|
9059
|
+
return O.toBase64(s);
|
|
9030
9060
|
}
|
|
9031
9061
|
/**
|
|
9032
9062
|
* Import and reconstruct transaction for signing
|
|
@@ -9035,7 +9065,7 @@ class ur {
|
|
|
9035
9065
|
* @returns Reconstructed transaction builder ready for signing
|
|
9036
9066
|
*/
|
|
9037
9067
|
static importForSigning(t, e) {
|
|
9038
|
-
const i =
|
|
9068
|
+
const i = O.fromBase64(t);
|
|
9039
9069
|
return ut.reconstruct(i, e);
|
|
9040
9070
|
}
|
|
9041
9071
|
/**
|
|
@@ -9063,14 +9093,14 @@ class ur {
|
|
|
9063
9093
|
* @returns New serialized state with updated fees (not signed yet)
|
|
9064
9094
|
*/
|
|
9065
9095
|
static rebuildWithNewFees(t, e) {
|
|
9066
|
-
const i =
|
|
9096
|
+
const i = O.fromBase64(t), r = {
|
|
9067
9097
|
...i,
|
|
9068
9098
|
baseParams: {
|
|
9069
9099
|
...i.baseParams,
|
|
9070
9100
|
feeRate: e
|
|
9071
9101
|
}
|
|
9072
9102
|
};
|
|
9073
|
-
return
|
|
9103
|
+
return O.toBase64(r);
|
|
9074
9104
|
}
|
|
9075
9105
|
/**
|
|
9076
9106
|
* Rebuild and immediately sign with new fee rate
|
|
@@ -9092,7 +9122,7 @@ class ur {
|
|
|
9092
9122
|
* @returns Parsed state object for inspection
|
|
9093
9123
|
*/
|
|
9094
9124
|
static inspect(t) {
|
|
9095
|
-
return
|
|
9125
|
+
return O.fromBase64(t);
|
|
9096
9126
|
}
|
|
9097
9127
|
/**
|
|
9098
9128
|
* Validate serialized state integrity
|
|
@@ -9101,7 +9131,7 @@ class ur {
|
|
|
9101
9131
|
*/
|
|
9102
9132
|
static validate(t) {
|
|
9103
9133
|
try {
|
|
9104
|
-
return
|
|
9134
|
+
return O.fromBase64(t), !0;
|
|
9105
9135
|
} catch {
|
|
9106
9136
|
return !1;
|
|
9107
9137
|
}
|
|
@@ -9112,7 +9142,7 @@ class ur {
|
|
|
9112
9142
|
* @returns Transaction type enum value
|
|
9113
9143
|
*/
|
|
9114
9144
|
static getType(t) {
|
|
9115
|
-
return
|
|
9145
|
+
return O.fromBase64(t).header.transactionType;
|
|
9116
9146
|
}
|
|
9117
9147
|
/**
|
|
9118
9148
|
* Parse base64-encoded state into state object
|
|
@@ -9120,7 +9150,7 @@ class ur {
|
|
|
9120
9150
|
* @returns Parsed state object
|
|
9121
9151
|
*/
|
|
9122
9152
|
static fromBase64(t) {
|
|
9123
|
-
return
|
|
9153
|
+
return O.fromBase64(t);
|
|
9124
9154
|
}
|
|
9125
9155
|
/**
|
|
9126
9156
|
* Serialize state object to base64
|
|
@@ -9128,7 +9158,7 @@ class ur {
|
|
|
9128
9158
|
* @returns Base64-encoded state
|
|
9129
9159
|
*/
|
|
9130
9160
|
static toBase64(t) {
|
|
9131
|
-
return
|
|
9161
|
+
return O.toBase64(t);
|
|
9132
9162
|
}
|
|
9133
9163
|
/**
|
|
9134
9164
|
* Convert serialized state to hex format
|
|
@@ -9136,8 +9166,8 @@ class ur {
|
|
|
9136
9166
|
* @returns Hex-encoded state
|
|
9137
9167
|
*/
|
|
9138
9168
|
static toHex(t) {
|
|
9139
|
-
const e =
|
|
9140
|
-
return
|
|
9169
|
+
const e = O.fromBase64(t);
|
|
9170
|
+
return O.toHex(e);
|
|
9141
9171
|
}
|
|
9142
9172
|
/**
|
|
9143
9173
|
* Convert hex format back to base64
|
|
@@ -9145,8 +9175,8 @@ class ur {
|
|
|
9145
9175
|
* @returns Base64-encoded state
|
|
9146
9176
|
*/
|
|
9147
9177
|
static fromHex(t) {
|
|
9148
|
-
const e =
|
|
9149
|
-
return
|
|
9178
|
+
const e = O.fromHex(t);
|
|
9179
|
+
return O.toBase64(e);
|
|
9150
9180
|
}
|
|
9151
9181
|
/**
|
|
9152
9182
|
* Add a partial signature to a multisig transaction state.
|
|
@@ -9158,7 +9188,7 @@ class ur {
|
|
|
9158
9188
|
* @returns Updated state with new signature, and signing result
|
|
9159
9189
|
*/
|
|
9160
9190
|
static async multiSigAddSignature(t, e) {
|
|
9161
|
-
const i =
|
|
9191
|
+
const i = O.fromBase64(t);
|
|
9162
9192
|
if (!et(i.typeSpecificData))
|
|
9163
9193
|
throw new Error("State is not a multisig transaction");
|
|
9164
9194
|
const r = i.typeSpecificData, s = r.pubkeys.map((f) => a.from(f, "hex"));
|
|
@@ -9192,7 +9222,7 @@ class ur {
|
|
|
9192
9222
|
}
|
|
9193
9223
|
};
|
|
9194
9224
|
return {
|
|
9195
|
-
state:
|
|
9225
|
+
state: O.toBase64(p),
|
|
9196
9226
|
signed: h.signed,
|
|
9197
9227
|
final: h.final,
|
|
9198
9228
|
psbtBase64: d
|
|
@@ -9206,7 +9236,7 @@ class ur {
|
|
|
9206
9236
|
* @returns True if the public key has already signed
|
|
9207
9237
|
*/
|
|
9208
9238
|
static multiSigHasSigned(t, e) {
|
|
9209
|
-
const i =
|
|
9239
|
+
const i = O.fromBase64(t);
|
|
9210
9240
|
if (!et(i.typeSpecificData))
|
|
9211
9241
|
throw new Error("State is not a multisig transaction");
|
|
9212
9242
|
const r = i.typeSpecificData;
|
|
@@ -9222,7 +9252,7 @@ class ur {
|
|
|
9222
9252
|
* @returns Object with signature count info
|
|
9223
9253
|
*/
|
|
9224
9254
|
static multiSigGetSignatureStatus(t) {
|
|
9225
|
-
const e =
|
|
9255
|
+
const e = O.fromBase64(t);
|
|
9226
9256
|
if (!et(e.typeSpecificData))
|
|
9227
9257
|
throw new Error("State is not a multisig transaction");
|
|
9228
9258
|
const i = e.typeSpecificData, r = i.minimumSignatures;
|
|
@@ -9265,7 +9295,7 @@ class ur {
|
|
|
9265
9295
|
* @returns Signed transaction hex ready for broadcast
|
|
9266
9296
|
*/
|
|
9267
9297
|
static multiSigFinalize(t) {
|
|
9268
|
-
const e =
|
|
9298
|
+
const e = O.fromBase64(t);
|
|
9269
9299
|
if (!et(e.typeSpecificData))
|
|
9270
9300
|
throw new Error("State is not a multisig transaction");
|
|
9271
9301
|
const i = e.typeSpecificData;
|
|
@@ -9291,7 +9321,7 @@ class ur {
|
|
|
9291
9321
|
* @returns PSBT in base64 format, or null if not yet built
|
|
9292
9322
|
*/
|
|
9293
9323
|
static multiSigGetPsbt(t) {
|
|
9294
|
-
const e =
|
|
9324
|
+
const e = O.fromBase64(t);
|
|
9295
9325
|
if (!et(e.typeSpecificData))
|
|
9296
9326
|
throw new Error("State is not a multisig transaction");
|
|
9297
9327
|
return e.typeSpecificData.existingPsbtBase64 || null;
|
|
@@ -9304,7 +9334,7 @@ class ur {
|
|
|
9304
9334
|
* @returns Updated state
|
|
9305
9335
|
*/
|
|
9306
9336
|
static multiSigUpdatePsbt(t, e) {
|
|
9307
|
-
const i =
|
|
9337
|
+
const i = O.fromBase64(t);
|
|
9308
9338
|
if (!et(i.typeSpecificData))
|
|
9309
9339
|
throw new Error("State is not a multisig transaction");
|
|
9310
9340
|
const r = {
|
|
@@ -9314,7 +9344,7 @@ class ur {
|
|
|
9314
9344
|
existingPsbtBase64: e
|
|
9315
9345
|
}
|
|
9316
9346
|
};
|
|
9317
|
-
return
|
|
9347
|
+
return O.toBase64(r);
|
|
9318
9348
|
}
|
|
9319
9349
|
}
|
|
9320
9350
|
class hr {
|
|
@@ -9340,7 +9370,7 @@ class hr {
|
|
|
9340
9370
|
const s = await r.json(), o = s.raw ?? [], c = t.usePendingUTXO ? [...s.confirmed, ...s.pending] : s.confirmed, u = [];
|
|
9341
9371
|
for (const f of c)
|
|
9342
9372
|
s.spentTransactions.some(
|
|
9343
|
-
(
|
|
9373
|
+
(y) => y.transactionId === f.transactionId && y.outputIndex === f.outputIndex
|
|
9344
9374
|
) || u.push(f);
|
|
9345
9375
|
if (u.length === 0)
|
|
9346
9376
|
throw new Error("No UTXO found");
|
|
@@ -9351,8 +9381,8 @@ class hr {
|
|
|
9351
9381
|
let d = 0n;
|
|
9352
9382
|
const p = t.requestedAmount;
|
|
9353
9383
|
for (const f of h) {
|
|
9354
|
-
const
|
|
9355
|
-
if (
|
|
9384
|
+
const y = BigInt(f.value);
|
|
9385
|
+
if (y <= 0n)
|
|
9356
9386
|
continue;
|
|
9357
9387
|
const S = f.raw;
|
|
9358
9388
|
if (S == null)
|
|
@@ -9364,10 +9394,10 @@ class hr {
|
|
|
9364
9394
|
throw new Error(
|
|
9365
9395
|
`Invalid raw index ${S} - not found in raw transactions array`
|
|
9366
9396
|
);
|
|
9367
|
-
if (d +=
|
|
9397
|
+
if (d += y, l.push({
|
|
9368
9398
|
transactionId: f.transactionId,
|
|
9369
9399
|
outputIndex: f.outputIndex,
|
|
9370
|
-
value:
|
|
9400
|
+
value: y,
|
|
9371
9401
|
scriptPubKey: f.scriptPubKey,
|
|
9372
9402
|
nonWitnessUtxo: a.from(b, "base64")
|
|
9373
9403
|
}), d > p)
|
|
@@ -9654,7 +9684,61 @@ class dr {
|
|
|
9654
9684
|
return new Si.sha256().update(t).digest();
|
|
9655
9685
|
}
|
|
9656
9686
|
}
|
|
9657
|
-
class
|
|
9687
|
+
class fr {
|
|
9688
|
+
constructor(t) {
|
|
9689
|
+
if (this.items = new pt(), t)
|
|
9690
|
+
for (const [e, i] of t)
|
|
9691
|
+
this.set(e, i);
|
|
9692
|
+
}
|
|
9693
|
+
get size() {
|
|
9694
|
+
return this.items.size;
|
|
9695
|
+
}
|
|
9696
|
+
set(t, e) {
|
|
9697
|
+
const i = t.tweakedToBigInt();
|
|
9698
|
+
return this.items.set(i, e), this;
|
|
9699
|
+
}
|
|
9700
|
+
get(t) {
|
|
9701
|
+
return this.items.get(t.tweakedToBigInt());
|
|
9702
|
+
}
|
|
9703
|
+
has(t) {
|
|
9704
|
+
return this.items.has(t.tweakedToBigInt());
|
|
9705
|
+
}
|
|
9706
|
+
delete(t) {
|
|
9707
|
+
const e = t.tweakedToBigInt();
|
|
9708
|
+
return this.items.delete(e);
|
|
9709
|
+
}
|
|
9710
|
+
clear() {
|
|
9711
|
+
this.items.clear();
|
|
9712
|
+
}
|
|
9713
|
+
indexOf(t) {
|
|
9714
|
+
return this.items.indexOf(t.tweakedToBigInt());
|
|
9715
|
+
}
|
|
9716
|
+
/**
|
|
9717
|
+
* WARNING, THIS RETURN NEW COPY OF THE KEYS
|
|
9718
|
+
*/
|
|
9719
|
+
*entries() {
|
|
9720
|
+
for (const [t, e] of this.items.entries())
|
|
9721
|
+
yield [v.fromBigInt(t), e];
|
|
9722
|
+
}
|
|
9723
|
+
*keys() {
|
|
9724
|
+
for (const t of this.items.keys())
|
|
9725
|
+
yield v.fromBigInt(t);
|
|
9726
|
+
}
|
|
9727
|
+
*values() {
|
|
9728
|
+
for (const t of this.items.values())
|
|
9729
|
+
yield t;
|
|
9730
|
+
}
|
|
9731
|
+
forEach(t, e) {
|
|
9732
|
+
for (const [i, r] of this.items.entries()) {
|
|
9733
|
+
const s = v.fromBigInt(0n, i);
|
|
9734
|
+
t.call(e, r, s, this);
|
|
9735
|
+
}
|
|
9736
|
+
}
|
|
9737
|
+
*[Symbol.iterator]() {
|
|
9738
|
+
yield* this.entries();
|
|
9739
|
+
}
|
|
9740
|
+
}
|
|
9741
|
+
class ye {
|
|
9658
9742
|
constructor(t = []) {
|
|
9659
9743
|
this.items = /* @__PURE__ */ new Set(), this.keys = [];
|
|
9660
9744
|
for (const e of t)
|
|
@@ -9675,7 +9759,7 @@ class we {
|
|
|
9675
9759
|
this.items.delete(e) && (this.keys = this.keys.filter((i) => i.toBigInt() !== e));
|
|
9676
9760
|
}
|
|
9677
9761
|
clone() {
|
|
9678
|
-
return new
|
|
9762
|
+
return new ye(this.keys);
|
|
9679
9763
|
}
|
|
9680
9764
|
clear() {
|
|
9681
9765
|
this.items.clear(), this.keys = [];
|
|
@@ -9690,16 +9774,16 @@ class we {
|
|
|
9690
9774
|
yield* this.keys;
|
|
9691
9775
|
}
|
|
9692
9776
|
}
|
|
9693
|
-
class
|
|
9777
|
+
class we {
|
|
9694
9778
|
constructor(t) {
|
|
9695
|
-
this.compareFn = t, this.map = new
|
|
9779
|
+
this.compareFn = t, this.map = new pt(), this.#t = [];
|
|
9696
9780
|
}
|
|
9697
9781
|
#t;
|
|
9698
9782
|
get size() {
|
|
9699
9783
|
return this.map.size;
|
|
9700
9784
|
}
|
|
9701
9785
|
static fromMap(t, e) {
|
|
9702
|
-
const i = new
|
|
9786
|
+
const i = new we(e);
|
|
9703
9787
|
for (const [r, s] of t)
|
|
9704
9788
|
i.set(r, s);
|
|
9705
9789
|
return i;
|
|
@@ -9811,7 +9895,7 @@ class me {
|
|
|
9811
9895
|
return { found: !1, index: e };
|
|
9812
9896
|
}
|
|
9813
9897
|
}
|
|
9814
|
-
class
|
|
9898
|
+
class pr {
|
|
9815
9899
|
constructor(t, e) {
|
|
9816
9900
|
this.type = t, this.data = e;
|
|
9817
9901
|
}
|
|
@@ -9820,8 +9904,8 @@ class be {
|
|
|
9820
9904
|
constructor() {
|
|
9821
9905
|
}
|
|
9822
9906
|
}
|
|
9823
|
-
var
|
|
9824
|
-
class
|
|
9907
|
+
var It = /* @__PURE__ */ ((n) => (n.Mainnet = "mainnet", n.Testnet = "testnet", n.Regtest = "regtest", n))(It || {}), oi = /* @__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))(oi || {});
|
|
9908
|
+
class gr extends be {
|
|
9825
9909
|
constructor() {
|
|
9826
9910
|
if (super(), this.isInitialized = !1, !window)
|
|
9827
9911
|
throw new Error("UnisatSigner can only be used in a browser environment");
|
|
@@ -9867,13 +9951,13 @@ class pr extends be {
|
|
|
9867
9951
|
return;
|
|
9868
9952
|
const t = await this.unisat.getNetwork();
|
|
9869
9953
|
switch (t) {
|
|
9870
|
-
case
|
|
9954
|
+
case It.Mainnet:
|
|
9871
9955
|
this._network = I;
|
|
9872
9956
|
break;
|
|
9873
|
-
case
|
|
9874
|
-
this._network =
|
|
9957
|
+
case It.Testnet:
|
|
9958
|
+
this._network = Bt;
|
|
9875
9959
|
break;
|
|
9876
|
-
case
|
|
9960
|
+
case It.Regtest:
|
|
9877
9961
|
this._network = zt;
|
|
9878
9962
|
break;
|
|
9879
9963
|
default:
|
|
@@ -9922,14 +10006,14 @@ class pr extends be {
|
|
|
9922
10006
|
if (le(h)) {
|
|
9923
10007
|
if (h.tapLeafScript && h.tapLeafScript.length > 0) {
|
|
9924
10008
|
for (const f of h.tapLeafScript)
|
|
9925
|
-
if (
|
|
10009
|
+
if (Sr(this.publicKey, f.script)) {
|
|
9926
10010
|
d = !0, p = !1;
|
|
9927
10011
|
break;
|
|
9928
10012
|
}
|
|
9929
10013
|
}
|
|
9930
10014
|
if (!d && h.tapInternalKey) {
|
|
9931
|
-
const f = h.tapInternalKey,
|
|
9932
|
-
f.equals(
|
|
10015
|
+
const f = h.tapInternalKey, y = B(this.publicKey);
|
|
10016
|
+
f.equals(y) && (d = !0, p = !0);
|
|
9933
10017
|
}
|
|
9934
10018
|
} else de(h, this.publicKey) && (d = !0, p = !1);
|
|
9935
10019
|
return d ? {
|
|
@@ -9997,11 +10081,11 @@ class pr extends be {
|
|
|
9997
10081
|
return i;
|
|
9998
10082
|
}
|
|
9999
10083
|
}
|
|
10000
|
-
function gr(n, t) {
|
|
10001
|
-
return Sr(n, t) !== -1;
|
|
10002
|
-
}
|
|
10003
10084
|
function Sr(n, t) {
|
|
10004
|
-
|
|
10085
|
+
return yr(n, t) !== -1;
|
|
10086
|
+
}
|
|
10087
|
+
function yr(n, t) {
|
|
10088
|
+
const e = dt(n), i = B(n), r = R(t);
|
|
10005
10089
|
if (r === null) throw new Error("Unknown script error");
|
|
10006
10090
|
return r.findIndex((s) => typeof s == "number" ? !1 : a.isBuffer(s) && (s.equals(n) || s.equals(e) || s.equals(i)));
|
|
10007
10091
|
}
|
|
@@ -10050,7 +10134,7 @@ class wr extends be {
|
|
|
10050
10134
|
);
|
|
10051
10135
|
if (!e)
|
|
10052
10136
|
throw new Error("Payment address not found");
|
|
10053
|
-
const i = e.address.startsWith("tb") ?
|
|
10137
|
+
const i = e.address.startsWith("tb") ? Bt : e.address.startsWith("bc") ? I : null;
|
|
10054
10138
|
if (!i) throw new Error("Network not supported");
|
|
10055
10139
|
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
10140
|
}
|
|
@@ -10105,15 +10189,15 @@ class wr extends be {
|
|
|
10105
10189
|
let p = !1, f = !1;
|
|
10106
10190
|
if (le(l)) {
|
|
10107
10191
|
if (l.tapLeafScript && l.tapLeafScript.length > 0) {
|
|
10108
|
-
for (const
|
|
10109
|
-
if (fe(this.publicKey,
|
|
10192
|
+
for (const y of l.tapLeafScript)
|
|
10193
|
+
if (fe(this.publicKey, y.script)) {
|
|
10110
10194
|
p = !0, f = !1;
|
|
10111
10195
|
break;
|
|
10112
10196
|
}
|
|
10113
10197
|
}
|
|
10114
10198
|
if (!p && l.tapInternalKey) {
|
|
10115
|
-
const
|
|
10116
|
-
|
|
10199
|
+
const y = l.tapInternalKey, S = B(this.publicKey);
|
|
10200
|
+
y.equals(S) && (p = !0, f = !0);
|
|
10117
10201
|
}
|
|
10118
10202
|
} else de(l, this.publicKey) && (p = !0, f = !1);
|
|
10119
10203
|
return p ? {
|
|
@@ -10354,19 +10438,19 @@ class Ht {
|
|
|
10354
10438
|
t[i] !== void 0 && !this.deleted[i] && this.set(t[i], e[i]);
|
|
10355
10439
|
}
|
|
10356
10440
|
}
|
|
10357
|
-
const
|
|
10441
|
+
const Pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10358
10442
|
__proto__: null,
|
|
10359
10443
|
ABICoder: dr,
|
|
10360
10444
|
ABIDataTypes: ni,
|
|
10361
10445
|
ADDRESS_BYTE_LENGTH: C,
|
|
10362
10446
|
ANCHOR_SCRIPT: re,
|
|
10363
|
-
Address:
|
|
10447
|
+
Address: v,
|
|
10364
10448
|
AddressGenerator: ae,
|
|
10365
10449
|
AddressMap: Fe,
|
|
10366
|
-
AddressSet:
|
|
10450
|
+
AddressSet: ye,
|
|
10367
10451
|
AddressTypes: J,
|
|
10368
10452
|
AddressVerificator: H,
|
|
10369
|
-
BIPStandard:
|
|
10453
|
+
BIPStandard: bt,
|
|
10370
10454
|
BOOLEAN_BYTE_LENGTH: Qi,
|
|
10371
10455
|
BinaryReader: qt,
|
|
10372
10456
|
BinaryWriter: D,
|
|
@@ -10380,7 +10464,7 @@ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10380
10464
|
ChallengeSubmission: ri,
|
|
10381
10465
|
ChallengeVerification: ii,
|
|
10382
10466
|
Compressor: N,
|
|
10383
|
-
Consensus:
|
|
10467
|
+
Consensus: Ot,
|
|
10384
10468
|
ConsolidatedInteractionTransaction: Ge,
|
|
10385
10469
|
ContractAddress: te,
|
|
10386
10470
|
ContractBaseMetadata: rr,
|
|
@@ -10390,17 +10474,18 @@ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10390
10474
|
CustomScriptTransaction: Wt,
|
|
10391
10475
|
DeploymentGenerator: Ft,
|
|
10392
10476
|
DeploymentTransaction: ft,
|
|
10393
|
-
DeterministicMap:
|
|
10477
|
+
DeterministicMap: we,
|
|
10394
10478
|
DeterministicSet: me,
|
|
10395
10479
|
EcKeyPair: A,
|
|
10396
10480
|
EpochValidator: ct,
|
|
10397
|
-
|
|
10481
|
+
ExtendedAddressMap: fr,
|
|
10482
|
+
FastMap: pt,
|
|
10398
10483
|
FeaturePriority: Q,
|
|
10399
10484
|
Features: W,
|
|
10400
10485
|
FundingTransaction: Mt,
|
|
10401
10486
|
Generator: q,
|
|
10402
10487
|
HashCommitmentGenerator: E,
|
|
10403
|
-
I128_BYTE_LENGTH:
|
|
10488
|
+
I128_BYTE_LENGTH: mt,
|
|
10404
10489
|
I16_BYTE_LENGTH: Yi,
|
|
10405
10490
|
I256_BYTE_LENGTH: qi,
|
|
10406
10491
|
I64_BYTE_LENGTH: $i,
|
|
@@ -10408,7 +10493,7 @@ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10408
10493
|
InteractionTransaction: Nt,
|
|
10409
10494
|
InteractionTransactionP2WDA: j,
|
|
10410
10495
|
LegacyCalldataGenerator: Ji,
|
|
10411
|
-
MINIMUM_AMOUNT_CA:
|
|
10496
|
+
MINIMUM_AMOUNT_CA: yt,
|
|
10412
10497
|
MINIMUM_AMOUNT_REWARD: V,
|
|
10413
10498
|
MLDSAKeyPair: P.MLDSAKeyPair,
|
|
10414
10499
|
MLDSAPublicKeyMetadata: Ve,
|
|
@@ -10417,16 +10502,16 @@ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10417
10502
|
MessageType: ai,
|
|
10418
10503
|
Mnemonic: ue,
|
|
10419
10504
|
MnemonicStrength: Rt,
|
|
10420
|
-
MultiSignGenerator:
|
|
10505
|
+
MultiSignGenerator: Et,
|
|
10421
10506
|
MultiSignTransaction: x,
|
|
10422
|
-
NetEvent:
|
|
10507
|
+
NetEvent: pr,
|
|
10423
10508
|
OPNET_DEPLOYMENT_VERSION: We,
|
|
10424
10509
|
OPNetConsensusConfig: $e,
|
|
10425
10510
|
OPNetLimitedProvider: hr,
|
|
10426
10511
|
OfflineTransactionManager: ur,
|
|
10427
10512
|
P2TR_MS: lr,
|
|
10428
10513
|
P2WDADetector: z,
|
|
10429
|
-
P2WDAGenerator:
|
|
10514
|
+
P2WDAGenerator: At,
|
|
10430
10515
|
PSBTTypes: si,
|
|
10431
10516
|
QuantumBIP32API: P.QuantumBIP32API,
|
|
10432
10517
|
QuantumBIP32Factory: P.QuantumBIP32Factory,
|
|
@@ -10447,21 +10532,21 @@ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10447
10532
|
TransactionFactory: Qe,
|
|
10448
10533
|
TransactionReconstructor: ut,
|
|
10449
10534
|
TransactionSequence: Xe,
|
|
10450
|
-
TransactionSerializer:
|
|
10535
|
+
TransactionSerializer: O,
|
|
10451
10536
|
TransactionStateCapture: $,
|
|
10452
|
-
TransactionType:
|
|
10537
|
+
TransactionType: w,
|
|
10453
10538
|
TweakedSigner: ce,
|
|
10454
10539
|
TweakedTransaction: Xt,
|
|
10455
10540
|
U128_BYTE_LENGTH: wt,
|
|
10456
|
-
U16_BYTE_LENGTH:
|
|
10457
|
-
U256_BYTE_LENGTH:
|
|
10541
|
+
U16_BYTE_LENGTH: Pt,
|
|
10542
|
+
U256_BYTE_LENGTH: Tt,
|
|
10458
10543
|
U32_BYTE_LENGTH: ht,
|
|
10459
10544
|
U64_BYTE_LENGTH: Ct,
|
|
10460
10545
|
U8_BYTE_LENGTH: Dt,
|
|
10461
10546
|
UnisatChainType: oi,
|
|
10462
|
-
UnisatSigner:
|
|
10547
|
+
UnisatSigner: gr,
|
|
10463
10548
|
Wallet: Z,
|
|
10464
|
-
WalletNetworks:
|
|
10549
|
+
WalletNetworks: It,
|
|
10465
10550
|
XverseNetwork: ui,
|
|
10466
10551
|
XverseSigner: wr,
|
|
10467
10552
|
buildBIPPath: He,
|
|
@@ -10482,19 +10567,19 @@ const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
10482
10567
|
number_BYTE_LENGTH: Xi,
|
|
10483
10568
|
version: Di,
|
|
10484
10569
|
versionBuffer: Me
|
|
10485
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
10570
|
+
}, Symbol.toStringTag, { value: "Module" })), Er = P.MLDSAKeyPair, Ar = P.MLDSASecurityLevel, Br = P.QuantumBIP32API, Or = P.QuantumBIP32Factory, vr = P.QuantumBIP32Interface, xr = P.QuantumDerivationPath, kr = P.QuantumSigner;
|
|
10486
10571
|
export {
|
|
10487
10572
|
dr as ABICoder,
|
|
10488
10573
|
ni as ABIDataTypes,
|
|
10489
10574
|
C as ADDRESS_BYTE_LENGTH,
|
|
10490
10575
|
re as ANCHOR_SCRIPT,
|
|
10491
|
-
|
|
10576
|
+
v as Address,
|
|
10492
10577
|
ae as AddressGenerator,
|
|
10493
10578
|
Fe as AddressMap,
|
|
10494
|
-
|
|
10579
|
+
ye as AddressSet,
|
|
10495
10580
|
J as AddressTypes,
|
|
10496
10581
|
H as AddressVerificator,
|
|
10497
|
-
|
|
10582
|
+
bt as BIPStandard,
|
|
10498
10583
|
Qi as BOOLEAN_BYTE_LENGTH,
|
|
10499
10584
|
qt as BinaryReader,
|
|
10500
10585
|
D as BinaryWriter,
|
|
@@ -10508,7 +10593,7 @@ export {
|
|
|
10508
10593
|
ri as ChallengeSubmission,
|
|
10509
10594
|
ii as ChallengeVerification,
|
|
10510
10595
|
N as Compressor,
|
|
10511
|
-
|
|
10596
|
+
Ot as Consensus,
|
|
10512
10597
|
Ge as ConsolidatedInteractionTransaction,
|
|
10513
10598
|
te as ContractAddress,
|
|
10514
10599
|
rr as ContractBaseMetadata,
|
|
@@ -10518,17 +10603,18 @@ export {
|
|
|
10518
10603
|
Wt as CustomScriptTransaction,
|
|
10519
10604
|
Ft as DeploymentGenerator,
|
|
10520
10605
|
ft as DeploymentTransaction,
|
|
10521
|
-
|
|
10606
|
+
we as DeterministicMap,
|
|
10522
10607
|
me as DeterministicSet,
|
|
10523
10608
|
A as EcKeyPair,
|
|
10524
10609
|
ct as EpochValidator,
|
|
10525
|
-
|
|
10610
|
+
fr as ExtendedAddressMap,
|
|
10611
|
+
pt as FastMap,
|
|
10526
10612
|
Q as FeaturePriority,
|
|
10527
10613
|
W as Features,
|
|
10528
10614
|
Mt as FundingTransaction,
|
|
10529
10615
|
q as Generator,
|
|
10530
10616
|
E as HashCommitmentGenerator,
|
|
10531
|
-
|
|
10617
|
+
mt as I128_BYTE_LENGTH,
|
|
10532
10618
|
Yi as I16_BYTE_LENGTH,
|
|
10533
10619
|
qi as I256_BYTE_LENGTH,
|
|
10534
10620
|
$i as I64_BYTE_LENGTH,
|
|
@@ -10536,31 +10622,31 @@ export {
|
|
|
10536
10622
|
Nt as InteractionTransaction,
|
|
10537
10623
|
j as InteractionTransactionP2WDA,
|
|
10538
10624
|
Ji as LegacyCalldataGenerator,
|
|
10539
|
-
|
|
10625
|
+
yt as MINIMUM_AMOUNT_CA,
|
|
10540
10626
|
V as MINIMUM_AMOUNT_REWARD,
|
|
10541
|
-
|
|
10627
|
+
Er as MLDSAKeyPair,
|
|
10542
10628
|
Ve as MLDSAPublicKeyMetadata,
|
|
10543
|
-
|
|
10629
|
+
Ar as MLDSASecurityLevel,
|
|
10544
10630
|
st as MessageSigner,
|
|
10545
10631
|
ai as MessageType,
|
|
10546
10632
|
ue as Mnemonic,
|
|
10547
10633
|
Rt as MnemonicStrength,
|
|
10548
|
-
|
|
10634
|
+
Et as MultiSignGenerator,
|
|
10549
10635
|
x as MultiSignTransaction,
|
|
10550
|
-
|
|
10636
|
+
pr as NetEvent,
|
|
10551
10637
|
We as OPNET_DEPLOYMENT_VERSION,
|
|
10552
10638
|
$e as OPNetConsensusConfig,
|
|
10553
10639
|
hr as OPNetLimitedProvider,
|
|
10554
10640
|
ur as OfflineTransactionManager,
|
|
10555
10641
|
lr as P2TR_MS,
|
|
10556
10642
|
z as P2WDADetector,
|
|
10557
|
-
|
|
10643
|
+
At as P2WDAGenerator,
|
|
10558
10644
|
si as PSBTTypes,
|
|
10559
|
-
|
|
10645
|
+
Br as QuantumBIP32API,
|
|
10560
10646
|
Or as QuantumBIP32Factory,
|
|
10561
|
-
|
|
10647
|
+
vr as QuantumBIP32Interface,
|
|
10562
10648
|
xr as QuantumDerivationPath,
|
|
10563
|
-
|
|
10649
|
+
kr as QuantumSigner,
|
|
10564
10650
|
qe as RoswellConsensus,
|
|
10565
10651
|
zi as SELECTOR_BYTE_LENGTH,
|
|
10566
10652
|
Se as SERIALIZATION_FORMAT_VERSION,
|
|
@@ -10575,21 +10661,21 @@ export {
|
|
|
10575
10661
|
Qe as TransactionFactory,
|
|
10576
10662
|
ut as TransactionReconstructor,
|
|
10577
10663
|
Xe as TransactionSequence,
|
|
10578
|
-
|
|
10664
|
+
O as TransactionSerializer,
|
|
10579
10665
|
$ as TransactionStateCapture,
|
|
10580
|
-
|
|
10666
|
+
w as TransactionType,
|
|
10581
10667
|
ce as TweakedSigner,
|
|
10582
10668
|
Xt as TweakedTransaction,
|
|
10583
10669
|
wt as U128_BYTE_LENGTH,
|
|
10584
|
-
|
|
10585
|
-
|
|
10670
|
+
Pt as U16_BYTE_LENGTH,
|
|
10671
|
+
Tt as U256_BYTE_LENGTH,
|
|
10586
10672
|
ht as U32_BYTE_LENGTH,
|
|
10587
10673
|
Ct as U64_BYTE_LENGTH,
|
|
10588
10674
|
Dt as U8_BYTE_LENGTH,
|
|
10589
10675
|
oi as UnisatChainType,
|
|
10590
|
-
|
|
10676
|
+
gr as UnisatSigner,
|
|
10591
10677
|
Z as Wallet,
|
|
10592
|
-
|
|
10678
|
+
It as WalletNetworks,
|
|
10593
10679
|
ui as XverseNetwork,
|
|
10594
10680
|
wr as XverseSigner,
|
|
10595
10681
|
He as buildBIPPath,
|
|
@@ -10608,7 +10694,7 @@ export {
|
|
|
10608
10694
|
et as isMultiSigSpecificData,
|
|
10609
10695
|
Ne as isOPWallet,
|
|
10610
10696
|
Xi as number_BYTE_LENGTH,
|
|
10611
|
-
|
|
10697
|
+
Pr as opnet,
|
|
10612
10698
|
Di as version,
|
|
10613
10699
|
Me as versionBuffer
|
|
10614
10700
|
};
|