@btc-vision/transaction 1.7.28 → 1.7.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/_version.d.ts +1 -1
- package/browser/btc-vision-bitcoin.js +1610 -1609
- package/browser/consensus/ConsensusConfig.d.ts +1 -5
- package/browser/consensus/IConsensusConfig.d.ts +6 -0
- package/browser/consensus/metadata/RoswellConsensus.d.ts +1 -1
- package/browser/epoch/interfaces/IChallengeSolution.d.ts +15 -1
- package/browser/generators/builders/CalldataGenerator.d.ts +2 -2
- package/browser/generators/builders/DeploymentGenerator.d.ts +2 -2
- package/browser/generators/builders/P2WDAGenerator.d.ts +2 -2
- package/browser/index.js +876 -1055
- package/browser/opnet.d.ts +10 -3
- package/browser/signer/AddressRotation.d.ts +2 -3
- package/browser/signer/IRotationSigner.d.ts +8 -0
- package/browser/transaction/TransactionFactory.d.ts +4 -27
- package/browser/transaction/browser/WalletNetworks.d.ts +14 -0
- package/browser/transaction/browser/Web3Provider.d.ts +2 -25
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts +2 -1
- package/browser/transaction/browser/types/Unisat.d.ts +5 -18
- package/browser/transaction/builders/CancelTransaction.d.ts +1 -4
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts +3 -3
- package/browser/transaction/builders/CustomScriptTransaction.d.ts +2 -8
- package/browser/transaction/builders/DeploymentTransaction.d.ts +3 -3
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +3 -3
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts +4 -0
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts +8 -0
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +6 -6
- package/browser/transaction/interfaces/ITransactionResponses.d.ts +26 -0
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts +17 -0
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts +24 -0
- package/browser/transaction/shared/TweakedTransaction.d.ts +2 -14
- package/browser/transaction/utils/WitnessUtils.d.ts +1 -0
- package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/browser/utxo/interfaces/IUTXO.d.ts +2 -2
- package/browser/vendors.js +90 -90
- package/browser/verification/TapscriptVerificator.d.ts +2 -2
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/consensus/ConsensusConfig.d.ts +1 -5
- package/build/consensus/IConsensusConfig.d.ts +6 -0
- package/build/consensus/IConsensusConfig.js +1 -0
- package/build/consensus/metadata/RoswellConsensus.d.ts +1 -1
- package/build/epoch/interfaces/IChallengeSolution.d.ts +15 -1
- package/build/epoch/validator/EpochValidator.js +35 -3
- package/build/generators/builders/CalldataGenerator.d.ts +2 -2
- package/build/generators/builders/DeploymentGenerator.d.ts +2 -2
- package/build/generators/builders/P2WDAGenerator.d.ts +2 -2
- package/build/opnet.d.ts +10 -3
- package/build/opnet.js +8 -2
- package/build/signer/AddressRotation.d.ts +2 -3
- package/build/signer/IRotationSigner.d.ts +8 -0
- package/build/signer/IRotationSigner.js +1 -0
- package/build/transaction/TransactionFactory.d.ts +4 -27
- package/build/transaction/TransactionFactory.js +1 -1
- package/build/transaction/browser/WalletNetworks.d.ts +14 -0
- package/build/transaction/browser/WalletNetworks.js +16 -0
- package/build/transaction/browser/Web3Provider.d.ts +2 -25
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +2 -1
- package/build/transaction/browser/extensions/UnisatSigner.js +4 -4
- package/build/transaction/browser/types/Unisat.d.ts +5 -18
- package/build/transaction/browser/types/Unisat.js +0 -16
- package/build/transaction/builders/CancelTransaction.d.ts +1 -4
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +3 -3
- package/build/transaction/builders/CustomScriptTransaction.d.ts +2 -8
- package/build/transaction/builders/DeploymentTransaction.d.ts +3 -3
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +3 -3
- package/build/transaction/builders/TransactionBuilder.js +3 -21
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts +4 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts +8 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ITransactionParameters.d.ts +6 -6
- package/build/transaction/interfaces/ITransactionResponses.d.ts +26 -0
- package/build/transaction/interfaces/ITransactionResponses.js +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts +17 -0
- package/build/transaction/interfaces/ITweakedTransactionData.js +1 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts +24 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.js +1 -0
- package/build/transaction/shared/TweakedTransaction.d.ts +2 -14
- package/build/transaction/shared/TweakedTransaction.js +3 -3
- package/build/transaction/utils/WitnessUtils.d.ts +1 -0
- package/build/transaction/utils/WitnessUtils.js +23 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/build/utxo/OPNetLimitedProvider.js +1 -1
- package/build/utxo/interfaces/IUTXO.d.ts +2 -2
- package/build/verification/TapscriptVerificator.d.ts +2 -2
- package/package.json +6 -3
- package/src/_version.ts +1 -1
- package/src/consensus/ConsensusConfig.ts +1 -28
- package/src/consensus/IConsensusConfig.ts +29 -0
- package/src/consensus/metadata/RoswellConsensus.ts +1 -1
- package/src/epoch/interfaces/IChallengeSolution.ts +13 -1
- package/src/epoch/validator/EpochValidator.ts +54 -3
- package/src/generators/builders/CalldataGenerator.ts +3 -3
- package/src/generators/builders/DeploymentGenerator.ts +3 -3
- package/src/generators/builders/P2WDAGenerator.ts +2 -2
- package/src/keypair/MessageSigner.ts +1 -1
- package/src/opnet.ts +10 -5
- package/src/signer/AddressRotation.ts +3 -4
- package/src/signer/IRotationSigner.ts +35 -0
- package/src/transaction/TransactionFactory.ts +14 -38
- package/src/transaction/browser/WalletNetworks.ts +15 -0
- package/src/transaction/browser/Web3Provider.ts +14 -78
- package/src/transaction/browser/extensions/UnisatSigner.ts +7 -5
- package/src/transaction/browser/types/Unisat.ts +5 -20
- package/src/transaction/builders/CancelTransaction.ts +2 -11
- package/src/transaction/builders/ConsolidatedInteractionTransaction.ts +3 -3
- package/src/transaction/builders/CustomScriptTransaction.ts +1 -15
- package/src/transaction/builders/DeploymentTransaction.ts +3 -3
- package/src/transaction/builders/InteractionTransactionP2WDA.ts +3 -3
- package/src/transaction/builders/SharedInteractionTransaction.ts +3 -3
- package/src/transaction/builders/TransactionBuilder.ts +2 -28
- package/src/transaction/interfaces/ICancelTransactionParameters.ts +8 -0
- package/src/transaction/interfaces/ICustomTransactionParameters.ts +15 -0
- package/src/transaction/interfaces/ITransactionParameters.ts +6 -6
- package/src/transaction/interfaces/ITransactionResponses.ts +29 -0
- package/src/transaction/interfaces/ITweakedTransactionData.ts +24 -0
- package/src/transaction/interfaces/IWeb3ProviderTypes.ts +74 -0
- package/src/transaction/offline/TransactionReconstructor.ts +1 -1
- package/src/transaction/shared/TweakedTransaction.ts +6 -30
- package/src/transaction/utils/WitnessUtils.ts +36 -0
- package/src/utxo/OPNetLimitedProvider.ts +3 -1
- package/src/utxo/interfaces/IUTXO.ts +2 -2
- package/src/verification/TapscriptVerificator.ts +2 -2
- package/browser/metadata/tokens.d.ts +0 -39
- package/browser/transaction/processor/PsbtTransaction.d.ts +0 -25
- package/build/metadata/tokens.d.ts +0 -39
- package/build/metadata/tokens.js +0 -100
- package/build/transaction/processor/PsbtTransaction.d.ts +0 -25
- package/build/transaction/processor/PsbtTransaction.js +0 -80
- package/src/metadata/tokens.ts +0 -139
- package/src/transaction/processor/PsbtTransaction.ts +0 -179
package/browser/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { B as a, f as
|
|
2
|
-
import { i as
|
|
3
|
-
import { s as
|
|
4
|
-
import { A as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
7
|
-
return a.from(
|
|
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 ve, d as Lt, l as Kt, m as pt, 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 wi, a as lt, c as jt, t as O, d as rt, e as it, f as L, g as ke, h as Zt, j as gt, k as Te, l as yi, 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 At, A as zt, B as _e, C as Ti, D as Ke, P as v, E as Pi, F as Pe, G as Ei, H as Ee, I as Ai, J as Oi, K as Bi, L as xi, M as F, T as Jt, N as vi } from "./btc-vision-bitcoin.js";
|
|
3
|
+
import { s as ki, m as Li, f as Ui } from "./noble-curves.js";
|
|
4
|
+
import { A as _i, s as ne, j as Ki, e as Ci } from "./noble-hashes.js";
|
|
5
|
+
const Di = "1.7.30";
|
|
6
|
+
function Fi(n, t = {}) {
|
|
7
|
+
return a.from(Vt.gzip(n, { level: t.level || 6 }));
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
return a.from(
|
|
9
|
+
function Ri(n) {
|
|
10
|
+
return a.from(Vt.ungzip(n));
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
return a.from(
|
|
12
|
+
function Wi(n, t = {}) {
|
|
13
|
+
return a.from(Vt.deflate(n, { level: t.level || 6 }));
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return a.from(
|
|
15
|
+
function Mi(n) {
|
|
16
|
+
return a.from(Vt.inflate(n));
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
gzipSync:
|
|
20
|
-
gunzipSync:
|
|
21
|
-
deflateSync:
|
|
22
|
-
inflateSync:
|
|
18
|
+
const Ae = {
|
|
19
|
+
gzipSync: Fi,
|
|
20
|
+
gunzipSync: Ri,
|
|
21
|
+
deflateSync: Wi,
|
|
22
|
+
inflateSync: Mi
|
|
23
23
|
};
|
|
24
24
|
class N {
|
|
25
25
|
static {
|
|
@@ -35,7 +35,7 @@ class N {
|
|
|
35
35
|
* @returns {Buffer} The compressed data.
|
|
36
36
|
*/
|
|
37
37
|
static compress(t) {
|
|
38
|
-
return
|
|
38
|
+
return Ae.gzipSync(t, N.zlibOptions);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Decompresses the data using gunzip.
|
|
@@ -43,26 +43,26 @@ class N {
|
|
|
43
43
|
* @returns {Buffer} The decompressed data.
|
|
44
44
|
*/
|
|
45
45
|
static decompress(t) {
|
|
46
|
-
return
|
|
46
|
+
return Ae.gunzipSync(t, N.zlibOptions);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
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
|
|
54
|
-
function
|
|
55
|
-
return
|
|
53
|
+
const at = ki.Point, Ni = at.Fn.ORDER, Hi = _i("TapTweak"), Oe = ne(Hi);
|
|
54
|
+
function Vi(n) {
|
|
55
|
+
return ne(Ci(Oe, Oe, n));
|
|
56
56
|
}
|
|
57
57
|
class A {
|
|
58
58
|
static {
|
|
59
|
-
this.BIP32 = Ce(
|
|
59
|
+
this.BIP32 = Ce(G);
|
|
60
60
|
}
|
|
61
61
|
static {
|
|
62
|
-
this.ECPair =
|
|
62
|
+
this.ECPair = di.ECPairFactory(G);
|
|
63
63
|
}
|
|
64
64
|
static {
|
|
65
|
-
|
|
65
|
+
at.BASE.precompute(8);
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* Generate a keypair from a WIF
|
|
@@ -70,7 +70,7 @@ class A {
|
|
|
70
70
|
* @param {Network} network - The network to use
|
|
71
71
|
* @returns {ECPairInterface} - The generated keypair
|
|
72
72
|
*/
|
|
73
|
-
static fromWIF(t, e =
|
|
73
|
+
static fromWIF(t, e = I) {
|
|
74
74
|
return this.ECPair.fromWIF(t, e);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -79,7 +79,7 @@ class A {
|
|
|
79
79
|
* @param {Network} network - The network to use
|
|
80
80
|
* @returns {ECPairInterface} - The generated keypair
|
|
81
81
|
*/
|
|
82
|
-
static fromPrivateKey(t, e =
|
|
82
|
+
static fromPrivateKey(t, e = I) {
|
|
83
83
|
return this.ECPair.fromPrivateKey(
|
|
84
84
|
a.isBuffer(t) ? t : a.from(t),
|
|
85
85
|
{ network: e }
|
|
@@ -91,7 +91,7 @@ class A {
|
|
|
91
91
|
* @param {Network} network - The network to use
|
|
92
92
|
* @returns {ECPairInterface} - The generated keypair
|
|
93
93
|
*/
|
|
94
|
-
static fromPublicKey(t, e =
|
|
94
|
+
static fromPublicKey(t, e = I) {
|
|
95
95
|
const i = a.isBuffer(t) ? t : a.from(t);
|
|
96
96
|
return this.ECPair.fromPublicKey(i, { network: e });
|
|
97
97
|
}
|
|
@@ -103,14 +103,14 @@ class A {
|
|
|
103
103
|
* @returns {string} - The generated address
|
|
104
104
|
* @throws {Error} - If the address cannot be generated
|
|
105
105
|
*/
|
|
106
|
-
static generateMultiSigAddress(t, e, i =
|
|
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 = wi({
|
|
110
110
|
m: e,
|
|
111
111
|
pubkeys: r,
|
|
112
112
|
network: i
|
|
113
|
-
}), c =
|
|
113
|
+
}), c = lt({ redeem: s, network: i }).address;
|
|
114
114
|
if (!c)
|
|
115
115
|
throw new Error("Failed to generate address");
|
|
116
116
|
return c;
|
|
@@ -122,7 +122,7 @@ class A {
|
|
|
122
122
|
* @returns {Buffer[]} - The verified public keys
|
|
123
123
|
* @throws {Error} - If the key cannot be regenerated
|
|
124
124
|
*/
|
|
125
|
-
static verifyPubKeys(t, e =
|
|
125
|
+
static verifyPubKeys(t, e = I) {
|
|
126
126
|
return t.map((i) => {
|
|
127
127
|
const r = A.fromPublicKey(i, e);
|
|
128
128
|
if (!r)
|
|
@@ -136,8 +136,8 @@ class A {
|
|
|
136
136
|
* @param {Network} network - The network to use
|
|
137
137
|
* @returns {string} - The address
|
|
138
138
|
*/
|
|
139
|
-
static getP2WPKHAddress(t, e =
|
|
140
|
-
const i =
|
|
139
|
+
static getP2WPKHAddress(t, e = I) {
|
|
140
|
+
const i = jt({ pubkey: a.from(t.publicKey), network: e });
|
|
141
141
|
if (!i.address)
|
|
142
142
|
throw new Error("Failed to generate wallet");
|
|
143
143
|
return i.address;
|
|
@@ -162,7 +162,7 @@ class A {
|
|
|
162
162
|
* @throws {Error} - If the address cannot be generated
|
|
163
163
|
*/
|
|
164
164
|
static tweakedPubKeyBufferToAddress(t, e) {
|
|
165
|
-
const { address: i } =
|
|
165
|
+
const { address: i } = rt({
|
|
166
166
|
pubkey: a.isBuffer(t) ? t : a.from(t),
|
|
167
167
|
network: e
|
|
168
168
|
});
|
|
@@ -177,15 +177,15 @@ class A {
|
|
|
177
177
|
* @param deploymentVersion - The deployment version (default is 0)
|
|
178
178
|
* @returns {string} - The generated P2OP address
|
|
179
179
|
*/
|
|
180
|
-
static p2op(t, e =
|
|
180
|
+
static p2op(t, e = I, i = 0) {
|
|
181
181
|
const r = a.concat([
|
|
182
182
|
a.from([i]),
|
|
183
|
-
|
|
183
|
+
it.crypto.hash160(a.from(t))
|
|
184
184
|
]);
|
|
185
185
|
if (r.length < 2 || r.length > 40)
|
|
186
186
|
throw new Error("Witness program must be 2-40 bytes.");
|
|
187
187
|
const s = L([g.OP_16, r]);
|
|
188
|
-
return
|
|
188
|
+
return ke(s, e);
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
191
191
|
* Get the address of a xOnly tweaked public key
|
|
@@ -196,7 +196,7 @@ class A {
|
|
|
196
196
|
*/
|
|
197
197
|
static xOnlyTweakedPubKeyToAddress(t, e) {
|
|
198
198
|
t.startsWith("0x") && (t = t.slice(2));
|
|
199
|
-
const i = a.from(t, "hex"), { address: r } =
|
|
199
|
+
const i = a.from(t, "hex"), { address: r } = rt({
|
|
200
200
|
pubkey: i,
|
|
201
201
|
network: e
|
|
202
202
|
});
|
|
@@ -212,7 +212,7 @@ class A {
|
|
|
212
212
|
*/
|
|
213
213
|
static tweakPublicKey(t) {
|
|
214
214
|
typeof t == "string" && t.startsWith("0x") && (t = t.slice(2));
|
|
215
|
-
const e =
|
|
215
|
+
const e = at.fromHex(t), i = (e.y & 1n) === 0n ? e : e.negate(), r = a.from(i.toBytes(!0).subarray(1)), s = Vi(r), o = Li(Ui(s), Ni), c = i.add(at.BASE.multiply(o));
|
|
216
216
|
return a.from(c.toBytes(!0));
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
@@ -222,9 +222,9 @@ class A {
|
|
|
222
222
|
* @returns {Uint8Array[]} - The tweaked public keys
|
|
223
223
|
*/
|
|
224
224
|
static tweakBatchSharedT(t, e) {
|
|
225
|
-
const i =
|
|
225
|
+
const i = at.BASE.multiply(e);
|
|
226
226
|
return t.map((r) => {
|
|
227
|
-
const s =
|
|
227
|
+
const s = at.fromHex(r);
|
|
228
228
|
return (s.y % 2n === 0n ? s : s.negate()).add(i).toBytes(!0);
|
|
229
229
|
});
|
|
230
230
|
}
|
|
@@ -235,7 +235,7 @@ class A {
|
|
|
235
235
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
236
236
|
* @returns An object containing both classical and quantum key information
|
|
237
237
|
*/
|
|
238
|
-
static generateWallet(t =
|
|
238
|
+
static generateWallet(t = I, e = P.MLDSASecurityLevel.LEVEL2) {
|
|
239
239
|
const i = this.ECPair.makeRandom({
|
|
240
240
|
network: t
|
|
241
241
|
}), r = this.getP2WPKHAddress(i, t);
|
|
@@ -260,8 +260,8 @@ class A {
|
|
|
260
260
|
* @param network - The Bitcoin network (default: bitcoin mainnet)
|
|
261
261
|
* @returns A random ML-DSA keypair
|
|
262
262
|
*/
|
|
263
|
-
static generateQuantumKeyPair(t = P.MLDSASecurityLevel.LEVEL2, e =
|
|
264
|
-
const i =
|
|
263
|
+
static generateQuantumKeyPair(t = P.MLDSASecurityLevel.LEVEL2, e = I) {
|
|
264
|
+
const i = Ki(64), r = P.QuantumBIP32Factory.fromSeed(
|
|
265
265
|
a.from(i),
|
|
266
266
|
e,
|
|
267
267
|
t
|
|
@@ -279,8 +279,8 @@ class A {
|
|
|
279
279
|
* @param {Network} network - The network to use
|
|
280
280
|
* @returns {boolean} - Whether the address is valid
|
|
281
281
|
*/
|
|
282
|
-
static verifyContractAddress(t, e =
|
|
283
|
-
return !!
|
|
282
|
+
static verifyContractAddress(t, e = I) {
|
|
283
|
+
return !!Zt(t, e);
|
|
284
284
|
}
|
|
285
285
|
/**
|
|
286
286
|
* Get the legacy segwit address from a keypair
|
|
@@ -288,9 +288,9 @@ class A {
|
|
|
288
288
|
* @param {Network} network - The network to use
|
|
289
289
|
* @returns {string} - The legacy address
|
|
290
290
|
*/
|
|
291
|
-
static getLegacySegwitAddress(t, e =
|
|
292
|
-
const i =
|
|
293
|
-
redeem:
|
|
291
|
+
static getLegacySegwitAddress(t, e = I) {
|
|
292
|
+
const i = gt({
|
|
293
|
+
redeem: jt({ pubkey: a.from(t.publicKey), network: e }),
|
|
294
294
|
network: e
|
|
295
295
|
});
|
|
296
296
|
if (!i.address)
|
|
@@ -303,8 +303,8 @@ class A {
|
|
|
303
303
|
* @param {Network} network - The network to use
|
|
304
304
|
* @returns {string} - The legacy address
|
|
305
305
|
*/
|
|
306
|
-
static getLegacyAddress(t, e =
|
|
307
|
-
const i =
|
|
306
|
+
static getLegacyAddress(t, e = I) {
|
|
307
|
+
const i = Te({ pubkey: a.from(t.publicKey), network: e });
|
|
308
308
|
if (!i.address)
|
|
309
309
|
throw new Error("Failed to generate wallet");
|
|
310
310
|
return i.address;
|
|
@@ -315,8 +315,8 @@ class A {
|
|
|
315
315
|
* @param {Network} network - The network to use
|
|
316
316
|
* @returns {string} - The legacy address
|
|
317
317
|
*/
|
|
318
|
-
static getP2PKH(t, e =
|
|
319
|
-
const i =
|
|
318
|
+
static getP2PKH(t, e = I) {
|
|
319
|
+
const i = Te({ pubkey: a.from(t), network: e });
|
|
320
320
|
if (!i.address)
|
|
321
321
|
throw new Error("Failed to generate wallet");
|
|
322
322
|
return i.address;
|
|
@@ -327,8 +327,8 @@ class A {
|
|
|
327
327
|
* @param {Network} network - The network to use
|
|
328
328
|
* @returns {string} - The legacy address
|
|
329
329
|
*/
|
|
330
|
-
static getP2PKAddress(t, e =
|
|
331
|
-
const i =
|
|
330
|
+
static getP2PKAddress(t, e = I) {
|
|
331
|
+
const i = yi({ 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");
|
|
@@ -338,7 +338,7 @@ class A {
|
|
|
338
338
|
* @param {Network} network - The network to use
|
|
339
339
|
* @returns {ECPairInterface} - The generated keypair
|
|
340
340
|
*/
|
|
341
|
-
static generateRandomKeyPair(t =
|
|
341
|
+
static generateRandomKeyPair(t = I) {
|
|
342
342
|
return this.ECPair.makeRandom({
|
|
343
343
|
network: t
|
|
344
344
|
});
|
|
@@ -349,7 +349,7 @@ class A {
|
|
|
349
349
|
* @param {Network} network - The network to use
|
|
350
350
|
* @returns {BIP32Interface} - The generated keypair
|
|
351
351
|
*/
|
|
352
|
-
static fromSeed(t, e =
|
|
352
|
+
static fromSeed(t, e = I) {
|
|
353
353
|
return this.BIP32.fromSeed(t, e);
|
|
354
354
|
}
|
|
355
355
|
/**
|
|
@@ -358,8 +358,8 @@ class A {
|
|
|
358
358
|
* @param {Network} network - The network to use
|
|
359
359
|
* @returns {string} - The taproot address
|
|
360
360
|
*/
|
|
361
|
-
static getTaprootAddress(t, e =
|
|
362
|
-
const { address: i } =
|
|
361
|
+
static getTaprootAddress(t, e = I) {
|
|
362
|
+
const { address: i } = rt({
|
|
363
363
|
internalPubkey: O(a.from(t.publicKey)),
|
|
364
364
|
network: e
|
|
365
365
|
});
|
|
@@ -373,8 +373,8 @@ class A {
|
|
|
373
373
|
* @param {Network} network - The network to use
|
|
374
374
|
* @returns {string} - The taproot address
|
|
375
375
|
*/
|
|
376
|
-
static getTaprootAddressFromAddress(t, e =
|
|
377
|
-
const { address: i } =
|
|
376
|
+
static getTaprootAddressFromAddress(t, e = I) {
|
|
377
|
+
const { address: i } = rt({
|
|
378
378
|
address: t,
|
|
379
379
|
network: e
|
|
380
380
|
});
|
|
@@ -388,14 +388,14 @@ class A {
|
|
|
388
388
|
* @param {Network} network - The network to use
|
|
389
389
|
* @returns {ECPairInterface} - The generated key pair
|
|
390
390
|
*/
|
|
391
|
-
static fromSeedKeyPair(t, e =
|
|
391
|
+
static fromSeedKeyPair(t, e = I) {
|
|
392
392
|
const r = this.BIP32.fromSeed(t, e).privateKey;
|
|
393
393
|
if (!r) throw new Error("Failed to generate key pair");
|
|
394
394
|
return this.ECPair.fromPrivateKey(a.from(r), { network: e });
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
const
|
|
398
|
-
class
|
|
397
|
+
const C = 32, zi = 4, It = 32, wt = 16, Ct = 8, ht = 4, Tt = 2, Dt = 1, qi = 32, yt = 16, $i = 8, Xi = 4, Yi = 2, Gi = 1, Qi = 1;
|
|
398
|
+
class X {
|
|
399
399
|
static {
|
|
400
400
|
this.EXPECTED_BUFFER_LENGTH = 32;
|
|
401
401
|
}
|
|
@@ -420,22 +420,22 @@ class Y {
|
|
|
420
420
|
}
|
|
421
421
|
static pointerToUint8Array(t) {
|
|
422
422
|
const e = t.toString(16).padStart(64, "0");
|
|
423
|
-
return
|
|
423
|
+
return X.hexToUint8Array(e);
|
|
424
424
|
}
|
|
425
425
|
static uint8ArrayToPointer(t) {
|
|
426
|
-
const e =
|
|
426
|
+
const e = X.uint8ArrayToHex(t);
|
|
427
427
|
return BigInt("0x" + e);
|
|
428
428
|
}
|
|
429
|
-
static valueToUint8Array(t, e =
|
|
429
|
+
static valueToUint8Array(t, e = It) {
|
|
430
430
|
const i = t.toString(16).padStart(e * 2, "0");
|
|
431
|
-
return
|
|
431
|
+
return X.hexToUint8Array(i);
|
|
432
432
|
}
|
|
433
433
|
static uint8ArrayToValue(t) {
|
|
434
|
-
const e =
|
|
434
|
+
const e = X.uint8ArrayToHex(t);
|
|
435
435
|
return BigInt(e ? "0x" + e : 0);
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
const
|
|
438
|
+
const ji = /^[0-9a-fA-F]+$/;
|
|
439
439
|
class K {
|
|
440
440
|
/**
|
|
441
441
|
* Converts satoshi to BTC
|
|
@@ -471,7 +471,7 @@ class K {
|
|
|
471
471
|
);
|
|
472
472
|
}
|
|
473
473
|
static isValidHex(t) {
|
|
474
|
-
return
|
|
474
|
+
return ji.test(t);
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
477
|
* Hashes the given data
|
|
@@ -479,13 +479,13 @@ class K {
|
|
|
479
479
|
* @returns {string} The hashed data
|
|
480
480
|
*/
|
|
481
481
|
static opnetHash(t) {
|
|
482
|
-
const e =
|
|
482
|
+
const e = Qt("sha512");
|
|
483
483
|
e.update(t);
|
|
484
484
|
const i = e.digest();
|
|
485
485
|
return `0x${a.from(i).toString("hex")}`;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
class
|
|
488
|
+
class z {
|
|
489
489
|
/**
|
|
490
490
|
* Check if a UTXO is a P2WDA output by examining its script structure
|
|
491
491
|
*
|
|
@@ -495,7 +495,7 @@ class q {
|
|
|
495
495
|
static isP2WDAUTXO(t) {
|
|
496
496
|
if (!t.witnessScript)
|
|
497
497
|
return !1;
|
|
498
|
-
const e =
|
|
498
|
+
const e = T.isBuffer(t.witnessScript) ? t.witnessScript : T.from(t.witnessScript, "hex");
|
|
499
499
|
return this.isP2WDAWitnessScript(e);
|
|
500
500
|
}
|
|
501
501
|
/**
|
|
@@ -509,13 +509,13 @@ class q {
|
|
|
509
509
|
*/
|
|
510
510
|
static isP2WDAWitnessScript(t) {
|
|
511
511
|
try {
|
|
512
|
-
const e =
|
|
512
|
+
const e = R(t);
|
|
513
513
|
if (!e || e.length !== 7)
|
|
514
514
|
return !1;
|
|
515
515
|
for (let i = 0; i < 5; i++)
|
|
516
516
|
if (e[i] !== g.OP_2DROP)
|
|
517
517
|
return !1;
|
|
518
|
-
return
|
|
518
|
+
return T.isBuffer(e[5]) && e[5].length === 33 && // Compressed public key
|
|
519
519
|
e[6] === g.OP_CHECKSIG;
|
|
520
520
|
} catch {
|
|
521
521
|
return !1;
|
|
@@ -539,7 +539,7 @@ class q {
|
|
|
539
539
|
g.OP_2DROP,
|
|
540
540
|
t,
|
|
541
541
|
g.OP_CHECKSIG
|
|
542
|
-
]), r =
|
|
542
|
+
]), r = lt({
|
|
543
543
|
redeem: { output: i },
|
|
544
544
|
network: e
|
|
545
545
|
});
|
|
@@ -559,13 +559,13 @@ class q {
|
|
|
559
559
|
*/
|
|
560
560
|
static extractPublicKeyFromP2WDA(t) {
|
|
561
561
|
try {
|
|
562
|
-
const e =
|
|
562
|
+
const e = R(t);
|
|
563
563
|
if (!e || e.length !== 7)
|
|
564
564
|
return null;
|
|
565
565
|
for (let i = 0; i < 5; i++)
|
|
566
566
|
if (e[i] !== g.OP_2DROP)
|
|
567
567
|
return null;
|
|
568
|
-
return
|
|
568
|
+
return T.isBuffer(e[5]) && e[5].length === 33 && e[6] === g.OP_CHECKSIG ? e[5] : null;
|
|
569
569
|
} catch {
|
|
570
570
|
return null;
|
|
571
571
|
}
|
|
@@ -582,7 +582,7 @@ class q {
|
|
|
582
582
|
static createSimpleP2WDAWitness(t, e) {
|
|
583
583
|
const i = [t];
|
|
584
584
|
for (let r = 0; r < 10; r++)
|
|
585
|
-
i.push(
|
|
585
|
+
i.push(T.alloc(0));
|
|
586
586
|
return i.push(e), i;
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
@@ -615,8 +615,8 @@ class q {
|
|
|
615
615
|
return t.length === 34 && t[0] === 0 && t[1] === 32;
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
|
-
|
|
619
|
-
var
|
|
618
|
+
ot(G);
|
|
619
|
+
var J = /* @__PURE__ */ ((n) => (n.P2PKH = "P2PKH", n.P2OP = "P2OP", n.P2SH_OR_P2SH_P2WPKH = "P2SH_OR_P2SH-P2WPKH", n.P2PK = "P2PK", n.P2TR = "P2TR", n.P2WPKH = "P2WPKH", n.P2WSH = "P2WSH", n.P2WDA = "P2WDA", n))(J || {});
|
|
620
620
|
class H {
|
|
621
621
|
/**
|
|
622
622
|
* Checks if the given address is a valid P2PKH address.
|
|
@@ -629,7 +629,7 @@ class H {
|
|
|
629
629
|
if (!t || t.length < 50) return !1;
|
|
630
630
|
let i = !1;
|
|
631
631
|
try {
|
|
632
|
-
|
|
632
|
+
Zt(t, e), i = Ut(t).version === 1;
|
|
633
633
|
} catch {
|
|
634
634
|
}
|
|
635
635
|
return i;
|
|
@@ -645,8 +645,8 @@ class H {
|
|
|
645
645
|
if (!t || t.length < 20 || t.length > 50) return !1;
|
|
646
646
|
let i = !1;
|
|
647
647
|
try {
|
|
648
|
-
const r =
|
|
649
|
-
|
|
648
|
+
const r = Ut(t);
|
|
649
|
+
Zt(t, e), i = r.version === 0 && r.data.length === 20;
|
|
650
650
|
} catch {
|
|
651
651
|
}
|
|
652
652
|
return i;
|
|
@@ -664,7 +664,7 @@ class H {
|
|
|
664
664
|
* @returns true if this is a valid P2WDA witness script
|
|
665
665
|
*/
|
|
666
666
|
static isP2WDAWitnessScript(t) {
|
|
667
|
-
return
|
|
667
|
+
return z.isP2WDAWitnessScript(t);
|
|
668
668
|
}
|
|
669
669
|
/**
|
|
670
670
|
* Checks if the given address is a valid P2PKH or P2SH address.
|
|
@@ -675,7 +675,7 @@ class H {
|
|
|
675
675
|
*/
|
|
676
676
|
static isP2PKHOrP2SH(t, e) {
|
|
677
677
|
try {
|
|
678
|
-
const i =
|
|
678
|
+
const i = Yt(t);
|
|
679
679
|
return i.version === e.pubKeyHash ? !0 : i.version === e.scriptHash;
|
|
680
680
|
} catch {
|
|
681
681
|
return !1;
|
|
@@ -753,7 +753,7 @@ class H {
|
|
|
753
753
|
static isValidP2OPAddress(t, e) {
|
|
754
754
|
if (!t || t.length < 20) return !1;
|
|
755
755
|
try {
|
|
756
|
-
const i =
|
|
756
|
+
const i = Ut(t);
|
|
757
757
|
return i.prefix === e.bech32 || i.prefix === e.bech32Opnet ? i.version === 16 && i.data.length === 21 : !1;
|
|
758
758
|
} catch {
|
|
759
759
|
return !1;
|
|
@@ -767,7 +767,7 @@ class H {
|
|
|
767
767
|
*/
|
|
768
768
|
static requireRedeemScript(t, e) {
|
|
769
769
|
try {
|
|
770
|
-
const i =
|
|
770
|
+
const i = Yt(t);
|
|
771
771
|
return i.version === e.pubKeyHash ? !1 : i.version === e.scriptHash;
|
|
772
772
|
} catch {
|
|
773
773
|
return !1;
|
|
@@ -792,7 +792,7 @@ class H {
|
|
|
792
792
|
if (H.isValidPublicKey(t, e))
|
|
793
793
|
return "P2PK";
|
|
794
794
|
try {
|
|
795
|
-
const i =
|
|
795
|
+
const i = Yt(t);
|
|
796
796
|
if (i.version === e.pubKeyHash)
|
|
797
797
|
return "P2PKH";
|
|
798
798
|
if (i.version === e.scriptHash)
|
|
@@ -800,7 +800,7 @@ class H {
|
|
|
800
800
|
} catch {
|
|
801
801
|
}
|
|
802
802
|
try {
|
|
803
|
-
const i =
|
|
803
|
+
const i = Ut(t);
|
|
804
804
|
if ((i.prefix === e.bech32Opnet || i.prefix === e.bech32) && i.version === 16 && i.data.length === 21)
|
|
805
805
|
return "P2OP";
|
|
806
806
|
if (i.prefix === e.bech32) {
|
|
@@ -865,7 +865,7 @@ class H {
|
|
|
865
865
|
isDefinitelyP2WDA: !1,
|
|
866
866
|
error: "Witness script does not match P2WDA pattern"
|
|
867
867
|
};
|
|
868
|
-
if (
|
|
868
|
+
if (lt({
|
|
869
869
|
redeem: { output: i },
|
|
870
870
|
network: e
|
|
871
871
|
}).address !== t)
|
|
@@ -875,7 +875,7 @@ class H {
|
|
|
875
875
|
isDefinitelyP2WDA: !1,
|
|
876
876
|
error: "Witness script does not match address"
|
|
877
877
|
};
|
|
878
|
-
const o =
|
|
878
|
+
const o = z.extractPublicKeyFromP2WDA(i);
|
|
879
879
|
return o ? {
|
|
880
880
|
isValid: !0,
|
|
881
881
|
isPotentiallyP2WDA: !0,
|
|
@@ -897,8 +897,8 @@ class H {
|
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
}
|
|
900
|
-
const
|
|
901
|
-
class
|
|
900
|
+
const nt = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
|
|
901
|
+
class De {
|
|
902
902
|
constructor(t = 1e4) {
|
|
903
903
|
this.maxTries = t;
|
|
904
904
|
}
|
|
@@ -918,14 +918,14 @@ class Re {
|
|
|
918
918
|
findOrDeriveValidPoint(t, e = !0, i = this.maxTries) {
|
|
919
919
|
if (t.length !== 32)
|
|
920
920
|
throw new Error("xBytes must be exactly 32 bytes.");
|
|
921
|
-
let r = this.bytesToBigInt(t) %
|
|
921
|
+
let r = this.bytesToBigInt(t) % nt, s = this.isValidX(r);
|
|
922
922
|
if (e && s === null)
|
|
923
923
|
throw new Error("The given x is not a valid curve point.");
|
|
924
924
|
let o = 0;
|
|
925
925
|
for (; s === null; )
|
|
926
|
-
if (r = (r + 1n) %
|
|
926
|
+
if (r = (r + 1n) % nt, s = this.isValidX(r), o++, o > i)
|
|
927
927
|
throw new Error(`Could not find a valid X point within ${i} increments.`);
|
|
928
|
-
const c = s, u = (
|
|
928
|
+
const c = s, u = (nt - c) % nt;
|
|
929
929
|
return { x: r, y1: c, y2: u };
|
|
930
930
|
}
|
|
931
931
|
/**
|
|
@@ -957,8 +957,8 @@ class Re {
|
|
|
957
957
|
* Returns the square root if it is, or null if not.
|
|
958
958
|
*/
|
|
959
959
|
isValidX(t) {
|
|
960
|
-
const e = (this.modPow(t, 3n,
|
|
961
|
-
return this.sqrtModP(e,
|
|
960
|
+
const e = (this.modPow(t, 3n, nt) + 7n) % nt;
|
|
961
|
+
return this.sqrtModP(e, nt);
|
|
962
962
|
}
|
|
963
963
|
/**
|
|
964
964
|
* Computes base^exp (mod m) using exponentiation by squaring.
|
|
@@ -1000,9 +1000,9 @@ class Re {
|
|
|
1000
1000
|
return e;
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
class
|
|
1003
|
+
class Zi {
|
|
1004
1004
|
constructor() {
|
|
1005
|
-
this.deriver = new
|
|
1005
|
+
this.deriver = new De();
|
|
1006
1006
|
}
|
|
1007
1007
|
generateHybridKeyFromHash(t) {
|
|
1008
1008
|
const e = this.deriver.findOrDeriveValidPoint(this.cloneBuffer(t), !1), i = this.deriver.getCanonicalY(e.y1, e.y2);
|
|
@@ -1012,7 +1012,7 @@ class Sr {
|
|
|
1012
1012
|
return a.from(t);
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
|
-
const
|
|
1015
|
+
const te = new Zi();
|
|
1016
1016
|
class M {
|
|
1017
1017
|
static {
|
|
1018
1018
|
this.UNSPENDABLE_INTERNAL_KEY = a.from(
|
|
@@ -1027,8 +1027,8 @@ class M {
|
|
|
1027
1027
|
* Generate a P2WSH address with CSV timelock
|
|
1028
1028
|
* Note: This uses ECDSA, not Schnorr (Schnorr only available in Taproot)
|
|
1029
1029
|
*/
|
|
1030
|
-
static generateTimeLockAddress(t, e =
|
|
1031
|
-
const r = this.generateTimeLockScript(t, i), s =
|
|
1030
|
+
static generateTimeLockAddress(t, e = I, i = M.CSV_BLOCKS) {
|
|
1031
|
+
const r = this.generateTimeLockScript(t, i), s = it.payments.p2wsh({
|
|
1032
1032
|
redeem: { output: r },
|
|
1033
1033
|
network: e
|
|
1034
1034
|
});
|
|
@@ -1043,10 +1043,10 @@ class M {
|
|
|
1043
1043
|
* Generate a P2TR address with CSV time lock
|
|
1044
1044
|
* Note: This uses Schnorr signatures
|
|
1045
1045
|
*/
|
|
1046
|
-
static generateTimeLockAddressP2TR(t, e =
|
|
1046
|
+
static generateTimeLockAddressP2TR(t, e = I, i = M.CSV_BLOCKS) {
|
|
1047
1047
|
if (t.length !== 32)
|
|
1048
1048
|
throw new Error("Public key must be 32 bytes for Taproot");
|
|
1049
|
-
const r = this.generateTimeLockScript(t, i), s =
|
|
1049
|
+
const r = this.generateTimeLockScript(t, i), s = it.payments.p2tr({
|
|
1050
1050
|
redeem: { output: r },
|
|
1051
1051
|
network: e,
|
|
1052
1052
|
internalPubkey: M.UNSPENDABLE_INTERNAL_KEY
|
|
@@ -1057,7 +1057,7 @@ class M {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
static generateTimeLockScript(t, e = M.CSV_BLOCKS) {
|
|
1059
1059
|
return L([
|
|
1060
|
-
|
|
1060
|
+
Le.encode(e),
|
|
1061
1061
|
g.OP_CHECKSEQUENCEVERIFY,
|
|
1062
1062
|
g.OP_DROP,
|
|
1063
1063
|
t,
|
|
@@ -1085,9 +1085,9 @@ class k extends Uint8Array {
|
|
|
1085
1085
|
// After processing, this is 32-byte tweaked x-only (same as original behavior)
|
|
1086
1086
|
#c;
|
|
1087
1087
|
constructor(t, e) {
|
|
1088
|
-
if (super(
|
|
1088
|
+
if (super(C), !!t) {
|
|
1089
1089
|
if (e) {
|
|
1090
|
-
if (![
|
|
1090
|
+
if (![C, 33, 65].includes(e.length))
|
|
1091
1091
|
throw new Error(`Invalid public key length ${e.length}`);
|
|
1092
1092
|
this.#d = new Uint8Array(e.length), this.#d.set(e);
|
|
1093
1093
|
}
|
|
@@ -1261,7 +1261,7 @@ class k extends Uint8Array {
|
|
|
1261
1261
|
* @returns {boolean}
|
|
1262
1262
|
*/
|
|
1263
1263
|
isDead() {
|
|
1264
|
-
for (let t = 0; t <
|
|
1264
|
+
for (let t = 0; t < C; t++)
|
|
1265
1265
|
if (this[t] !== 0)
|
|
1266
1266
|
return !1;
|
|
1267
1267
|
return !0;
|
|
@@ -1362,7 +1362,7 @@ class k extends Uint8Array {
|
|
|
1362
1362
|
*/
|
|
1363
1363
|
lessThan(t) {
|
|
1364
1364
|
const e = this;
|
|
1365
|
-
for (let i = 0; i <
|
|
1365
|
+
for (let i = 0; i < C; i++) {
|
|
1366
1366
|
const r = e[i], s = t[i];
|
|
1367
1367
|
if (r < s)
|
|
1368
1368
|
return !0;
|
|
@@ -1377,7 +1377,7 @@ class k extends Uint8Array {
|
|
|
1377
1377
|
*/
|
|
1378
1378
|
greaterThan(t) {
|
|
1379
1379
|
const e = this;
|
|
1380
|
-
for (let i = 0; i <
|
|
1380
|
+
for (let i = 0; i < C; i++) {
|
|
1381
1381
|
const r = e[i], s = t[i];
|
|
1382
1382
|
if (r > s)
|
|
1383
1383
|
return !0;
|
|
@@ -1490,7 +1490,7 @@ class k extends Uint8Array {
|
|
|
1490
1490
|
if (e.length !== 33)
|
|
1491
1491
|
throw new Error("P2WDA requires a compressed public key (33 bytes)");
|
|
1492
1492
|
try {
|
|
1493
|
-
const i =
|
|
1493
|
+
const i = z.generateP2WDAAddress(e, t);
|
|
1494
1494
|
return this.#s = t, this.#h = i, {
|
|
1495
1495
|
address: i.address,
|
|
1496
1496
|
witnessScript: i.witnessScript
|
|
@@ -1573,8 +1573,8 @@ class k extends Uint8Array {
|
|
|
1573
1573
|
* @param {ArrayLike<number>} mldsaPublicKey - The MLDSA public key or its hash
|
|
1574
1574
|
*/
|
|
1575
1575
|
setMldsaKey(t) {
|
|
1576
|
-
if (t.length ===
|
|
1577
|
-
const e = new Uint8Array(
|
|
1576
|
+
if (t.length === C) {
|
|
1577
|
+
const e = new Uint8Array(C);
|
|
1578
1578
|
e.set(t), super.set(e);
|
|
1579
1579
|
} else {
|
|
1580
1580
|
if (![1312, 1952, 2592].includes(t.length))
|
|
@@ -1582,7 +1582,7 @@ class k extends Uint8Array {
|
|
|
1582
1582
|
`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
1583
|
);
|
|
1584
1584
|
this.#l = new Uint8Array(t.length), this.#l.set(t);
|
|
1585
|
-
const i =
|
|
1585
|
+
const i = ne(new Uint8Array(t)), r = new Uint8Array(C);
|
|
1586
1586
|
r.set(i), super.set(r);
|
|
1587
1587
|
}
|
|
1588
1588
|
}
|
|
@@ -1595,9 +1595,9 @@ class k extends Uint8Array {
|
|
|
1595
1595
|
this.#g = !0;
|
|
1596
1596
|
const t = this.#d;
|
|
1597
1597
|
if (t)
|
|
1598
|
-
if (t.length ===
|
|
1599
|
-
const e = a.alloc(
|
|
1600
|
-
e.set(t), this.#n =
|
|
1598
|
+
if (t.length === C) {
|
|
1599
|
+
const e = a.alloc(C);
|
|
1600
|
+
e.set(t), this.#n = te.generateHybridKeyFromHash(e), this.#c = t;
|
|
1601
1601
|
} else
|
|
1602
1602
|
this.autoFormat(t);
|
|
1603
1603
|
}
|
|
@@ -1607,16 +1607,16 @@ class k extends Uint8Array {
|
|
|
1607
1607
|
*/
|
|
1608
1608
|
autoFormat(t) {
|
|
1609
1609
|
const e = t[0];
|
|
1610
|
-
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t = k.uncompressedToCompressed(t)), this.#i = Uint8Array.from(t), this.#u = A.fromPublicKey(this.#i), this.#r =
|
|
1610
|
+
e === 3 || e === 2 || (e === 4 || e === 6 || e === 7) && (t = k.uncompressedToCompressed(t)), this.#i = Uint8Array.from(t), this.#u = A.fromPublicKey(this.#i), this.#r = mi(this.#i);
|
|
1611
1611
|
const i = O(
|
|
1612
1612
|
A.tweakPublicKey(a.from(this.#i))
|
|
1613
1613
|
);
|
|
1614
|
-
this.#n =
|
|
1614
|
+
this.#n = te.generateHybridKeyFromHash(i), this.#c = new Uint8Array(C), this.#c.set(i);
|
|
1615
1615
|
}
|
|
1616
1616
|
}
|
|
1617
|
-
class
|
|
1617
|
+
class Ot {
|
|
1618
1618
|
constructor(t) {
|
|
1619
|
-
if (this._keys = [], this._values = {}, t instanceof
|
|
1619
|
+
if (this._keys = [], this._values = {}, t instanceof Ot)
|
|
1620
1620
|
this.setAll(t);
|
|
1621
1621
|
else if (t)
|
|
1622
1622
|
for (const [e, i] of t)
|
|
@@ -1680,7 +1680,7 @@ class vt {
|
|
|
1680
1680
|
}
|
|
1681
1681
|
class Fe {
|
|
1682
1682
|
constructor(t) {
|
|
1683
|
-
if (this.items = new
|
|
1683
|
+
if (this.items = new Ot(), t)
|
|
1684
1684
|
for (const [e, i] of t)
|
|
1685
1685
|
this.set(e, i);
|
|
1686
1686
|
}
|
|
@@ -1732,7 +1732,7 @@ class Fe {
|
|
|
1732
1732
|
yield* this.entries();
|
|
1733
1733
|
}
|
|
1734
1734
|
}
|
|
1735
|
-
class
|
|
1735
|
+
class qt {
|
|
1736
1736
|
constructor(t) {
|
|
1737
1737
|
this.currentOffset = 0, this.buffer = new DataView(t.buffer, t.byteOffset, t.byteLength);
|
|
1738
1738
|
}
|
|
@@ -1759,43 +1759,43 @@ class Qt {
|
|
|
1759
1759
|
* Reads a single unsigned byte (u8).
|
|
1760
1760
|
*/
|
|
1761
1761
|
readU8() {
|
|
1762
|
-
this.verifyEnd(this.currentOffset +
|
|
1762
|
+
this.verifyEnd(this.currentOffset + Dt);
|
|
1763
1763
|
const t = this.buffer.getUint8(this.currentOffset);
|
|
1764
|
-
return this.currentOffset +=
|
|
1764
|
+
return this.currentOffset += Dt, t;
|
|
1765
1765
|
}
|
|
1766
1766
|
/**
|
|
1767
1767
|
* Reads an unsigned 16-bit integer. By default, big-endian.
|
|
1768
1768
|
* @param be - Endianness; true means big-endian (the default).
|
|
1769
1769
|
*/
|
|
1770
1770
|
readU16(t = !0) {
|
|
1771
|
-
this.verifyEnd(this.currentOffset +
|
|
1771
|
+
this.verifyEnd(this.currentOffset + Tt);
|
|
1772
1772
|
const e = this.buffer.getUint16(this.currentOffset, !t);
|
|
1773
|
-
return this.currentOffset +=
|
|
1773
|
+
return this.currentOffset += Tt, e;
|
|
1774
1774
|
}
|
|
1775
1775
|
/**
|
|
1776
1776
|
* Reads an unsigned 32-bit integer. By default, big-endian.
|
|
1777
1777
|
* @param be - Endianness; true means big-endian (the default).
|
|
1778
1778
|
*/
|
|
1779
1779
|
readU32(t = !0) {
|
|
1780
|
-
this.verifyEnd(this.currentOffset +
|
|
1780
|
+
this.verifyEnd(this.currentOffset + ht);
|
|
1781
1781
|
const e = this.buffer.getUint32(this.currentOffset, !t);
|
|
1782
|
-
return this.currentOffset +=
|
|
1782
|
+
return this.currentOffset += ht, e;
|
|
1783
1783
|
}
|
|
1784
1784
|
/**
|
|
1785
1785
|
* Reads an unsigned 64-bit integer. By default, big-endian.
|
|
1786
1786
|
* @param be - Endianness; true means big-endian (the default).
|
|
1787
1787
|
*/
|
|
1788
1788
|
readU64(t = !0) {
|
|
1789
|
-
this.verifyEnd(this.currentOffset +
|
|
1789
|
+
this.verifyEnd(this.currentOffset + Ct);
|
|
1790
1790
|
const e = this.buffer.getBigUint64(this.currentOffset, !t);
|
|
1791
|
-
return this.currentOffset +=
|
|
1791
|
+
return this.currentOffset += Ct, e;
|
|
1792
1792
|
}
|
|
1793
1793
|
/**
|
|
1794
1794
|
* Reads a 128-bit unsigned integer. By default, read big-endian.
|
|
1795
1795
|
* @param be - Endianness; true => big-endian (default).
|
|
1796
1796
|
*/
|
|
1797
1797
|
readU128(t = !0) {
|
|
1798
|
-
const e = this.readBytes(
|
|
1798
|
+
const e = this.readBytes(wt);
|
|
1799
1799
|
let i = e;
|
|
1800
1800
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1801
1801
|
}
|
|
@@ -1804,7 +1804,7 @@ class Qt {
|
|
|
1804
1804
|
* @param be - Endianness; true => big-endian (default).
|
|
1805
1805
|
*/
|
|
1806
1806
|
readU256(t = !0) {
|
|
1807
|
-
const e = this.readBytes(
|
|
1807
|
+
const e = this.readBytes(It);
|
|
1808
1808
|
let i = e;
|
|
1809
1809
|
return t || (i = this.reverseBytes(e)), BigInt("0x" + this.toHexString(i));
|
|
1810
1810
|
}
|
|
@@ -1813,7 +1813,7 @@ class Qt {
|
|
|
1813
1813
|
* @param be - Endianness; true => big-endian (default).
|
|
1814
1814
|
*/
|
|
1815
1815
|
readI128(t = !0) {
|
|
1816
|
-
const e = this.readBytes(
|
|
1816
|
+
const e = this.readBytes(yt);
|
|
1817
1817
|
let i = e;
|
|
1818
1818
|
t || (i = this.reverseBytes(e));
|
|
1819
1819
|
let r = BigInt("0x" + this.toHexString(i));
|
|
@@ -1871,7 +1871,7 @@ class Qt {
|
|
|
1871
1871
|
* Reads an address.
|
|
1872
1872
|
*/
|
|
1873
1873
|
readAddress() {
|
|
1874
|
-
const t = Array.from(this.readBytes(
|
|
1874
|
+
const t = Array.from(this.readBytes(C));
|
|
1875
1875
|
return new k(t);
|
|
1876
1876
|
}
|
|
1877
1877
|
/**
|
|
@@ -1991,32 +1991,32 @@ class Qt {
|
|
|
1991
1991
|
return Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
1992
1992
|
}
|
|
1993
1993
|
}
|
|
1994
|
-
class
|
|
1994
|
+
class D {
|
|
1995
1995
|
constructor(t = 0) {
|
|
1996
1996
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(t);
|
|
1997
1997
|
}
|
|
1998
1998
|
static estimateArrayOfBufferLength(t) {
|
|
1999
1999
|
if (t.length > 65535) throw new Error("Array size is too large");
|
|
2000
|
-
let e =
|
|
2000
|
+
let e = Tt;
|
|
2001
2001
|
for (let i = 0; i < t.length; i++)
|
|
2002
|
-
e +=
|
|
2002
|
+
e += ht + t[i].length;
|
|
2003
2003
|
return e;
|
|
2004
2004
|
}
|
|
2005
2005
|
writeU8(t) {
|
|
2006
2006
|
if (t > 255) throw new Error("u8 value is too large.");
|
|
2007
|
-
this.allocSafe(
|
|
2007
|
+
this.allocSafe(Dt), this.buffer.setUint8(this.currentOffset++, t);
|
|
2008
2008
|
}
|
|
2009
2009
|
writeU16(t, e = !0) {
|
|
2010
2010
|
if (t > 65535) throw new Error("u16 value is too large.");
|
|
2011
|
-
this.allocSafe(
|
|
2011
|
+
this.allocSafe(Tt), this.buffer.setUint16(this.currentOffset, t, !e), this.currentOffset += 2;
|
|
2012
2012
|
}
|
|
2013
2013
|
writeU32(t, e = !0) {
|
|
2014
2014
|
if (t > 4294967295) throw new Error("u32 value is too large.");
|
|
2015
|
-
this.allocSafe(
|
|
2015
|
+
this.allocSafe(ht), this.buffer.setUint32(this.currentOffset, t, !e), this.currentOffset += 4;
|
|
2016
2016
|
}
|
|
2017
2017
|
writeU64(t, e = !0) {
|
|
2018
2018
|
if (t > 18446744073709551615n) throw new Error("u64 value is too large.");
|
|
2019
|
-
this.allocSafe(
|
|
2019
|
+
this.allocSafe(Ct), this.buffer.setBigUint64(this.currentOffset, t, !e), this.currentOffset += 8;
|
|
2020
2020
|
}
|
|
2021
2021
|
writeSelector(t) {
|
|
2022
2022
|
this.writeU32(t, !0);
|
|
@@ -2027,9 +2027,9 @@ class C {
|
|
|
2027
2027
|
writeI128(t, e = !0) {
|
|
2028
2028
|
if (t > 170141183460469231731687303715884105727n || t < -170141183460469231731687303715884105728n)
|
|
2029
2029
|
throw new Error("i128 value is too large.");
|
|
2030
|
-
this.allocSafe(
|
|
2031
|
-
const i =
|
|
2032
|
-
if (i.byteLength !==
|
|
2030
|
+
this.allocSafe(yt);
|
|
2031
|
+
const i = X.valueToUint8Array(t, yt);
|
|
2032
|
+
if (i.byteLength !== yt)
|
|
2033
2033
|
throw new Error(`Invalid i128 value: ${t}`);
|
|
2034
2034
|
if (e)
|
|
2035
2035
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2041,9 +2041,9 @@ class C {
|
|
|
2041
2041
|
writeU256(t, e = !0) {
|
|
2042
2042
|
if (t > 115792089237316195423570985008687907853269984665640564039457584007913129639935n && t < 0n)
|
|
2043
2043
|
throw new Error("u256 value is too large or negative.");
|
|
2044
|
-
this.allocSafe(
|
|
2045
|
-
const i =
|
|
2046
|
-
if (i.byteLength !==
|
|
2044
|
+
this.allocSafe(It);
|
|
2045
|
+
const i = X.valueToUint8Array(t);
|
|
2046
|
+
if (i.byteLength !== It)
|
|
2047
2047
|
throw new Error(`Invalid u256 value: ${t}`);
|
|
2048
2048
|
if (e)
|
|
2049
2049
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2055,9 +2055,9 @@ class C {
|
|
|
2055
2055
|
writeU128(t, e = !0) {
|
|
2056
2056
|
if (t > 340282366920938463463374607431768211455n && t < 0n)
|
|
2057
2057
|
throw new Error("u128 value is too large or negative.");
|
|
2058
|
-
this.allocSafe(
|
|
2059
|
-
const i =
|
|
2060
|
-
if (i.byteLength !==
|
|
2058
|
+
this.allocSafe(wt);
|
|
2059
|
+
const i = X.valueToUint8Array(t, wt);
|
|
2060
|
+
if (i.byteLength !== wt)
|
|
2061
2061
|
throw new Error(`Invalid u128 value: ${t}`);
|
|
2062
2062
|
if (e)
|
|
2063
2063
|
for (let r = 0; r < i.byteLength; r++)
|
|
@@ -2077,7 +2077,7 @@ class C {
|
|
|
2077
2077
|
}
|
|
2078
2078
|
writeStringWithLength(t) {
|
|
2079
2079
|
const i = new TextEncoder().encode(t);
|
|
2080
|
-
this.allocSafe(
|
|
2080
|
+
this.allocSafe(ht + i.length), this.writeU32(i.length), this.writeBytes(i);
|
|
2081
2081
|
}
|
|
2082
2082
|
writeAddress(t) {
|
|
2083
2083
|
this.verifyAddress(t), this.writeBytes(t);
|
|
@@ -2092,7 +2092,7 @@ class C {
|
|
|
2092
2092
|
this.currentOffset = 0, this.buffer = this.getDefaultBuffer(4);
|
|
2093
2093
|
}
|
|
2094
2094
|
toBytesReader() {
|
|
2095
|
-
return new
|
|
2095
|
+
return new qt(this.getBuffer());
|
|
2096
2096
|
}
|
|
2097
2097
|
getOffset() {
|
|
2098
2098
|
return this.currentOffset;
|
|
@@ -2120,7 +2120,7 @@ class C {
|
|
|
2120
2120
|
this.writeU32(t.length), this.writeBytes(t);
|
|
2121
2121
|
}
|
|
2122
2122
|
writeArrayOfBuffer(t, e = !0) {
|
|
2123
|
-
const i =
|
|
2123
|
+
const i = D.estimateArrayOfBufferLength(t);
|
|
2124
2124
|
this.allocSafe(i), this.writeU16(t.length, e);
|
|
2125
2125
|
for (let r = 0; r < t.length; r++)
|
|
2126
2126
|
this.writeU32(t[r].length, e), this.writeBytes(t[r]);
|
|
@@ -2180,9 +2180,9 @@ class C {
|
|
|
2180
2180
|
this.writeBytesWithLength(t[e]);
|
|
2181
2181
|
}
|
|
2182
2182
|
verifyAddress(t) {
|
|
2183
|
-
if (t.byteLength >
|
|
2183
|
+
if (t.byteLength > C)
|
|
2184
2184
|
throw new Error(
|
|
2185
|
-
`Address is too long ${t.byteLength} > ${
|
|
2185
|
+
`Address is too long ${t.byteLength} > ${C} bytes`
|
|
2186
2186
|
);
|
|
2187
2187
|
}
|
|
2188
2188
|
resize(t) {
|
|
@@ -2195,10 +2195,10 @@ class C {
|
|
|
2195
2195
|
return new DataView(new ArrayBuffer(t));
|
|
2196
2196
|
}
|
|
2197
2197
|
}
|
|
2198
|
-
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 || {}),
|
|
2199
|
-
class
|
|
2200
|
-
constructor(t, e, i =
|
|
2201
|
-
this.network =
|
|
2198
|
+
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
|
+
class q {
|
|
2200
|
+
constructor(t, e, i = I) {
|
|
2201
|
+
this.network = I, this.senderPubKey = t, this.contractSaltPubKey = e, this.network = i, this.xSenderPubKey = O(t);
|
|
2202
2202
|
}
|
|
2203
2203
|
static {
|
|
2204
2204
|
this.DATA_CHUNK_SIZE = 512;
|
|
@@ -2214,7 +2214,7 @@ class $ {
|
|
|
2214
2214
|
return i.writeUIntBE(e, 0, 3), a.from([this.senderPubKey[0], ...i]);
|
|
2215
2215
|
}
|
|
2216
2216
|
getHeader(t, e = []) {
|
|
2217
|
-
const i = new
|
|
2217
|
+
const i = new D(12);
|
|
2218
2218
|
return i.writeBytes(this.buildHeader(e)), i.writeU64(t), a.from(i.getBuffer());
|
|
2219
2219
|
}
|
|
2220
2220
|
/**
|
|
@@ -2224,7 +2224,7 @@ class $ {
|
|
|
2224
2224
|
* @protected
|
|
2225
2225
|
* @returns {Array<Buffer[]>} - The chunks
|
|
2226
2226
|
*/
|
|
2227
|
-
splitBufferIntoChunks(t, e =
|
|
2227
|
+
splitBufferIntoChunks(t, e = q.DATA_CHUNK_SIZE) {
|
|
2228
2228
|
const i = [];
|
|
2229
2229
|
for (let r = 0; r < t.length; r += e) {
|
|
2230
2230
|
const s = Math.min(e, t.length - r), o = a.alloc(s);
|
|
@@ -2250,7 +2250,7 @@ class $ {
|
|
|
2250
2250
|
}
|
|
2251
2251
|
}
|
|
2252
2252
|
encodeAccessListFeature(t, e) {
|
|
2253
|
-
const i = new
|
|
2253
|
+
const i = new D();
|
|
2254
2254
|
i.writeU16(Object.keys(t.data).length);
|
|
2255
2255
|
for (const r in t.data) {
|
|
2256
2256
|
const s = k.fromString(r), o = t.data[r];
|
|
@@ -2267,11 +2267,11 @@ class $ {
|
|
|
2267
2267
|
encodeChallengeSubmission(t, e) {
|
|
2268
2268
|
if ("verifySignature" in t.data && !t.data.verifySignature())
|
|
2269
2269
|
throw new Error("Invalid signature in challenge submission feature");
|
|
2270
|
-
const i = new
|
|
2270
|
+
const i = new D();
|
|
2271
2271
|
i.writeBytes(t.data.publicKey.toBuffer()), i.writeBytes(t.data.solution), t.data.graffiti && i.writeBytesWithLength(t.data.graffiti), e.writeBytesWithLength(i.getBuffer());
|
|
2272
2272
|
}
|
|
2273
2273
|
encodeLinkRequest(t, e) {
|
|
2274
|
-
const i = t.data, r = new
|
|
2274
|
+
const i = t.data, r = new D();
|
|
2275
2275
|
if (r.writeU8(i.level), r.writeBytes(i.hashedPublicKey), r.writeBoolean(i.verifyRequest), i.verifyRequest) {
|
|
2276
2276
|
if (!i.publicKey || !i.mldsaSignature)
|
|
2277
2277
|
throw new Error(
|
|
@@ -2284,8 +2284,8 @@ class $ {
|
|
|
2284
2284
|
r.writeBytes(i.legacySignature), e.writeBytesWithLength(r.getBuffer());
|
|
2285
2285
|
}
|
|
2286
2286
|
}
|
|
2287
|
-
class
|
|
2288
|
-
constructor(t, e, i =
|
|
2287
|
+
class oe extends q {
|
|
2288
|
+
constructor(t, e, i = I) {
|
|
2289
2289
|
super(t, e, i);
|
|
2290
2290
|
}
|
|
2291
2291
|
/**
|
|
@@ -2311,7 +2311,7 @@ class ce extends $ {
|
|
|
2311
2311
|
* Compile an interaction bitcoin script
|
|
2312
2312
|
* @param {Buffer} calldata - The calldata to use
|
|
2313
2313
|
* @param {Buffer} contractSecret - The contract secret
|
|
2314
|
-
* @param {
|
|
2314
|
+
* @param {IChallengeSolution} challenge
|
|
2315
2315
|
* @param maxPriority - Amount of satoshis to spend max on priority fee
|
|
2316
2316
|
* @param {Feature<Features>[]} featuresRaw - The features to use
|
|
2317
2317
|
* @returns {Buffer} - The compiled script
|
|
@@ -2325,7 +2325,7 @@ class ce extends $ {
|
|
|
2325
2325
|
if (s && s.length) {
|
|
2326
2326
|
const f = s.sort(
|
|
2327
2327
|
(S, b) => S.priority - b.priority
|
|
2328
|
-
), w = new
|
|
2328
|
+
), w = new D();
|
|
2329
2329
|
for (let S = 0; S < f.length; S++) {
|
|
2330
2330
|
const b = f[S];
|
|
2331
2331
|
c.push(b.opcode), this.encodeFeature(b, w);
|
|
@@ -2343,19 +2343,19 @@ class ce extends $ {
|
|
|
2343
2343
|
this.xSenderPubKey,
|
|
2344
2344
|
g.OP_DUP,
|
|
2345
2345
|
g.OP_HASH256,
|
|
2346
|
-
|
|
2346
|
+
Y(this.xSenderPubKey),
|
|
2347
2347
|
g.OP_EQUALVERIFY,
|
|
2348
2348
|
g.OP_CHECKSIGVERIFY,
|
|
2349
2349
|
this.contractSaltPubKey,
|
|
2350
2350
|
g.OP_CHECKSIGVERIFY,
|
|
2351
2351
|
g.OP_HASH160,
|
|
2352
|
-
|
|
2352
|
+
dt(e),
|
|
2353
2353
|
g.OP_EQUALVERIFY,
|
|
2354
2354
|
g.OP_DEPTH,
|
|
2355
2355
|
g.OP_1,
|
|
2356
2356
|
g.OP_NUMEQUAL,
|
|
2357
2357
|
g.OP_IF,
|
|
2358
|
-
|
|
2358
|
+
q.MAGIC
|
|
2359
2359
|
];
|
|
2360
2360
|
h = h.concat(
|
|
2361
2361
|
...u,
|
|
@@ -2366,13 +2366,13 @@ class ce extends $ {
|
|
|
2366
2366
|
g.OP_ENDIF
|
|
2367
2367
|
);
|
|
2368
2368
|
const l = h.flat(), d = L(l);
|
|
2369
|
-
if (!
|
|
2369
|
+
if (!R(d))
|
|
2370
2370
|
throw new Error("Failed to decompile script??");
|
|
2371
2371
|
return d;
|
|
2372
2372
|
}
|
|
2373
2373
|
}
|
|
2374
|
-
class
|
|
2375
|
-
constructor(t, e =
|
|
2374
|
+
class Re extends q {
|
|
2375
|
+
constructor(t, e = I) {
|
|
2376
2376
|
super(t, void 0, e);
|
|
2377
2377
|
}
|
|
2378
2378
|
/**
|
|
@@ -2383,14 +2383,14 @@ class We extends $ {
|
|
|
2383
2383
|
*/
|
|
2384
2384
|
compile(t) {
|
|
2385
2385
|
const e = t.flat(), i = L(e);
|
|
2386
|
-
if (!
|
|
2386
|
+
if (!R(i))
|
|
2387
2387
|
throw new Error("Failed to decompile script??");
|
|
2388
2388
|
return i;
|
|
2389
2389
|
}
|
|
2390
2390
|
}
|
|
2391
|
-
const
|
|
2392
|
-
class
|
|
2393
|
-
constructor(t, e, i =
|
|
2391
|
+
const We = 0, Me = a.from([We]);
|
|
2392
|
+
class Ft extends q {
|
|
2393
|
+
constructor(t, e, i = I) {
|
|
2394
2394
|
super(t, e, i);
|
|
2395
2395
|
}
|
|
2396
2396
|
/**
|
|
@@ -2412,7 +2412,7 @@ class Nt extends $ {
|
|
|
2412
2412
|
s,
|
|
2413
2413
|
o
|
|
2414
2414
|
), u = L(c);
|
|
2415
|
-
if (!
|
|
2415
|
+
if (!R(u))
|
|
2416
2416
|
throw new Error("Failed to decompile script??");
|
|
2417
2417
|
return u;
|
|
2418
2418
|
}
|
|
@@ -2422,7 +2422,7 @@ class Nt extends $ {
|
|
|
2422
2422
|
if (o && o.length) {
|
|
2423
2423
|
const p = o.sort(
|
|
2424
2424
|
(w, S) => w.priority - S.priority
|
|
2425
|
-
), f = new
|
|
2425
|
+
), f = new D();
|
|
2426
2426
|
for (let w = 0; w < p.length; w++) {
|
|
2427
2427
|
const S = p[w];
|
|
2428
2428
|
h.push(S.opcode), this.encodeFeature(S, f);
|
|
@@ -2440,19 +2440,19 @@ class Nt extends $ {
|
|
|
2440
2440
|
this.xSenderPubKey,
|
|
2441
2441
|
g.OP_DUP,
|
|
2442
2442
|
g.OP_HASH256,
|
|
2443
|
-
|
|
2443
|
+
Y(this.xSenderPubKey),
|
|
2444
2444
|
g.OP_EQUALVERIFY,
|
|
2445
2445
|
g.OP_CHECKSIGVERIFY,
|
|
2446
2446
|
this.contractSaltPubKey,
|
|
2447
2447
|
g.OP_CHECKSIGVERIFY,
|
|
2448
2448
|
g.OP_HASH256,
|
|
2449
|
-
|
|
2449
|
+
Y(e),
|
|
2450
2450
|
g.OP_EQUALVERIFY,
|
|
2451
2451
|
g.OP_DEPTH,
|
|
2452
2452
|
g.OP_1,
|
|
2453
2453
|
g.OP_NUMEQUAL,
|
|
2454
2454
|
g.OP_IF,
|
|
2455
|
-
|
|
2455
|
+
q.MAGIC,
|
|
2456
2456
|
...l,
|
|
2457
2457
|
g.OP_0,
|
|
2458
2458
|
...u,
|
|
@@ -2464,8 +2464,8 @@ class Nt extends $ {
|
|
|
2464
2464
|
].flat();
|
|
2465
2465
|
}
|
|
2466
2466
|
}
|
|
2467
|
-
class E extends
|
|
2468
|
-
constructor(t, e =
|
|
2467
|
+
class E extends ve {
|
|
2468
|
+
constructor(t, e = I) {
|
|
2469
2469
|
if (super(), this.logColor = "#4a90d9", t.length !== 33)
|
|
2470
2470
|
throw new Error("Public key must be 33 bytes (compressed)");
|
|
2471
2471
|
this.publicKey = t, this.network = e;
|
|
@@ -2561,7 +2561,7 @@ class E extends ke {
|
|
|
2561
2561
|
*/
|
|
2562
2562
|
static validateHashCommittedScript(t) {
|
|
2563
2563
|
try {
|
|
2564
|
-
const e =
|
|
2564
|
+
const e = R(t);
|
|
2565
2565
|
if (!e || e.length < 5)
|
|
2566
2566
|
return !1;
|
|
2567
2567
|
const i = e.length - 1;
|
|
@@ -2591,7 +2591,7 @@ class E extends ke {
|
|
|
2591
2591
|
*/
|
|
2592
2592
|
static extractDataHashes(t) {
|
|
2593
2593
|
try {
|
|
2594
|
-
const e =
|
|
2594
|
+
const e = R(t);
|
|
2595
2595
|
if (!e || !E.validateHashCommittedScript(t))
|
|
2596
2596
|
return null;
|
|
2597
2597
|
const i = e.slice(0, -2), r = [];
|
|
@@ -2610,7 +2610,7 @@ class E extends ke {
|
|
|
2610
2610
|
*/
|
|
2611
2611
|
static extractPublicKey(t) {
|
|
2612
2612
|
try {
|
|
2613
|
-
const e =
|
|
2613
|
+
const e = R(t);
|
|
2614
2614
|
return !e || !E.validateHashCommittedScript(t) ? null : e[e.length - 2];
|
|
2615
2615
|
} catch {
|
|
2616
2616
|
return null;
|
|
@@ -2628,7 +2628,7 @@ class E extends ke {
|
|
|
2628
2628
|
if (!i || i.length !== t.length)
|
|
2629
2629
|
return !1;
|
|
2630
2630
|
for (let r = 0; r < t.length; r++) {
|
|
2631
|
-
const s =
|
|
2631
|
+
const s = dt(t[r]);
|
|
2632
2632
|
if (!i[r].equals(s))
|
|
2633
2633
|
return !1;
|
|
2634
2634
|
}
|
|
@@ -2643,7 +2643,7 @@ class E extends ke {
|
|
|
2643
2643
|
* @returns Fee estimates
|
|
2644
2644
|
*/
|
|
2645
2645
|
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)), w = BigInt(Math.ceil(p * e)), S = f + w, b = BigInt(s) * E.MIN_OUTPUT_VALUE,
|
|
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)), w = BigInt(Math.ceil(p * e)), S = f + w, b = BigInt(s) * E.MIN_OUTPUT_VALUE, _ = S + b;
|
|
2647
2647
|
return {
|
|
2648
2648
|
compressedSize: r,
|
|
2649
2649
|
outputCount: s,
|
|
@@ -2654,7 +2654,7 @@ class E extends ke {
|
|
|
2654
2654
|
revealFee: w,
|
|
2655
2655
|
totalFee: S,
|
|
2656
2656
|
outputsValue: b,
|
|
2657
|
-
totalCost:
|
|
2657
|
+
totalCost: _
|
|
2658
2658
|
};
|
|
2659
2659
|
}
|
|
2660
2660
|
/**
|
|
@@ -2662,7 +2662,7 @@ class E extends ke {
|
|
|
2662
2662
|
* HASH160 = RIPEMD160(SHA256(data))
|
|
2663
2663
|
*/
|
|
2664
2664
|
hashChunk(t) {
|
|
2665
|
-
return
|
|
2665
|
+
return dt(t);
|
|
2666
2666
|
}
|
|
2667
2667
|
/**
|
|
2668
2668
|
* Generate a hash-committed witness script for multiple data chunks.
|
|
@@ -2703,7 +2703,7 @@ class E extends ke {
|
|
|
2703
2703
|
* @returns P2WSH address info
|
|
2704
2704
|
*/
|
|
2705
2705
|
generateP2WSHAddress(t) {
|
|
2706
|
-
const e =
|
|
2706
|
+
const e = lt({
|
|
2707
2707
|
redeem: { output: t },
|
|
2708
2708
|
network: this.network
|
|
2709
2709
|
});
|
|
@@ -2760,8 +2760,8 @@ class E extends ke {
|
|
|
2760
2760
|
), s;
|
|
2761
2761
|
}
|
|
2762
2762
|
}
|
|
2763
|
-
class
|
|
2764
|
-
constructor(t, e =
|
|
2763
|
+
class Ji extends q {
|
|
2764
|
+
constructor(t, e = I) {
|
|
2765
2765
|
super(t, a.alloc(0), e);
|
|
2766
2766
|
}
|
|
2767
2767
|
/**
|
|
@@ -2800,7 +2800,7 @@ class wr extends $ {
|
|
|
2800
2800
|
if (s && s.length) {
|
|
2801
2801
|
const f = s.sort(
|
|
2802
2802
|
(S, b) => S.priority - b.priority
|
|
2803
|
-
), w = new
|
|
2803
|
+
), w = new D();
|
|
2804
2804
|
for (let S = 0; S < f.length; S++) {
|
|
2805
2805
|
const b = f[S];
|
|
2806
2806
|
c.push(b.opcode), this.encodeFeature(b, w);
|
|
@@ -2816,7 +2816,7 @@ class wr extends $ {
|
|
|
2816
2816
|
this.senderPubKey,
|
|
2817
2817
|
g.OP_DUP,
|
|
2818
2818
|
g.OP_HASH256,
|
|
2819
|
-
|
|
2819
|
+
Y(this.senderPubKey),
|
|
2820
2820
|
g.OP_EQUALVERIFY,
|
|
2821
2821
|
g.OP_CHECKSIGVERIFY,
|
|
2822
2822
|
e,
|
|
@@ -2825,7 +2825,7 @@ class wr extends $ {
|
|
|
2825
2825
|
g.OP_1,
|
|
2826
2826
|
g.OP_NUMEQUAL,
|
|
2827
2827
|
g.OP_IF,
|
|
2828
|
-
|
|
2828
|
+
q.MAGIC
|
|
2829
2829
|
];
|
|
2830
2830
|
h = h.concat(
|
|
2831
2831
|
...u,
|
|
@@ -2836,12 +2836,12 @@ class wr extends $ {
|
|
|
2836
2836
|
g.OP_ENDIF
|
|
2837
2837
|
);
|
|
2838
2838
|
const l = h.flat(), d = L(l);
|
|
2839
|
-
if (!
|
|
2839
|
+
if (!R(d))
|
|
2840
2840
|
throw new Error("Failed to decompile script??");
|
|
2841
2841
|
return d;
|
|
2842
2842
|
}
|
|
2843
2843
|
}
|
|
2844
|
-
class
|
|
2844
|
+
class Pt {
|
|
2845
2845
|
static {
|
|
2846
2846
|
this.MAXIMUM_SUPPORTED_SIGNATURE = 255;
|
|
2847
2847
|
}
|
|
@@ -2850,9 +2850,9 @@ class At {
|
|
|
2850
2850
|
throw new Error("Minimum signatures must be greater than 1");
|
|
2851
2851
|
if (t.length < e)
|
|
2852
2852
|
throw new Error("The amount of public keys is lower than the minimum required");
|
|
2853
|
-
if (e >
|
|
2853
|
+
if (e > Pt.MAXIMUM_SUPPORTED_SIGNATURE)
|
|
2854
2854
|
throw new Error(
|
|
2855
|
-
`The maximum amount of signatures is ${
|
|
2855
|
+
`The maximum amount of signatures is ${Pt.MAXIMUM_SUPPORTED_SIGNATURE}`
|
|
2856
2856
|
);
|
|
2857
2857
|
const r = a.alloc(1);
|
|
2858
2858
|
r.writeUInt8(e), t = t.filter(
|
|
@@ -2879,16 +2879,16 @@ class At {
|
|
|
2879
2879
|
g.OP_NUMEQUAL
|
|
2880
2880
|
// Use NUMEQUALVERIFY to ensure the correct number of signatures
|
|
2881
2881
|
].flat(), h = L(u);
|
|
2882
|
-
if (!
|
|
2882
|
+
if (!R(h))
|
|
2883
2883
|
throw new Error("Failed to decompile script.");
|
|
2884
2884
|
return h;
|
|
2885
2885
|
}
|
|
2886
2886
|
}
|
|
2887
|
-
class
|
|
2887
|
+
class Et extends q {
|
|
2888
2888
|
static {
|
|
2889
2889
|
this.P2WDA_VERSION = 1;
|
|
2890
2890
|
}
|
|
2891
|
-
constructor(t, e, i =
|
|
2891
|
+
constructor(t, e, i = I) {
|
|
2892
2892
|
super(t, e, i);
|
|
2893
2893
|
}
|
|
2894
2894
|
/**
|
|
@@ -2924,8 +2924,8 @@ class Ot extends $ {
|
|
|
2924
2924
|
throw new Error("Contract salt public key not set");
|
|
2925
2925
|
if (e.length !== 32)
|
|
2926
2926
|
throw new Error("Contract secret must be exactly 32 bytes");
|
|
2927
|
-
const o = new
|
|
2928
|
-
o.writeU8(
|
|
2927
|
+
const o = new D();
|
|
2928
|
+
o.writeU8(Et.P2WDA_VERSION);
|
|
2929
2929
|
const c = s.sort((u, h) => u.priority - h.priority);
|
|
2930
2930
|
return o.writeBytes(
|
|
2931
2931
|
this.getHeader(
|
|
@@ -2952,32 +2952,32 @@ class Ot extends $ {
|
|
|
2952
2952
|
t.writeU8(i.opcode), this.encodeFeature(i, t);
|
|
2953
2953
|
}
|
|
2954
2954
|
}
|
|
2955
|
-
|
|
2956
|
-
class
|
|
2955
|
+
ot(G);
|
|
2956
|
+
class ae {
|
|
2957
2957
|
// Generate a valid SegWit address from random bytes
|
|
2958
2958
|
static generatePKSH(t, e) {
|
|
2959
2959
|
if (t.length !== 32) throw new Error("Invalid hash length");
|
|
2960
|
-
const i =
|
|
2960
|
+
const i = bi(t);
|
|
2961
2961
|
return this.toSegwitAddress(i, e);
|
|
2962
2962
|
}
|
|
2963
2963
|
// Generate a valid Taproot address from a public key
|
|
2964
2964
|
static generateTaprootAddress(t, e) {
|
|
2965
2965
|
if (t.length !== 32) throw new Error("Invalid public key length");
|
|
2966
|
-
const i =
|
|
2967
|
-
return i.unshift(1),
|
|
2966
|
+
const i = Lt.bech32m.toWords(t);
|
|
2967
|
+
return i.unshift(1), Lt.bech32m.encode(e.bech32, i);
|
|
2968
2968
|
}
|
|
2969
2969
|
// Convert a hash to a SegWit address
|
|
2970
2970
|
static toSegwitAddress(t, e) {
|
|
2971
|
-
const i =
|
|
2972
|
-
return i.unshift(0),
|
|
2971
|
+
const i = Lt.bech32.toWords(t);
|
|
2972
|
+
return i.unshift(0), Lt.bech32.encode(e.bech32, i);
|
|
2973
2973
|
}
|
|
2974
2974
|
}
|
|
2975
|
-
class
|
|
2975
|
+
class tt {
|
|
2976
2976
|
static {
|
|
2977
2977
|
this.TAP_SCRIPT_VERSION = 192;
|
|
2978
2978
|
}
|
|
2979
2979
|
static getContractAddress(t) {
|
|
2980
|
-
const e = t.network ||
|
|
2980
|
+
const e = t.network || I, r = new Ft(
|
|
2981
2981
|
t.deployerPubKey,
|
|
2982
2982
|
O(t.contractSaltPubKey),
|
|
2983
2983
|
e
|
|
@@ -2994,17 +2994,17 @@ class et {
|
|
|
2994
2994
|
]), o = [
|
|
2995
2995
|
{
|
|
2996
2996
|
output: r,
|
|
2997
|
-
version:
|
|
2997
|
+
version: tt.TAP_SCRIPT_VERSION
|
|
2998
2998
|
},
|
|
2999
2999
|
{
|
|
3000
3000
|
output: s,
|
|
3001
|
-
version:
|
|
3001
|
+
version: tt.TAP_SCRIPT_VERSION
|
|
3002
3002
|
}
|
|
3003
3003
|
];
|
|
3004
|
-
return
|
|
3004
|
+
return tt.generateAddressFromScript(t, o);
|
|
3005
3005
|
}
|
|
3006
3006
|
static verifyControlBlock(t, e) {
|
|
3007
|
-
const i = t.network ||
|
|
3007
|
+
const i = t.network || I, s = new Ft(
|
|
3008
3008
|
t.deployerPubKey,
|
|
3009
3009
|
O(t.contractSaltPubKey),
|
|
3010
3010
|
i
|
|
@@ -3021,38 +3021,38 @@ class et {
|
|
|
3021
3021
|
]), c = [
|
|
3022
3022
|
{
|
|
3023
3023
|
output: s,
|
|
3024
|
-
version:
|
|
3024
|
+
version: tt.TAP_SCRIPT_VERSION
|
|
3025
3025
|
},
|
|
3026
3026
|
{
|
|
3027
3027
|
output: o,
|
|
3028
|
-
version:
|
|
3028
|
+
version: tt.TAP_SCRIPT_VERSION
|
|
3029
3029
|
}
|
|
3030
|
-
], h =
|
|
3030
|
+
], h = rt({
|
|
3031
3031
|
internalPubkey: O(t.deployerPubKey),
|
|
3032
3032
|
network: i,
|
|
3033
3033
|
scriptTree: c,
|
|
3034
3034
|
redeem: {
|
|
3035
3035
|
output: s,
|
|
3036
|
-
redeemVersion:
|
|
3036
|
+
redeemVersion: tt.TAP_SCRIPT_VERSION
|
|
3037
3037
|
}
|
|
3038
3038
|
}).witness;
|
|
3039
3039
|
return !h || h.length === 0 ? !1 : h[h.length - 1].equals(e);
|
|
3040
3040
|
}
|
|
3041
3041
|
static getContractSeed(t, e, i) {
|
|
3042
|
-
const r =
|
|
3043
|
-
return
|
|
3042
|
+
const r = Y(e), s = a.concat([t, i, r]);
|
|
3043
|
+
return Y(s);
|
|
3044
3044
|
}
|
|
3045
3045
|
static generateAddressFromScript(t, e) {
|
|
3046
|
-
const i = t.network ||
|
|
3046
|
+
const i = t.network || I, r = {
|
|
3047
3047
|
internalPubkey: O(t.deployerPubKey),
|
|
3048
3048
|
network: i,
|
|
3049
3049
|
scriptTree: e
|
|
3050
3050
|
};
|
|
3051
|
-
return
|
|
3051
|
+
return rt(r).address;
|
|
3052
3052
|
}
|
|
3053
3053
|
}
|
|
3054
|
-
|
|
3055
|
-
class
|
|
3054
|
+
ot(G);
|
|
3055
|
+
class ce {
|
|
3056
3056
|
/**
|
|
3057
3057
|
* Tweak a signer
|
|
3058
3058
|
* @param {Signer} signer - The signer to tweak
|
|
@@ -3063,22 +3063,22 @@ class he {
|
|
|
3063
3063
|
let i = t.privateKey;
|
|
3064
3064
|
if (!i)
|
|
3065
3065
|
throw new Error("Private key is required for tweaking signer!");
|
|
3066
|
-
t.publicKey[0] === 3 && (i =
|
|
3067
|
-
const r =
|
|
3066
|
+
t.publicKey[0] === 3 && (i = Kt.privateNegate(i));
|
|
3067
|
+
const r = Kt.privateAdd(
|
|
3068
3068
|
i,
|
|
3069
|
-
|
|
3069
|
+
Ii(O(a.from(t.publicKey)), e.tweakHash)
|
|
3070
3070
|
);
|
|
3071
3071
|
if (!r)
|
|
3072
3072
|
throw new Error("Invalid tweaked private key!");
|
|
3073
3073
|
return A.fromPrivateKey(a.from(r), e.network);
|
|
3074
3074
|
}
|
|
3075
3075
|
}
|
|
3076
|
-
function
|
|
3076
|
+
function Ne(n) {
|
|
3077
3077
|
return typeof n == "object" && n !== null && "web3" in n && typeof n.web3 == "object" && "getMLDSAPublicKey" in n.web3 && "signMLDSAMessage" in n.web3;
|
|
3078
3078
|
}
|
|
3079
|
-
class
|
|
3079
|
+
class tr {
|
|
3080
3080
|
sha256(t) {
|
|
3081
|
-
return
|
|
3081
|
+
return Ue(a.from(t));
|
|
3082
3082
|
}
|
|
3083
3083
|
/**
|
|
3084
3084
|
* Attempts to sign a message using OP_WALLET if available in browser environment.
|
|
@@ -3206,7 +3206,7 @@ class yr {
|
|
|
3206
3206
|
* @returns {SignedMessage} The Schnorr signature.
|
|
3207
3207
|
*/
|
|
3208
3208
|
tweakAndSignMessage(t, e, i) {
|
|
3209
|
-
const r =
|
|
3209
|
+
const r = ce.tweakSigner(t, { network: i });
|
|
3210
3210
|
return this.signMessage(r, e);
|
|
3211
3211
|
}
|
|
3212
3212
|
/**
|
|
@@ -3221,7 +3221,7 @@ class yr {
|
|
|
3221
3221
|
throw new Error("Private key not found in keypair.");
|
|
3222
3222
|
const i = this.sha256(e);
|
|
3223
3223
|
return {
|
|
3224
|
-
signature:
|
|
3224
|
+
signature: Kt.signSchnorr(i, t.privateKey),
|
|
3225
3225
|
message: i
|
|
3226
3226
|
};
|
|
3227
3227
|
}
|
|
@@ -3237,7 +3237,7 @@ class yr {
|
|
|
3237
3237
|
if (typeof e == "string" && (e = a.from(e, "utf-8")), i.length !== 64)
|
|
3238
3238
|
throw new Error("Invalid signature length.");
|
|
3239
3239
|
const r = this.sha256(e);
|
|
3240
|
-
return
|
|
3240
|
+
return Kt.verifySchnorr(r, O(a.from(t)), i);
|
|
3241
3241
|
}
|
|
3242
3242
|
/**
|
|
3243
3243
|
* Tweak the public key and verify a signature.
|
|
@@ -3292,12 +3292,12 @@ class yr {
|
|
|
3292
3292
|
if (typeof window > "u")
|
|
3293
3293
|
return null;
|
|
3294
3294
|
const t = window;
|
|
3295
|
-
return !t.opnet || !
|
|
3295
|
+
return !t.opnet || !Ne(t.opnet) ? null : t.opnet;
|
|
3296
3296
|
}
|
|
3297
3297
|
}
|
|
3298
|
-
const
|
|
3299
|
-
|
|
3300
|
-
class
|
|
3298
|
+
const st = new tr();
|
|
3299
|
+
ot(G);
|
|
3300
|
+
class Z {
|
|
3301
3301
|
/**
|
|
3302
3302
|
* Create a new Wallet instance
|
|
3303
3303
|
*
|
|
@@ -3308,7 +3308,7 @@ class J {
|
|
|
3308
3308
|
* @param chainCode - Optional chain code for BIP32 derivation (32 bytes)
|
|
3309
3309
|
* @throws {Error} If the private keys are invalid
|
|
3310
3310
|
*/
|
|
3311
|
-
constructor(t, e, i =
|
|
3311
|
+
constructor(t, e, i = I, r = P.MLDSASecurityLevel.LEVEL2, s) {
|
|
3312
3312
|
this.network = i, this._securityLevel = r;
|
|
3313
3313
|
const o = t.startsWith("0x") ? t.replace("0x", "") : t;
|
|
3314
3314
|
K.isValidHex(o) ? this._keypair = A.fromPrivateKey(
|
|
@@ -3464,8 +3464,8 @@ class J {
|
|
|
3464
3464
|
* @param chainCode - Optional chain code for BIP32 derivation
|
|
3465
3465
|
* @returns A Wallet instance
|
|
3466
3466
|
*/
|
|
3467
|
-
static fromWif(t, e, i =
|
|
3468
|
-
return new
|
|
3467
|
+
static fromWif(t, e, i = I, r = P.MLDSASecurityLevel.LEVEL2, s) {
|
|
3468
|
+
return new Z(t, e, i, r, s);
|
|
3469
3469
|
}
|
|
3470
3470
|
/**
|
|
3471
3471
|
* Generate a new random wallet with both classical and quantum keys
|
|
@@ -3474,11 +3474,11 @@ class J {
|
|
|
3474
3474
|
* @param securityLevel - The ML-DSA security level (default: LEVEL2/44)
|
|
3475
3475
|
* @returns A new Wallet instance with randomly generated keys
|
|
3476
3476
|
*/
|
|
3477
|
-
static generate(t =
|
|
3477
|
+
static generate(t = I, e = P.MLDSASecurityLevel.LEVEL2) {
|
|
3478
3478
|
const i = A.generateWallet(t, e);
|
|
3479
3479
|
if (!i.quantumPrivateKey)
|
|
3480
3480
|
throw new Error("Failed to generate quantum keys");
|
|
3481
|
-
return new
|
|
3481
|
+
return new Z(
|
|
3482
3482
|
i.privateKey,
|
|
3483
3483
|
i.quantumPrivateKey,
|
|
3484
3484
|
t,
|
|
@@ -3495,8 +3495,8 @@ class J {
|
|
|
3495
3495
|
* @param chainCode - Optional chain code for BIP32 derivation
|
|
3496
3496
|
* @returns A Wallet instance
|
|
3497
3497
|
*/
|
|
3498
|
-
static fromPrivateKeys(t, e, i =
|
|
3499
|
-
return new
|
|
3498
|
+
static fromPrivateKeys(t, e, i = I, r = P.MLDSASecurityLevel.LEVEL2, s) {
|
|
3499
|
+
return new Z(
|
|
3500
3500
|
t,
|
|
3501
3501
|
e,
|
|
3502
3502
|
i,
|
|
@@ -3558,7 +3558,7 @@ class J {
|
|
|
3558
3558
|
throw new Error("Failed to derive classical private key");
|
|
3559
3559
|
if (!r.chainCode)
|
|
3560
3560
|
throw new Error("Failed to derive classical chain code");
|
|
3561
|
-
return new
|
|
3561
|
+
return new Z(
|
|
3562
3562
|
a.from(r.privateKey).toString("hex"),
|
|
3563
3563
|
e.toBase58(),
|
|
3564
3564
|
this.network,
|
|
@@ -3567,8 +3567,8 @@ class J {
|
|
|
3567
3567
|
);
|
|
3568
3568
|
}
|
|
3569
3569
|
}
|
|
3570
|
-
var
|
|
3571
|
-
function
|
|
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 || {}), mt = /* @__PURE__ */ ((n) => (n[n.BIP44 = 44] = "BIP44", n[n.BIP49 = 49] = "BIP49", n[n.BIP84 = 84] = "BIP84", n[n.BIP86 = 86] = "BIP86", n))(mt || {});
|
|
3571
|
+
function er(n) {
|
|
3572
3572
|
switch (n) {
|
|
3573
3573
|
case 44:
|
|
3574
3574
|
return "BIP44: Legacy addresses (P2PKH), widely used by Unisat and other wallets";
|
|
@@ -3582,12 +3582,12 @@ function mr(n) {
|
|
|
3582
3582
|
return "Unknown BIP standard";
|
|
3583
3583
|
}
|
|
3584
3584
|
}
|
|
3585
|
-
function
|
|
3585
|
+
function He(n, t, e, i, r) {
|
|
3586
3586
|
return `m/${n}'/${t}'/${e}'/${i}/${r}`;
|
|
3587
3587
|
}
|
|
3588
|
-
|
|
3589
|
-
const
|
|
3590
|
-
class
|
|
3588
|
+
ot(G);
|
|
3589
|
+
const ir = P.BIP32Factory(G);
|
|
3590
|
+
class ue {
|
|
3591
3591
|
/**
|
|
3592
3592
|
* Create a new Mnemonic instance from an existing phrase
|
|
3593
3593
|
*
|
|
@@ -3597,10 +3597,10 @@ class le {
|
|
|
3597
3597
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
3598
3598
|
* @throws {Error} If the mnemonic phrase is invalid
|
|
3599
3599
|
*/
|
|
3600
|
-
constructor(t, e = "", i =
|
|
3601
|
-
if (!
|
|
3600
|
+
constructor(t, e = "", i = I, r = P.MLDSASecurityLevel.LEVEL2) {
|
|
3601
|
+
if (!pt.validateMnemonic(t))
|
|
3602
3602
|
throw new Error("Invalid mnemonic phrase");
|
|
3603
|
-
this._phrase = t, this._passphrase = e, this._network = i, this._securityLevel = r, this._seed =
|
|
3603
|
+
this._phrase = t, this._passphrase = e, this._network = i, this._securityLevel = r, this._seed = pt.mnemonicToSeedSync(this._phrase, this._passphrase), this._classicalRoot = ir.fromSeed(this._seed, this._network), this._quantumRoot = P.QuantumBIP32Factory.fromSeed(
|
|
3604
3604
|
this._seed,
|
|
3605
3605
|
this._network,
|
|
3606
3606
|
this._securityLevel
|
|
@@ -3646,8 +3646,8 @@ class le {
|
|
|
3646
3646
|
* @param strength - The entropy strength in bits (default: 256 for 24 words)
|
|
3647
3647
|
* @returns A new random mnemonic phrase
|
|
3648
3648
|
*/
|
|
3649
|
-
static generatePhrase(t =
|
|
3650
|
-
return
|
|
3649
|
+
static generatePhrase(t = Rt.MAXIMUM) {
|
|
3650
|
+
return pt.generateMnemonic(t);
|
|
3651
3651
|
}
|
|
3652
3652
|
/**
|
|
3653
3653
|
* Generate a new Mnemonic instance with a random phrase
|
|
@@ -3658,9 +3658,9 @@ class le {
|
|
|
3658
3658
|
* @param securityLevel - The ML-DSA security level for quantum keys (default: LEVEL2/44)
|
|
3659
3659
|
* @returns A new Mnemonic instance
|
|
3660
3660
|
*/
|
|
3661
|
-
static generate(t =
|
|
3662
|
-
const s =
|
|
3663
|
-
return new
|
|
3661
|
+
static generate(t = Rt.MAXIMUM, e = "", i = I, r = P.MLDSASecurityLevel.LEVEL2) {
|
|
3662
|
+
const s = pt.generateMnemonic(t);
|
|
3663
|
+
return new ue(s, e, i, r);
|
|
3664
3664
|
}
|
|
3665
3665
|
/**
|
|
3666
3666
|
* Validate a mnemonic phrase
|
|
@@ -3669,7 +3669,7 @@ class le {
|
|
|
3669
3669
|
* @returns True if the phrase is valid, false otherwise
|
|
3670
3670
|
*/
|
|
3671
3671
|
static validate(t) {
|
|
3672
|
-
return
|
|
3672
|
+
return pt.validateMnemonic(t);
|
|
3673
3673
|
}
|
|
3674
3674
|
/**
|
|
3675
3675
|
* Derive a wallet at a specific index using BIP360 (quantum) and configurable BIP standard (classical) paths
|
|
@@ -3695,14 +3695,14 @@ class le {
|
|
|
3695
3695
|
* const wallet3 = mnemonic.derive(0, 0, false, BIPStandard.BIP86);
|
|
3696
3696
|
* ```
|
|
3697
3697
|
*/
|
|
3698
|
-
derive(t = 0, e = 0, i = !1, r =
|
|
3698
|
+
derive(t = 0, e = 0, i = !1, r = mt.BIP84) {
|
|
3699
3699
|
const s = this.buildClassicalPath(e, t, i, r), o = this._classicalRoot.derivePath(s);
|
|
3700
3700
|
if (!o.privateKey)
|
|
3701
3701
|
throw new Error(`Failed to derive classical private key at index ${t}`);
|
|
3702
3702
|
const c = this.buildQuantumPath(e, t, i), u = this._quantumRoot.derivePath(c);
|
|
3703
3703
|
if (!u.privateKey)
|
|
3704
3704
|
throw new Error(`Failed to derive quantum private key at index ${t}`);
|
|
3705
|
-
return new
|
|
3705
|
+
return new Z(
|
|
3706
3706
|
a.from(o.privateKey).toString("hex"),
|
|
3707
3707
|
a.from(u.privateKey).toString("hex"),
|
|
3708
3708
|
this._network,
|
|
@@ -3725,19 +3725,19 @@ class le {
|
|
|
3725
3725
|
* @param isChange - Whether this is a change address (default: false)
|
|
3726
3726
|
* @returns A Wallet instance with both classical and quantum keys
|
|
3727
3727
|
*/
|
|
3728
|
-
deriveUnisat(t =
|
|
3728
|
+
deriveUnisat(t = J.P2TR, e = 0, i = 0, r = !1) {
|
|
3729
3729
|
let s;
|
|
3730
3730
|
switch (t) {
|
|
3731
|
-
case
|
|
3731
|
+
case J.P2PKH:
|
|
3732
3732
|
s = 44;
|
|
3733
3733
|
break;
|
|
3734
|
-
case
|
|
3734
|
+
case J.P2SH_OR_P2SH_P2WPKH:
|
|
3735
3735
|
s = 49;
|
|
3736
3736
|
break;
|
|
3737
|
-
case
|
|
3737
|
+
case J.P2WPKH:
|
|
3738
3738
|
s = 84;
|
|
3739
3739
|
break;
|
|
3740
|
-
case
|
|
3740
|
+
case J.P2TR:
|
|
3741
3741
|
s = 86;
|
|
3742
3742
|
break;
|
|
3743
3743
|
default:
|
|
@@ -3749,7 +3749,7 @@ class le {
|
|
|
3749
3749
|
const l = `m/360'/${o}'/${i}'/${c}/${e}`, d = this._quantumRoot.derivePath(l);
|
|
3750
3750
|
if (!d.privateKey)
|
|
3751
3751
|
throw new Error(`Failed to derive quantum private key at path ${l}`);
|
|
3752
|
-
return new
|
|
3752
|
+
return new Z(
|
|
3753
3753
|
a.from(h.privateKey).toString("hex"),
|
|
3754
3754
|
a.from(d.privateKey).toString("hex"),
|
|
3755
3755
|
this._network,
|
|
@@ -3767,7 +3767,7 @@ class le {
|
|
|
3767
3767
|
* @param isChange - Whether these are change addresses (default: false)
|
|
3768
3768
|
* @returns Array of Wallet instances
|
|
3769
3769
|
*/
|
|
3770
|
-
deriveMultipleUnisat(t =
|
|
3770
|
+
deriveMultipleUnisat(t = J.P2TR, e = 5, i = 0, r = 0, s = !1) {
|
|
3771
3771
|
const o = [];
|
|
3772
3772
|
for (let c = 0; c < e; c++)
|
|
3773
3773
|
o.push(this.deriveUnisat(t, i + c, r, s));
|
|
@@ -3783,7 +3783,7 @@ class le {
|
|
|
3783
3783
|
* @param bipStandard - The BIP standard to use for classical derivation (default: BIP84)
|
|
3784
3784
|
* @returns An array of Wallet instances
|
|
3785
3785
|
*/
|
|
3786
|
-
deriveMultiple(t, e = 0, i = 0, r = !1, s =
|
|
3786
|
+
deriveMultiple(t, e = 0, i = 0, r = !1, s = mt.BIP84) {
|
|
3787
3787
|
const o = [];
|
|
3788
3788
|
for (let c = 0; c < t; c++)
|
|
3789
3789
|
o.push(this.derive(e + c, i, r, s));
|
|
@@ -3802,7 +3802,7 @@ class le {
|
|
|
3802
3802
|
throw new Error(`Failed to derive classical private key at path ${t}`);
|
|
3803
3803
|
if (!r.privateKey)
|
|
3804
3804
|
throw new Error(`Failed to derive quantum private key at path ${e}`);
|
|
3805
|
-
return new
|
|
3805
|
+
return new Z(
|
|
3806
3806
|
a.from(i.privateKey).toString("hex"),
|
|
3807
3807
|
a.from(r.privateKey).toString("hex"),
|
|
3808
3808
|
this._network,
|
|
@@ -3835,9 +3835,9 @@ class le {
|
|
|
3835
3835
|
* @param bipStandard - The BIP standard to use (default: BIP84)
|
|
3836
3836
|
* @returns The derivation path string
|
|
3837
3837
|
*/
|
|
3838
|
-
buildClassicalPath(t, e, i, r =
|
|
3838
|
+
buildClassicalPath(t, e, i, r = mt.BIP84) {
|
|
3839
3839
|
const s = this.getCoinType();
|
|
3840
|
-
return
|
|
3840
|
+
return He(r, s, t, i ? 1 : 0, e);
|
|
3841
3841
|
}
|
|
3842
3842
|
/**
|
|
3843
3843
|
* Build a quantum derivation path (BIP360)
|
|
@@ -3856,11 +3856,11 @@ class le {
|
|
|
3856
3856
|
* @returns The coin type (0 for mainnet, 1 for testnet/regtest)
|
|
3857
3857
|
*/
|
|
3858
3858
|
getCoinType() {
|
|
3859
|
-
return this._network.bech32 ===
|
|
3859
|
+
return this._network.bech32 === At.bech32 || this._network.bech32 === zt.bech32 ? 1 : 0;
|
|
3860
3860
|
}
|
|
3861
3861
|
}
|
|
3862
|
-
var
|
|
3863
|
-
function
|
|
3862
|
+
var Ve = /* @__PURE__ */ ((n) => (n[n.MLDSA44 = 1312] = "MLDSA44", n[n.MLDSA65 = 1952] = "MLDSA65", n[n.MLDSA87 = 2592] = "MLDSA87", n))(Ve || {});
|
|
3863
|
+
function ee(n) {
|
|
3864
3864
|
switch (n) {
|
|
3865
3865
|
case 1312:
|
|
3866
3866
|
return P.MLDSASecurityLevel.LEVEL2;
|
|
@@ -3872,15 +3872,15 @@ function ne(n) {
|
|
|
3872
3872
|
throw new Error(`Invalid MLDSA public key length: ${n}`);
|
|
3873
3873
|
}
|
|
3874
3874
|
}
|
|
3875
|
-
class
|
|
3876
|
-
constructor(t =
|
|
3875
|
+
class rr {
|
|
3876
|
+
constructor(t = I) {
|
|
3877
3877
|
this.network = t;
|
|
3878
3878
|
}
|
|
3879
3879
|
/**
|
|
3880
3880
|
* @description Get the contract address
|
|
3881
3881
|
* @param {Network} network - The network to get the address for
|
|
3882
3882
|
*/
|
|
3883
|
-
static getAddress(t =
|
|
3883
|
+
static getAddress(t = I) {
|
|
3884
3884
|
throw new Error("Method not implemented.");
|
|
3885
3885
|
}
|
|
3886
3886
|
/**
|
|
@@ -3890,25 +3890,25 @@ class Tr {
|
|
|
3890
3890
|
return this.address;
|
|
3891
3891
|
}
|
|
3892
3892
|
}
|
|
3893
|
-
var
|
|
3894
|
-
function
|
|
3893
|
+
var he = /* @__PURE__ */ ((n) => (n[n.Bitcoin = 0] = "Bitcoin", n[n.Fractal = 1] = "Fractal", n))(he || {});
|
|
3894
|
+
function ze(n) {
|
|
3895
3895
|
return new Map(n);
|
|
3896
3896
|
}
|
|
3897
|
-
function
|
|
3897
|
+
function sr(n) {
|
|
3898
3898
|
return {
|
|
3899
3899
|
enabled: !0,
|
|
3900
|
-
signerMap: n instanceof Map ? n :
|
|
3900
|
+
signerMap: n instanceof Map ? n : ze(n)
|
|
3901
3901
|
};
|
|
3902
3902
|
}
|
|
3903
|
-
function
|
|
3903
|
+
function nr() {
|
|
3904
3904
|
return {
|
|
3905
3905
|
enabled: !1,
|
|
3906
3906
|
signerMap: /* @__PURE__ */ new Map()
|
|
3907
3907
|
};
|
|
3908
3908
|
}
|
|
3909
|
-
var y = /* @__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))(y || {}),
|
|
3910
|
-
const
|
|
3911
|
-
CONSENSUS:
|
|
3909
|
+
var y = /* @__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))(y || {}), Bt = /* @__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))(Bt || {});
|
|
3910
|
+
const qe = {
|
|
3911
|
+
CONSENSUS: Bt.Roswell,
|
|
3912
3912
|
CONSENSUS_NAME: "Roswell",
|
|
3913
3913
|
// The block height at which this consensus was enabled.
|
|
3914
3914
|
ENABLED_AT_BLOCK: 0n
|
|
@@ -3924,26 +3924,43 @@ const $e = {
|
|
|
3924
3924
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES: 250n,
|
|
3925
3925
|
// Equivalent to 56500 satoshis, calculated from UNWRAP_CONSOLIDATION_PREPAID_FEES.
|
|
3926
3926
|
//UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT: 56500n,
|
|
3927
|
-
},
|
|
3928
|
-
[
|
|
3929
|
-
},
|
|
3930
|
-
function
|
|
3931
|
-
|
|
3927
|
+
}, $e = {
|
|
3928
|
+
[Bt.Roswell]: qe
|
|
3929
|
+
}, $t = Bt.Roswell, or = $e[$t];
|
|
3930
|
+
function ie(n) {
|
|
3931
|
+
let t = a.allocUnsafe(0);
|
|
3932
|
+
function e(o) {
|
|
3933
|
+
t = a.concat([t, a.from(o)]);
|
|
3934
|
+
}
|
|
3935
|
+
function i(o) {
|
|
3936
|
+
const c = t.length, u = fi(o);
|
|
3937
|
+
t = a.concat([t, a.allocUnsafe(u)]), pi(o, t, c);
|
|
3938
|
+
}
|
|
3939
|
+
function r(o) {
|
|
3940
|
+
i(o.length), e(o);
|
|
3941
|
+
}
|
|
3942
|
+
function s(o) {
|
|
3943
|
+
i(o.length), o.forEach(r);
|
|
3944
|
+
}
|
|
3945
|
+
return s(n), t;
|
|
3946
|
+
}
|
|
3947
|
+
function le(n) {
|
|
3948
|
+
return n && !!(n.tapInternalKey || n.tapMerkleRoot || n.tapLeafScript && n.tapLeafScript.length || n.tapBip32Derivation && n.tapBip32Derivation.length || n.witnessUtxo && _e(n.witnessUtxo.script));
|
|
3932
3949
|
}
|
|
3933
|
-
function
|
|
3950
|
+
function ar(n) {
|
|
3934
3951
|
return n.redeemScript ? n.redeemScript : n.witnessScript ? n.witnessScript : n.witnessUtxo ? n.witnessUtxo.script : (n.nonWitnessUtxo, null);
|
|
3935
3952
|
}
|
|
3936
|
-
function
|
|
3953
|
+
function de(n, t) {
|
|
3937
3954
|
if (n.nonWitnessUtxo && !n.redeemScript && !n.witnessScript && !n.witnessUtxo || n.redeemScript)
|
|
3938
3955
|
return !0;
|
|
3939
|
-
const e =
|
|
3940
|
-
return e ?
|
|
3956
|
+
const e = ar(n);
|
|
3957
|
+
return e ? fe(t, e) : !1;
|
|
3941
3958
|
}
|
|
3942
|
-
function
|
|
3943
|
-
return
|
|
3959
|
+
function fe(n, t) {
|
|
3960
|
+
return Ti(n, t) !== -1;
|
|
3944
3961
|
}
|
|
3945
|
-
var
|
|
3946
|
-
class
|
|
3962
|
+
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 ve {
|
|
3947
3964
|
constructor(t) {
|
|
3948
3965
|
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) => {
|
|
3949
3966
|
const u = this.inputs[e];
|
|
@@ -3957,22 +3974,22 @@ class Lt extends ke {
|
|
|
3957
3974
|
if (this.anchorInputIndices.has(e))
|
|
3958
3975
|
return {
|
|
3959
3976
|
finalScriptSig: void 0,
|
|
3960
|
-
finalScriptWitness:
|
|
3977
|
+
finalScriptWitness: T.from([0])
|
|
3961
3978
|
};
|
|
3962
3979
|
if (c && s && i.witnessScript) {
|
|
3963
3980
|
if (!i.partialSig || i.partialSig.length === 0)
|
|
3964
3981
|
throw new Error(`No signatures for P2WSH input #${e}`);
|
|
3965
|
-
if (
|
|
3982
|
+
if (z.isP2WDAWitnessScript(i.witnessScript))
|
|
3966
3983
|
return this.finalizeSecondaryP2WDA(e, i);
|
|
3967
3984
|
if (this.csvInputIndices.has(e)) {
|
|
3968
3985
|
const d = [i.partialSig[0].signature, i.witnessScript];
|
|
3969
3986
|
return {
|
|
3970
3987
|
finalScriptSig: void 0,
|
|
3971
|
-
finalScriptWitness:
|
|
3988
|
+
finalScriptWitness: ie(d)
|
|
3972
3989
|
};
|
|
3973
3990
|
}
|
|
3974
3991
|
}
|
|
3975
|
-
return
|
|
3992
|
+
return Ke(
|
|
3976
3993
|
e,
|
|
3977
3994
|
i,
|
|
3978
3995
|
r,
|
|
@@ -3982,7 +3999,7 @@ class Lt extends ke {
|
|
|
3982
3999
|
!0,
|
|
3983
4000
|
this.unlockScript
|
|
3984
4001
|
);
|
|
3985
|
-
}, this.signer = t.signer, this.network = t.network, this.noSignatures = t.noSignatures || !1, this.nonWitnessUtxo = t.nonWitnessUtxo, this.unlockScript = t.unlockScript, this.isBrowser = typeof window < "u", t.txVersion && (this.txVersion = t.txVersion), t.mldsaSigner && (this._mldsaSigner = t.mldsaSigner, this._hashedPublicKey =
|
|
4002
|
+
}, this.signer = t.signer, this.network = t.network, this.noSignatures = t.noSignatures || !1, this.nonWitnessUtxo = t.nonWitnessUtxo, this.unlockScript = t.unlockScript, this.isBrowser = typeof window < "u", t.txVersion && (this.txVersion = t.txVersion), t.mldsaSigner && (this._mldsaSigner = t.mldsaSigner, this._hashedPublicKey = st.sha256(this._mldsaSigner.publicKey)), t.addressRotation?.enabled && (this.addressRotationEnabled = !0, this.signerMap = t.addressRotation.signerMap);
|
|
3986
4003
|
}
|
|
3987
4004
|
/**
|
|
3988
4005
|
* Get the MLDSA signer
|
|
@@ -4009,11 +4026,11 @@ class Lt extends ke {
|
|
|
4009
4026
|
static readScriptWitnessToWitnessStack(t) {
|
|
4010
4027
|
let e = 0;
|
|
4011
4028
|
function i(c) {
|
|
4012
|
-
const u =
|
|
4029
|
+
const u = T.from(t.subarray(e, e + c));
|
|
4013
4030
|
return e += c, u;
|
|
4014
4031
|
}
|
|
4015
4032
|
function r() {
|
|
4016
|
-
const c =
|
|
4033
|
+
const c = gi(t, e);
|
|
4017
4034
|
return e += c.bytes, c.numberValue || 0;
|
|
4018
4035
|
}
|
|
4019
4036
|
function s() {
|
|
@@ -4169,7 +4186,7 @@ class Lt extends ke {
|
|
|
4169
4186
|
*/
|
|
4170
4187
|
internalPubKeyToXOnlyForInput(t) {
|
|
4171
4188
|
const e = this.getSignerForInput(t);
|
|
4172
|
-
return O(
|
|
4189
|
+
return O(T.from(e.publicKey));
|
|
4173
4190
|
}
|
|
4174
4191
|
/**
|
|
4175
4192
|
* Get the tweaked signer for a specific input.
|
|
@@ -4226,7 +4243,7 @@ class Lt extends ke {
|
|
|
4226
4243
|
async signInput(t, e, i, r, s = !1, o = !1) {
|
|
4227
4244
|
if (this.anchorInputIndices.has(i)) return;
|
|
4228
4245
|
const c = r.publicKey;
|
|
4229
|
-
let u =
|
|
4246
|
+
let u = le(e);
|
|
4230
4247
|
s && (u = !u);
|
|
4231
4248
|
let h = !1, l = !1;
|
|
4232
4249
|
if (u)
|
|
@@ -4237,7 +4254,7 @@ class Lt extends ke {
|
|
|
4237
4254
|
`Failed to sign Taproot script path input ${i} (reverse: ${s}): ${d.message}`
|
|
4238
4255
|
), l = !0;
|
|
4239
4256
|
}
|
|
4240
|
-
else if (s ||
|
|
4257
|
+
else if (s || de(e, c))
|
|
4241
4258
|
try {
|
|
4242
4259
|
await this.signNonTaprootInput(r, t, i), h = !0;
|
|
4243
4260
|
} catch (d) {
|
|
@@ -4300,14 +4317,14 @@ class Lt extends ke {
|
|
|
4300
4317
|
* @returns {Buffer}
|
|
4301
4318
|
*/
|
|
4302
4319
|
internalPubKeyToXOnly() {
|
|
4303
|
-
return O(
|
|
4320
|
+
return O(T.from(this.signer.publicKey));
|
|
4304
4321
|
}
|
|
4305
4322
|
/**
|
|
4306
4323
|
* Internal init.
|
|
4307
4324
|
* @protected
|
|
4308
4325
|
*/
|
|
4309
4326
|
internalInit() {
|
|
4310
|
-
this.scriptData =
|
|
4327
|
+
this.scriptData = rt(this.generateScriptAddress()), this.tapData = rt(this.generateTapData());
|
|
4311
4328
|
}
|
|
4312
4329
|
/**
|
|
4313
4330
|
* Tweak the signer for the interaction
|
|
@@ -4326,49 +4343,49 @@ class Lt extends ke {
|
|
|
4326
4343
|
network: this.network
|
|
4327
4344
|
};
|
|
4328
4345
|
if (t && (i.tweakHash = this.getTweakerHash()), "privateKey" in e)
|
|
4329
|
-
return
|
|
4346
|
+
return ce.tweakSigner(e, i);
|
|
4330
4347
|
}
|
|
4331
4348
|
generateP2SHRedeemScript(t) {
|
|
4332
|
-
const e =
|
|
4349
|
+
const e = lt({
|
|
4333
4350
|
redeem: { output: t },
|
|
4334
4351
|
network: this.network
|
|
4335
4352
|
});
|
|
4336
|
-
return
|
|
4353
|
+
return gt({
|
|
4337
4354
|
redeem: e,
|
|
4338
4355
|
network: this.network
|
|
4339
4356
|
}).output;
|
|
4340
4357
|
}
|
|
4341
4358
|
generateP2SHRedeemScriptLegacy(t) {
|
|
4342
|
-
const e =
|
|
4359
|
+
const e = dt(this.signer.publicKey), i = L([
|
|
4343
4360
|
g.OP_DUP,
|
|
4344
4361
|
g.OP_HASH160,
|
|
4345
4362
|
e,
|
|
4346
4363
|
g.OP_EQUALVERIFY,
|
|
4347
4364
|
g.OP_CHECKSIG
|
|
4348
|
-
]), r =
|
|
4365
|
+
]), r = dt(i), s = L([
|
|
4349
4366
|
g.OP_HASH160,
|
|
4350
4367
|
r,
|
|
4351
4368
|
g.OP_EQUAL
|
|
4352
|
-
]), o =
|
|
4369
|
+
]), o = lt({
|
|
4353
4370
|
redeem: { output: i },
|
|
4354
4371
|
// Use the custom redeem script
|
|
4355
4372
|
network: this.network
|
|
4356
|
-
}), c =
|
|
4373
|
+
}), c = gt({
|
|
4357
4374
|
redeem: o,
|
|
4358
4375
|
// The P2WSH is wrapped inside the P2SH
|
|
4359
4376
|
network: this.network
|
|
4360
4377
|
});
|
|
4361
|
-
if (
|
|
4378
|
+
if (ke(s, this.network) === t && c.redeem && c.redeem.output)
|
|
4362
4379
|
return {
|
|
4363
4380
|
redeemScript: i,
|
|
4364
4381
|
outputScript: c.redeem.output
|
|
4365
4382
|
};
|
|
4366
4383
|
}
|
|
4367
4384
|
generateP2SHP2PKHRedeemScript(t, e) {
|
|
4368
|
-
const i = this.addressRotationEnabled && e !== void 0 ? this.getSignerForInput(e) : this.signer, r =
|
|
4385
|
+
const i = this.addressRotationEnabled && e !== void 0 ? this.getSignerForInput(e) : this.signer, r = T.isBuffer(i.publicKey) ? i.publicKey : T.from(i.publicKey, "hex"), s = jt({
|
|
4369
4386
|
pubkey: r,
|
|
4370
4387
|
network: this.network
|
|
4371
|
-
}), o =
|
|
4388
|
+
}), o = gt({
|
|
4372
4389
|
redeem: s,
|
|
4373
4390
|
network: this.network
|
|
4374
4391
|
}), c = o.address;
|
|
@@ -4389,7 +4406,7 @@ class Lt extends ke {
|
|
|
4389
4406
|
* @returns {PsbtInputExtended} The PSBT input extended
|
|
4390
4407
|
*/
|
|
4391
4408
|
generatePsbtInputExtended(t, e, i = !1) {
|
|
4392
|
-
const r =
|
|
4409
|
+
const r = T.from(t.scriptPubKey.hex, "hex"), s = {
|
|
4393
4410
|
hash: t.transactionId,
|
|
4394
4411
|
index: t.outputIndex,
|
|
4395
4412
|
sequence: this.sequence,
|
|
@@ -4398,17 +4415,17 @@ class Lt extends ke {
|
|
|
4398
4415
|
script: r
|
|
4399
4416
|
}
|
|
4400
4417
|
};
|
|
4401
|
-
if (
|
|
4418
|
+
if (Pi(r))
|
|
4402
4419
|
if (t.nonWitnessUtxo)
|
|
4403
|
-
s.nonWitnessUtxo =
|
|
4420
|
+
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4404
4421
|
else
|
|
4405
4422
|
throw new Error("Missing nonWitnessUtxo for P2PKH UTXO");
|
|
4406
|
-
else if (!(
|
|
4423
|
+
else if (!(Pe(r) || Ei(r))) if (Ee(r))
|
|
4407
4424
|
this.processP2WSHInput(t, s, e);
|
|
4408
|
-
else if (
|
|
4425
|
+
else if (Ai(r)) {
|
|
4409
4426
|
let o;
|
|
4410
4427
|
if (t.redeemScript)
|
|
4411
|
-
o =
|
|
4428
|
+
o = T.isBuffer(t.redeemScript) ? t.redeemScript : T.from(t.redeemScript, "hex");
|
|
4412
4429
|
else {
|
|
4413
4430
|
if (!t.scriptPubKey.address)
|
|
4414
4431
|
throw new Error(
|
|
@@ -4423,24 +4440,24 @@ class Lt extends ke {
|
|
|
4423
4440
|
o = h.redeemScript;
|
|
4424
4441
|
}
|
|
4425
4442
|
s.redeemScript = o;
|
|
4426
|
-
const c =
|
|
4443
|
+
const c = gt({ redeem: { output: s.redeemScript } });
|
|
4427
4444
|
if (!c.redeem)
|
|
4428
4445
|
throw new Error("Failed to extract redeem script from P2SH UTXO");
|
|
4429
4446
|
const u = c.redeem.output;
|
|
4430
4447
|
if (!u)
|
|
4431
4448
|
throw new Error("Failed to extract redeem output from P2SH UTXO");
|
|
4432
|
-
t.nonWitnessUtxo && (s.nonWitnessUtxo =
|
|
4433
|
-
} else if (
|
|
4449
|
+
t.nonWitnessUtxo && (s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex")), Pe(u) ? delete s.nonWitnessUtxo : Ee(u) ? (delete s.nonWitnessUtxo, this.processP2WSHInput(t, s, e)) : delete s.witnessUtxo;
|
|
4450
|
+
} else if (_e(r)) {
|
|
4434
4451
|
if (this.sighashTypes) {
|
|
4435
|
-
const o =
|
|
4452
|
+
const o = Xt.calculateSignHash(this.sighashTypes);
|
|
4436
4453
|
o && (s.sighashType = o);
|
|
4437
4454
|
}
|
|
4438
4455
|
this.addressRotationEnabled ? s.tapInternalKey = this.internalPubKeyToXOnlyForInput(e) : (this.tweakSigner(), s.tapInternalKey = this.internalPubKeyToXOnly());
|
|
4439
|
-
} else if (
|
|
4456
|
+
} else if (Oi(r))
|
|
4440
4457
|
this.anchorInputIndices.add(e), s.isPayToAnchor = !0;
|
|
4441
|
-
else if (
|
|
4458
|
+
else if (Bi(r) || xi(r))
|
|
4442
4459
|
if (t.nonWitnessUtxo)
|
|
4443
|
-
s.nonWitnessUtxo =
|
|
4460
|
+
s.nonWitnessUtxo = T.isBuffer(t.nonWitnessUtxo) ? t.nonWitnessUtxo : T.from(t.nonWitnessUtxo, "hex");
|
|
4444
4461
|
else
|
|
4445
4462
|
throw new Error("Missing nonWitnessUtxo for P2PK or P2MS UTXO");
|
|
4446
4463
|
else
|
|
@@ -4450,10 +4467,10 @@ class Lt extends ke {
|
|
|
4450
4467
|
processP2WSHInput(t, e, i) {
|
|
4451
4468
|
if (!t.witnessScript)
|
|
4452
4469
|
throw new Error("Missing witnessScript for P2WSH UTXO");
|
|
4453
|
-
e.witnessScript =
|
|
4454
|
-
const r =
|
|
4470
|
+
e.witnessScript = T.isBuffer(t.witnessScript) ? t.witnessScript : T.from(t.witnessScript, "hex");
|
|
4471
|
+
const r = R(e.witnessScript);
|
|
4455
4472
|
if (r && this.isCSVScript(r)) {
|
|
4456
|
-
const s =
|
|
4473
|
+
const s = R(e.witnessScript);
|
|
4457
4474
|
if (s && this.isCSVScript(s)) {
|
|
4458
4475
|
this.csvInputIndices.add(i);
|
|
4459
4476
|
const o = this.extractCSVBlocks(s);
|
|
@@ -4484,13 +4501,13 @@ class Lt extends ke {
|
|
|
4484
4501
|
throw new Error(`No signature for P2WDA input #${t}`);
|
|
4485
4502
|
if (!e.witnessScript)
|
|
4486
4503
|
throw new Error(`No witness script for P2WDA input #${t}`);
|
|
4487
|
-
const i =
|
|
4504
|
+
const i = z.createSimpleP2WDAWitness(
|
|
4488
4505
|
e.partialSig[0].signature,
|
|
4489
4506
|
e.witnessScript
|
|
4490
4507
|
);
|
|
4491
4508
|
return {
|
|
4492
4509
|
finalScriptSig: void 0,
|
|
4493
|
-
finalScriptWitness:
|
|
4510
|
+
finalScriptWitness: ie(i)
|
|
4494
4511
|
};
|
|
4495
4512
|
}
|
|
4496
4513
|
async signInputsWalletBased(t) {
|
|
@@ -4518,8 +4535,8 @@ class Lt extends ke {
|
|
|
4518
4535
|
for (let e = 0; e < t.length; e++)
|
|
4519
4536
|
if (t[e] === g.OP_CHECKSEQUENCEVERIFY && e > 0) {
|
|
4520
4537
|
const i = t[e - 1];
|
|
4521
|
-
if (
|
|
4522
|
-
return
|
|
4538
|
+
if (T.isBuffer(i))
|
|
4539
|
+
return Le.decode(i);
|
|
4523
4540
|
if (typeof i == "number") {
|
|
4524
4541
|
if (i === g.OP_0 || i === g.OP_FALSE)
|
|
4525
4542
|
return 0;
|
|
@@ -4552,7 +4569,7 @@ class Lt extends ke {
|
|
|
4552
4569
|
isTaprootScriptSpend(t, e) {
|
|
4553
4570
|
if (t.tapLeafScript && t.tapLeafScript.length > 0) {
|
|
4554
4571
|
for (const i of t.tapLeafScript)
|
|
4555
|
-
if (
|
|
4572
|
+
if (fe(e, i.script))
|
|
4556
4573
|
return !0;
|
|
4557
4574
|
}
|
|
4558
4575
|
return !1;
|
|
@@ -4571,35 +4588,35 @@ class Lt extends ke {
|
|
|
4571
4588
|
"signInput" in t ? await t.signInput(e, i) : e.signInput(i, t);
|
|
4572
4589
|
}
|
|
4573
4590
|
}
|
|
4574
|
-
function
|
|
4591
|
+
function Gt(n, t) {
|
|
4575
4592
|
return JSON.stringify(n) === JSON.stringify(t);
|
|
4576
4593
|
}
|
|
4577
|
-
function
|
|
4578
|
-
if (
|
|
4594
|
+
function cr(n) {
|
|
4595
|
+
if (Gt(n, I))
|
|
4579
4596
|
return "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
4580
|
-
if (
|
|
4597
|
+
if (Gt(n, At))
|
|
4581
4598
|
return "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
4582
|
-
if (
|
|
4599
|
+
if (Gt(n, zt))
|
|
4583
4600
|
return "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206";
|
|
4584
4601
|
throw new Error("Unsupported network for chain ID retrieval");
|
|
4585
4602
|
}
|
|
4586
|
-
function
|
|
4587
|
-
return Uint8Array.from(a.from(
|
|
4603
|
+
function Be(n) {
|
|
4604
|
+
return Uint8Array.from(a.from(cr(n), "hex"));
|
|
4588
4605
|
}
|
|
4589
|
-
const
|
|
4606
|
+
const xe = Uint8Array.from(
|
|
4590
4607
|
a.from(
|
|
4591
4608
|
"e784995a412d773988c4b8e333d7b39dfb3cabf118d0d645411a916ca2407939",
|
|
4592
4609
|
// sha256("OP_NET")
|
|
4593
4610
|
"hex"
|
|
4594
4611
|
)
|
|
4595
4612
|
);
|
|
4596
|
-
|
|
4597
|
-
const
|
|
4598
|
-
class m extends
|
|
4613
|
+
ot(G);
|
|
4614
|
+
const V = 330n, St = 297n, re = a.from("51024e73", "hex");
|
|
4615
|
+
class m extends Xt {
|
|
4599
4616
|
constructor(t) {
|
|
4600
4617
|
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)
|
|
4601
4618
|
throw new Error("Vout value is less than the value to send");
|
|
4602
|
-
this.transaction = new
|
|
4619
|
+
this.transaction = new F({
|
|
4603
4620
|
network: this.network,
|
|
4604
4621
|
version: this.txVersion
|
|
4605
4622
|
});
|
|
@@ -4617,21 +4634,7 @@ class m extends Lt {
|
|
|
4617
4634
|
* @returns {Buffer}
|
|
4618
4635
|
*/
|
|
4619
4636
|
static witnessStackToScriptWitness(t) {
|
|
4620
|
-
|
|
4621
|
-
function i(c) {
|
|
4622
|
-
e = a.concat([e, a.from(c)]);
|
|
4623
|
-
}
|
|
4624
|
-
function r(c) {
|
|
4625
|
-
const u = e.length, h = Ui(c);
|
|
4626
|
-
e = a.concat([e, a.allocUnsafe(h)]), _i(c, e, u);
|
|
4627
|
-
}
|
|
4628
|
-
function s(c) {
|
|
4629
|
-
r(c.length), i(c);
|
|
4630
|
-
}
|
|
4631
|
-
function o(c) {
|
|
4632
|
-
r(c.length), c.forEach(s);
|
|
4633
|
-
}
|
|
4634
|
-
return o(t), e;
|
|
4637
|
+
return ie(t);
|
|
4635
4638
|
}
|
|
4636
4639
|
addOPReturn(t) {
|
|
4637
4640
|
const e = L([g.OP_RETURN, t]);
|
|
@@ -4643,7 +4646,7 @@ class m extends Lt {
|
|
|
4643
4646
|
addAnchor() {
|
|
4644
4647
|
this.addOutput({
|
|
4645
4648
|
value: 0,
|
|
4646
|
-
script:
|
|
4649
|
+
script: re
|
|
4647
4650
|
});
|
|
4648
4651
|
}
|
|
4649
4652
|
async getFundingTransactionParameters() {
|
|
@@ -4749,7 +4752,7 @@ class m extends Lt {
|
|
|
4749
4752
|
throw new Error("Output value is 0 and no script provided");
|
|
4750
4753
|
if (i.script.length < 2)
|
|
4751
4754
|
throw new Error("Output script is too short");
|
|
4752
|
-
if (i.script[0] !== g.OP_RETURN && !i.script.equals(
|
|
4755
|
+
if (i.script[0] !== g.OP_RETURN && !i.script.equals(re))
|
|
4753
4756
|
throw new Error(
|
|
4754
4757
|
"Output script must start with OP_RETURN or be an ANCHOR when value is 0"
|
|
4755
4758
|
);
|
|
@@ -4789,7 +4792,7 @@ class m extends Lt {
|
|
|
4789
4792
|
*/
|
|
4790
4793
|
async estimateTransactionFees() {
|
|
4791
4794
|
await Promise.resolve();
|
|
4792
|
-
const t = new
|
|
4795
|
+
const t = new F({ network: this.network }), e = this.getInputs(), i = this.getOutputs();
|
|
4793
4796
|
t.addInputs(e), t.addOutputs(i);
|
|
4794
4797
|
const r = a.alloc(64, 0), s = a.alloc(72, 0), o = a.alloc(33, 2), c = (p, f) => {
|
|
4795
4798
|
if (f.isPayToAnchor || this.anchorInputIndices.has(p))
|
|
@@ -4797,9 +4800,9 @@ class m extends Lt {
|
|
|
4797
4800
|
finalScriptSig: void 0,
|
|
4798
4801
|
finalScriptWitness: a.from([0])
|
|
4799
4802
|
};
|
|
4800
|
-
if (f.witnessScript &&
|
|
4803
|
+
if (f.witnessScript && z.isP2WDAWitnessScript(f.witnessScript)) {
|
|
4801
4804
|
const S = [];
|
|
4802
|
-
for (let
|
|
4805
|
+
for (let _ = 0; _ < 10; _++)
|
|
4803
4806
|
S.push(a.alloc(0));
|
|
4804
4807
|
const b = a.alloc(72, 0);
|
|
4805
4808
|
return {
|
|
@@ -4811,7 +4814,7 @@ class m extends Lt {
|
|
|
4811
4814
|
};
|
|
4812
4815
|
}
|
|
4813
4816
|
if (p === 0 && this.tapLeafScript) {
|
|
4814
|
-
const S = a.alloc(32, 0), b = this.tapLeafScript.script,
|
|
4817
|
+
const S = a.alloc(32, 0), b = this.tapLeafScript.script, _ = a.alloc(65, 0);
|
|
4815
4818
|
return {
|
|
4816
4819
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4817
4820
|
S,
|
|
@@ -4820,15 +4823,15 @@ class m extends Lt {
|
|
|
4820
4823
|
r,
|
|
4821
4824
|
// Second Schnorr signature
|
|
4822
4825
|
b,
|
|
4823
|
-
|
|
4826
|
+
_
|
|
4824
4827
|
])
|
|
4825
4828
|
};
|
|
4826
4829
|
}
|
|
4827
4830
|
if (f.witnessUtxo) {
|
|
4828
|
-
const S = f.witnessUtxo.script, b =
|
|
4831
|
+
const S = f.witnessUtxo.script, b = it.script.decompile(S);
|
|
4829
4832
|
if (b && b.length === 5 && b[0] === g.OP_DUP && b[1] === g.OP_HASH160 && b[3] === g.OP_EQUALVERIFY && b[4] === g.OP_CHECKSIG)
|
|
4830
4833
|
return {
|
|
4831
|
-
finalScriptSig:
|
|
4834
|
+
finalScriptSig: it.script.compile([
|
|
4832
4835
|
s,
|
|
4833
4836
|
o
|
|
4834
4837
|
]),
|
|
@@ -4850,18 +4853,18 @@ class m extends Lt {
|
|
|
4850
4853
|
finalScriptWitness: m.witnessStackToScriptWitness(b)
|
|
4851
4854
|
};
|
|
4852
4855
|
}
|
|
4853
|
-
const S =
|
|
4856
|
+
const S = it.script.decompile(f.witnessScript);
|
|
4854
4857
|
if (S && S.length >= 4) {
|
|
4855
|
-
const b = S[0],
|
|
4856
|
-
if (typeof b == "number" && b >= g.OP_1 &&
|
|
4857
|
-
const
|
|
4858
|
-
for (let
|
|
4859
|
-
|
|
4858
|
+
const b = S[0], _ = S[S.length - 1];
|
|
4859
|
+
if (typeof b == "number" && b >= g.OP_1 && _ === g.OP_CHECKMULTISIG) {
|
|
4860
|
+
const xt = b - g.OP_1 + 1, vt = [];
|
|
4861
|
+
for (let kt = 0; kt < xt; kt++)
|
|
4862
|
+
vt.push(s);
|
|
4860
4863
|
return {
|
|
4861
4864
|
finalScriptWitness: m.witnessStackToScriptWitness([
|
|
4862
4865
|
a.alloc(0),
|
|
4863
4866
|
// OP_0 due to multisig bug
|
|
4864
|
-
...
|
|
4867
|
+
...vt,
|
|
4865
4868
|
f.witnessScript
|
|
4866
4869
|
])
|
|
4867
4870
|
};
|
|
@@ -4874,7 +4877,7 @@ class m extends Lt {
|
|
|
4874
4877
|
])
|
|
4875
4878
|
};
|
|
4876
4879
|
} else if (f.redeemScript) {
|
|
4877
|
-
const S =
|
|
4880
|
+
const S = it.script.decompile(f.redeemScript);
|
|
4878
4881
|
if (S && S.length === 2 && S[0] === g.OP_0 && a.isBuffer(S[1]) && S[1].length === 20)
|
|
4879
4882
|
return {
|
|
4880
4883
|
finalScriptSig: f.redeemScript,
|
|
@@ -4886,7 +4889,7 @@ class m extends Lt {
|
|
|
4886
4889
|
}
|
|
4887
4890
|
if (f.redeemScript && !f.witnessScript && !f.witnessUtxo)
|
|
4888
4891
|
return {
|
|
4889
|
-
finalScriptSig:
|
|
4892
|
+
finalScriptSig: it.script.compile([s, f.redeemScript]),
|
|
4890
4893
|
finalScriptWitness: void 0
|
|
4891
4894
|
};
|
|
4892
4895
|
const w = f.witnessUtxo?.script;
|
|
@@ -4904,7 +4907,7 @@ class m extends Lt {
|
|
|
4904
4907
|
s,
|
|
4905
4908
|
o
|
|
4906
4909
|
])
|
|
4907
|
-
} :
|
|
4910
|
+
} : Ke(
|
|
4908
4911
|
p,
|
|
4909
4912
|
f,
|
|
4910
4913
|
w,
|
|
@@ -4927,10 +4930,10 @@ class m extends Lt {
|
|
|
4927
4930
|
), d;
|
|
4928
4931
|
}
|
|
4929
4932
|
async rebuildFromBase64(t) {
|
|
4930
|
-
return this.transaction =
|
|
4933
|
+
return this.transaction = F.fromBase64(t, {
|
|
4931
4934
|
network: this.network,
|
|
4932
4935
|
version: this.txVersion
|
|
4933
|
-
}), this.signed = !1, this.sighashTypes = [
|
|
4936
|
+
}), this.signed = !1, this.sighashTypes = [Jt.SIGHASH_ANYONECANPAY, Jt.SIGHASH_ALL], await this.signPSBT();
|
|
4934
4937
|
}
|
|
4935
4938
|
setPSBT(t) {
|
|
4936
4939
|
this.transaction = t;
|
|
@@ -5037,10 +5040,10 @@ class m extends Lt {
|
|
|
5037
5040
|
const t = O(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5038
5041
|
if (e.length !== 33)
|
|
5039
5042
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5040
|
-
const i =
|
|
5041
|
-
r.writeU8(P.MLDSASecurityLevel.LEVEL2), r.writeBytes(this.hashedPublicKey), r.writeBytes(t), r.writeBytes(e), r.writeBytes(
|
|
5042
|
-
const s = r.getBuffer(), o =
|
|
5043
|
-
if (!
|
|
5043
|
+
const i = Be(this.network), r = new D();
|
|
5044
|
+
r.writeU8(P.MLDSASecurityLevel.LEVEL2), r.writeBytes(this.hashedPublicKey), r.writeBytes(t), r.writeBytes(e), r.writeBytes(xe), r.writeBytes(i);
|
|
5045
|
+
const s = r.getBuffer(), o = st.signMessage(this.tweakedSigner, s);
|
|
5046
|
+
if (!st.verifySignature(t, s, o.signature))
|
|
5044
5047
|
throw new Error("Could not verify generated legacy signature for MLDSA link request");
|
|
5045
5048
|
return a.from(o.signature);
|
|
5046
5049
|
}
|
|
@@ -5052,13 +5055,13 @@ class m extends Lt {
|
|
|
5052
5055
|
const t = O(this.tweakedSigner.publicKey), e = this.signer.publicKey;
|
|
5053
5056
|
if (e.length !== 33)
|
|
5054
5057
|
throw new Error("Original public key must be compressed (33 bytes)");
|
|
5055
|
-
const i =
|
|
5058
|
+
const i = Be(this.network), r = ee(this.mldsaSigner.publicKey.length);
|
|
5056
5059
|
if (r !== P.MLDSASecurityLevel.LEVEL2)
|
|
5057
5060
|
throw new Error("Only MLDSA level 2 is supported for link requests");
|
|
5058
|
-
const s = new
|
|
5059
|
-
s.writeU8(r), s.writeBytes(this.hashedPublicKey), s.writeBytes(this.mldsaSigner.publicKey), s.writeBytes(t), s.writeBytes(e), s.writeBytes(
|
|
5060
|
-
const o = s.getBuffer(), c =
|
|
5061
|
-
if (!
|
|
5061
|
+
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(xe), s.writeBytes(i);
|
|
5063
|
+
const o = s.getBuffer(), c = st.signMLDSAMessage(this.mldsaSigner, o);
|
|
5064
|
+
if (!st.verifyMLDSASignature(
|
|
5062
5065
|
this.mldsaSigner,
|
|
5063
5066
|
o,
|
|
5064
5067
|
c.signature
|
|
@@ -5071,13 +5074,13 @@ class m extends Lt {
|
|
|
5071
5074
|
let s = null;
|
|
5072
5075
|
t.revealMLDSAPublicKey && (s = this.generateMLDSASignature());
|
|
5073
5076
|
const o = {
|
|
5074
|
-
priority:
|
|
5077
|
+
priority: Q.MLDSA_LINK_PUBKEY,
|
|
5075
5078
|
opcode: W.MLDSA_LINK_PUBKEY,
|
|
5076
5079
|
data: {
|
|
5077
5080
|
verifyRequest: !!t.revealMLDSAPublicKey,
|
|
5078
5081
|
publicKey: i.publicKey,
|
|
5079
5082
|
hashedPublicKey: this.hashedPublicKey,
|
|
5080
|
-
level:
|
|
5083
|
+
level: ee(i.publicKey.length),
|
|
5081
5084
|
legacySignature: r,
|
|
5082
5085
|
mldsaSignature: s
|
|
5083
5086
|
}
|
|
@@ -5184,13 +5187,13 @@ class m extends Lt {
|
|
|
5184
5187
|
addFeeToOutput(t, e, i, r) {
|
|
5185
5188
|
if (r) {
|
|
5186
5189
|
let s;
|
|
5187
|
-
t >
|
|
5190
|
+
t > V + St ? s = St : s = t, this.addOutput(
|
|
5188
5191
|
{
|
|
5189
5192
|
value: Number(s),
|
|
5190
5193
|
address: e
|
|
5191
5194
|
},
|
|
5192
5195
|
!0
|
|
5193
|
-
), s ===
|
|
5196
|
+
), s === St && t - St > V && this.addOutput(
|
|
5194
5197
|
{
|
|
5195
5198
|
value: Number(t - s),
|
|
5196
5199
|
address: i.address
|
|
@@ -5198,7 +5201,7 @@ class m extends Lt {
|
|
|
5198
5201
|
!0
|
|
5199
5202
|
);
|
|
5200
5203
|
} else {
|
|
5201
|
-
const s = t <
|
|
5204
|
+
const s = t < V ? V : t;
|
|
5202
5205
|
this.addOutput(
|
|
5203
5206
|
{
|
|
5204
5207
|
value: Number(s),
|
|
@@ -5336,7 +5339,7 @@ class m extends Lt {
|
|
|
5336
5339
|
return !1;
|
|
5337
5340
|
}
|
|
5338
5341
|
}
|
|
5339
|
-
class
|
|
5342
|
+
class Wt extends m {
|
|
5340
5343
|
constructor(t) {
|
|
5341
5344
|
if (super(t), this.type = y.CUSTOM_CODE, this.tapLeafScript = null, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5342
5345
|
if (!this.tapLeafScript)
|
|
@@ -5351,7 +5354,7 @@ class Vt extends m {
|
|
|
5351
5354
|
};
|
|
5352
5355
|
}, !t.script) throw new Error("Bitcoin script is required");
|
|
5353
5356
|
if (!t.witnesses) throw new Error("Witness(es) are required");
|
|
5354
|
-
this.witnesses = t.witnesses, this.randomBytes = t.randomBytes || K.rndBytes(), this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.scriptSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.scriptSeed, this.network), this.generator = new
|
|
5357
|
+
this.witnesses = t.witnesses, this.randomBytes = t.randomBytes || K.rndBytes(), this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.scriptSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.scriptSeed, this.network), this.generator = new Re(this.internalPubKeyToXOnly(), this.network), this.compiledTargetScript = this.generator.compile(t.script), this.scriptTree = this.getScriptTree(), this.internalInit(), this._scriptAddress = ae.generatePKSH(this.scriptSeed, this.network);
|
|
5355
5358
|
}
|
|
5356
5359
|
/**
|
|
5357
5360
|
* @description Get the contract address (PKSH)
|
|
@@ -5470,7 +5473,7 @@ class Vt extends m {
|
|
|
5470
5473
|
* @private
|
|
5471
5474
|
*/
|
|
5472
5475
|
getContractSeed() {
|
|
5473
|
-
return
|
|
5476
|
+
return Y(this.randomBytes);
|
|
5474
5477
|
}
|
|
5475
5478
|
/**
|
|
5476
5479
|
* Get the public keys for the redeem scripts
|
|
@@ -5521,7 +5524,7 @@ class Vt extends m {
|
|
|
5521
5524
|
];
|
|
5522
5525
|
}
|
|
5523
5526
|
}
|
|
5524
|
-
class
|
|
5527
|
+
class pe extends m {
|
|
5525
5528
|
constructor(t) {
|
|
5526
5529
|
if (super(t), this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5527
5530
|
if (!this.tapLeafScript)
|
|
@@ -5539,7 +5542,7 @@ class ge extends m {
|
|
|
5539
5542
|
this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.disableAutoRefund = t.disableAutoRefund || !1, this.epochChallenge = M.generateTimeLockAddress(
|
|
5540
5543
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
5541
5544
|
this.network
|
|
5542
|
-
), this.calldata = N.compress(t.calldata), this.randomBytes = t.randomBytes || K.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.calldataGenerator = new
|
|
5545
|
+
), this.calldata = N.compress(t.calldata), this.randomBytes = t.randomBytes || K.rndBytes(), this.scriptSigner = this.generateKeyPairFromSeed(), this.calldataGenerator = new oe(
|
|
5543
5546
|
a.from(this.signer.publicKey),
|
|
5544
5547
|
this.scriptSignerXOnlyPubKey(),
|
|
5545
5548
|
this.network
|
|
@@ -5717,7 +5720,7 @@ class ge extends m {
|
|
|
5717
5720
|
if (!this.to) throw new Error("To address is required");
|
|
5718
5721
|
const t = this.getTransactionOPNetFee();
|
|
5719
5722
|
this.addFeeToOutput(t, this.to, this.epochChallenge, !1);
|
|
5720
|
-
const e = t <
|
|
5723
|
+
const e = t < V ? V : t, i = this.addOptionalOutputsAndGetAmount();
|
|
5721
5724
|
this.disableAutoRefund || await this.addRefundOutput(e + i);
|
|
5722
5725
|
}
|
|
5723
5726
|
/**
|
|
@@ -5752,7 +5755,7 @@ class ge extends m {
|
|
|
5752
5755
|
};
|
|
5753
5756
|
}
|
|
5754
5757
|
}
|
|
5755
|
-
class
|
|
5758
|
+
class ft extends m {
|
|
5756
5759
|
constructor(t) {
|
|
5757
5760
|
if (super(t), this.type = y.DEPLOYMENT, this.tapLeafScript = null, this.deploymentVersion = 0, this.targetScriptRedeem = null, this.leftOverFundsScriptRedeem = null, this.customFinalizer = (e, i) => {
|
|
5758
5761
|
if (!this.tapLeafScript)
|
|
@@ -5769,11 +5772,11 @@ class pt extends m {
|
|
|
5769
5772
|
};
|
|
5770
5773
|
}, !this.hashedPublicKey)
|
|
5771
5774
|
throw new Error("MLDSA signer must be defined to deploy a contract.");
|
|
5772
|
-
if (this.bytecode = N.compress(a.concat([
|
|
5775
|
+
if (this.bytecode = N.compress(a.concat([Me, t.bytecode])), this.verifyBytecode(), t.calldata && (this.calldata = t.calldata, this.verifyCalldata()), !t.challenge) throw new Error("Challenge solution is required");
|
|
5773
5776
|
if (this.randomBytes = t.randomBytes || K.rndBytes(), this.challenge = t.challenge, this.LOCK_LEAF_SCRIPT = this.defineLockScript(), this.epochChallenge = M.generateTimeLockAddress(
|
|
5774
5777
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
5775
5778
|
this.network
|
|
5776
|
-
), this.contractSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.contractSeed, this.network), this.deploymentGenerator = new
|
|
5779
|
+
), this.contractSeed = this.getContractSeed(), this.contractSigner = A.fromSeedKeyPair(this.contractSeed, this.network), this.deploymentGenerator = new Ft(
|
|
5777
5780
|
a.from(this.signer.publicKey),
|
|
5778
5781
|
this.contractSignerXOnlyPubKey(),
|
|
5779
5782
|
this.network
|
|
@@ -5940,7 +5943,7 @@ class pt extends m {
|
|
|
5940
5943
|
generateFeatures(t) {
|
|
5941
5944
|
const e = [], i = t.challenge.getSubmission();
|
|
5942
5945
|
if (i && e.push({
|
|
5943
|
-
priority:
|
|
5946
|
+
priority: Q.MLDSA_LINK_PUBKEY,
|
|
5944
5947
|
opcode: W.EPOCH_SUBMISSION,
|
|
5945
5948
|
data: i
|
|
5946
5949
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
@@ -5950,12 +5953,12 @@ class pt extends m {
|
|
|
5950
5953
|
return t.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(t, e), e;
|
|
5951
5954
|
}
|
|
5952
5955
|
verifyCalldata() {
|
|
5953
|
-
if (this.calldata && this.calldata.length >
|
|
5956
|
+
if (this.calldata && this.calldata.length > pe.MAXIMUM_CALLDATA_SIZE)
|
|
5954
5957
|
throw new Error("Calldata size overflow.");
|
|
5955
5958
|
}
|
|
5956
5959
|
verifyBytecode() {
|
|
5957
5960
|
if (!this.bytecode) throw new Error("Bytecode is required");
|
|
5958
|
-
if (this.bytecode.length >
|
|
5961
|
+
if (this.bytecode.length > ft.MAXIMUM_CONTRACT_SIZE)
|
|
5959
5962
|
throw new Error("Contract size overflow.");
|
|
5960
5963
|
}
|
|
5961
5964
|
/**
|
|
@@ -5965,8 +5968,8 @@ class pt extends m {
|
|
|
5965
5968
|
getContractSeed() {
|
|
5966
5969
|
if (!this.bytecode)
|
|
5967
5970
|
throw new Error("Bytecode is required");
|
|
5968
|
-
const t = this.internalPubKeyToXOnly(), e =
|
|
5969
|
-
return
|
|
5971
|
+
const t = this.internalPubKeyToXOnly(), e = Y(this.randomBytes), i = Y(this.bytecode), r = a.concat([t, e, i]);
|
|
5972
|
+
return Y(r);
|
|
5970
5973
|
}
|
|
5971
5974
|
/**
|
|
5972
5975
|
* Get the public keys for the redeem scripts
|
|
@@ -6019,7 +6022,7 @@ class pt extends m {
|
|
|
6019
6022
|
];
|
|
6020
6023
|
}
|
|
6021
6024
|
}
|
|
6022
|
-
class
|
|
6025
|
+
class Mt extends m {
|
|
6023
6026
|
constructor(t) {
|
|
6024
6027
|
super(t), this.type = y.FUNDING, this.amount = t.amount, this.splitInputsInto = t.splitInputsInto ?? 1, this.internalInit();
|
|
6025
6028
|
}
|
|
@@ -6062,7 +6065,7 @@ class zt extends m {
|
|
|
6062
6065
|
return this.signer;
|
|
6063
6066
|
}
|
|
6064
6067
|
}
|
|
6065
|
-
class
|
|
6068
|
+
class Nt extends pe {
|
|
6066
6069
|
constructor(t) {
|
|
6067
6070
|
if (super(t), this.type = y.INTERACTION, this.tapLeafScript = null, !t.contract)
|
|
6068
6071
|
throw new Error("parameters.contract is required for interaction transaction.");
|
|
@@ -6088,13 +6091,13 @@ class qt extends ge {
|
|
|
6088
6091
|
generateFeatures(t) {
|
|
6089
6092
|
const e = [];
|
|
6090
6093
|
t.loadedStorage && e.push({
|
|
6091
|
-
priority:
|
|
6094
|
+
priority: Q.ACCESS_LIST,
|
|
6092
6095
|
opcode: W.ACCESS_LIST,
|
|
6093
6096
|
data: t.loadedStorage
|
|
6094
6097
|
});
|
|
6095
6098
|
const i = t.challenge.getSubmission();
|
|
6096
6099
|
if (i && e.push({
|
|
6097
|
-
priority:
|
|
6100
|
+
priority: Q.EPOCH_SUBMISSION,
|
|
6098
6101
|
opcode: W.EPOCH_SUBMISSION,
|
|
6099
6102
|
data: i
|
|
6100
6103
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
@@ -6104,7 +6107,7 @@ class qt extends ge {
|
|
|
6104
6107
|
return t.linkMLDSAPublicKeyToAddress && this.generateMLDSALinkRequest(t, e), e;
|
|
6105
6108
|
}
|
|
6106
6109
|
}
|
|
6107
|
-
class
|
|
6110
|
+
class j extends m {
|
|
6108
6111
|
constructor(t) {
|
|
6109
6112
|
if (super(t), this.type = y.INTERACTION, this.p2wdaInputIndices = /* @__PURE__ */ new Set(), this.compiledOperationData = null, !t.to)
|
|
6110
6113
|
throw new Error("Contract address (to) is required");
|
|
@@ -6114,8 +6117,8 @@ class Z extends m {
|
|
|
6114
6117
|
throw new Error("Calldata is required");
|
|
6115
6118
|
if (!t.challenge)
|
|
6116
6119
|
throw new Error("Challenge solution is required");
|
|
6117
|
-
if (this.disableAutoRefund = t.disableAutoRefund || !1, this.contractAddress = t.to, this.contractSecret =
|
|
6118
|
-
|
|
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 Et(
|
|
6121
|
+
T.from(this.signer.publicKey),
|
|
6119
6122
|
this.scriptSignerXOnlyPubKey(),
|
|
6120
6123
|
this.network
|
|
6121
6124
|
), this.contractSecret.length !== 32)
|
|
@@ -6124,10 +6127,10 @@ class Z extends m {
|
|
|
6124
6127
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
6125
6128
|
this.network
|
|
6126
6129
|
), this.validateP2WDAInputs(), t.compiledTargetScript)
|
|
6127
|
-
if (
|
|
6130
|
+
if (T.isBuffer(t.compiledTargetScript))
|
|
6128
6131
|
this.compiledOperationData = t.compiledTargetScript;
|
|
6129
6132
|
else if (typeof t.compiledTargetScript == "string")
|
|
6130
|
-
this.compiledOperationData =
|
|
6133
|
+
this.compiledOperationData = T.from(t.compiledTargetScript, "hex");
|
|
6131
6134
|
else
|
|
6132
6135
|
throw new Error("Invalid compiled target script format.");
|
|
6133
6136
|
else
|
|
@@ -6193,13 +6196,13 @@ class Z extends m {
|
|
|
6193
6196
|
generateFeatures(t) {
|
|
6194
6197
|
const e = [];
|
|
6195
6198
|
t.loadedStorage && e.push({
|
|
6196
|
-
priority:
|
|
6199
|
+
priority: Q.ACCESS_LIST,
|
|
6197
6200
|
opcode: W.ACCESS_LIST,
|
|
6198
6201
|
data: t.loadedStorage
|
|
6199
6202
|
});
|
|
6200
6203
|
const i = t.challenge.getSubmission();
|
|
6201
6204
|
return i && e.push({
|
|
6202
|
-
priority:
|
|
6205
|
+
priority: Q.EPOCH_SUBMISSION,
|
|
6203
6206
|
opcode: W.EPOCH_SUBMISSION,
|
|
6204
6207
|
data: i
|
|
6205
6208
|
}), e;
|
|
@@ -6214,19 +6217,19 @@ class Z extends m {
|
|
|
6214
6217
|
* Get script signer x-only pubkey (same as SharedInteractionTransaction)
|
|
6215
6218
|
*/
|
|
6216
6219
|
scriptSignerXOnlyPubKey() {
|
|
6217
|
-
return O(
|
|
6220
|
+
return O(T.from(this.scriptSigner.publicKey));
|
|
6218
6221
|
}
|
|
6219
6222
|
/**
|
|
6220
6223
|
* Validate that input 0 is P2WDA
|
|
6221
6224
|
*/
|
|
6222
6225
|
validateP2WDAInputs() {
|
|
6223
|
-
if (this.utxos.length === 0 || !
|
|
6226
|
+
if (this.utxos.length === 0 || !z.isP2WDAUTXO(this.utxos[0]))
|
|
6224
6227
|
throw new Error("Input 0 must be a P2WDA UTXO");
|
|
6225
6228
|
for (let t = 0; t < this.utxos.length; t++)
|
|
6226
|
-
|
|
6229
|
+
z.isP2WDAUTXO(this.utxos[t]) && this.p2wdaInputIndices.add(t);
|
|
6227
6230
|
for (let t = 0; t < this.optionalInputs.length; t++) {
|
|
6228
6231
|
const e = this.utxos.length + t;
|
|
6229
|
-
|
|
6232
|
+
z.isP2WDAUTXO(this.optionalInputs[t]) && this.p2wdaInputIndices.add(e);
|
|
6230
6233
|
}
|
|
6231
6234
|
}
|
|
6232
6235
|
/**
|
|
@@ -6236,12 +6239,12 @@ class Z extends m {
|
|
|
6236
6239
|
if (!this.compiledOperationData)
|
|
6237
6240
|
throw new Error("Operation data not compiled");
|
|
6238
6241
|
const t = this.compiledOperationData.length;
|
|
6239
|
-
if (!
|
|
6242
|
+
if (!Et.validateWitnessSize(t)) {
|
|
6240
6243
|
const i = t + 64, r = Math.ceil(i * 0.7), s = Math.ceil(
|
|
6241
|
-
r /
|
|
6244
|
+
r / j.MAX_BYTES_PER_WITNESS
|
|
6242
6245
|
);
|
|
6243
6246
|
throw new Error(
|
|
6244
|
-
`Please dont use P2WDA for this operation. Data too large. Raw size: ${t} bytes, estimated compressed: ${r} bytes, needs ${s} witness fields, max is ${
|
|
6247
|
+
`Please dont use P2WDA for this operation. Data too large. Raw size: ${t} bytes, estimated compressed: ${r} bytes, needs ${s} witness fields, max is ${j.MAX_WITNESS_FIELDS}`
|
|
6245
6248
|
);
|
|
6246
6249
|
}
|
|
6247
6250
|
}
|
|
@@ -6256,17 +6259,17 @@ class Z extends m {
|
|
|
6256
6259
|
throw new Error(`No witness script for P2WDA input #${t}`);
|
|
6257
6260
|
if (!this.compiledOperationData)
|
|
6258
6261
|
throw new Error("Operation data not compiled");
|
|
6259
|
-
const i = e.partialSig[0].signature, r =
|
|
6262
|
+
const i = e.partialSig[0].signature, r = T.concat([i, this.compiledOperationData]), s = st.signMessage(
|
|
6260
6263
|
this.signer,
|
|
6261
6264
|
r
|
|
6262
|
-
), o =
|
|
6263
|
-
if (h.length >
|
|
6265
|
+
), o = T.from(s.signature), c = T.concat([o, this.compiledOperationData]), u = N.compress(c), h = this.splitIntoWitnessChunks(u);
|
|
6266
|
+
if (h.length > j.MAX_WITNESS_FIELDS)
|
|
6264
6267
|
throw new Error(
|
|
6265
|
-
`Compressed data needs ${h.length} witness fields, max is ${
|
|
6268
|
+
`Compressed data needs ${h.length} witness fields, max is ${j.MAX_WITNESS_FIELDS}`
|
|
6266
6269
|
);
|
|
6267
6270
|
const l = [i];
|
|
6268
|
-
for (let d = 0; d <
|
|
6269
|
-
l.push(d < h.length ? h[d] :
|
|
6271
|
+
for (let d = 0; d < j.MAX_WITNESS_FIELDS; d++)
|
|
6272
|
+
l.push(d < h.length ? h[d] : T.alloc(0));
|
|
6270
6273
|
return l.push(e.witnessScript), {
|
|
6271
6274
|
finalScriptSig: void 0,
|
|
6272
6275
|
finalScriptWitness: m.witnessStackToScriptWitness(l)
|
|
@@ -6280,15 +6283,15 @@ class Z extends m {
|
|
|
6280
6283
|
let i = 0;
|
|
6281
6284
|
for (; i < t.length; ) {
|
|
6282
6285
|
const r = Math.min(
|
|
6283
|
-
|
|
6286
|
+
j.MAX_BYTES_PER_WITNESS,
|
|
6284
6287
|
t.length - i
|
|
6285
6288
|
);
|
|
6286
|
-
e.push(
|
|
6289
|
+
e.push(T.from(t.subarray(i, i + r))), i += r;
|
|
6287
6290
|
}
|
|
6288
6291
|
return e;
|
|
6289
6292
|
}
|
|
6290
6293
|
}
|
|
6291
|
-
class
|
|
6294
|
+
class ge extends m {
|
|
6292
6295
|
constructor(t) {
|
|
6293
6296
|
super({
|
|
6294
6297
|
...t,
|
|
@@ -6450,7 +6453,7 @@ class Se extends m {
|
|
|
6450
6453
|
};
|
|
6451
6454
|
}
|
|
6452
6455
|
}
|
|
6453
|
-
class
|
|
6456
|
+
class Ge extends m {
|
|
6454
6457
|
constructor(t) {
|
|
6455
6458
|
if (super(t), this.type = y.INTERACTION, this.cachedValuePerOutput = null, !t.to)
|
|
6456
6459
|
throw new Error("Contract address (to) is required");
|
|
@@ -6460,20 +6463,20 @@ class Qe extends m {
|
|
|
6460
6463
|
throw new Error("Calldata is required");
|
|
6461
6464
|
if (!t.challenge)
|
|
6462
6465
|
throw new Error("Challenge solution is required");
|
|
6463
|
-
if (this.contractAddress = t.to, this.contractSecret =
|
|
6466
|
+
if (this.contractAddress = t.to, this.contractSecret = T.from(t.contract.replace("0x", ""), "hex"), this.disableAutoRefund = t.disableAutoRefund || !1, this.maxChunkSize = t.maxChunkSize ?? E.MAX_CHUNK_SIZE, this.contractSecret.length !== 32)
|
|
6464
6467
|
throw new Error("Invalid contract secret length. Expected 32 bytes.");
|
|
6465
6468
|
if (this.calldata = N.compress(t.calldata), this.randomBytes = t.randomBytes || K.rndBytes(), this.scriptSigner = A.fromSeedKeyPair(this.randomBytes, this.network), this.challenge = t.challenge, this.epochChallenge = M.generateTimeLockAddress(
|
|
6466
6469
|
this.challenge.publicKey.originalPublicKeyBuffer(),
|
|
6467
6470
|
this.network
|
|
6468
|
-
), this.calldataGenerator = new
|
|
6469
|
-
|
|
6470
|
-
O(
|
|
6471
|
+
), this.calldataGenerator = new oe(
|
|
6472
|
+
T.from(this.signer.publicKey),
|
|
6473
|
+
O(T.from(this.scriptSigner.publicKey)),
|
|
6471
6474
|
this.network
|
|
6472
6475
|
), t.compiledTargetScript)
|
|
6473
|
-
if (
|
|
6476
|
+
if (T.isBuffer(t.compiledTargetScript))
|
|
6474
6477
|
this.compiledTargetScript = t.compiledTargetScript;
|
|
6475
6478
|
else if (typeof t.compiledTargetScript == "string")
|
|
6476
|
-
this.compiledTargetScript =
|
|
6479
|
+
this.compiledTargetScript = T.from(t.compiledTargetScript, "hex");
|
|
6477
6480
|
else
|
|
6478
6481
|
throw new Error("Invalid compiled target script format.");
|
|
6479
6482
|
else
|
|
@@ -6485,7 +6488,7 @@ class Qe extends m {
|
|
|
6485
6488
|
this.generateFeatures(t)
|
|
6486
6489
|
);
|
|
6487
6490
|
this.hashCommitmentGenerator = new E(
|
|
6488
|
-
|
|
6491
|
+
T.from(this.signer.publicKey),
|
|
6489
6492
|
this.network
|
|
6490
6493
|
), this.commitmentOutputs = this.hashCommitmentGenerator.prepareChunks(
|
|
6491
6494
|
this.compiledTargetScript,
|
|
@@ -6574,7 +6577,7 @@ class Qe extends m {
|
|
|
6574
6577
|
* @param setupTxId The transaction ID of the setup transaction
|
|
6575
6578
|
*/
|
|
6576
6579
|
buildRevealTransaction(t) {
|
|
6577
|
-
const e = new
|
|
6580
|
+
const e = new F({ network: this.network }), i = this.calculateValuePerOutput();
|
|
6578
6581
|
for (let p = 0; p < this.commitmentOutputs.length; p++) {
|
|
6579
6582
|
const f = this.commitmentOutputs[p];
|
|
6580
6583
|
e.addInput({
|
|
@@ -6587,7 +6590,7 @@ class Qe extends m {
|
|
|
6587
6590
|
witnessScript: f.witnessScript
|
|
6588
6591
|
});
|
|
6589
6592
|
}
|
|
6590
|
-
const r = BigInt(this.commitmentOutputs.length) * i, s = this.getTransactionOPNetFee(), o = s <
|
|
6593
|
+
const r = BigInt(this.commitmentOutputs.length) * i, s = this.getTransactionOPNetFee(), o = s < V ? V : s;
|
|
6591
6594
|
e.addOutput({
|
|
6592
6595
|
address: this.epochChallenge.address,
|
|
6593
6596
|
value: Number(o)
|
|
@@ -6683,14 +6686,14 @@ class Qe extends m {
|
|
|
6683
6686
|
calculateValuePerOutput() {
|
|
6684
6687
|
if (this.cachedValuePerOutput !== null)
|
|
6685
6688
|
return this.cachedValuePerOutput;
|
|
6686
|
-
const t = this.commitmentOutputs.length, e = this.getTransactionOPNetFee(), i = e <
|
|
6689
|
+
const t = this.commitmentOutputs.length, e = this.getTransactionOPNetFee(), i = e < V ? V : e, r = this.estimateRevealVBytes(), s = BigInt(Math.ceil(r * this.feeRate)), o = i + s + m.MINIMUM_DUST, c = BigInt(Math.ceil(Number(o) / t)), u = E.MIN_OUTPUT_VALUE;
|
|
6687
6690
|
return this.cachedValuePerOutput = c > u ? c : u, this.cachedValuePerOutput;
|
|
6688
6691
|
}
|
|
6689
6692
|
/**
|
|
6690
6693
|
* Get refund address.
|
|
6691
6694
|
*/
|
|
6692
6695
|
getRefundAddress() {
|
|
6693
|
-
return this.from ? this.from :
|
|
6696
|
+
return this.from ? this.from : ae.generatePKSH(this.signer.publicKey, this.network);
|
|
6694
6697
|
}
|
|
6695
6698
|
/**
|
|
6696
6699
|
* Generate features (same as InteractionTransaction).
|
|
@@ -6698,13 +6701,13 @@ class Qe extends m {
|
|
|
6698
6701
|
generateFeatures(t) {
|
|
6699
6702
|
const e = [];
|
|
6700
6703
|
t.loadedStorage && e.push({
|
|
6701
|
-
priority:
|
|
6704
|
+
priority: Q.ACCESS_LIST,
|
|
6702
6705
|
opcode: W.ACCESS_LIST,
|
|
6703
6706
|
data: t.loadedStorage
|
|
6704
6707
|
});
|
|
6705
6708
|
const i = t.challenge.getSubmission();
|
|
6706
6709
|
if (i && e.push({
|
|
6707
|
-
priority:
|
|
6710
|
+
priority: Q.EPOCH_SUBMISSION,
|
|
6708
6711
|
opcode: W.EPOCH_SUBMISSION,
|
|
6709
6712
|
data: i
|
|
6710
6713
|
}), t.revealMLDSAPublicKey && !t.linkMLDSAPublicKeyToAddress)
|
|
@@ -6726,7 +6729,7 @@ class Qe extends m {
|
|
|
6726
6729
|
}
|
|
6727
6730
|
}
|
|
6728
6731
|
}
|
|
6729
|
-
class
|
|
6732
|
+
class Qe {
|
|
6730
6733
|
constructor() {
|
|
6731
6734
|
this.debug = !1, this.DUMMY_PUBKEY = a.alloc(32, 1), this.P2TR_SCRIPT = a.concat([a.from([81, 32]), this.DUMMY_PUBKEY]), this.INITIAL_FUNDING_ESTIMATE = 2000n, this.MAX_ITERATIONS = 10;
|
|
6732
6735
|
}
|
|
@@ -6747,7 +6750,7 @@ class je {
|
|
|
6747
6750
|
return e;
|
|
6748
6751
|
if (!("signer" in t))
|
|
6749
6752
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6750
|
-
const r = await new
|
|
6753
|
+
const r = await new ge(t).signTransaction();
|
|
6751
6754
|
return {
|
|
6752
6755
|
transaction: r.toHex(),
|
|
6753
6756
|
nextUTXOs: this.getUTXOAsTransaction(r, t.from, 0),
|
|
@@ -6770,7 +6773,7 @@ class je {
|
|
|
6770
6773
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6771
6774
|
const e = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: i, estimatedAmount: r, challenge: s } = await this.iterateFundingAmount(
|
|
6772
6775
|
{ ...t, optionalInputs: e },
|
|
6773
|
-
|
|
6776
|
+
Wt,
|
|
6774
6777
|
async (p) => {
|
|
6775
6778
|
const f = await p.estimateTransactionFees(), w = this.getPriorityFee(t), S = p.getOptionalOutputValue();
|
|
6776
6779
|
return f + w + S;
|
|
@@ -6801,7 +6804,7 @@ class je {
|
|
|
6801
6804
|
estimatedFees: i.estimatedFees,
|
|
6802
6805
|
compiledTargetScript: i.exportCompiledTargetScript(),
|
|
6803
6806
|
optionalInputs: e
|
|
6804
|
-
}, d = await new
|
|
6807
|
+
}, d = await new Wt(h).signTransaction();
|
|
6805
6808
|
return [
|
|
6806
6809
|
u.tx.toHex(),
|
|
6807
6810
|
d.toHex(),
|
|
@@ -6830,10 +6833,10 @@ class je {
|
|
|
6830
6833
|
return this.signP2WDAInteraction(t);
|
|
6831
6834
|
const r = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: s, estimatedAmount: o, challenge: c } = await this.iterateFundingAmount(
|
|
6832
6835
|
{ ...t, optionalInputs: r },
|
|
6833
|
-
|
|
6836
|
+
Nt,
|
|
6834
6837
|
async (S) => {
|
|
6835
|
-
const b = await S.estimateTransactionFees(),
|
|
6836
|
-
return b +
|
|
6838
|
+
const b = await S.estimateTransactionFees(), _ = S.getTotalOutputValue();
|
|
6839
|
+
return b + _;
|
|
6837
6840
|
},
|
|
6838
6841
|
"Interaction"
|
|
6839
6842
|
);
|
|
@@ -6869,7 +6872,7 @@ class je {
|
|
|
6869
6872
|
nonWitnessUtxo: l.tx.toBuffer(),
|
|
6870
6873
|
estimatedFees: s.estimatedFees,
|
|
6871
6874
|
optionalInputs: r
|
|
6872
|
-
}, f = new
|
|
6875
|
+
}, f = new Nt(p), w = await f.signTransaction();
|
|
6873
6876
|
return {
|
|
6874
6877
|
interactionAddress: s.getScriptAddress(),
|
|
6875
6878
|
fundingTransaction: l.tx.toHex(),
|
|
@@ -6913,7 +6916,7 @@ class je {
|
|
|
6913
6916
|
throw new Error('Field "signer" not provided.');
|
|
6914
6917
|
if (!t.challenge)
|
|
6915
6918
|
throw new Error('Field "challenge" not provided.');
|
|
6916
|
-
const e = this.parseOptionalInputs(t.optionalInputs), i = new
|
|
6919
|
+
const e = this.parseOptionalInputs(t.optionalInputs), i = new Ge({
|
|
6917
6920
|
...t,
|
|
6918
6921
|
optionalInputs: e
|
|
6919
6922
|
}), r = await i.build();
|
|
@@ -6943,10 +6946,10 @@ class je {
|
|
|
6943
6946
|
throw new Error('Field "signer" not provided, OP_WALLET not detected.');
|
|
6944
6947
|
const i = this.parseOptionalInputs(t.optionalInputs), { finalTransaction: r, estimatedAmount: s, challenge: o } = await this.iterateFundingAmount(
|
|
6945
6948
|
{ ...t, optionalInputs: i },
|
|
6946
|
-
|
|
6947
|
-
async (
|
|
6948
|
-
const
|
|
6949
|
-
return
|
|
6949
|
+
ft,
|
|
6950
|
+
async (xt) => {
|
|
6951
|
+
const vt = await xt.estimateTransactionFees(), kt = this.getPriorityFee(t), li = xt.getOptionalOutputValue();
|
|
6952
|
+
return vt + kt + li;
|
|
6950
6953
|
},
|
|
6951
6954
|
"Deployment"
|
|
6952
6955
|
);
|
|
@@ -6962,7 +6965,7 @@ class je {
|
|
|
6962
6965
|
if (!u)
|
|
6963
6966
|
throw new Error("Could not sign funding transaction.");
|
|
6964
6967
|
c.estimatedFees = u.estimatedFees;
|
|
6965
|
-
const l = await new
|
|
6968
|
+
const l = await new Mt({
|
|
6966
6969
|
...c,
|
|
6967
6970
|
optionalInputs: [],
|
|
6968
6971
|
optionalOutputs: []
|
|
@@ -6986,7 +6989,7 @@ class je {
|
|
|
6986
6989
|
nonWitnessUtxo: l.toBuffer(),
|
|
6987
6990
|
estimatedFees: r.estimatedFees,
|
|
6988
6991
|
optionalInputs: i
|
|
6989
|
-
}, w = new
|
|
6992
|
+
}, w = new ft(f), S = await w.signTransaction(), b = l.outs[1], _ = {
|
|
6990
6993
|
transactionId: l.getId(),
|
|
6991
6994
|
outputIndex: 1,
|
|
6992
6995
|
scriptPubKey: {
|
|
@@ -6999,7 +7002,7 @@ class je {
|
|
|
6999
7002
|
transaction: [l.toHex(), S.toHex()],
|
|
7000
7003
|
contractAddress: w.getContractAddress(),
|
|
7001
7004
|
contractPubKey: w.contractPubKey,
|
|
7002
|
-
utxos: [
|
|
7005
|
+
utxos: [_],
|
|
7003
7006
|
challenge: o.toRaw(),
|
|
7004
7007
|
inputUtxos: t.utxos
|
|
7005
7008
|
};
|
|
@@ -7134,7 +7137,7 @@ class je {
|
|
|
7134
7137
|
*/
|
|
7135
7138
|
async createFundTransaction(t) {
|
|
7136
7139
|
if (!t.to) throw new Error('Field "to" not provided.');
|
|
7137
|
-
const e = new
|
|
7140
|
+
const e = new Mt(t), i = await e.signTransaction();
|
|
7138
7141
|
if (!i)
|
|
7139
7142
|
throw new Error("Could not sign funding transaction.");
|
|
7140
7143
|
return {
|
|
@@ -7156,7 +7159,7 @@ class je {
|
|
|
7156
7159
|
* @returns {boolean} - true if any UTXO is P2WDA, false otherwise
|
|
7157
7160
|
*/
|
|
7158
7161
|
hasP2WDAInputs(t) {
|
|
7159
|
-
return t.some((e) =>
|
|
7162
|
+
return t.some((e) => z.isP2WDAUTXO(e));
|
|
7160
7163
|
}
|
|
7161
7164
|
/**
|
|
7162
7165
|
* Write PSBT header with type and consensus version.
|
|
@@ -7166,7 +7169,7 @@ class je {
|
|
|
7166
7169
|
*/
|
|
7167
7170
|
writePSBTHeader(t, e) {
|
|
7168
7171
|
const i = a.from(e, "base64"), r = a.alloc(2);
|
|
7169
|
-
return r.writeUInt8(t, 0), r.writeUInt8(
|
|
7172
|
+
return r.writeUInt8(t, 0), r.writeUInt8($t, 1), a.concat([r, i]).toString("hex");
|
|
7170
7173
|
}
|
|
7171
7174
|
/**
|
|
7172
7175
|
* Sign a P2WDA interaction transaction
|
|
@@ -7192,7 +7195,7 @@ class je {
|
|
|
7192
7195
|
throw new Error(
|
|
7193
7196
|
"P2WDA interactions require a signer. OP_WALLET is not supported for P2WDA."
|
|
7194
7197
|
);
|
|
7195
|
-
const e = this.parseOptionalInputs(t.optionalInputs), i = new
|
|
7198
|
+
const e = this.parseOptionalInputs(t.optionalInputs), i = new j({
|
|
7196
7199
|
...t,
|
|
7197
7200
|
optionalInputs: e
|
|
7198
7201
|
}), r = await i.signTransaction();
|
|
@@ -7231,14 +7234,14 @@ class je {
|
|
|
7231
7234
|
* @param {new (params: P) => T} TransactionClass - The transaction class constructor
|
|
7232
7235
|
* @param {(tx: T) => Promise<bigint>} calculateAmount - Function to calculate required amount
|
|
7233
7236
|
* @param {string} debugPrefix - Prefix for debug logging
|
|
7234
|
-
* @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge:
|
|
7237
|
+
* @returns {Promise<{finalTransaction: T, estimatedAmount: bigint, challenge: IChallengeSolution | null}>} - The final transaction and estimated amount
|
|
7235
7238
|
*/
|
|
7236
7239
|
async iterateFundingAmount(t, e, i, r) {
|
|
7237
7240
|
const s = "randomBytes" in t ? t.randomBytes ?? K.rndBytes() : K.rndBytes(), o = k.dead().p2tr(t.network);
|
|
7238
7241
|
let c = this.INITIAL_FUNDING_ESTIMATE, u = 0n, h = 0, l = null, d = null;
|
|
7239
7242
|
for (; h < this.MAX_ITERATIONS && c !== u; ) {
|
|
7240
7243
|
u = c;
|
|
7241
|
-
const p = new
|
|
7244
|
+
const p = new Jt();
|
|
7242
7245
|
p.addOutput(this.P2TR_SCRIPT, Number(c));
|
|
7243
7246
|
const f = {
|
|
7244
7247
|
transactionId: a.alloc(32, 0).toString("hex"),
|
|
@@ -7266,9 +7269,9 @@ class je {
|
|
|
7266
7269
|
await S.generateTransactionMinimalSignatures(), c = await i(S);
|
|
7267
7270
|
} catch (b) {
|
|
7268
7271
|
if (b instanceof Error) {
|
|
7269
|
-
const
|
|
7270
|
-
if (
|
|
7271
|
-
c = BigInt(
|
|
7272
|
+
const _ = b.message.match(/need (\d+) sats but only have (\d+) sats/);
|
|
7273
|
+
if (_)
|
|
7274
|
+
c = BigInt(_[1]), this.debug && console.log(
|
|
7272
7275
|
`${r}: Caught insufficient funds, updating to ${c}`
|
|
7273
7276
|
);
|
|
7274
7277
|
else
|
|
@@ -7320,7 +7323,7 @@ class x extends m {
|
|
|
7320
7323
|
if (super({
|
|
7321
7324
|
...t,
|
|
7322
7325
|
signer: A.fromPrivateKey(
|
|
7323
|
-
|
|
7326
|
+
Ue(a.from("aaaaaaaa", "utf-8"))
|
|
7324
7327
|
),
|
|
7325
7328
|
priorityFee: 0n,
|
|
7326
7329
|
gasSatFee: 0n
|
|
@@ -7333,7 +7336,7 @@ class x extends m {
|
|
|
7333
7336
|
};
|
|
7334
7337
|
}, !t.pubkeys)
|
|
7335
7338
|
throw new Error("Pubkeys are required");
|
|
7336
|
-
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 =
|
|
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 = Pt.compile(
|
|
7337
7340
|
t.pubkeys,
|
|
7338
7341
|
this.minimumSignatures
|
|
7339
7342
|
), this.scriptTree = this.getScriptTree(), this.internalInit();
|
|
@@ -7363,7 +7366,7 @@ class x extends m {
|
|
|
7363
7366
|
* @returns {MultiSignTransaction} The multisig transaction
|
|
7364
7367
|
*/
|
|
7365
7368
|
static fromBase64(t) {
|
|
7366
|
-
const e =
|
|
7369
|
+
const e = F.fromBase64(t.psbt, { network: t.network });
|
|
7367
7370
|
return new x({
|
|
7368
7371
|
...t,
|
|
7369
7372
|
psbt: e
|
|
@@ -7706,23 +7709,23 @@ class x extends m {
|
|
|
7706
7709
|
};
|
|
7707
7710
|
}
|
|
7708
7711
|
}
|
|
7709
|
-
const
|
|
7710
|
-
function
|
|
7712
|
+
const Se = 1, _t = 66;
|
|
7713
|
+
function je(n) {
|
|
7711
7714
|
return n.type === y.FUNDING;
|
|
7712
7715
|
}
|
|
7713
|
-
function
|
|
7716
|
+
function Ze(n) {
|
|
7714
7717
|
return n.type === y.DEPLOYMENT;
|
|
7715
7718
|
}
|
|
7716
|
-
function
|
|
7719
|
+
function Je(n) {
|
|
7717
7720
|
return n.type === y.INTERACTION;
|
|
7718
7721
|
}
|
|
7719
|
-
function
|
|
7722
|
+
function et(n) {
|
|
7720
7723
|
return n.type === y.MULTI_SIG;
|
|
7721
7724
|
}
|
|
7722
|
-
function
|
|
7725
|
+
function ti(n) {
|
|
7723
7726
|
return n.type === y.CUSTOM_CODE;
|
|
7724
7727
|
}
|
|
7725
|
-
function
|
|
7728
|
+
function ei(n) {
|
|
7726
7729
|
return n.type === y.CANCEL;
|
|
7727
7730
|
}
|
|
7728
7731
|
class B {
|
|
@@ -7732,7 +7735,7 @@ class B {
|
|
|
7732
7735
|
* @returns Buffer containing serialized state with checksum
|
|
7733
7736
|
*/
|
|
7734
7737
|
static serialize(t) {
|
|
7735
|
-
const e = new
|
|
7738
|
+
const e = new D();
|
|
7736
7739
|
this.writeHeader(e, t.header), this.writeBaseParams(e, t.baseParams), this.writeUTXOArray(e, t.utxos), this.writeUTXOArray(e, t.optionalInputs), this.writeOutputArray(e, t.optionalOutputs), e.writeBoolean(t.addressRotationEnabled), this.writeSignerMappings(e, t.signerMappings), this.writeTypeSpecificData(e, t.typeSpecificData), this.writePrecomputedData(e, t.precomputedData);
|
|
7737
7740
|
const i = a.from(e.getBuffer()), r = this.calculateChecksum(i);
|
|
7738
7741
|
return a.concat([i, r]);
|
|
@@ -7749,8 +7752,8 @@ class B {
|
|
|
7749
7752
|
const e = t.subarray(-32), i = t.subarray(0, -32), r = this.calculateChecksum(i);
|
|
7750
7753
|
if (!e.equals(r))
|
|
7751
7754
|
throw new Error("Invalid checksum - data may be corrupted");
|
|
7752
|
-
const s = new
|
|
7753
|
-
if (o.formatVersion >
|
|
7755
|
+
const s = new qt(i), o = this.readHeader(s);
|
|
7756
|
+
if (o.formatVersion > Se)
|
|
7754
7757
|
throw new Error(`Unsupported format version: ${o.formatVersion}`);
|
|
7755
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), w = this.readPrecomputedData(s);
|
|
7756
7759
|
return {
|
|
@@ -7798,13 +7801,13 @@ class B {
|
|
|
7798
7801
|
return this.deserialize(a.from(t, "hex"));
|
|
7799
7802
|
}
|
|
7800
7803
|
static writeHeader(t, e) {
|
|
7801
|
-
t.writeU8(
|
|
7804
|
+
t.writeU8(_t), t.writeU8(e.formatVersion), t.writeU8(e.consensusVersion), t.writeU8(e.transactionType), t.writeU32(e.chainId), t.writeU64(BigInt(e.timestamp));
|
|
7802
7805
|
}
|
|
7803
7806
|
static readHeader(t) {
|
|
7804
7807
|
const e = t.readU8();
|
|
7805
|
-
if (e !==
|
|
7808
|
+
if (e !== _t)
|
|
7806
7809
|
throw new Error(
|
|
7807
|
-
`Invalid magic byte: expected 0x${
|
|
7810
|
+
`Invalid magic byte: expected 0x${_t.toString(16)}, got 0x${e.toString(16)}`
|
|
7808
7811
|
);
|
|
7809
7812
|
return {
|
|
7810
7813
|
formatVersion: t.readU8(),
|
|
@@ -8073,13 +8076,13 @@ class B {
|
|
|
8073
8076
|
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();
|
|
8074
8077
|
let d;
|
|
8075
8078
|
if (l) {
|
|
8076
|
-
const p = t.readStringWithLength(), f = t.readStringWithLength(), w = "0x" + a.from(t.readBytesWithLength()).toString("hex"), b = t.readBoolean() ? "0x" + a.from(t.readBytesWithLength()).toString("hex") : void 0,
|
|
8079
|
+
const p = t.readStringWithLength(), f = t.readStringWithLength(), w = "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");
|
|
8077
8080
|
d = {
|
|
8078
8081
|
mldsaPublicKey: p,
|
|
8079
8082
|
legacyPublicKey: f,
|
|
8080
8083
|
solution: w,
|
|
8081
8084
|
graffiti: b,
|
|
8082
|
-
signature:
|
|
8085
|
+
signature: _
|
|
8083
8086
|
};
|
|
8084
8087
|
}
|
|
8085
8088
|
return {
|
|
@@ -8139,8 +8142,8 @@ class B {
|
|
|
8139
8142
|
* Calculate double SHA256 checksum (Bitcoin standard)
|
|
8140
8143
|
*/
|
|
8141
8144
|
static calculateChecksum(t) {
|
|
8142
|
-
const e =
|
|
8143
|
-
return
|
|
8145
|
+
const e = Qt("sha256").update(t).digest();
|
|
8146
|
+
return Qt("sha256").update(e).digest();
|
|
8144
8147
|
}
|
|
8145
8148
|
static networkNameToU8(t) {
|
|
8146
8149
|
switch (t) {
|
|
@@ -8167,7 +8170,7 @@ class B {
|
|
|
8167
8170
|
}
|
|
8168
8171
|
}
|
|
8169
8172
|
}
|
|
8170
|
-
class
|
|
8173
|
+
class $ {
|
|
8171
8174
|
/**
|
|
8172
8175
|
* Capture state from a FundingTransaction
|
|
8173
8176
|
*/
|
|
@@ -8250,8 +8253,8 @@ class X {
|
|
|
8250
8253
|
*/
|
|
8251
8254
|
static createHeader(t, e, i) {
|
|
8252
8255
|
return {
|
|
8253
|
-
formatVersion:
|
|
8254
|
-
consensusVersion:
|
|
8256
|
+
formatVersion: Se,
|
|
8257
|
+
consensusVersion: $t,
|
|
8255
8258
|
transactionType: t,
|
|
8256
8259
|
chainId: i ?? this.networkToChainId(e),
|
|
8257
8260
|
timestamp: Date.now()
|
|
@@ -8438,13 +8441,13 @@ class X {
|
|
|
8438
8441
|
* Convert network to chain ID
|
|
8439
8442
|
*/
|
|
8440
8443
|
static networkToChainId(t) {
|
|
8441
|
-
return
|
|
8444
|
+
return he.Bitcoin;
|
|
8442
8445
|
}
|
|
8443
8446
|
}
|
|
8444
|
-
function
|
|
8447
|
+
function U(n) {
|
|
8445
8448
|
return a.from(n.replace("0x", ""), "hex");
|
|
8446
8449
|
}
|
|
8447
|
-
class
|
|
8450
|
+
class ct {
|
|
8448
8451
|
static {
|
|
8449
8452
|
this.BLOCKS_PER_EPOCH = 5n;
|
|
8450
8453
|
}
|
|
@@ -8464,7 +8467,7 @@ class ut {
|
|
|
8464
8467
|
* Calculate SHA-1 hash
|
|
8465
8468
|
*/
|
|
8466
8469
|
static sha1(t) {
|
|
8467
|
-
return
|
|
8470
|
+
return vi(a.isBuffer(t) ? t : a.from(t));
|
|
8468
8471
|
}
|
|
8469
8472
|
/**
|
|
8470
8473
|
* Calculate mining preimage
|
|
@@ -8529,8 +8532,33 @@ class ut {
|
|
|
8529
8532
|
* Validate epoch winner from raw data
|
|
8530
8533
|
*/
|
|
8531
8534
|
static validateEpochWinner(t) {
|
|
8532
|
-
|
|
8533
|
-
|
|
8535
|
+
try {
|
|
8536
|
+
const e = BigInt(t.epochNumber), i = k.fromString(
|
|
8537
|
+
t.mldsaPublicKey,
|
|
8538
|
+
t.legacyPublicKey
|
|
8539
|
+
), r = U(t.solution), s = U(t.salt), o = t.difficulty, c = {
|
|
8540
|
+
epochHash: U(t.verification.epochHash),
|
|
8541
|
+
epochRoot: U(t.verification.epochRoot),
|
|
8542
|
+
targetHash: U(t.verification.targetHash),
|
|
8543
|
+
targetChecksum: U(t.verification.targetChecksum),
|
|
8544
|
+
startBlock: BigInt(t.verification.startBlock),
|
|
8545
|
+
endBlock: BigInt(t.verification.endBlock),
|
|
8546
|
+
proofs: Object.freeze(t.verification.proofs.map((w) => U(w)))
|
|
8547
|
+
}, u = this.calculatePreimage(
|
|
8548
|
+
c.targetChecksum,
|
|
8549
|
+
i.toBuffer(),
|
|
8550
|
+
s
|
|
8551
|
+
), h = this.sha1(u), l = this.uint8ArrayToBuffer(h);
|
|
8552
|
+
if (!l.equals(r) || this.countMatchingBits(
|
|
8553
|
+
l,
|
|
8554
|
+
c.targetHash
|
|
8555
|
+
) !== o)
|
|
8556
|
+
return !1;
|
|
8557
|
+
const p = e * this.BLOCKS_PER_EPOCH, f = p + this.BLOCKS_PER_EPOCH - 1n;
|
|
8558
|
+
return !(c.startBlock !== p || c.endBlock !== f);
|
|
8559
|
+
} catch {
|
|
8560
|
+
return !1;
|
|
8561
|
+
}
|
|
8534
8562
|
}
|
|
8535
8563
|
/**
|
|
8536
8564
|
* Validate epoch winner from Preimage instance
|
|
@@ -8560,35 +8588,35 @@ class ut {
|
|
|
8560
8588
|
};
|
|
8561
8589
|
}
|
|
8562
8590
|
}
|
|
8563
|
-
class
|
|
8591
|
+
class ii {
|
|
8564
8592
|
constructor(t) {
|
|
8565
|
-
this.epochHash =
|
|
8593
|
+
this.epochHash = U(t.epochHash), this.epochRoot = U(t.epochRoot), this.targetHash = U(t.targetHash), this.targetChecksum = U(t.targetChecksum), this.startBlock = BigInt(t.startBlock), this.endBlock = BigInt(t.endBlock), this.proofs = Object.freeze(t.proofs.map((e) => U(e)));
|
|
8566
8594
|
}
|
|
8567
8595
|
}
|
|
8568
|
-
class
|
|
8596
|
+
class ri {
|
|
8569
8597
|
constructor(t, e) {
|
|
8570
|
-
this.epochNumber = e, this.publicKey = k.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution =
|
|
8598
|
+
this.epochNumber = e, this.publicKey = k.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution = U(t.solution), this.graffiti = t.graffiti ? U(t.graffiti) : void 0, this.signature = U(t.signature);
|
|
8571
8599
|
}
|
|
8572
8600
|
verifySignature() {
|
|
8573
|
-
const t = new
|
|
8601
|
+
const t = new D();
|
|
8574
8602
|
t.writeAddress(this.publicKey), t.writeU64(this.epochNumber), t.writeBytes(this.solution), this.graffiti && t.writeBytes(this.graffiti);
|
|
8575
8603
|
const e = t.getBuffer();
|
|
8576
|
-
return
|
|
8604
|
+
return st.verifySignature(
|
|
8577
8605
|
this.publicKey.tweakedPublicKeyToBuffer(),
|
|
8578
8606
|
e,
|
|
8579
8607
|
this.signature
|
|
8580
8608
|
);
|
|
8581
8609
|
}
|
|
8582
8610
|
}
|
|
8583
|
-
class
|
|
8611
|
+
class se {
|
|
8584
8612
|
constructor(t) {
|
|
8585
|
-
this.epochNumber = BigInt(t.epochNumber), this.publicKey = k.fromString(t.mldsaPublicKey, t.legacyPublicKey), this.solution =
|
|
8613
|
+
this.epochNumber = BigInt(t.epochNumber), this.publicKey = k.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;
|
|
8586
8614
|
}
|
|
8587
8615
|
/**
|
|
8588
8616
|
* Static method to validate from raw data directly
|
|
8589
8617
|
*/
|
|
8590
8618
|
static validateRaw(t) {
|
|
8591
|
-
return
|
|
8619
|
+
return ct.validateEpochWinner(t);
|
|
8592
8620
|
}
|
|
8593
8621
|
verifySubmissionSignature() {
|
|
8594
8622
|
if (!this.submission)
|
|
@@ -8607,7 +8635,7 @@ class $t {
|
|
|
8607
8635
|
* @returns {boolean} True if the challenge is valid
|
|
8608
8636
|
*/
|
|
8609
8637
|
verify() {
|
|
8610
|
-
return
|
|
8638
|
+
return ct.validateChallengeSolution(this);
|
|
8611
8639
|
}
|
|
8612
8640
|
/**
|
|
8613
8641
|
* Get the preimage challenge
|
|
@@ -8651,7 +8679,7 @@ class $t {
|
|
|
8651
8679
|
* @returns {Promise<Buffer>} The calculated solution hash
|
|
8652
8680
|
*/
|
|
8653
8681
|
calculateSolution() {
|
|
8654
|
-
return
|
|
8682
|
+
return ct.calculateSolution(
|
|
8655
8683
|
this.verification.targetChecksum,
|
|
8656
8684
|
this.publicKey.toBuffer(),
|
|
8657
8685
|
this.salt
|
|
@@ -8663,7 +8691,7 @@ class $t {
|
|
|
8663
8691
|
* @returns {Promise<{valid: boolean; difficulty: number}>} Validation result
|
|
8664
8692
|
*/
|
|
8665
8693
|
checkDifficulty(t) {
|
|
8666
|
-
return
|
|
8694
|
+
return ct.checkDifficulty(
|
|
8667
8695
|
this.solution,
|
|
8668
8696
|
this.verification.targetHash,
|
|
8669
8697
|
t
|
|
@@ -8674,10 +8702,10 @@ class $t {
|
|
|
8674
8702
|
* @returns {bigint | null} The target block number or null if epoch 0
|
|
8675
8703
|
*/
|
|
8676
8704
|
getMiningTargetBlock() {
|
|
8677
|
-
return
|
|
8705
|
+
return ct.getMiningTargetBlock(this.epochNumber);
|
|
8678
8706
|
}
|
|
8679
8707
|
}
|
|
8680
|
-
class
|
|
8708
|
+
class ut {
|
|
8681
8709
|
/**
|
|
8682
8710
|
* Reconstruct and optionally rebuild transaction with new parameters
|
|
8683
8711
|
* @param state - Serialized transaction state
|
|
@@ -8709,17 +8737,17 @@ class ht {
|
|
|
8709
8737
|
estimatedFees: t.precomputedData.estimatedFees ? BigInt(t.precomputedData.estimatedFees) : void 0,
|
|
8710
8738
|
compiledTargetScript: t.precomputedData.compiledTargetScript ? a.from(t.precomputedData.compiledTargetScript, "hex") : void 0
|
|
8711
8739
|
}, p = t.typeSpecificData;
|
|
8712
|
-
if (
|
|
8740
|
+
if (je(p))
|
|
8713
8741
|
return this.reconstructFunding(d, p);
|
|
8714
|
-
if (
|
|
8742
|
+
if (Ze(p))
|
|
8715
8743
|
return this.reconstructDeployment(d, p, t);
|
|
8716
|
-
if (
|
|
8744
|
+
if (Je(p))
|
|
8717
8745
|
return this.reconstructInteraction(d, p, t);
|
|
8718
|
-
if (
|
|
8746
|
+
if (et(p))
|
|
8719
8747
|
return this.reconstructMultiSig(d, p);
|
|
8720
|
-
if (
|
|
8748
|
+
if (ti(p))
|
|
8721
8749
|
return this.reconstructCustomScript(d, p, t);
|
|
8722
|
-
if (
|
|
8750
|
+
if (ei(p))
|
|
8723
8751
|
return this.reconstructCancel(d, p);
|
|
8724
8752
|
throw new Error(`Unsupported transaction type: ${t.header.transactionType}`);
|
|
8725
8753
|
}
|
|
@@ -8732,13 +8760,13 @@ class ht {
|
|
|
8732
8760
|
amount: BigInt(e.amount),
|
|
8733
8761
|
splitInputsInto: e.splitInputsInto
|
|
8734
8762
|
};
|
|
8735
|
-
return new
|
|
8763
|
+
return new Mt(i);
|
|
8736
8764
|
}
|
|
8737
8765
|
/**
|
|
8738
8766
|
* Reconstruct a DeploymentTransaction
|
|
8739
8767
|
*/
|
|
8740
8768
|
static reconstructDeployment(t, e, i) {
|
|
8741
|
-
const r = new
|
|
8769
|
+
const r = new se(e.challenge), s = {
|
|
8742
8770
|
...t,
|
|
8743
8771
|
bytecode: a.from(e.bytecode, "hex"),
|
|
8744
8772
|
calldata: e.calldata ? a.from(e.calldata, "hex") : void 0,
|
|
@@ -8747,13 +8775,13 @@ class ht {
|
|
|
8747
8775
|
revealMLDSAPublicKey: e.revealMLDSAPublicKey,
|
|
8748
8776
|
linkMLDSAPublicKeyToAddress: e.linkMLDSAPublicKeyToAddress
|
|
8749
8777
|
};
|
|
8750
|
-
return new
|
|
8778
|
+
return new ft(s);
|
|
8751
8779
|
}
|
|
8752
8780
|
/**
|
|
8753
8781
|
* Reconstruct an InteractionTransaction
|
|
8754
8782
|
*/
|
|
8755
8783
|
static reconstructInteraction(t, e, i) {
|
|
8756
|
-
const r = new
|
|
8784
|
+
const r = new se(e.challenge);
|
|
8757
8785
|
if (!t.to)
|
|
8758
8786
|
throw new Error('InteractionTransaction requires a "to" address');
|
|
8759
8787
|
const s = {
|
|
@@ -8769,7 +8797,7 @@ class ht {
|
|
|
8769
8797
|
revealMLDSAPublicKey: e.revealMLDSAPublicKey,
|
|
8770
8798
|
linkMLDSAPublicKeyToAddress: e.linkMLDSAPublicKeyToAddress
|
|
8771
8799
|
};
|
|
8772
|
-
return new
|
|
8800
|
+
return new Nt(s);
|
|
8773
8801
|
}
|
|
8774
8802
|
/**
|
|
8775
8803
|
* Reconstruct a MultiSignTransaction
|
|
@@ -8823,7 +8851,7 @@ class ht {
|
|
|
8823
8851
|
annex: o,
|
|
8824
8852
|
randomBytes: i.precomputedData.randomBytes ? a.from(i.precomputedData.randomBytes, "hex") : void 0
|
|
8825
8853
|
};
|
|
8826
|
-
return new
|
|
8854
|
+
return new Wt(c);
|
|
8827
8855
|
}
|
|
8828
8856
|
/**
|
|
8829
8857
|
* Reconstruct a CancelTransaction
|
|
@@ -8833,7 +8861,7 @@ class ht {
|
|
|
8833
8861
|
...t,
|
|
8834
8862
|
compiledTargetScript: a.from(e.compiledTargetScript, "hex")
|
|
8835
8863
|
};
|
|
8836
|
-
return new
|
|
8864
|
+
return new ge(i);
|
|
8837
8865
|
}
|
|
8838
8866
|
/**
|
|
8839
8867
|
* Build address rotation config from options
|
|
@@ -8894,17 +8922,17 @@ class ht {
|
|
|
8894
8922
|
static nameToNetwork(t) {
|
|
8895
8923
|
switch (t) {
|
|
8896
8924
|
case "mainnet":
|
|
8897
|
-
return
|
|
8925
|
+
return I;
|
|
8898
8926
|
case "testnet":
|
|
8899
|
-
return
|
|
8927
|
+
return At;
|
|
8900
8928
|
case "regtest":
|
|
8901
|
-
return
|
|
8929
|
+
return zt;
|
|
8902
8930
|
default:
|
|
8903
8931
|
throw new Error(`Unknown network: ${t}`);
|
|
8904
8932
|
}
|
|
8905
8933
|
}
|
|
8906
8934
|
}
|
|
8907
|
-
class
|
|
8935
|
+
class ur {
|
|
8908
8936
|
/**
|
|
8909
8937
|
* Export a FundingTransaction for offline signing
|
|
8910
8938
|
* @param params - Funding transaction parameters
|
|
@@ -8912,7 +8940,7 @@ class Br {
|
|
|
8912
8940
|
* @returns Base64-encoded serialized state
|
|
8913
8941
|
*/
|
|
8914
8942
|
static exportFunding(t, e) {
|
|
8915
|
-
const i =
|
|
8943
|
+
const i = $.fromFunding(t, e);
|
|
8916
8944
|
return B.toBase64(i);
|
|
8917
8945
|
}
|
|
8918
8946
|
/**
|
|
@@ -8922,7 +8950,7 @@ class Br {
|
|
|
8922
8950
|
* @returns Base64-encoded serialized state
|
|
8923
8951
|
*/
|
|
8924
8952
|
static exportDeployment(t, e) {
|
|
8925
|
-
const i =
|
|
8953
|
+
const i = $.fromDeployment(t, e);
|
|
8926
8954
|
return B.toBase64(i);
|
|
8927
8955
|
}
|
|
8928
8956
|
/**
|
|
@@ -8932,7 +8960,7 @@ class Br {
|
|
|
8932
8960
|
* @returns Base64-encoded serialized state
|
|
8933
8961
|
*/
|
|
8934
8962
|
static exportInteraction(t, e) {
|
|
8935
|
-
const i =
|
|
8963
|
+
const i = $.fromInteraction(t, e);
|
|
8936
8964
|
return B.toBase64(i);
|
|
8937
8965
|
}
|
|
8938
8966
|
/**
|
|
@@ -8942,7 +8970,7 @@ class Br {
|
|
|
8942
8970
|
* @returns Base64-encoded serialized state
|
|
8943
8971
|
*/
|
|
8944
8972
|
static exportMultiSig(t, e) {
|
|
8945
|
-
const i =
|
|
8973
|
+
const i = $.fromMultiSig(t, e);
|
|
8946
8974
|
return B.toBase64(i);
|
|
8947
8975
|
}
|
|
8948
8976
|
/**
|
|
@@ -8952,7 +8980,7 @@ class Br {
|
|
|
8952
8980
|
* @returns Base64-encoded serialized state
|
|
8953
8981
|
*/
|
|
8954
8982
|
static exportCustomScript(t, e) {
|
|
8955
|
-
const i =
|
|
8983
|
+
const i = $.fromCustomScript(t, e);
|
|
8956
8984
|
return B.toBase64(i);
|
|
8957
8985
|
}
|
|
8958
8986
|
/**
|
|
@@ -8962,7 +8990,7 @@ class Br {
|
|
|
8962
8990
|
* @returns Base64-encoded serialized state
|
|
8963
8991
|
*/
|
|
8964
8992
|
static exportCancel(t, e) {
|
|
8965
|
-
const i =
|
|
8993
|
+
const i = $.fromCancel(t, e);
|
|
8966
8994
|
return B.toBase64(i);
|
|
8967
8995
|
}
|
|
8968
8996
|
/**
|
|
@@ -8978,19 +9006,19 @@ class Br {
|
|
|
8978
9006
|
let s;
|
|
8979
9007
|
switch (r) {
|
|
8980
9008
|
case y.FUNDING:
|
|
8981
|
-
s =
|
|
9009
|
+
s = $.fromFunding(
|
|
8982
9010
|
e,
|
|
8983
9011
|
i
|
|
8984
9012
|
);
|
|
8985
9013
|
break;
|
|
8986
9014
|
case y.DEPLOYMENT:
|
|
8987
|
-
s =
|
|
9015
|
+
s = $.fromDeployment(
|
|
8988
9016
|
e,
|
|
8989
9017
|
i
|
|
8990
9018
|
);
|
|
8991
9019
|
break;
|
|
8992
9020
|
case y.INTERACTION:
|
|
8993
|
-
s =
|
|
9021
|
+
s = $.fromInteraction(
|
|
8994
9022
|
e,
|
|
8995
9023
|
i
|
|
8996
9024
|
);
|
|
@@ -9008,7 +9036,7 @@ class Br {
|
|
|
9008
9036
|
*/
|
|
9009
9037
|
static importForSigning(t, e) {
|
|
9010
9038
|
const i = B.fromBase64(t);
|
|
9011
|
-
return
|
|
9039
|
+
return ut.reconstruct(i, e);
|
|
9012
9040
|
}
|
|
9013
9041
|
/**
|
|
9014
9042
|
* Complete signing and export signed transaction
|
|
@@ -9131,12 +9159,12 @@ class Br {
|
|
|
9131
9159
|
*/
|
|
9132
9160
|
static async multiSigAddSignature(t, e) {
|
|
9133
9161
|
const i = B.fromBase64(t);
|
|
9134
|
-
if (!
|
|
9162
|
+
if (!et(i.typeSpecificData))
|
|
9135
9163
|
throw new Error("State is not a multisig transaction");
|
|
9136
9164
|
const r = i.typeSpecificData, s = r.pubkeys.map((f) => a.from(f, "hex"));
|
|
9137
9165
|
let o;
|
|
9138
|
-
const c =
|
|
9139
|
-
r.existingPsbtBase64 ? o =
|
|
9166
|
+
const c = ut.nameToNetwork(i.baseParams.networkName);
|
|
9167
|
+
r.existingPsbtBase64 ? o = F.fromBase64(r.existingPsbtBase64, { network: c }) : o = await this.importForSigning(t, {
|
|
9140
9168
|
signer: e
|
|
9141
9169
|
}).signPSBT();
|
|
9142
9170
|
const u = [];
|
|
@@ -9179,12 +9207,12 @@ class Br {
|
|
|
9179
9207
|
*/
|
|
9180
9208
|
static multiSigHasSigned(t, e) {
|
|
9181
9209
|
const i = B.fromBase64(t);
|
|
9182
|
-
if (!
|
|
9210
|
+
if (!et(i.typeSpecificData))
|
|
9183
9211
|
throw new Error("State is not a multisig transaction");
|
|
9184
9212
|
const r = i.typeSpecificData;
|
|
9185
9213
|
if (!r.existingPsbtBase64)
|
|
9186
9214
|
return !1;
|
|
9187
|
-
const s =
|
|
9215
|
+
const s = ut.nameToNetwork(i.baseParams.networkName), o = F.fromBase64(r.existingPsbtBase64, { network: s }), c = a.isBuffer(e) ? e : a.from(e, "hex");
|
|
9188
9216
|
return x.verifyIfSigned(o, c);
|
|
9189
9217
|
}
|
|
9190
9218
|
/**
|
|
@@ -9195,7 +9223,7 @@ class Br {
|
|
|
9195
9223
|
*/
|
|
9196
9224
|
static multiSigGetSignatureStatus(t) {
|
|
9197
9225
|
const e = B.fromBase64(t);
|
|
9198
|
-
if (!
|
|
9226
|
+
if (!et(e.typeSpecificData))
|
|
9199
9227
|
throw new Error("State is not a multisig transaction");
|
|
9200
9228
|
const i = e.typeSpecificData, r = i.minimumSignatures;
|
|
9201
9229
|
if (!i.existingPsbtBase64)
|
|
@@ -9205,7 +9233,7 @@ class Br {
|
|
|
9205
9233
|
isComplete: !1,
|
|
9206
9234
|
signers: []
|
|
9207
9235
|
};
|
|
9208
|
-
const s =
|
|
9236
|
+
const s = ut.nameToNetwork(e.baseParams.networkName), o = F.fromBase64(i.existingPsbtBase64, { network: s }), c = /* @__PURE__ */ new Set();
|
|
9209
9237
|
for (let h = i.originalInputCount; h < o.data.inputs.length; h++) {
|
|
9210
9238
|
const l = o.data.inputs[h];
|
|
9211
9239
|
if (l.tapScriptSig)
|
|
@@ -9238,12 +9266,12 @@ class Br {
|
|
|
9238
9266
|
*/
|
|
9239
9267
|
static multiSigFinalize(t) {
|
|
9240
9268
|
const e = B.fromBase64(t);
|
|
9241
|
-
if (!
|
|
9269
|
+
if (!et(e.typeSpecificData))
|
|
9242
9270
|
throw new Error("State is not a multisig transaction");
|
|
9243
9271
|
const i = e.typeSpecificData;
|
|
9244
9272
|
if (!i.existingPsbtBase64)
|
|
9245
9273
|
throw new Error("No PSBT found in state - transaction has not been signed");
|
|
9246
|
-
const r =
|
|
9274
|
+
const r = ut.nameToNetwork(e.baseParams.networkName), s = F.fromBase64(i.existingPsbtBase64, { network: r }), o = i.pubkeys.map((h) => a.from(h, "hex")), c = [];
|
|
9247
9275
|
for (let h = i.originalInputCount; h < s.data.inputs.length; h++)
|
|
9248
9276
|
c.push(o);
|
|
9249
9277
|
if (!x.attemptFinalizeInputs(
|
|
@@ -9264,7 +9292,7 @@ class Br {
|
|
|
9264
9292
|
*/
|
|
9265
9293
|
static multiSigGetPsbt(t) {
|
|
9266
9294
|
const e = B.fromBase64(t);
|
|
9267
|
-
if (!
|
|
9295
|
+
if (!et(e.typeSpecificData))
|
|
9268
9296
|
throw new Error("State is not a multisig transaction");
|
|
9269
9297
|
return e.typeSpecificData.existingPsbtBase64 || null;
|
|
9270
9298
|
}
|
|
@@ -9277,7 +9305,7 @@ class Br {
|
|
|
9277
9305
|
*/
|
|
9278
9306
|
static multiSigUpdatePsbt(t, e) {
|
|
9279
9307
|
const i = B.fromBase64(t);
|
|
9280
|
-
if (!
|
|
9308
|
+
if (!et(i.typeSpecificData))
|
|
9281
9309
|
throw new Error("State is not a multisig transaction");
|
|
9282
9310
|
const r = {
|
|
9283
9311
|
...i,
|
|
@@ -9289,7 +9317,7 @@ class Br {
|
|
|
9289
9317
|
return B.toBase64(r);
|
|
9290
9318
|
}
|
|
9291
9319
|
}
|
|
9292
|
-
class
|
|
9320
|
+
class hr {
|
|
9293
9321
|
constructor(t) {
|
|
9294
9322
|
this.opnetAPIUrl = t, this.utxoPath = "address/utxos", this.rpc = "json-rpc";
|
|
9295
9323
|
}
|
|
@@ -9413,7 +9441,7 @@ class xr {
|
|
|
9413
9441
|
priorityFee: 0n,
|
|
9414
9442
|
gasSatFee: 330n,
|
|
9415
9443
|
mldsaSigner: null
|
|
9416
|
-
}, l = await new
|
|
9444
|
+
}, l = await new Qe().createBTCTransfer(u), d = await this.broadcastTransaction(l.tx, !1);
|
|
9417
9445
|
return d || { error: "Could not broadcast transaction" };
|
|
9418
9446
|
}
|
|
9419
9447
|
/**
|
|
@@ -9500,100 +9528,8 @@ class xr {
|
|
|
9500
9528
|
return new UnwrapGeneration(result as UnwrappedGenerationParameters);
|
|
9501
9529
|
}*/
|
|
9502
9530
|
}
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
super(t), this.logColor = "#00ffe1", this.feesAddition = 10000n, this.sighashTypes = [], this.signer = t.signer, this.network = t.network, this.transaction = t.psbt, this.ignoreSignatureError(), this.tweakSigner(), this.internalInit();
|
|
9506
|
-
}
|
|
9507
|
-
static fromBase64(t, e) {
|
|
9508
|
-
const i = _.fromBase64(t, {
|
|
9509
|
-
network: e.network
|
|
9510
|
-
});
|
|
9511
|
-
return new Tt({
|
|
9512
|
-
...e,
|
|
9513
|
-
psbt: i
|
|
9514
|
-
});
|
|
9515
|
-
}
|
|
9516
|
-
static fromHex(t, e) {
|
|
9517
|
-
const i = _.fromHex(t, {
|
|
9518
|
-
network: e.network
|
|
9519
|
-
});
|
|
9520
|
-
return new Tt({
|
|
9521
|
-
...e,
|
|
9522
|
-
psbt: i
|
|
9523
|
-
});
|
|
9524
|
-
}
|
|
9525
|
-
static from(t) {
|
|
9526
|
-
const e = new _({ network: t.network });
|
|
9527
|
-
return new Tt({
|
|
9528
|
-
...t,
|
|
9529
|
-
psbt: e
|
|
9530
|
-
});
|
|
9531
|
-
}
|
|
9532
|
-
/**
|
|
9533
|
-
* @description Extract the transaction
|
|
9534
|
-
*/
|
|
9535
|
-
extractTransaction() {
|
|
9536
|
-
return this.transaction.extractTransaction();
|
|
9537
|
-
}
|
|
9538
|
-
/**
|
|
9539
|
-
* Final tx hex string.
|
|
9540
|
-
*/
|
|
9541
|
-
final() {
|
|
9542
|
-
return this.extractTransaction().toHex();
|
|
9543
|
-
}
|
|
9544
|
-
/**
|
|
9545
|
-
* Get the psbt as a hex string
|
|
9546
|
-
*/
|
|
9547
|
-
toHex() {
|
|
9548
|
-
return this.transaction.toHex();
|
|
9549
|
-
}
|
|
9550
|
-
/**
|
|
9551
|
-
* @description Add an input to the transaction
|
|
9552
|
-
* @param input
|
|
9553
|
-
* @param checkPartialSigs
|
|
9554
|
-
*/
|
|
9555
|
-
addInput(t, e = !1) {
|
|
9556
|
-
this.transaction.addInput(t, e);
|
|
9557
|
-
}
|
|
9558
|
-
/**
|
|
9559
|
-
* @description Add an output to the transaction
|
|
9560
|
-
* @param output
|
|
9561
|
-
*/
|
|
9562
|
-
addOutput(t) {
|
|
9563
|
-
t.value && this.transaction.addOutput(t);
|
|
9564
|
-
}
|
|
9565
|
-
/**
|
|
9566
|
-
* Attempt to finalize all inputs
|
|
9567
|
-
* @returns {boolean} True if all inputs were finalized
|
|
9568
|
-
*/
|
|
9569
|
-
attemptFinalizeInputs(t = 1) {
|
|
9570
|
-
try {
|
|
9571
|
-
const e = this.transaction.data.inputs;
|
|
9572
|
-
for (let i = t; i < e.length; i++) {
|
|
9573
|
-
const r = e[i];
|
|
9574
|
-
r.finalScriptWitness ? this.transaction.finalizeTaprootInput(i, r.finalScriptWitness) : this.transaction.finalizeInput(i);
|
|
9575
|
-
}
|
|
9576
|
-
return !0;
|
|
9577
|
-
} catch (e) {
|
|
9578
|
-
return this.warn(e.stack || "Couldn't finalize inputs"), !1;
|
|
9579
|
-
}
|
|
9580
|
-
}
|
|
9581
|
-
getPSBT() {
|
|
9582
|
-
return this.transaction;
|
|
9583
|
-
}
|
|
9584
|
-
/*private getTotalOutputAmount(vaults: VaultUTXOs[]): bigint {
|
|
9585
|
-
let total = BigInt(0);
|
|
9586
|
-
for (const vault of vaults) {
|
|
9587
|
-
for (const utxo of vault.utxos) {
|
|
9588
|
-
total += BigInt(utxo.value);
|
|
9589
|
-
}
|
|
9590
|
-
}
|
|
9591
|
-
|
|
9592
|
-
return total;
|
|
9593
|
-
}*/
|
|
9594
|
-
}
|
|
9595
|
-
var ni = /* @__PURE__ */ ((n) => (n[n.UNWRAP = 0] = "UNWRAP", n))(ni || {});
|
|
9596
|
-
class vr {
|
|
9531
|
+
var si = /* @__PURE__ */ ((n) => (n[n.UNWRAP = 0] = "UNWRAP", n))(si || {});
|
|
9532
|
+
class lr {
|
|
9597
9533
|
/**
|
|
9598
9534
|
* Generate a multi-sig address
|
|
9599
9535
|
* @param {Buffer[]} pubKeys - The public keys to use
|
|
@@ -9602,7 +9538,7 @@ class vr {
|
|
|
9602
9538
|
* @returns {string} - The generated address
|
|
9603
9539
|
* @throws {Error} - If the address cannot be generated
|
|
9604
9540
|
*/
|
|
9605
|
-
static generateMultiSigAddress(t, e, i =
|
|
9541
|
+
static generateMultiSigAddress(t, e, i = I) {
|
|
9606
9542
|
if (A.verifyPubKeys(t, i).length !== t.length) throw new Error("Contains invalid public keys");
|
|
9607
9543
|
const s = {
|
|
9608
9544
|
network: i,
|
|
@@ -9620,10 +9556,10 @@ class vr {
|
|
|
9620
9556
|
return o;
|
|
9621
9557
|
}
|
|
9622
9558
|
}
|
|
9623
|
-
var
|
|
9624
|
-
class
|
|
9559
|
+
var ni = /* @__PURE__ */ ((n) => (n.UINT8 = "UINT8", n.UINT16 = "UINT16", n.UINT32 = "UINT32", n.UINT64 = "UINT64", n.UINT128 = "UINT128", n.UINT256 = "UINT256", n.INT128 = "INT128", n.BOOL = "BOOL", n.ADDRESS = "ADDRESS", n.STRING = "STRING", n.BYTES4 = "BYTES4", n.BYTES32 = "BYTES32", n.BYTES = "BYTES", n.ADDRESS_UINT256_TUPLE = "ADDRESS_UINT256_TUPLE", n.ARRAY_OF_ADDRESSES = "ARRAY_OF_ADDRESSES", n.ARRAY_OF_UINT256 = "ARRAY_OF_UINT256", n.ARRAY_OF_UINT128 = "ARRAY_OF_UINT128", n.ARRAY_OF_UINT64 = "ARRAY_OF_UINT64", n.ARRAY_OF_UINT32 = "ARRAY_OF_UINT32", n.ARRAY_OF_UINT16 = "ARRAY_OF_UINT16", n.ARRAY_OF_UINT8 = "ARRAY_OF_UINT8", n.ARRAY_OF_STRING = "ARRAY_OF_STRING", n.ARRAY_OF_BYTES = "ARRAY_OF_BYTES", n.ARRAY_OF_BUFFERS = "ARRAY_OF_BUFFERS", n))(ni || {});
|
|
9560
|
+
class dr {
|
|
9625
9561
|
decodeData(t, e) {
|
|
9626
|
-
const i = new
|
|
9562
|
+
const i = new qt(t), r = [];
|
|
9627
9563
|
for (let s = 0; s < e.length; s++)
|
|
9628
9564
|
switch (e[s]) {
|
|
9629
9565
|
case "UINT8":
|
|
@@ -9709,16 +9645,16 @@ class kr {
|
|
|
9709
9645
|
return t.toString(16);
|
|
9710
9646
|
}
|
|
9711
9647
|
bigIntToUint8Array(t, e) {
|
|
9712
|
-
const i = new Uint8Array(e), r =
|
|
9648
|
+
const i = new Uint8Array(e), r = X.valueToUint8Array(t);
|
|
9713
9649
|
for (let s = 0; s < e; s++)
|
|
9714
9650
|
i[s] = r[s] || 0;
|
|
9715
9651
|
return i;
|
|
9716
9652
|
}
|
|
9717
9653
|
sha256(t) {
|
|
9718
|
-
return new
|
|
9654
|
+
return new Si.sha256().update(t).digest();
|
|
9719
9655
|
}
|
|
9720
9656
|
}
|
|
9721
|
-
class
|
|
9657
|
+
class we {
|
|
9722
9658
|
constructor(t = []) {
|
|
9723
9659
|
this.items = /* @__PURE__ */ new Set(), this.keys = [];
|
|
9724
9660
|
for (const e of t)
|
|
@@ -9739,7 +9675,7 @@ class ye {
|
|
|
9739
9675
|
this.items.delete(e) && (this.keys = this.keys.filter((i) => i.toBigInt() !== e));
|
|
9740
9676
|
}
|
|
9741
9677
|
clone() {
|
|
9742
|
-
return new
|
|
9678
|
+
return new we(this.keys);
|
|
9743
9679
|
}
|
|
9744
9680
|
clear() {
|
|
9745
9681
|
this.items.clear(), this.keys = [];
|
|
@@ -9754,16 +9690,16 @@ class ye {
|
|
|
9754
9690
|
yield* this.keys;
|
|
9755
9691
|
}
|
|
9756
9692
|
}
|
|
9757
|
-
class
|
|
9693
|
+
class ye {
|
|
9758
9694
|
constructor(t) {
|
|
9759
|
-
this.compareFn = t, this.map = new
|
|
9695
|
+
this.compareFn = t, this.map = new Ot(), this.#t = [];
|
|
9760
9696
|
}
|
|
9761
9697
|
#t;
|
|
9762
9698
|
get size() {
|
|
9763
9699
|
return this.map.size;
|
|
9764
9700
|
}
|
|
9765
9701
|
static fromMap(t, e) {
|
|
9766
|
-
const i = new
|
|
9702
|
+
const i = new ye(e);
|
|
9767
9703
|
for (const [r, s] of t)
|
|
9768
9704
|
i.set(r, s);
|
|
9769
9705
|
return i;
|
|
@@ -9827,7 +9763,7 @@ class me {
|
|
|
9827
9763
|
yield [t, this.map.get(t)];
|
|
9828
9764
|
}
|
|
9829
9765
|
}
|
|
9830
|
-
class
|
|
9766
|
+
class me {
|
|
9831
9767
|
constructor(t) {
|
|
9832
9768
|
this.compareFn = t, this.elements = [];
|
|
9833
9769
|
}
|
|
@@ -9835,7 +9771,7 @@ class be {
|
|
|
9835
9771
|
return this.elements.length;
|
|
9836
9772
|
}
|
|
9837
9773
|
static fromSet(t, e) {
|
|
9838
|
-
const i = new
|
|
9774
|
+
const i = new me(e);
|
|
9839
9775
|
for (const r of t)
|
|
9840
9776
|
i.add(r);
|
|
9841
9777
|
return i;
|
|
@@ -9875,17 +9811,17 @@ class be {
|
|
|
9875
9811
|
return { found: !1, index: e };
|
|
9876
9812
|
}
|
|
9877
9813
|
}
|
|
9878
|
-
class
|
|
9814
|
+
class fr {
|
|
9879
9815
|
constructor(t, e) {
|
|
9880
9816
|
this.type = t, this.data = e;
|
|
9881
9817
|
}
|
|
9882
9818
|
}
|
|
9883
|
-
class
|
|
9819
|
+
class be {
|
|
9884
9820
|
constructor() {
|
|
9885
9821
|
}
|
|
9886
9822
|
}
|
|
9887
|
-
var
|
|
9888
|
-
class
|
|
9823
|
+
var bt = /* @__PURE__ */ ((n) => (n.testnet = "testnet", n.mainnet = "mainnet", n.regtest = "regtest", n))(bt || {}), 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 || {});
|
|
9824
|
+
class pr extends be {
|
|
9889
9825
|
constructor() {
|
|
9890
9826
|
if (super(), this.isInitialized = !1, !window)
|
|
9891
9827
|
throw new Error("UnisatSigner can only be used in a browser environment");
|
|
@@ -9931,14 +9867,14 @@ class Ur extends Te {
|
|
|
9931
9867
|
return;
|
|
9932
9868
|
const t = await this.unisat.getNetwork();
|
|
9933
9869
|
switch (t) {
|
|
9934
|
-
case
|
|
9935
|
-
this._network =
|
|
9870
|
+
case bt.mainnet:
|
|
9871
|
+
this._network = I;
|
|
9936
9872
|
break;
|
|
9937
|
-
case
|
|
9938
|
-
this._network =
|
|
9873
|
+
case bt.testnet:
|
|
9874
|
+
this._network = At;
|
|
9939
9875
|
break;
|
|
9940
|
-
case
|
|
9941
|
-
this._network =
|
|
9876
|
+
case bt.regtest:
|
|
9877
|
+
this._network = zt;
|
|
9942
9878
|
break;
|
|
9943
9879
|
default:
|
|
9944
9880
|
throw new Error(`Invalid network: ${t}`);
|
|
@@ -9983,10 +9919,10 @@ class Ur extends Te {
|
|
|
9983
9919
|
e.push(c);
|
|
9984
9920
|
const u = o.data.inputs.map((h, l) => {
|
|
9985
9921
|
let d = !1, p = !1;
|
|
9986
|
-
if (
|
|
9922
|
+
if (le(h)) {
|
|
9987
9923
|
if (h.tapLeafScript && h.tapLeafScript.length > 0) {
|
|
9988
9924
|
for (const f of h.tapLeafScript)
|
|
9989
|
-
if (
|
|
9925
|
+
if (gr(this.publicKey, f.script)) {
|
|
9990
9926
|
d = !0, p = !1;
|
|
9991
9927
|
break;
|
|
9992
9928
|
}
|
|
@@ -9995,7 +9931,7 @@ class Ur extends Te {
|
|
|
9995
9931
|
const f = h.tapInternalKey, w = O(this.publicKey);
|
|
9996
9932
|
f.equals(w) && (d = !0, p = !0);
|
|
9997
9933
|
}
|
|
9998
|
-
} else
|
|
9934
|
+
} else de(h, this.publicKey) && (d = !0, p = !1);
|
|
9999
9935
|
return d ? {
|
|
10000
9936
|
index: l,
|
|
10001
9937
|
publicKey: this.publicKey.toString("hex"),
|
|
@@ -10007,7 +9943,7 @@ class Ur extends Te {
|
|
|
10007
9943
|
toSignInputs: u
|
|
10008
9944
|
});
|
|
10009
9945
|
}
|
|
10010
|
-
const r = await this.unisat.signPsbt(e[0], i[0]), s =
|
|
9946
|
+
const r = await this.unisat.signPsbt(e[0], i[0]), s = F.fromHex(r);
|
|
10011
9947
|
t[0].combine(s);
|
|
10012
9948
|
}
|
|
10013
9949
|
hasAlreadySignedTapScriptSig(t) {
|
|
@@ -10052,7 +9988,7 @@ class Ur extends Te {
|
|
|
10052
9988
|
}
|
|
10053
9989
|
]).flat()
|
|
10054
9990
|
}, c = t.toHex(), u = await this.unisat.signPsbt(c, o);
|
|
10055
|
-
return
|
|
9991
|
+
return F.fromHex(u);
|
|
10056
9992
|
}
|
|
10057
9993
|
getNonDuplicateScriptSig(t, e) {
|
|
10058
9994
|
const i = [];
|
|
@@ -10061,15 +9997,15 @@ class Ur extends Te {
|
|
|
10061
9997
|
return i;
|
|
10062
9998
|
}
|
|
10063
9999
|
}
|
|
10064
|
-
function
|
|
10065
|
-
return
|
|
10000
|
+
function gr(n, t) {
|
|
10001
|
+
return Sr(n, t) !== -1;
|
|
10066
10002
|
}
|
|
10067
|
-
function
|
|
10068
|
-
const e =
|
|
10003
|
+
function Sr(n, t) {
|
|
10004
|
+
const e = dt(n), i = O(n), r = R(t);
|
|
10069
10005
|
if (r === null) throw new Error("Unknown script error");
|
|
10070
10006
|
return r.findIndex((s) => typeof s == "number" ? !1 : a.isBuffer(s) && (s.equals(n) || s.equals(e) || s.equals(i)));
|
|
10071
10007
|
}
|
|
10072
|
-
class
|
|
10008
|
+
class wr extends be {
|
|
10073
10009
|
constructor() {
|
|
10074
10010
|
if (super(), this.isInitialized = !1, !window)
|
|
10075
10011
|
throw new Error("XverseSigner can only be used in a browser environment");
|
|
@@ -10114,7 +10050,7 @@ class Dr extends Te {
|
|
|
10114
10050
|
);
|
|
10115
10051
|
if (!e)
|
|
10116
10052
|
throw new Error("Payment address not found");
|
|
10117
|
-
const i = e.address.startsWith("tb") ?
|
|
10053
|
+
const i = e.address.startsWith("tb") ? At : e.address.startsWith("bc") ? I : null;
|
|
10118
10054
|
if (!i) throw new Error("Network not supported");
|
|
10119
10055
|
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;
|
|
10120
10056
|
}
|
|
@@ -10167,10 +10103,10 @@ class Dr extends Te {
|
|
|
10167
10103
|
e.push(u);
|
|
10168
10104
|
const h = c.data.inputs.map((l, d) => {
|
|
10169
10105
|
let p = !1, f = !1;
|
|
10170
|
-
if (
|
|
10106
|
+
if (le(l)) {
|
|
10171
10107
|
if (l.tapLeafScript && l.tapLeafScript.length > 0) {
|
|
10172
10108
|
for (const w of l.tapLeafScript)
|
|
10173
|
-
if (
|
|
10109
|
+
if (fe(this.publicKey, w.script)) {
|
|
10174
10110
|
p = !0, f = !1;
|
|
10175
10111
|
break;
|
|
10176
10112
|
}
|
|
@@ -10179,7 +10115,7 @@ class Dr extends Te {
|
|
|
10179
10115
|
const w = l.tapInternalKey, S = O(this.publicKey);
|
|
10180
10116
|
w.equals(S) && (p = !0, f = !0);
|
|
10181
10117
|
}
|
|
10182
|
-
} else
|
|
10118
|
+
} else de(l, this.publicKey) && (p = !0, f = !1);
|
|
10183
10119
|
return p ? {
|
|
10184
10120
|
index: d,
|
|
10185
10121
|
publicKey: this.publicKey.toString("hex"),
|
|
@@ -10198,7 +10134,7 @@ class Dr extends Te {
|
|
|
10198
10134
|
signInputs: r
|
|
10199
10135
|
});
|
|
10200
10136
|
if ("error" in s) throw new Error(s.error.message);
|
|
10201
|
-
const o =
|
|
10137
|
+
const o = F.fromBase64(s.result.psbt);
|
|
10202
10138
|
t[0].combine(o);
|
|
10203
10139
|
}
|
|
10204
10140
|
hasAlreadySignedTapScriptSig(t) {
|
|
@@ -10248,7 +10184,7 @@ class Dr extends Te {
|
|
|
10248
10184
|
signInputs: u
|
|
10249
10185
|
});
|
|
10250
10186
|
if ("error" in h) throw new Error(h.error.message);
|
|
10251
|
-
return
|
|
10187
|
+
return F.fromBase64(h.result.psbt);
|
|
10252
10188
|
}
|
|
10253
10189
|
getNonDuplicateScriptSig(t, e) {
|
|
10254
10190
|
const i = [];
|
|
@@ -10257,87 +10193,10 @@ class Dr extends Te {
|
|
|
10257
10193
|
return i;
|
|
10258
10194
|
}
|
|
10259
10195
|
}
|
|
10260
|
-
var
|
|
10261
|
-
|
|
10262
|
-
return k.dead();
|
|
10263
|
-
}
|
|
10264
|
-
const di = R(), fi = R(), pi = R(), gi = R(), Si = R(), wi = R(), yi = R(), mi = R(), bi = R(), Ti = R(), Ii = R(), Pi = R(), Ei = R(), Ai = R(), Oi = R();
|
|
10265
|
-
var Bi = /* @__PURE__ */ ((n) => (n.Mainnet = "mainnet", n.Testnet = "testnet", n.Regtest = "regtest", n))(Bi || {});
|
|
10266
|
-
class xi {
|
|
10267
|
-
constructor() {
|
|
10268
|
-
this.metadata = {
|
|
10269
|
-
[Bt.Bitcoin]: {
|
|
10270
|
-
testnet: {
|
|
10271
|
-
factory: wi,
|
|
10272
|
-
pool: yi,
|
|
10273
|
-
wbtc: mi,
|
|
10274
|
-
moto: bi,
|
|
10275
|
-
router: Ti
|
|
10276
|
-
},
|
|
10277
|
-
regtest: {
|
|
10278
|
-
factory: di,
|
|
10279
|
-
pool: fi,
|
|
10280
|
-
wbtc: pi,
|
|
10281
|
-
moto: gi,
|
|
10282
|
-
router: Si
|
|
10283
|
-
}
|
|
10284
|
-
},
|
|
10285
|
-
[Bt.Fractal]: {
|
|
10286
|
-
mainnet: {
|
|
10287
|
-
factory: Ii,
|
|
10288
|
-
pool: Pi,
|
|
10289
|
-
wbtc: Ei,
|
|
10290
|
-
moto: Ai,
|
|
10291
|
-
router: Oi
|
|
10292
|
-
}
|
|
10293
|
-
}
|
|
10294
|
-
};
|
|
10295
|
-
}
|
|
10296
|
-
getFactoryAddress(t, e) {
|
|
10297
|
-
const i = this.metadata[e][t]?.factory;
|
|
10298
|
-
if (!i)
|
|
10299
|
-
throw new Error(
|
|
10300
|
-
`Factory address not found for network ${t} and chainId ${e}`
|
|
10301
|
-
);
|
|
10302
|
-
return i;
|
|
10303
|
-
}
|
|
10304
|
-
getPoolAddress(t, e) {
|
|
10305
|
-
const i = this.metadata[e][t]?.pool;
|
|
10306
|
-
if (!i)
|
|
10307
|
-
throw new Error(`Pool address not found for network ${t} and chainId ${e}`);
|
|
10308
|
-
return i;
|
|
10309
|
-
}
|
|
10310
|
-
getWBTCAddress(t, e) {
|
|
10311
|
-
const i = this.metadata[e][t]?.wbtc;
|
|
10312
|
-
if (!i)
|
|
10313
|
-
throw new Error(`WBTC address not found for network ${t} and chainId ${e}`);
|
|
10314
|
-
return i;
|
|
10315
|
-
}
|
|
10316
|
-
getMOTOAddress(t, e) {
|
|
10317
|
-
const i = this.metadata[e][t]?.moto;
|
|
10318
|
-
if (!i)
|
|
10319
|
-
throw new Error(`MOTO address not found for network ${t} and chainId ${e}`);
|
|
10320
|
-
return i;
|
|
10321
|
-
}
|
|
10322
|
-
getRouterAddress(t, e) {
|
|
10323
|
-
const i = this.metadata[e][t]?.router;
|
|
10324
|
-
if (!i)
|
|
10325
|
-
throw new Error(
|
|
10326
|
-
`Router address not found for network ${t} and chainId ${e}`
|
|
10327
|
-
);
|
|
10328
|
-
return i;
|
|
10329
|
-
}
|
|
10330
|
-
getAddresses(t, e) {
|
|
10331
|
-
const i = this.metadata[e][t];
|
|
10332
|
-
if (!i)
|
|
10333
|
-
throw new Error(`Metadata not found for network ${t} and chainId ${e}`);
|
|
10334
|
-
return i;
|
|
10335
|
-
}
|
|
10336
|
-
}
|
|
10337
|
-
const Cr = new xi();
|
|
10338
|
-
class Xt {
|
|
10196
|
+
var ai = /* @__PURE__ */ ((n) => (n.ecdsa = "ecdsa", n.bip322 = "bip322-simple", n))(ai || {}), ci = /* @__PURE__ */ ((n) => (n.ecdsa = "ecdsa", n.schnorr = "schnorr", n))(ci || {}), ui = /* @__PURE__ */ ((n) => (n.mainnet = "mainnet", n.testnet = "testnet", n.signet = "Signet", n))(ui || {}), hi = /* @__PURE__ */ ((n) => (n.ECDSA = "ECDSA", n.BIP322 = "BIP322", n))(hi || {});
|
|
10197
|
+
class Ht {
|
|
10339
10198
|
constructor() {
|
|
10340
|
-
this._size = 0, this.capacity =
|
|
10199
|
+
this._size = 0, this.capacity = Ht.INITIAL_CAPACITY, this.#t = new Array(this.capacity), this.#e = new Array(this.capacity), this.deleted = new Array(this.capacity).fill(!1);
|
|
10341
10200
|
}
|
|
10342
10201
|
static {
|
|
10343
10202
|
this.INITIAL_CAPACITY = 16;
|
|
@@ -10353,7 +10212,7 @@ class Xt {
|
|
|
10353
10212
|
set(t, e) {
|
|
10354
10213
|
let i = !0;
|
|
10355
10214
|
const r = this.findInsertIndex(t);
|
|
10356
|
-
return (this.#t[r] === void 0 || this.deleted[r]) && (this._size++, i = !1), this.#t[r] = t, this.#e[r] = e, this.deleted[r] = !1, this._size > this.capacity *
|
|
10215
|
+
return (this.#t[r] === void 0 || this.deleted[r]) && (this._size++, i = !1), this.#t[r] = t, this.#e[r] = e, this.deleted[r] = !1, this._size > this.capacity * Ht.LOAD_FACTOR && this.resize(), i;
|
|
10357
10216
|
}
|
|
10358
10217
|
get(t) {
|
|
10359
10218
|
const e = this.findIndex(t);
|
|
@@ -10495,299 +10354,261 @@ class Xt {
|
|
|
10495
10354
|
t[i] !== void 0 && !this.deleted[i] && this.set(t[i], e[i]);
|
|
10496
10355
|
}
|
|
10497
10356
|
}
|
|
10498
|
-
const
|
|
10357
|
+
const Tr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
10499
10358
|
__proto__: null,
|
|
10500
|
-
ABICoder:
|
|
10501
|
-
ABIDataTypes:
|
|
10502
|
-
ADDRESS_BYTE_LENGTH:
|
|
10503
|
-
ANCHOR_SCRIPT:
|
|
10359
|
+
ABICoder: dr,
|
|
10360
|
+
ABIDataTypes: ni,
|
|
10361
|
+
ADDRESS_BYTE_LENGTH: C,
|
|
10362
|
+
ANCHOR_SCRIPT: re,
|
|
10504
10363
|
Address: k,
|
|
10505
|
-
AddressGenerator:
|
|
10364
|
+
AddressGenerator: ae,
|
|
10506
10365
|
AddressMap: Fe,
|
|
10507
|
-
AddressSet:
|
|
10508
|
-
AddressTypes:
|
|
10366
|
+
AddressSet: we,
|
|
10367
|
+
AddressTypes: J,
|
|
10509
10368
|
AddressVerificator: H,
|
|
10510
|
-
BIPStandard:
|
|
10511
|
-
BOOLEAN_BYTE_LENGTH:
|
|
10512
|
-
BinaryReader:
|
|
10513
|
-
BinaryWriter:
|
|
10369
|
+
BIPStandard: mt,
|
|
10370
|
+
BOOLEAN_BYTE_LENGTH: Qi,
|
|
10371
|
+
BinaryReader: qt,
|
|
10372
|
+
BinaryWriter: D,
|
|
10514
10373
|
BitcoinUtils: K,
|
|
10515
|
-
BufferHelper:
|
|
10516
|
-
CSVModes:
|
|
10517
|
-
CalldataGenerator:
|
|
10518
|
-
CancelTransaction:
|
|
10519
|
-
ChainId:
|
|
10520
|
-
ChallengeSolution:
|
|
10521
|
-
ChallengeSubmission:
|
|
10522
|
-
ChallengeVerification:
|
|
10374
|
+
BufferHelper: X,
|
|
10375
|
+
CSVModes: Ye,
|
|
10376
|
+
CalldataGenerator: oe,
|
|
10377
|
+
CancelTransaction: ge,
|
|
10378
|
+
ChainId: he,
|
|
10379
|
+
ChallengeSolution: se,
|
|
10380
|
+
ChallengeSubmission: ri,
|
|
10381
|
+
ChallengeVerification: ii,
|
|
10523
10382
|
Compressor: N,
|
|
10524
|
-
Consensus:
|
|
10525
|
-
ConsolidatedInteractionTransaction:
|
|
10526
|
-
ContractAddress:
|
|
10527
|
-
ContractBaseMetadata:
|
|
10528
|
-
CustomGenerator:
|
|
10529
|
-
CustomKeypair:
|
|
10530
|
-
CustomMap:
|
|
10531
|
-
CustomScriptTransaction:
|
|
10532
|
-
DeploymentGenerator:
|
|
10533
|
-
DeploymentTransaction:
|
|
10534
|
-
DeterministicMap:
|
|
10535
|
-
DeterministicSet:
|
|
10383
|
+
Consensus: Bt,
|
|
10384
|
+
ConsolidatedInteractionTransaction: Ge,
|
|
10385
|
+
ContractAddress: te,
|
|
10386
|
+
ContractBaseMetadata: rr,
|
|
10387
|
+
CustomGenerator: Re,
|
|
10388
|
+
CustomKeypair: be,
|
|
10389
|
+
CustomMap: Ht,
|
|
10390
|
+
CustomScriptTransaction: Wt,
|
|
10391
|
+
DeploymentGenerator: Ft,
|
|
10392
|
+
DeploymentTransaction: ft,
|
|
10393
|
+
DeterministicMap: ye,
|
|
10394
|
+
DeterministicSet: me,
|
|
10536
10395
|
EcKeyPair: A,
|
|
10537
|
-
EpochValidator:
|
|
10538
|
-
|
|
10539
|
-
|
|
10540
|
-
FACTORY_ADDRESS_TESTNET: wi,
|
|
10541
|
-
FastMap: vt,
|
|
10542
|
-
FeaturePriority: j,
|
|
10396
|
+
EpochValidator: ct,
|
|
10397
|
+
FastMap: Ot,
|
|
10398
|
+
FeaturePriority: Q,
|
|
10543
10399
|
Features: W,
|
|
10544
|
-
FundingTransaction:
|
|
10545
|
-
Generator:
|
|
10400
|
+
FundingTransaction: Mt,
|
|
10401
|
+
Generator: q,
|
|
10546
10402
|
HashCommitmentGenerator: E,
|
|
10547
|
-
I128_BYTE_LENGTH:
|
|
10548
|
-
I16_BYTE_LENGTH:
|
|
10549
|
-
I256_BYTE_LENGTH:
|
|
10550
|
-
I64_BYTE_LENGTH:
|
|
10551
|
-
I8_BYTE_LENGTH:
|
|
10552
|
-
InteractionTransaction:
|
|
10553
|
-
InteractionTransactionP2WDA:
|
|
10554
|
-
LegacyCalldataGenerator:
|
|
10555
|
-
MINIMUM_AMOUNT_CA:
|
|
10556
|
-
MINIMUM_AMOUNT_REWARD:
|
|
10403
|
+
I128_BYTE_LENGTH: yt,
|
|
10404
|
+
I16_BYTE_LENGTH: Yi,
|
|
10405
|
+
I256_BYTE_LENGTH: qi,
|
|
10406
|
+
I64_BYTE_LENGTH: $i,
|
|
10407
|
+
I8_BYTE_LENGTH: Gi,
|
|
10408
|
+
InteractionTransaction: Nt,
|
|
10409
|
+
InteractionTransactionP2WDA: j,
|
|
10410
|
+
LegacyCalldataGenerator: Ji,
|
|
10411
|
+
MINIMUM_AMOUNT_CA: St,
|
|
10412
|
+
MINIMUM_AMOUNT_REWARD: V,
|
|
10557
10413
|
MLDSAKeyPair: P.MLDSAKeyPair,
|
|
10558
|
-
MLDSAPublicKeyMetadata:
|
|
10414
|
+
MLDSAPublicKeyMetadata: Ve,
|
|
10559
10415
|
MLDSASecurityLevel: P.MLDSASecurityLevel,
|
|
10560
|
-
|
|
10561
|
-
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
10565
|
-
Mnemonic: le,
|
|
10566
|
-
MnemonicStrength: Ht,
|
|
10567
|
-
MultiSignGenerator: At,
|
|
10416
|
+
MessageSigner: st,
|
|
10417
|
+
MessageType: ai,
|
|
10418
|
+
Mnemonic: ue,
|
|
10419
|
+
MnemonicStrength: Rt,
|
|
10420
|
+
MultiSignGenerator: Pt,
|
|
10568
10421
|
MultiSignTransaction: x,
|
|
10569
|
-
NetEvent:
|
|
10570
|
-
OPNET_DEPLOYMENT_VERSION:
|
|
10571
|
-
OPNetConsensusConfig:
|
|
10572
|
-
OPNetLimitedProvider:
|
|
10573
|
-
|
|
10574
|
-
|
|
10575
|
-
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
P2WDADetector: q,
|
|
10579
|
-
P2WDAGenerator: Ot,
|
|
10580
|
-
POOL_ADDRESS_FRACTAL: Pi,
|
|
10581
|
-
POOL_ADDRESS_REGTEST: fi,
|
|
10582
|
-
POOL_ADDRESS_TESTNET: yi,
|
|
10583
|
-
PSBTTypes: ni,
|
|
10584
|
-
PsbtTransaction: Tt,
|
|
10422
|
+
NetEvent: fr,
|
|
10423
|
+
OPNET_DEPLOYMENT_VERSION: We,
|
|
10424
|
+
OPNetConsensusConfig: $e,
|
|
10425
|
+
OPNetLimitedProvider: hr,
|
|
10426
|
+
OfflineTransactionManager: ur,
|
|
10427
|
+
P2TR_MS: lr,
|
|
10428
|
+
P2WDADetector: z,
|
|
10429
|
+
P2WDAGenerator: Et,
|
|
10430
|
+
PSBTTypes: si,
|
|
10585
10431
|
QuantumBIP32API: P.QuantumBIP32API,
|
|
10586
10432
|
QuantumBIP32Factory: P.QuantumBIP32Factory,
|
|
10587
10433
|
QuantumBIP32Interface: P.QuantumBIP32Interface,
|
|
10588
10434
|
QuantumDerivationPath: P.QuantumDerivationPath,
|
|
10589
10435
|
QuantumSigner: P.QuantumSigner,
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
|
|
10595
|
-
|
|
10596
|
-
|
|
10597
|
-
|
|
10598
|
-
|
|
10599
|
-
SignatureType: ui,
|
|
10600
|
-
SigningProtocol: li,
|
|
10601
|
-
TapscriptVerificator: et,
|
|
10436
|
+
RoswellConsensus: qe,
|
|
10437
|
+
SELECTOR_BYTE_LENGTH: zi,
|
|
10438
|
+
SERIALIZATION_FORMAT_VERSION: Se,
|
|
10439
|
+
SERIALIZATION_MAGIC_BYTE: _t,
|
|
10440
|
+
Secp256k1PointDeriver: De,
|
|
10441
|
+
SharedInteractionTransaction: pe,
|
|
10442
|
+
SignatureType: ci,
|
|
10443
|
+
SigningProtocol: hi,
|
|
10444
|
+
TapscriptVerificator: tt,
|
|
10602
10445
|
TimeLockGenerator: M,
|
|
10603
10446
|
TransactionBuilder: m,
|
|
10604
|
-
TransactionFactory:
|
|
10605
|
-
TransactionReconstructor:
|
|
10606
|
-
TransactionSequence:
|
|
10447
|
+
TransactionFactory: Qe,
|
|
10448
|
+
TransactionReconstructor: ut,
|
|
10449
|
+
TransactionSequence: Xe,
|
|
10607
10450
|
TransactionSerializer: B,
|
|
10608
|
-
TransactionStateCapture:
|
|
10451
|
+
TransactionStateCapture: $,
|
|
10609
10452
|
TransactionType: y,
|
|
10610
|
-
TweakedSigner:
|
|
10611
|
-
TweakedTransaction:
|
|
10612
|
-
U128_BYTE_LENGTH:
|
|
10613
|
-
U16_BYTE_LENGTH:
|
|
10614
|
-
U256_BYTE_LENGTH:
|
|
10615
|
-
U32_BYTE_LENGTH:
|
|
10616
|
-
U64_BYTE_LENGTH:
|
|
10617
|
-
U8_BYTE_LENGTH:
|
|
10618
|
-
UnisatChainType:
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
|
|
10622
|
-
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
|
|
10629
|
-
|
|
10630
|
-
|
|
10631
|
-
|
|
10632
|
-
|
|
10633
|
-
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
|
|
10639
|
-
|
|
10640
|
-
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
version: tr,
|
|
10644
|
-
versionBuffer: Ne
|
|
10645
|
-
}, Symbol.toStringTag, { value: "Module" })), Hr = P.MLDSAKeyPair, Vr = P.MLDSASecurityLevel, zr = P.QuantumBIP32API, qr = P.QuantumBIP32Factory, $r = P.QuantumBIP32Interface, Xr = P.QuantumDerivationPath, Yr = P.QuantumSigner;
|
|
10453
|
+
TweakedSigner: ce,
|
|
10454
|
+
TweakedTransaction: Xt,
|
|
10455
|
+
U128_BYTE_LENGTH: wt,
|
|
10456
|
+
U16_BYTE_LENGTH: Tt,
|
|
10457
|
+
U256_BYTE_LENGTH: It,
|
|
10458
|
+
U32_BYTE_LENGTH: ht,
|
|
10459
|
+
U64_BYTE_LENGTH: Ct,
|
|
10460
|
+
U8_BYTE_LENGTH: Dt,
|
|
10461
|
+
UnisatChainType: oi,
|
|
10462
|
+
UnisatSigner: pr,
|
|
10463
|
+
Wallet: Z,
|
|
10464
|
+
WalletNetworks: bt,
|
|
10465
|
+
XverseNetwork: ui,
|
|
10466
|
+
XverseSigner: wr,
|
|
10467
|
+
buildBIPPath: He,
|
|
10468
|
+
createAddressRotation: sr,
|
|
10469
|
+
createSignerMap: ze,
|
|
10470
|
+
currentConsensus: $t,
|
|
10471
|
+
currentConsensusConfig: or,
|
|
10472
|
+
disabledAddressRotation: nr,
|
|
10473
|
+
getBIPDescription: er,
|
|
10474
|
+
getLevelFromPublicKeyLength: ee,
|
|
10475
|
+
isCancelSpecificData: ei,
|
|
10476
|
+
isCustomScriptSpecificData: ti,
|
|
10477
|
+
isDeploymentSpecificData: Ze,
|
|
10478
|
+
isFundingSpecificData: je,
|
|
10479
|
+
isInteractionSpecificData: Je,
|
|
10480
|
+
isMultiSigSpecificData: et,
|
|
10481
|
+
isOPWallet: Ne,
|
|
10482
|
+
number_BYTE_LENGTH: Xi,
|
|
10483
|
+
version: Di,
|
|
10484
|
+
versionBuffer: Me
|
|
10485
|
+
}, Symbol.toStringTag, { value: "Module" })), Pr = P.MLDSAKeyPair, Er = P.MLDSASecurityLevel, Ar = P.QuantumBIP32API, Or = P.QuantumBIP32Factory, Br = P.QuantumBIP32Interface, xr = P.QuantumDerivationPath, vr = P.QuantumSigner;
|
|
10646
10486
|
export {
|
|
10647
|
-
|
|
10648
|
-
|
|
10649
|
-
|
|
10650
|
-
|
|
10487
|
+
dr as ABICoder,
|
|
10488
|
+
ni as ABIDataTypes,
|
|
10489
|
+
C as ADDRESS_BYTE_LENGTH,
|
|
10490
|
+
re as ANCHOR_SCRIPT,
|
|
10651
10491
|
k as Address,
|
|
10652
|
-
|
|
10492
|
+
ae as AddressGenerator,
|
|
10653
10493
|
Fe as AddressMap,
|
|
10654
|
-
|
|
10655
|
-
|
|
10494
|
+
we as AddressSet,
|
|
10495
|
+
J as AddressTypes,
|
|
10656
10496
|
H as AddressVerificator,
|
|
10657
|
-
|
|
10658
|
-
|
|
10659
|
-
|
|
10660
|
-
|
|
10497
|
+
mt as BIPStandard,
|
|
10498
|
+
Qi as BOOLEAN_BYTE_LENGTH,
|
|
10499
|
+
qt as BinaryReader,
|
|
10500
|
+
D as BinaryWriter,
|
|
10661
10501
|
K as BitcoinUtils,
|
|
10662
|
-
|
|
10663
|
-
|
|
10664
|
-
|
|
10665
|
-
|
|
10666
|
-
|
|
10667
|
-
|
|
10668
|
-
|
|
10669
|
-
|
|
10502
|
+
X as BufferHelper,
|
|
10503
|
+
Ye as CSVModes,
|
|
10504
|
+
oe as CalldataGenerator,
|
|
10505
|
+
ge as CancelTransaction,
|
|
10506
|
+
he as ChainId,
|
|
10507
|
+
se as ChallengeSolution,
|
|
10508
|
+
ri as ChallengeSubmission,
|
|
10509
|
+
ii as ChallengeVerification,
|
|
10670
10510
|
N as Compressor,
|
|
10671
|
-
|
|
10672
|
-
|
|
10673
|
-
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
|
|
10677
|
-
|
|
10678
|
-
|
|
10679
|
-
|
|
10680
|
-
|
|
10681
|
-
|
|
10682
|
-
|
|
10511
|
+
Bt as Consensus,
|
|
10512
|
+
Ge as ConsolidatedInteractionTransaction,
|
|
10513
|
+
te as ContractAddress,
|
|
10514
|
+
rr as ContractBaseMetadata,
|
|
10515
|
+
Re as CustomGenerator,
|
|
10516
|
+
be as CustomKeypair,
|
|
10517
|
+
Ht as CustomMap,
|
|
10518
|
+
Wt as CustomScriptTransaction,
|
|
10519
|
+
Ft as DeploymentGenerator,
|
|
10520
|
+
ft as DeploymentTransaction,
|
|
10521
|
+
ye as DeterministicMap,
|
|
10522
|
+
me as DeterministicSet,
|
|
10683
10523
|
A as EcKeyPair,
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
wi as FACTORY_ADDRESS_TESTNET,
|
|
10688
|
-
vt as FastMap,
|
|
10689
|
-
j as FeaturePriority,
|
|
10524
|
+
ct as EpochValidator,
|
|
10525
|
+
Ot as FastMap,
|
|
10526
|
+
Q as FeaturePriority,
|
|
10690
10527
|
W as Features,
|
|
10691
|
-
|
|
10692
|
-
|
|
10528
|
+
Mt as FundingTransaction,
|
|
10529
|
+
q as Generator,
|
|
10693
10530
|
E as HashCommitmentGenerator,
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
|
-
|
|
10697
|
-
|
|
10698
|
-
|
|
10699
|
-
|
|
10700
|
-
|
|
10701
|
-
|
|
10702
|
-
|
|
10703
|
-
|
|
10704
|
-
|
|
10705
|
-
|
|
10706
|
-
|
|
10707
|
-
|
|
10708
|
-
|
|
10709
|
-
|
|
10710
|
-
|
|
10711
|
-
|
|
10712
|
-
le as Mnemonic,
|
|
10713
|
-
Ht as MnemonicStrength,
|
|
10714
|
-
At as MultiSignGenerator,
|
|
10531
|
+
yt as I128_BYTE_LENGTH,
|
|
10532
|
+
Yi as I16_BYTE_LENGTH,
|
|
10533
|
+
qi as I256_BYTE_LENGTH,
|
|
10534
|
+
$i as I64_BYTE_LENGTH,
|
|
10535
|
+
Gi as I8_BYTE_LENGTH,
|
|
10536
|
+
Nt as InteractionTransaction,
|
|
10537
|
+
j as InteractionTransactionP2WDA,
|
|
10538
|
+
Ji as LegacyCalldataGenerator,
|
|
10539
|
+
St as MINIMUM_AMOUNT_CA,
|
|
10540
|
+
V as MINIMUM_AMOUNT_REWARD,
|
|
10541
|
+
Pr as MLDSAKeyPair,
|
|
10542
|
+
Ve as MLDSAPublicKeyMetadata,
|
|
10543
|
+
Er as MLDSASecurityLevel,
|
|
10544
|
+
st as MessageSigner,
|
|
10545
|
+
ai as MessageType,
|
|
10546
|
+
ue as Mnemonic,
|
|
10547
|
+
Rt as MnemonicStrength,
|
|
10548
|
+
Pt as MultiSignGenerator,
|
|
10715
10549
|
x as MultiSignTransaction,
|
|
10716
|
-
|
|
10717
|
-
|
|
10718
|
-
|
|
10719
|
-
|
|
10720
|
-
|
|
10721
|
-
|
|
10722
|
-
|
|
10723
|
-
|
|
10724
|
-
|
|
10725
|
-
|
|
10726
|
-
|
|
10727
|
-
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10737
|
-
|
|
10738
|
-
|
|
10739
|
-
Ti as ROUTER_ADDRESS_TESTNET,
|
|
10740
|
-
$e as RoswellConsensus,
|
|
10741
|
-
cr as SELECTOR_BYTE_LENGTH,
|
|
10742
|
-
we as SERIALIZATION_FORMAT_VERSION,
|
|
10743
|
-
Rt as SERIALIZATION_MAGIC_BYTE,
|
|
10744
|
-
Re as Secp256k1PointDeriver,
|
|
10745
|
-
ge as SharedInteractionTransaction,
|
|
10746
|
-
ui as SignatureType,
|
|
10747
|
-
li as SigningProtocol,
|
|
10748
|
-
et as TapscriptVerificator,
|
|
10550
|
+
fr as NetEvent,
|
|
10551
|
+
We as OPNET_DEPLOYMENT_VERSION,
|
|
10552
|
+
$e as OPNetConsensusConfig,
|
|
10553
|
+
hr as OPNetLimitedProvider,
|
|
10554
|
+
ur as OfflineTransactionManager,
|
|
10555
|
+
lr as P2TR_MS,
|
|
10556
|
+
z as P2WDADetector,
|
|
10557
|
+
Et as P2WDAGenerator,
|
|
10558
|
+
si as PSBTTypes,
|
|
10559
|
+
Ar as QuantumBIP32API,
|
|
10560
|
+
Or as QuantumBIP32Factory,
|
|
10561
|
+
Br as QuantumBIP32Interface,
|
|
10562
|
+
xr as QuantumDerivationPath,
|
|
10563
|
+
vr as QuantumSigner,
|
|
10564
|
+
qe as RoswellConsensus,
|
|
10565
|
+
zi as SELECTOR_BYTE_LENGTH,
|
|
10566
|
+
Se as SERIALIZATION_FORMAT_VERSION,
|
|
10567
|
+
_t as SERIALIZATION_MAGIC_BYTE,
|
|
10568
|
+
De as Secp256k1PointDeriver,
|
|
10569
|
+
pe as SharedInteractionTransaction,
|
|
10570
|
+
ci as SignatureType,
|
|
10571
|
+
hi as SigningProtocol,
|
|
10572
|
+
tt as TapscriptVerificator,
|
|
10749
10573
|
M as TimeLockGenerator,
|
|
10750
10574
|
m as TransactionBuilder,
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10575
|
+
Qe as TransactionFactory,
|
|
10576
|
+
ut as TransactionReconstructor,
|
|
10577
|
+
Xe as TransactionSequence,
|
|
10754
10578
|
B as TransactionSerializer,
|
|
10755
|
-
|
|
10579
|
+
$ as TransactionStateCapture,
|
|
10756
10580
|
y as TransactionType,
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10764
|
-
|
|
10765
|
-
|
|
10766
|
-
|
|
10767
|
-
|
|
10768
|
-
|
|
10769
|
-
|
|
10770
|
-
|
|
10771
|
-
|
|
10772
|
-
|
|
10773
|
-
|
|
10774
|
-
|
|
10775
|
-
|
|
10776
|
-
|
|
10777
|
-
|
|
10778
|
-
|
|
10779
|
-
|
|
10780
|
-
|
|
10781
|
-
|
|
10782
|
-
|
|
10783
|
-
|
|
10784
|
-
|
|
10785
|
-
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
Nr as opnet,
|
|
10791
|
-
tr as version,
|
|
10792
|
-
Ne as versionBuffer
|
|
10581
|
+
ce as TweakedSigner,
|
|
10582
|
+
Xt as TweakedTransaction,
|
|
10583
|
+
wt as U128_BYTE_LENGTH,
|
|
10584
|
+
Tt as U16_BYTE_LENGTH,
|
|
10585
|
+
It as U256_BYTE_LENGTH,
|
|
10586
|
+
ht as U32_BYTE_LENGTH,
|
|
10587
|
+
Ct as U64_BYTE_LENGTH,
|
|
10588
|
+
Dt as U8_BYTE_LENGTH,
|
|
10589
|
+
oi as UnisatChainType,
|
|
10590
|
+
pr as UnisatSigner,
|
|
10591
|
+
Z as Wallet,
|
|
10592
|
+
bt as WalletNetworks,
|
|
10593
|
+
ui as XverseNetwork,
|
|
10594
|
+
wr as XverseSigner,
|
|
10595
|
+
He as buildBIPPath,
|
|
10596
|
+
sr as createAddressRotation,
|
|
10597
|
+
ze as createSignerMap,
|
|
10598
|
+
$t as currentConsensus,
|
|
10599
|
+
or as currentConsensusConfig,
|
|
10600
|
+
nr as disabledAddressRotation,
|
|
10601
|
+
er as getBIPDescription,
|
|
10602
|
+
ee as getLevelFromPublicKeyLength,
|
|
10603
|
+
ei as isCancelSpecificData,
|
|
10604
|
+
ti as isCustomScriptSpecificData,
|
|
10605
|
+
Ze as isDeploymentSpecificData,
|
|
10606
|
+
je as isFundingSpecificData,
|
|
10607
|
+
Je as isInteractionSpecificData,
|
|
10608
|
+
et as isMultiSigSpecificData,
|
|
10609
|
+
Ne as isOPWallet,
|
|
10610
|
+
Xi as number_BYTE_LENGTH,
|
|
10611
|
+
Tr as opnet,
|
|
10612
|
+
Di as version,
|
|
10613
|
+
Me as versionBuffer
|
|
10793
10614
|
};
|