@arkade-os/sdk 0.5.2 → 0.5.3
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/dist/adapters/expo.cjs +5 -5
- package/dist/adapters/expo.d.cts +2 -2
- package/dist/adapters/expo.d.ts +2 -2
- package/dist/adapters/expo.js +3 -3
- package/dist/{asyncStorageTaskQueue-DIn7bTqN.d.ts → asyncStorageTaskQueue-B3U5gQ-i.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-BtEc3Qca.d.cts → asyncStorageTaskQueue-C9PkPcW_.d.cts} +1 -1
- package/dist/{chunk-PVFQFQBY.cjs → chunk-5WRA66RV.cjs} +10 -10
- package/dist/{chunk-PVFQFQBY.cjs.map → chunk-5WRA66RV.cjs.map} +1 -1
- package/dist/{chunk-U5XG7SWA.js → chunk-6FL4N4S2.js} +3 -3
- package/dist/{chunk-U5XG7SWA.js.map → chunk-6FL4N4S2.js.map} +1 -1
- package/dist/{chunk-OM6FJ76H.cjs → chunk-BYPBVHVA.cjs} +48 -48
- package/dist/{chunk-OM6FJ76H.cjs.map → chunk-BYPBVHVA.cjs.map} +1 -1
- package/dist/{chunk-AJWXVQYG.js → chunk-HAQAWBYG.js} +95 -47
- package/dist/chunk-HAQAWBYG.js.map +1 -0
- package/dist/{chunk-GGKR4O5X.cjs → chunk-KW7ZEWYS.cjs} +6 -3
- package/dist/chunk-KW7ZEWYS.cjs.map +1 -0
- package/dist/{chunk-HKG26NUT.js → chunk-OPX2HRWM.js} +6 -3
- package/dist/chunk-OPX2HRWM.js.map +1 -0
- package/dist/{chunk-2OCYL6BJ.cjs → chunk-OUTWUYJ4.cjs} +589 -541
- package/dist/chunk-OUTWUYJ4.cjs.map +1 -0
- package/dist/{chunk-LWRMSC4M.js → chunk-P7B4LQ3H.js} +3 -3
- package/dist/{chunk-LWRMSC4M.js.map → chunk-P7B4LQ3H.js.map} +1 -1
- package/dist/{chunk-2QRUQXLS.js → chunk-T7C3E2HL.js} +4 -4
- package/dist/{chunk-2QRUQXLS.js.map → chunk-T7C3E2HL.js.map} +1 -1
- package/dist/{chunk-MOBDJ7U2.js → chunk-Y4BL3YYX.js} +4 -4
- package/dist/{chunk-MOBDJ7U2.js.map → chunk-Y4BL3YYX.js.map} +1 -1
- package/dist/{chunk-64R7CRKN.cjs → chunk-ZMSM3NOH.cjs} +18 -18
- package/dist/{chunk-64R7CRKN.cjs.map → chunk-ZMSM3NOH.cjs.map} +1 -1
- package/dist/{chunk-TAIWH3HG.cjs → chunk-ZPF4I3K2.cjs} +16 -16
- package/dist/{chunk-TAIWH3HG.cjs.map → chunk-ZPF4I3K2.cjs.map} +1 -1
- package/dist/contracts/handlers/index.cjs +9 -9
- package/dist/contracts/handlers/index.d.cts +3 -3
- package/dist/contracts/handlers/index.d.ts +3 -3
- package/dist/contracts/handlers/index.js +2 -2
- package/dist/{delegate-CaL8EN4Q.d.cts → delegate-ByfKszb6.d.cts} +1 -1
- package/dist/{delegate-Jd4zs88Q.d.ts → delegate-Cd28gxpM.d.ts} +1 -1
- package/dist/{index-D-xqVzf8.d.ts → index-B6X2E7W_.d.ts} +2 -2
- package/dist/{index-DdKxfC29.d.cts → index-BURzbRup.d.cts} +12 -0
- package/dist/{index-DdKxfC29.d.ts → index-BURzbRup.d.ts} +12 -0
- package/dist/{index-BwdGzNSn.d.cts → index-DgH_0j14.d.cts} +2 -2
- package/dist/index.cjs +313 -313
- package/dist/index.d.cts +22 -9
- package/dist/index.d.ts +22 -9
- package/dist/index.js +4 -4
- package/dist/repositories/realm/index.cjs +35 -35
- package/dist/repositories/realm/index.d.cts +2 -2
- package/dist/repositories/realm/index.d.ts +2 -2
- package/dist/repositories/realm/index.js +5 -5
- package/dist/repositories/sqlite/index.cjs +33 -33
- package/dist/repositories/sqlite/index.d.cts +2 -2
- package/dist/repositories/sqlite/index.d.ts +2 -2
- package/dist/repositories/sqlite/index.js +5 -5
- package/dist/{taskRunner-ZyGGjtIq.d.ts → taskRunner-BaNCSxqK.d.ts} +1 -1
- package/dist/{taskRunner-67YSEpsz.d.cts → taskRunner-i56-drQV.d.cts} +1 -1
- package/dist/wallet/expo/background.cjs +14 -14
- package/dist/wallet/expo/background.d.cts +3 -3
- package/dist/wallet/expo/background.d.ts +3 -3
- package/dist/wallet/expo/background.js +6 -6
- package/dist/wallet/expo/index.cjs +18 -15
- package/dist/wallet/expo/index.cjs.map +1 -1
- package/dist/wallet/expo/index.d.cts +5 -4
- package/dist/wallet/expo/index.d.ts +5 -4
- package/dist/wallet/expo/index.js +8 -5
- package/dist/wallet/expo/index.js.map +1 -1
- package/dist/{wallet-B8LW7cV1.d.cts → wallet-BjQugVUt.d.cts} +7 -3
- package/dist/{wallet-bFS7VybL.d.ts → wallet-BnmhohgZ.d.ts} +7 -3
- package/dist/worker/expo/index.cjs +9 -9
- package/dist/worker/expo/index.d.cts +4 -4
- package/dist/worker/expo/index.d.ts +4 -4
- package/dist/worker/expo/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-2OCYL6BJ.cjs.map +0 -1
- package/dist/chunk-AJWXVQYG.js.map +0 -1
- package/dist/chunk-GGKR4O5X.cjs.map +0 -1
- package/dist/chunk-HKG26NUT.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkZMSM3NOH_cjs = require('./chunk-ZMSM3NOH.cjs');
|
|
4
|
+
var chunkBYPBVHVA_cjs = require('./chunk-BYPBVHVA.cjs');
|
|
5
|
+
var chunkKW7ZEWYS_cjs = require('./chunk-KW7ZEWYS.cjs');
|
|
6
6
|
var utils_js = require('@scure/btc-signer/utils.js');
|
|
7
7
|
var btcSigner = require('@scure/btc-signer');
|
|
8
8
|
var base = require('@scure/base');
|
|
@@ -187,7 +187,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
187
187
|
noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
|
|
188
188
|
const tx = this.graph.find(txid);
|
|
189
189
|
if (!tx) throw new Error(`missing tx for txid ${txid}`);
|
|
190
|
-
const cosigners =
|
|
190
|
+
const cosigners = chunkKW7ZEWYS_cjs.getArkPsbtFields(tx.root, 0, chunkKW7ZEWYS_cjs.CosignerPublicKey).map(
|
|
191
191
|
(c) => base.hex.encode(c.key.subarray(1))
|
|
192
192
|
// xonly pubkey
|
|
193
193
|
);
|
|
@@ -239,7 +239,7 @@ var TreeSignerSession = class _TreeSignerSession {
|
|
|
239
239
|
if (!aggNonce) throw new Error("missing aggregate nonce");
|
|
240
240
|
const prevoutAmounts = [];
|
|
241
241
|
const prevoutScripts = [];
|
|
242
|
-
const cosigners =
|
|
242
|
+
const cosigners = chunkKW7ZEWYS_cjs.getArkPsbtFields(g.root, 0, chunkKW7ZEWYS_cjs.CosignerPublicKey).map((c) => c.key);
|
|
243
243
|
const { finalKey } = aggregateKeys(cosigners, true, {
|
|
244
244
|
taprootTweak: this.scriptRoot
|
|
245
245
|
});
|
|
@@ -322,7 +322,7 @@ var SingleKey = class _SingleKey {
|
|
|
322
322
|
async sign(tx, inputIndexes) {
|
|
323
323
|
const txCpy = tx.clone();
|
|
324
324
|
if (!inputIndexes) {
|
|
325
|
-
|
|
325
|
+
chunkKW7ZEWYS_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
|
|
326
326
|
try {
|
|
327
327
|
if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
|
|
328
328
|
throw new Error("Failed to sign transaction");
|
|
@@ -422,7 +422,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
422
422
|
let network;
|
|
423
423
|
if ("descriptor" in opts && typeof opts.descriptor === "string") {
|
|
424
424
|
descriptor = opts.descriptor;
|
|
425
|
-
network =
|
|
425
|
+
network = chunkBYPBVHVA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
426
426
|
} else {
|
|
427
427
|
network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
428
428
|
descriptor = descriptorsScure.scriptExpressions.trBIP32({
|
|
@@ -499,7 +499,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
499
499
|
}
|
|
500
500
|
/** Returns true when `descriptor` is derived from this identity's seed. */
|
|
501
501
|
ownsDescriptor(descriptor) {
|
|
502
|
-
return
|
|
502
|
+
return chunkBYPBVHVA_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* Signs each request with the key derived from its descriptor.
|
|
@@ -538,7 +538,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
538
538
|
}
|
|
539
539
|
// ── internal helpers ─────────────────────────────────────────────
|
|
540
540
|
derivePrivateKeyForDescriptor(descriptor) {
|
|
541
|
-
const network =
|
|
541
|
+
const network = chunkBYPBVHVA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
542
542
|
const expansion = descriptorsScure.expand({ descriptor, network });
|
|
543
543
|
if (expansion.isRanged) {
|
|
544
544
|
throw new Error(
|
|
@@ -563,7 +563,7 @@ var SeedIdentity = class _SeedIdentity {
|
|
|
563
563
|
signTxWithKey(tx, key, inputIndexes) {
|
|
564
564
|
const txCpy = tx.clone();
|
|
565
565
|
if (!inputIndexes) {
|
|
566
|
-
|
|
566
|
+
chunkKW7ZEWYS_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
|
|
567
567
|
try {
|
|
568
568
|
if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
|
|
569
569
|
throw new Error("Failed to sign transaction");
|
|
@@ -615,7 +615,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
615
615
|
/** Wildcard account-descriptor template (e.g. `tr([fp/86'/0'/0']xpub/0/*)`). */
|
|
616
616
|
descriptor;
|
|
617
617
|
constructor(descriptor) {
|
|
618
|
-
const network =
|
|
618
|
+
const network = chunkBYPBVHVA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
619
619
|
let expansion;
|
|
620
620
|
try {
|
|
621
621
|
expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
|
|
@@ -650,7 +650,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
|
|
|
650
650
|
}
|
|
651
651
|
/** Returns true when `descriptor` derives from this identity's xpub. */
|
|
652
652
|
ownsDescriptor(descriptor) {
|
|
653
|
-
return
|
|
653
|
+
return chunkBYPBVHVA_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
|
|
654
654
|
}
|
|
655
655
|
};
|
|
656
656
|
function serializeSeedOwnedSigningIdentity(identity) {
|
|
@@ -793,10 +793,10 @@ var DescriptorIdentity = class {
|
|
|
793
793
|
this.base = base;
|
|
794
794
|
}
|
|
795
795
|
async xOnlyPublicKey() {
|
|
796
|
-
return
|
|
796
|
+
return chunkBYPBVHVA_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
797
797
|
}
|
|
798
798
|
async compressedPublicKey() {
|
|
799
|
-
return
|
|
799
|
+
return chunkBYPBVHVA_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
|
|
800
800
|
}
|
|
801
801
|
async sign(tx, inputIndexes) {
|
|
802
802
|
const [signed] = await this.signer.signWithDescriptor([
|
|
@@ -856,8 +856,8 @@ var StaticDescriptorProvider = class _StaticDescriptorProvider {
|
|
|
856
856
|
}
|
|
857
857
|
isOurs(descriptor) {
|
|
858
858
|
try {
|
|
859
|
-
const normalized =
|
|
860
|
-
const pubKey =
|
|
859
|
+
const normalized = chunkBYPBVHVA_cjs.normalizeToDescriptor(descriptor);
|
|
860
|
+
const pubKey = chunkBYPBVHVA_cjs.extractPubKey(normalized);
|
|
861
861
|
return pubKey.toLowerCase() === this.pubKeyHex.toLowerCase();
|
|
862
862
|
} catch {
|
|
863
863
|
return false;
|
|
@@ -1194,7 +1194,7 @@ function unwrapKeyring(provider) {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
function keyOf(descriptor) {
|
|
1196
1196
|
try {
|
|
1197
|
-
return
|
|
1197
|
+
return chunkBYPBVHVA_cjs.extractPubKey(chunkBYPBVHVA_cjs.normalizeToDescriptor(descriptor)).toLowerCase();
|
|
1198
1198
|
} catch {
|
|
1199
1199
|
return void 0;
|
|
1200
1200
|
}
|
|
@@ -1285,12 +1285,12 @@ async function resolveDescriptorSigner(descriptor, identity, provider) {
|
|
|
1285
1285
|
signMessageWithDescriptor: (ownedDescriptor, message, signatureType) => identity.signDescriptorMessage(ownedDescriptor, message, signatureType)
|
|
1286
1286
|
} : void 0;
|
|
1287
1287
|
const owner = providerOwner ?? identityOwner;
|
|
1288
|
-
if (owner &&
|
|
1288
|
+
if (owner && chunkBYPBVHVA_cjs.parseHDDescriptor(descriptor)) {
|
|
1289
1289
|
return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
|
|
1290
1290
|
}
|
|
1291
1291
|
let key;
|
|
1292
1292
|
try {
|
|
1293
|
-
key =
|
|
1293
|
+
key = chunkBYPBVHVA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1294
1294
|
} catch {
|
|
1295
1295
|
throw new ForeignDescriptorError(descriptor);
|
|
1296
1296
|
}
|
|
@@ -1343,14 +1343,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
|
|
|
1343
1343
|
}
|
|
1344
1344
|
var PREIMAGE_INDEX = 0;
|
|
1345
1345
|
function isPerArtifactDescriptor(descriptor) {
|
|
1346
|
-
return
|
|
1346
|
+
return chunkBYPBVHVA_cjs.parseHDDescriptor(descriptor) !== null;
|
|
1347
1347
|
}
|
|
1348
1348
|
async function provisionDescriptor(wallet) {
|
|
1349
1349
|
const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
|
|
1350
|
-
return allocated ?? await
|
|
1350
|
+
return allocated ?? await chunkBYPBVHVA_cjs.identityDescriptor(wallet.identity);
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionRefundKey(wallet) {
|
|
1353
|
-
const descriptorPromise =
|
|
1353
|
+
const descriptorPromise = chunkBYPBVHVA_cjs.identityDescriptor(wallet.identity);
|
|
1354
1354
|
const identityPubkeyPromise = wallet.identity.xOnlyPublicKey();
|
|
1355
1355
|
void identityPubkeyPromise.catch(() => void 0);
|
|
1356
1356
|
const descriptor = await descriptorPromise;
|
|
@@ -1365,7 +1365,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1365
1365
|
);
|
|
1366
1366
|
}
|
|
1367
1367
|
const address = await wallet.getAddress();
|
|
1368
|
-
const { pkScript } =
|
|
1368
|
+
const { pkScript } = chunkKW7ZEWYS_cjs.ArkAddress.decode(address);
|
|
1369
1369
|
return { descriptor, pubkey, pkScript, address };
|
|
1370
1370
|
}
|
|
1371
1371
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1413,7 +1413,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1413
1413
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1414
1414
|
let expected;
|
|
1415
1415
|
try {
|
|
1416
|
-
expected =
|
|
1416
|
+
expected = chunkBYPBVHVA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1417
1417
|
} catch (cause) {
|
|
1418
1418
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1419
1419
|
}
|
|
@@ -1495,7 +1495,7 @@ function debugLog(debug, ...args) {
|
|
|
1495
1495
|
}
|
|
1496
1496
|
function normalizeOptions(pathOrOptions) {
|
|
1497
1497
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
1498
|
-
|
|
1498
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
1499
1499
|
return {
|
|
1500
1500
|
path: o.path,
|
|
1501
1501
|
updateViaCache: o.updateViaCache ?? "none",
|
|
@@ -1618,14 +1618,14 @@ var RestDelegateProvider = class {
|
|
|
1618
1618
|
*/
|
|
1619
1619
|
async delegate(intent, forfeitTxs, options) {
|
|
1620
1620
|
const url = `${this.url}/v1/delegate`;
|
|
1621
|
-
const response = await
|
|
1621
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(url, {
|
|
1622
1622
|
method: "POST",
|
|
1623
1623
|
headers: {
|
|
1624
1624
|
"Content-Type": "application/json"
|
|
1625
1625
|
},
|
|
1626
1626
|
body: JSON.stringify({
|
|
1627
1627
|
intent: {
|
|
1628
|
-
message:
|
|
1628
|
+
message: chunkKW7ZEWYS_cjs.Intent.encodeMessage(intent.message),
|
|
1629
1629
|
proof: intent.proof
|
|
1630
1630
|
},
|
|
1631
1631
|
forfeit_txs: forfeitTxs,
|
|
@@ -1644,7 +1644,7 @@ var RestDelegateProvider = class {
|
|
|
1644
1644
|
*/
|
|
1645
1645
|
async getDelegateInfo() {
|
|
1646
1646
|
const url = `${this.url}/v1/delegator/info`;
|
|
1647
|
-
const response = await
|
|
1647
|
+
const response = await chunkKW7ZEWYS_cjs.rateGate.runHttp(url, () => chunkKW7ZEWYS_cjs.baseFetch(url));
|
|
1648
1648
|
if (!response.ok) {
|
|
1649
1649
|
const errorText2 = await response.text();
|
|
1650
1650
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1700,7 +1700,7 @@ async function collectPages(read) {
|
|
|
1700
1700
|
return items;
|
|
1701
1701
|
}
|
|
1702
1702
|
function scriptFromArkAddress(address) {
|
|
1703
|
-
return base.hex.encode(
|
|
1703
|
+
return base.hex.encode(chunkKW7ZEWYS_cjs.ArkAddress.decode(address).pkScript);
|
|
1704
1704
|
}
|
|
1705
1705
|
|
|
1706
1706
|
// src/repositories/walletRepository.ts
|
|
@@ -1762,9 +1762,9 @@ async function collectScriptVtxos(repository, script, options) {
|
|
|
1762
1762
|
return [...byOutpoint.values()].map((row) => row.vtxo);
|
|
1763
1763
|
}
|
|
1764
1764
|
function unspentScriptVtxos(rows, copies) {
|
|
1765
|
-
const spent = copies.filter((copy) =>
|
|
1765
|
+
const spent = copies.filter((copy) => chunkKW7ZEWYS_cjs.isVtxoSpent(copy.vtxo));
|
|
1766
1766
|
return rows.filter(
|
|
1767
|
-
(row) => !
|
|
1767
|
+
(row) => !chunkKW7ZEWYS_cjs.isVtxoSpent(row.vtxo) && !spent.some(
|
|
1768
1768
|
(copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
|
|
1769
1769
|
)
|
|
1770
1770
|
);
|
|
@@ -1847,7 +1847,7 @@ var ESPLORA_URL = {
|
|
|
1847
1847
|
regtest: "http://localhost:3000/api"
|
|
1848
1848
|
};
|
|
1849
1849
|
var EsploraProvider = class {
|
|
1850
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1850
|
+
constructor(baseUrl = ESPLORA_URL[chunkKW7ZEWYS_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1851
1851
|
this.baseUrl = baseUrl;
|
|
1852
1852
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1853
1853
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1862,7 +1862,7 @@ var EsploraProvider = class {
|
|
|
1862
1862
|
*/
|
|
1863
1863
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1864
1864
|
async getCoins(address) {
|
|
1865
|
-
const response = await
|
|
1865
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1866
1866
|
if (!response.ok) {
|
|
1867
1867
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1868
1868
|
}
|
|
@@ -1871,12 +1871,12 @@ var EsploraProvider = class {
|
|
|
1871
1871
|
async getFeeRate() {
|
|
1872
1872
|
let url = `${this.baseUrl}/fee-estimates`;
|
|
1873
1873
|
let key = "1";
|
|
1874
|
-
let response = await
|
|
1874
|
+
let response = await chunkKW7ZEWYS_cjs.baseFetch(url);
|
|
1875
1875
|
if (response.status === 404) {
|
|
1876
1876
|
await response.body?.cancel();
|
|
1877
1877
|
url = `${this.baseUrl}/v1/fees/recommended`;
|
|
1878
1878
|
key = "fastestFee";
|
|
1879
|
-
response = await
|
|
1879
|
+
response = await chunkKW7ZEWYS_cjs.baseFetch(url);
|
|
1880
1880
|
}
|
|
1881
1881
|
if (response.status === 404) {
|
|
1882
1882
|
await response.body?.cancel();
|
|
@@ -1913,7 +1913,7 @@ var EsploraProvider = class {
|
|
|
1913
1913
|
}
|
|
1914
1914
|
}
|
|
1915
1915
|
async getTxOutspends(txid) {
|
|
1916
|
-
const response = await
|
|
1916
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1917
1917
|
if (!response.ok) {
|
|
1918
1918
|
const error = await response.text();
|
|
1919
1919
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1921,7 +1921,7 @@ var EsploraProvider = class {
|
|
|
1921
1921
|
return response.json();
|
|
1922
1922
|
}
|
|
1923
1923
|
async getTransactions(address) {
|
|
1924
|
-
const response = await
|
|
1924
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1925
1925
|
if (!response.ok) {
|
|
1926
1926
|
const error = await response.text();
|
|
1927
1927
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1930,14 +1930,14 @@ var EsploraProvider = class {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
/** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
|
|
1932
1932
|
async getAddressStats(address) {
|
|
1933
|
-
const response = await
|
|
1933
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1934
1934
|
if (!response.ok) {
|
|
1935
1935
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1936
1936
|
}
|
|
1937
1937
|
return response.json();
|
|
1938
1938
|
}
|
|
1939
1939
|
async getRawTransaction(txid) {
|
|
1940
|
-
const response = await
|
|
1940
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1941
1941
|
if (!response.ok) {
|
|
1942
1942
|
const error = await response.text();
|
|
1943
1943
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1945,7 +1945,7 @@ var EsploraProvider = class {
|
|
|
1945
1945
|
return base.hex.decode((await response.text()).trim());
|
|
1946
1946
|
}
|
|
1947
1947
|
async getTxStatus(txid) {
|
|
1948
|
-
const txresponse = await
|
|
1948
|
+
const txresponse = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1949
1949
|
if (!txresponse.ok) {
|
|
1950
1950
|
throw new Error(txresponse.statusText);
|
|
1951
1951
|
}
|
|
@@ -1953,7 +1953,7 @@ var EsploraProvider = class {
|
|
|
1953
1953
|
if (!tx.status.confirmed) {
|
|
1954
1954
|
return { confirmed: false };
|
|
1955
1955
|
}
|
|
1956
|
-
const response = await
|
|
1956
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1957
1957
|
if (!response.ok) {
|
|
1958
1958
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1959
1959
|
}
|
|
@@ -2227,9 +2227,9 @@ var EsploraProvider = class {
|
|
|
2227
2227
|
return { subscribers, teardown, started };
|
|
2228
2228
|
}
|
|
2229
2229
|
async getChainTip() {
|
|
2230
|
-
let tipBlocks = await
|
|
2230
|
+
let tipBlocks = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2231
2231
|
if (tipBlocks.status === 404) {
|
|
2232
|
-
tipBlocks = await
|
|
2232
|
+
tipBlocks = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2233
2233
|
}
|
|
2234
2234
|
if (!tipBlocks.ok) {
|
|
2235
2235
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2250,7 +2250,7 @@ var EsploraProvider = class {
|
|
|
2250
2250
|
};
|
|
2251
2251
|
}
|
|
2252
2252
|
async broadcastPackage(parent, child) {
|
|
2253
|
-
const response = await
|
|
2253
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2254
2254
|
method: "POST",
|
|
2255
2255
|
headers: {
|
|
2256
2256
|
"Content-Type": "application/json"
|
|
@@ -2266,7 +2266,7 @@ var EsploraProvider = class {
|
|
|
2266
2266
|
return result;
|
|
2267
2267
|
}
|
|
2268
2268
|
async broadcastTx(tx) {
|
|
2269
|
-
const response = await
|
|
2269
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2270
2270
|
method: "POST",
|
|
2271
2271
|
headers: {
|
|
2272
2272
|
"Content-Type": "text/plain"
|
|
@@ -2438,7 +2438,7 @@ function findP2AOutput(tx) {
|
|
|
2438
2438
|
var CHILD_DUST_AMOUNT = 546;
|
|
2439
2439
|
function buildAnchorChild(params) {
|
|
2440
2440
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2441
|
-
const child = new
|
|
2441
|
+
const child = new chunkKW7ZEWYS_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2442
2442
|
const anchor = findP2AOutput(parent);
|
|
2443
2443
|
child.addInput(anchor);
|
|
2444
2444
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
@@ -2487,7 +2487,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2487
2487
|
);
|
|
2488
2488
|
}
|
|
2489
2489
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2490
|
-
const tx = new
|
|
2490
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction({
|
|
2491
2491
|
version: 3,
|
|
2492
2492
|
lockTime: txLocktime
|
|
2493
2493
|
});
|
|
@@ -2514,7 +2514,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
|
|
|
2514
2514
|
connectorsGraph.validate();
|
|
2515
2515
|
if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
|
|
2516
2516
|
const rootInput = connectorsGraph.root.getInput(0);
|
|
2517
|
-
const settlementTx =
|
|
2517
|
+
const settlementTx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
|
|
2518
2518
|
if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
|
|
2519
2519
|
throw ErrInvalidSettlementTxOutputs;
|
|
2520
2520
|
const expectedRootTxid = settlementTx.id;
|
|
@@ -2563,7 +2563,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2563
2563
|
if (previousScriptKey.length !== 32) {
|
|
2564
2564
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2565
2565
|
}
|
|
2566
|
-
const cosigners =
|
|
2566
|
+
const cosigners = chunkKW7ZEWYS_cjs.getArkPsbtFields(child.root, 0, chunkKW7ZEWYS_cjs.CosignerPublicKey);
|
|
2567
2567
|
if (cosigners.length === 0) {
|
|
2568
2568
|
throw ErrMissingCosignersPublicKeys;
|
|
2569
2569
|
}
|
|
@@ -2621,7 +2621,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2621
2621
|
return new _EmulatorPacket(entries);
|
|
2622
2622
|
}
|
|
2623
2623
|
static fromBytes(data) {
|
|
2624
|
-
const reader = new
|
|
2624
|
+
const reader = new chunkZMSM3NOH_cjs.BufferReader(data);
|
|
2625
2625
|
const entryCount = reader.readCompactSize();
|
|
2626
2626
|
const entries = [];
|
|
2627
2627
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2639,7 +2639,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2639
2639
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2640
2640
|
}
|
|
2641
2641
|
serialize() {
|
|
2642
|
-
const writer = new
|
|
2642
|
+
const writer = new chunkZMSM3NOH_cjs.BufferWriter();
|
|
2643
2643
|
writer.writeCompactSize(this.entries.length);
|
|
2644
2644
|
for (const entry of this.entries) {
|
|
2645
2645
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2726,7 +2726,7 @@ var Extension = class _Extension {
|
|
|
2726
2726
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2727
2727
|
);
|
|
2728
2728
|
}
|
|
2729
|
-
const reader = new
|
|
2729
|
+
const reader = new chunkZMSM3NOH_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2730
2730
|
const packets = [];
|
|
2731
2731
|
while (reader.remaining() > 0) {
|
|
2732
2732
|
const packetType = reader.readByte();
|
|
@@ -2799,7 +2799,7 @@ var Extension = class _Extension {
|
|
|
2799
2799
|
* getAssetPacket returns the embedded Packet, or null if not present.
|
|
2800
2800
|
*/
|
|
2801
2801
|
getAssetPacket() {
|
|
2802
|
-
return this.packets.find((p) => p instanceof
|
|
2802
|
+
return this.packets.find((p) => p instanceof chunkZMSM3NOH_cjs.Packet) ?? null;
|
|
2803
2803
|
}
|
|
2804
2804
|
/**
|
|
2805
2805
|
* getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
|
|
@@ -2823,8 +2823,8 @@ var Extension = class _Extension {
|
|
|
2823
2823
|
};
|
|
2824
2824
|
function parsePacket(packetType, data) {
|
|
2825
2825
|
switch (packetType) {
|
|
2826
|
-
case
|
|
2827
|
-
return
|
|
2826
|
+
case chunkZMSM3NOH_cjs.Packet.PACKET_TYPE:
|
|
2827
|
+
return chunkZMSM3NOH_cjs.Packet.fromBytes(data);
|
|
2828
2828
|
case EmulatorPacket.PACKET_TYPE:
|
|
2829
2829
|
return EmulatorPacket.fromBytes(data);
|
|
2830
2830
|
default:
|
|
@@ -2871,22 +2871,22 @@ function buildOpReturnScript(data) {
|
|
|
2871
2871
|
}
|
|
2872
2872
|
return script;
|
|
2873
2873
|
}
|
|
2874
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2875
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2874
|
+
var ErrOffchainOutputNotFound = (address) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2875
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
2876
2876
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2877
2877
|
);
|
|
2878
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2879
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2878
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2879
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
2880
2880
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2881
2881
|
);
|
|
2882
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2883
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2882
|
+
var ErrOnchainOutputNotFound = (address) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2883
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
2884
2884
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2885
2885
|
);
|
|
2886
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
2886
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
2887
2887
|
`${kind} output ${index} of the intent proof is not present in what the server built`
|
|
2888
2888
|
);
|
|
2889
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
2889
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
2890
2890
|
`offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
|
|
2891
2891
|
);
|
|
2892
2892
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2895,7 +2895,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2895
2895
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2896
2896
|
if (!validatedCommitmentTxid) return;
|
|
2897
2897
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2898
|
-
throw new
|
|
2898
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
2899
2899
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2900
2900
|
);
|
|
2901
2901
|
}
|
|
@@ -2905,7 +2905,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2905
2905
|
for (const recipient of recipients) {
|
|
2906
2906
|
let arkAddress;
|
|
2907
2907
|
try {
|
|
2908
|
-
arkAddress =
|
|
2908
|
+
arkAddress = chunkKW7ZEWYS_cjs.ArkAddress.decode(recipient.address);
|
|
2909
2909
|
} catch {
|
|
2910
2910
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2911
2911
|
continue;
|
|
@@ -2917,7 +2917,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2917
2917
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2918
2918
|
for (const recipient of recipients) {
|
|
2919
2919
|
try {
|
|
2920
|
-
|
|
2920
|
+
chunkKW7ZEWYS_cjs.ArkAddress.decode(recipient.address);
|
|
2921
2921
|
} catch {
|
|
2922
2922
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2923
2923
|
continue;
|
|
@@ -2926,7 +2926,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2926
2926
|
}
|
|
2927
2927
|
}
|
|
2928
2928
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
2929
|
-
const proof =
|
|
2929
|
+
const proof = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
2930
2930
|
const onchain = new Set(onchainOutputIndexes);
|
|
2931
2931
|
const declared = [];
|
|
2932
2932
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3218,7 +3218,7 @@ function assetMintResolver() {
|
|
|
3218
3218
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3219
3219
|
const minted = tx.assets.filter((a) => {
|
|
3220
3220
|
try {
|
|
3221
|
-
return base.hex.encode(
|
|
3221
|
+
return base.hex.encode(chunkZMSM3NOH_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3222
3222
|
} catch {
|
|
3223
3223
|
return false;
|
|
3224
3224
|
}
|
|
@@ -3295,7 +3295,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3295
3295
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3296
3296
|
inputsByAssetId.set(asset.assetId, [
|
|
3297
3297
|
...existing ?? [],
|
|
3298
|
-
|
|
3298
|
+
chunkZMSM3NOH_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3299
3299
|
]);
|
|
3300
3300
|
}
|
|
3301
3301
|
}
|
|
@@ -3307,7 +3307,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3307
3307
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3308
3308
|
outputsByAssetId.set(asset.assetId, [
|
|
3309
3309
|
...existing ?? [],
|
|
3310
|
-
|
|
3310
|
+
chunkZMSM3NOH_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3311
3311
|
]);
|
|
3312
3312
|
}
|
|
3313
3313
|
}
|
|
@@ -3318,7 +3318,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3318
3318
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3319
3319
|
outputsByAssetId.set(asset.assetId, [
|
|
3320
3320
|
...existing ?? [],
|
|
3321
|
-
|
|
3321
|
+
chunkZMSM3NOH_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3322
3322
|
]);
|
|
3323
3323
|
}
|
|
3324
3324
|
}
|
|
@@ -3327,11 +3327,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3327
3327
|
for (const assetIdStr of allAssetIds) {
|
|
3328
3328
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3329
3329
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3330
|
-
const assetId =
|
|
3331
|
-
const group =
|
|
3330
|
+
const assetId = chunkZMSM3NOH_cjs.AssetId.fromString(assetIdStr);
|
|
3331
|
+
const group = chunkZMSM3NOH_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3332
3332
|
groups.push(group);
|
|
3333
3333
|
}
|
|
3334
|
-
return
|
|
3334
|
+
return chunkZMSM3NOH_cjs.Packet.create(groups);
|
|
3335
3335
|
}
|
|
3336
3336
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3337
3337
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3415,7 +3415,7 @@ function meetsInputExpiryFloor(coin, floor) {
|
|
|
3415
3415
|
}
|
|
3416
3416
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3417
3417
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3418
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3418
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkBYPBVHVA_cjs.toXOnly(bytes, "signer key"));
|
|
3419
3419
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3420
3420
|
}
|
|
3421
3421
|
function signerSetFromInfo(info) {
|
|
@@ -3462,14 +3462,14 @@ var toTimelock = (value) => ({
|
|
|
3462
3462
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3463
3463
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3464
3464
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3465
|
-
throw new
|
|
3465
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3466
3466
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3467
3467
|
);
|
|
3468
3468
|
}
|
|
3469
3469
|
const seconds = toSeconds(timelock);
|
|
3470
3470
|
if (seconds < policy.minSeconds) {
|
|
3471
3471
|
const remedy = overrideOption ? `; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it` : "";
|
|
3472
|
-
throw new
|
|
3472
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3473
3473
|
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor${remedy}`
|
|
3474
3474
|
);
|
|
3475
3475
|
}
|
|
@@ -3490,7 +3490,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3490
3490
|
}
|
|
3491
3491
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3492
3492
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3493
|
-
throw new
|
|
3493
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3494
3494
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3495
3495
|
);
|
|
3496
3496
|
}
|
|
@@ -3499,21 +3499,21 @@ function assertValidBatchExpiry(batchExpiry, policy) {
|
|
|
3499
3499
|
function assertValidServerUnrollScript(checkpointTapscript, network, advertisedForfeitPubkey) {
|
|
3500
3500
|
let script;
|
|
3501
3501
|
try {
|
|
3502
|
-
script =
|
|
3502
|
+
script = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3503
3503
|
} catch (e) {
|
|
3504
|
-
throw new
|
|
3504
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3505
3505
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3506
3506
|
);
|
|
3507
3507
|
}
|
|
3508
3508
|
if (advertisedForfeitPubkey !== void 0) {
|
|
3509
3509
|
const { pubkeys } = script.params;
|
|
3510
3510
|
if (pubkeys.length !== 1) {
|
|
3511
|
-
throw new
|
|
3511
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3512
3512
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3513
3513
|
);
|
|
3514
3514
|
}
|
|
3515
3515
|
if (!utils_js.equalBytes(pubkeys[0], advertisedForfeitPubkey)) {
|
|
3516
|
-
throw new
|
|
3516
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3517
3517
|
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(advertisedForfeitPubkey)}`
|
|
3518
3518
|
);
|
|
3519
3519
|
}
|
|
@@ -3556,8 +3556,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3556
3556
|
function buildVirtualTx(inputs, outputs) {
|
|
3557
3557
|
let lockTime = 0n;
|
|
3558
3558
|
for (const input of inputs) {
|
|
3559
|
-
const tapscript =
|
|
3560
|
-
if (
|
|
3559
|
+
const tapscript = chunkKW7ZEWYS_cjs.decodeTapscript(chunkKW7ZEWYS_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3560
|
+
if (chunkKW7ZEWYS_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3561
3561
|
if (lockTime !== 0n) {
|
|
3562
3562
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3563
3563
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3568,7 +3568,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3568
3568
|
}
|
|
3569
3569
|
}
|
|
3570
3570
|
}
|
|
3571
|
-
const tx = new
|
|
3571
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction({
|
|
3572
3572
|
version: 3,
|
|
3573
3573
|
lockTime: Number(lockTime)
|
|
3574
3574
|
});
|
|
@@ -3578,12 +3578,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3578
3578
|
index: input.vout,
|
|
3579
3579
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3580
3580
|
witnessUtxo: {
|
|
3581
|
-
script:
|
|
3581
|
+
script: chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3582
3582
|
amount: BigInt(input.value)
|
|
3583
3583
|
},
|
|
3584
3584
|
tapLeafScript: [input.tapLeafScript]
|
|
3585
3585
|
});
|
|
3586
|
-
|
|
3586
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(tx, i, chunkKW7ZEWYS_cjs.VtxoTaprootTree, input.tapTree);
|
|
3587
3587
|
}
|
|
3588
3588
|
for (const output of outputs) {
|
|
3589
3589
|
tx.addOutput(output);
|
|
@@ -3594,8 +3594,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3594
3594
|
return tx;
|
|
3595
3595
|
}
|
|
3596
3596
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3597
|
-
const collaborativeClosure =
|
|
3598
|
-
const checkpointVtxoScript = new
|
|
3597
|
+
const collaborativeClosure = chunkKW7ZEWYS_cjs.decodeTapscript(chunkKW7ZEWYS_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3598
|
+
const checkpointVtxoScript = new chunkKW7ZEWYS_cjs.VtxoScript([
|
|
3599
3599
|
serverUnrollScript.script,
|
|
3600
3600
|
collaborativeClosure.script
|
|
3601
3601
|
]);
|
|
@@ -3671,7 +3671,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3671
3671
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3672
3672
|
const sig = signature.subarray(0, 64);
|
|
3673
3673
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3674
|
-
const sighashName =
|
|
3674
|
+
const sighashName = chunkKW7ZEWYS_cjs.formatSighash(sighashType);
|
|
3675
3675
|
throw new Error(
|
|
3676
3676
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3677
3677
|
);
|
|
@@ -3745,7 +3745,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3745
3745
|
}
|
|
3746
3746
|
function isValidArkAddress(address) {
|
|
3747
3747
|
try {
|
|
3748
|
-
|
|
3748
|
+
chunkKW7ZEWYS_cjs.ArkAddress.decode(address);
|
|
3749
3749
|
return true;
|
|
3750
3750
|
} catch (e) {
|
|
3751
3751
|
return false;
|
|
@@ -3753,16 +3753,16 @@ function isValidArkAddress(address) {
|
|
|
3753
3753
|
}
|
|
3754
3754
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3755
3755
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3756
|
-
throw new
|
|
3756
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3757
3757
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3758
3758
|
);
|
|
3759
3759
|
}
|
|
3760
3760
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3761
3761
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3762
|
-
const server =
|
|
3762
|
+
const server = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3763
3763
|
const local = byTxid.get(server.id);
|
|
3764
3764
|
if (!local) {
|
|
3765
|
-
throw new
|
|
3765
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3766
3766
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3767
3767
|
);
|
|
3768
3768
|
}
|
|
@@ -3772,14 +3772,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3772
3772
|
}
|
|
3773
3773
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3774
3774
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3775
|
-
throw new
|
|
3775
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3776
3776
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3777
3777
|
);
|
|
3778
3778
|
}
|
|
3779
3779
|
if (response.finalArkTx === void 0) return;
|
|
3780
|
-
const finalTxid =
|
|
3780
|
+
const finalTxid = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3781
3781
|
if (finalTxid !== signedArkTx.id) {
|
|
3782
|
-
throw new
|
|
3782
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3783
3783
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3784
3784
|
);
|
|
3785
3785
|
}
|
|
@@ -3791,20 +3791,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3791
3791
|
`${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
|
|
3792
3792
|
);
|
|
3793
3793
|
}
|
|
3794
|
-
const script =
|
|
3794
|
+
const script = chunkKW7ZEWYS_cjs.scriptFromTapLeafScript(leaf);
|
|
3795
3795
|
let leafPubkeys;
|
|
3796
3796
|
try {
|
|
3797
|
-
leafPubkeys =
|
|
3798
|
-
(key) => base.hex.encode(
|
|
3797
|
+
leafPubkeys = chunkKW7ZEWYS_cjs.decodeTapscript(script).params.pubkeys.map(
|
|
3798
|
+
(key) => base.hex.encode(chunkBYPBVHVA_cjs.toXOnly(key, "leaf key"))
|
|
3799
3799
|
);
|
|
3800
3800
|
} catch (error) {
|
|
3801
|
-
throw new
|
|
3801
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3802
3802
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3803
3803
|
);
|
|
3804
3804
|
}
|
|
3805
3805
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3806
3806
|
if (!signer) {
|
|
3807
|
-
throw new
|
|
3807
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3808
3808
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
3809
3809
|
);
|
|
3810
3810
|
}
|
|
@@ -3818,7 +3818,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3818
3818
|
payment_js.tapLeafHash(script)
|
|
3819
3819
|
);
|
|
3820
3820
|
} catch (error) {
|
|
3821
|
-
throw new
|
|
3821
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3822
3822
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3823
3823
|
);
|
|
3824
3824
|
}
|
|
@@ -3827,20 +3827,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3827
3827
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3828
3828
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3829
3829
|
if (checkpoint.inputsLength !== 1) {
|
|
3830
|
-
throw new
|
|
3830
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3831
3831
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3832
3832
|
);
|
|
3833
3833
|
}
|
|
3834
3834
|
const spent = checkpoint.getInput(0);
|
|
3835
3835
|
if (!spent.txid || spent.index === void 0) {
|
|
3836
|
-
throw new
|
|
3836
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3837
3837
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3838
3838
|
);
|
|
3839
3839
|
}
|
|
3840
3840
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3841
3841
|
const input = byOutpoint.get(outpoint);
|
|
3842
3842
|
if (!input) {
|
|
3843
|
-
throw new
|
|
3843
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3844
3844
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3845
3845
|
);
|
|
3846
3846
|
}
|
|
@@ -3848,50 +3848,54 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3848
3848
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3849
3849
|
);
|
|
3850
3850
|
if (!rebuilt) {
|
|
3851
|
-
throw new
|
|
3851
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3852
3852
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3853
3853
|
);
|
|
3854
3854
|
}
|
|
3855
3855
|
}
|
|
3856
3856
|
}
|
|
3857
3857
|
async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
3858
|
-
const
|
|
3858
|
+
const oneShot = options?.oneShot !== false;
|
|
3859
|
+
const { arkTx: signedArkTx, userSignedCheckpoints: batchSigned } = await signer.signArkTx(
|
|
3859
3860
|
offchainTx.arkTx,
|
|
3860
3861
|
offchainTx.checkpoints
|
|
3861
3862
|
);
|
|
3862
|
-
if (
|
|
3863
|
+
if (batchSigned && batchSigned.length !== offchainTx.checkpoints.length) {
|
|
3863
3864
|
throw new Error(
|
|
3864
|
-
`signer returned ${
|
|
3865
|
+
`signer returned ${batchSigned.length} signed checkpoints, expected ${offchainTx.checkpoints.length}`
|
|
3865
3866
|
);
|
|
3866
3867
|
}
|
|
3868
|
+
const userSignedCheckpoints = (batchSigned ?? (oneShot ? await Promise.all(offchainTx.checkpoints.map((c) => signer.signCheckpoint(c.clone()))) : void 0))?.map((c) => withArkInputWitness(c, signedArkTx));
|
|
3867
3869
|
await hooks?.beforeSubmit?.();
|
|
3868
3870
|
const response = await provider.submitTx(
|
|
3869
3871
|
base.base64.encode(signedArkTx.toPSBT()),
|
|
3870
|
-
offchainTx.checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
3872
|
+
(oneShot ? userSignedCheckpoints : offchainTx.checkpoints.map((c) => withArkInputWitness(c, signedArkTx))).map((c) => base.base64.encode(c.toPSBT()))
|
|
3871
3873
|
);
|
|
3872
3874
|
assertSubmittedArkTxid(response, signedArkTx, "submitTx");
|
|
3873
3875
|
const { arkTxid, signedCheckpointTxs } = response;
|
|
3874
3876
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3877
|
+
if (!oneShot) {
|
|
3878
|
+
matched.forEach(({ server }, index) => {
|
|
3879
|
+
try {
|
|
3880
|
+
chunkKW7ZEWYS_cjs.assertAllowedSighashTypes(server);
|
|
3881
|
+
} catch (error) {
|
|
3882
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3883
|
+
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3884
|
+
);
|
|
3885
|
+
}
|
|
3886
|
+
});
|
|
3887
|
+
}
|
|
3884
3888
|
const verify = options?.verifyServerSignatures;
|
|
3885
3889
|
if (verify) {
|
|
3886
3890
|
if (response.finalArkTx === void 0) {
|
|
3887
|
-
throw new
|
|
3891
|
+
throw new chunkKW7ZEWYS_cjs.ServerResponseMismatchError(
|
|
3888
3892
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3889
3893
|
);
|
|
3890
3894
|
}
|
|
3891
|
-
const finalArkTx =
|
|
3895
|
+
const finalArkTx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3892
3896
|
const serverPubkeys = new Set(
|
|
3893
3897
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
3894
|
-
(key) => base.hex.encode(
|
|
3898
|
+
(key) => base.hex.encode(chunkBYPBVHVA_cjs.toXOnly(key, "server key"))
|
|
3895
3899
|
)
|
|
3896
3900
|
);
|
|
3897
3901
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
@@ -3907,26 +3911,62 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3907
3911
|
({ server, local }, index) => assertServerSignedLeaf(server, local, 0, serverPubkeys, `submitTx checkpoint ${index}`)
|
|
3908
3912
|
);
|
|
3909
3913
|
}
|
|
3914
|
+
const result = { arkTxid, finalArkTx: response.finalArkTx, signedCheckpointTxs };
|
|
3910
3915
|
let finalCheckpoints;
|
|
3911
3916
|
if (userSignedCheckpoints) {
|
|
3912
3917
|
const userByTxid = new Map(
|
|
3913
3918
|
userSignedCheckpoints.map((c, i) => [offchainTx.checkpoints[i].id, c])
|
|
3914
3919
|
);
|
|
3920
|
+
if (oneShot && matched.every(
|
|
3921
|
+
({ server, local }) => carriesTapscriptSigs(server, userByTxid.get(local.id))
|
|
3922
|
+
)) {
|
|
3923
|
+
await hooks?.afterFinalize?.();
|
|
3924
|
+
return result;
|
|
3925
|
+
}
|
|
3915
3926
|
finalCheckpoints = matched.map(({ server, local }) => {
|
|
3916
|
-
|
|
3927
|
+
const userSigned = userByTxid.get(local.id);
|
|
3928
|
+
combineTapscriptSigs(userSigned, server);
|
|
3929
|
+
carryConditionWitness(userSigned, server);
|
|
3917
3930
|
return base.base64.encode(server.toPSBT());
|
|
3918
3931
|
});
|
|
3919
3932
|
} else {
|
|
3920
3933
|
finalCheckpoints = await Promise.all(
|
|
3921
|
-
matched.map(async ({ server }) => {
|
|
3934
|
+
matched.map(async ({ server, local }) => {
|
|
3922
3935
|
const signed = await signer.signCheckpoint(server);
|
|
3936
|
+
carryConditionWitness(local, signed);
|
|
3923
3937
|
return base.base64.encode(signed.toPSBT());
|
|
3924
3938
|
})
|
|
3925
3939
|
);
|
|
3926
3940
|
}
|
|
3927
3941
|
await provider.finalizeTx(arkTxid, finalCheckpoints);
|
|
3928
3942
|
await hooks?.afterFinalize?.();
|
|
3929
|
-
return
|
|
3943
|
+
return result;
|
|
3944
|
+
}
|
|
3945
|
+
function carryConditionWitness(ours, server) {
|
|
3946
|
+
if (chunkKW7ZEWYS_cjs.getArkPsbtFields(server, 0, chunkKW7ZEWYS_cjs.ConditionWitness).length > 0) return;
|
|
3947
|
+
const [witness] = chunkKW7ZEWYS_cjs.getArkPsbtFields(ours, 0, chunkKW7ZEWYS_cjs.ConditionWitness);
|
|
3948
|
+
if (witness) chunkKW7ZEWYS_cjs.setArkPsbtField(server, 0, chunkKW7ZEWYS_cjs.ConditionWitness, witness);
|
|
3949
|
+
}
|
|
3950
|
+
function withArkInputWitness(checkpoint, signedArkTx) {
|
|
3951
|
+
if (chunkKW7ZEWYS_cjs.getArkPsbtFields(checkpoint, 0, chunkKW7ZEWYS_cjs.ConditionWitness).length > 0) return checkpoint;
|
|
3952
|
+
for (let i = 0; i < signedArkTx.inputsLength; i++) {
|
|
3953
|
+
const { txid } = signedArkTx.getInput(i);
|
|
3954
|
+
if (!txid || base.hex.encode(txid) !== checkpoint.id) continue;
|
|
3955
|
+
const [witness] = chunkKW7ZEWYS_cjs.getArkPsbtFields(signedArkTx, i, chunkKW7ZEWYS_cjs.ConditionWitness);
|
|
3956
|
+
if (!witness) return checkpoint;
|
|
3957
|
+
const carried = checkpoint.clone();
|
|
3958
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(carried, 0, chunkKW7ZEWYS_cjs.ConditionWitness, witness);
|
|
3959
|
+
return carried;
|
|
3960
|
+
}
|
|
3961
|
+
return checkpoint;
|
|
3962
|
+
}
|
|
3963
|
+
function carriesTapscriptSigs(server, userSigned) {
|
|
3964
|
+
const entries = (tx) => (tx.getInput(0).tapScriptSig ?? []).map(
|
|
3965
|
+
([{ pubKey, leafHash }, sig]) => base.hex.encode(pubKey) + base.hex.encode(leafHash) + base.hex.encode(sig)
|
|
3966
|
+
);
|
|
3967
|
+
const have = new Set(entries(server));
|
|
3968
|
+
const want = entries(userSigned);
|
|
3969
|
+
return want.length > 0 && want.every((entry) => have.has(entry));
|
|
3930
3970
|
}
|
|
3931
3971
|
async function signAndSubmitOffchainTx(params) {
|
|
3932
3972
|
const offchainTx = buildOffchainTx(params.inputs, params.outputs, params.serverUnrollScript);
|
|
@@ -3935,7 +3975,8 @@ async function signAndSubmitOffchainTx(params) {
|
|
|
3935
3975
|
signCheckpoint: (checkpoint) => params.identity.sign(checkpoint)
|
|
3936
3976
|
};
|
|
3937
3977
|
const { arkTxid } = await submitOffchainTx(params.provider, offchainTx, signer, void 0, {
|
|
3938
|
-
verifyServerSignatures: params.verifyServerSignatures
|
|
3978
|
+
verifyServerSignatures: params.verifyServerSignatures,
|
|
3979
|
+
oneShot: params.oneShot
|
|
3939
3980
|
});
|
|
3940
3981
|
return arkTxid;
|
|
3941
3982
|
}
|
|
@@ -3955,7 +3996,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
|
|
|
3955
3996
|
base.base64.encode(arkTx.toPSBT()),
|
|
3956
3997
|
checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
3957
3998
|
);
|
|
3958
|
-
const txid =
|
|
3999
|
+
const txid = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
|
|
3959
4000
|
assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
|
|
3960
4001
|
return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
|
|
3961
4002
|
}
|
|
@@ -3963,12 +4004,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3963
4004
|
return {
|
|
3964
4005
|
...identity,
|
|
3965
4006
|
sign: async (tx, inputIndexes) => {
|
|
3966
|
-
const signed =
|
|
4007
|
+
const signed = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(
|
|
3967
4008
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3968
4009
|
);
|
|
3969
4010
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3970
4011
|
for (const index of indexes) {
|
|
3971
|
-
|
|
4012
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(signed, index, chunkKW7ZEWYS_cjs.ConditionWitness, [preimage]);
|
|
3972
4013
|
}
|
|
3973
4014
|
return signed;
|
|
3974
4015
|
}
|
|
@@ -4151,7 +4192,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
4151
4192
|
};
|
|
4152
4193
|
}
|
|
4153
4194
|
function deriveContractTapscripts(contract) {
|
|
4154
|
-
const handler =
|
|
4195
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
4155
4196
|
if (!handler) {
|
|
4156
4197
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4157
4198
|
}
|
|
@@ -4254,7 +4295,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
|
|
|
4254
4295
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
4255
4296
|
let derived;
|
|
4256
4297
|
try {
|
|
4257
|
-
derived =
|
|
4298
|
+
derived = chunkKW7ZEWYS_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
4258
4299
|
} catch (e) {
|
|
4259
4300
|
throw new Error(
|
|
4260
4301
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -4271,7 +4312,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4271
4312
|
for (const recipient of recipients) {
|
|
4272
4313
|
let address;
|
|
4273
4314
|
try {
|
|
4274
|
-
address =
|
|
4315
|
+
address = chunkKW7ZEWYS_cjs.ArkAddress.decode(recipient.address);
|
|
4275
4316
|
} catch (e) {
|
|
4276
4317
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
4277
4318
|
}
|
|
@@ -4296,7 +4337,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4296
4337
|
|
|
4297
4338
|
// src/contracts/spendability.ts
|
|
4298
4339
|
function isContractGenericallySpendable(contract) {
|
|
4299
|
-
return
|
|
4340
|
+
return chunkBYPBVHVA_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
4300
4341
|
}
|
|
4301
4342
|
function gatedContracts(contracts) {
|
|
4302
4343
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -4318,7 +4359,7 @@ function gateExclusion(gated) {
|
|
|
4318
4359
|
return (vtxo) => {
|
|
4319
4360
|
const type = gatedTypeOf(vtxo, gated);
|
|
4320
4361
|
if (type === void 0) return void 0;
|
|
4321
|
-
if (!
|
|
4362
|
+
if (!chunkBYPBVHVA_cjs.contractHandlers.has(type)) {
|
|
4322
4363
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
4323
4364
|
}
|
|
4324
4365
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4354,7 +4395,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4354
4395
|
continue;
|
|
4355
4396
|
}
|
|
4356
4397
|
for (const v of vtxos) {
|
|
4357
|
-
if (!
|
|
4398
|
+
if (!chunkKW7ZEWYS_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
4358
4399
|
out.add(`${v.txid}:${v.vout}`);
|
|
4359
4400
|
}
|
|
4360
4401
|
}
|
|
@@ -4390,14 +4431,14 @@ function byValueDescending(vtxos) {
|
|
|
4390
4431
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4391
4432
|
}
|
|
4392
4433
|
async function fetchTimeHeight(wallet) {
|
|
4393
|
-
return
|
|
4434
|
+
return chunkKW7ZEWYS_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4394
4435
|
}
|
|
4395
4436
|
function heldVtxosOf(wallet) {
|
|
4396
4437
|
const held = wallet.getHeldVtxos;
|
|
4397
4438
|
return typeof held === "function" ? held.call(wallet) : Promise.resolve([]);
|
|
4398
4439
|
}
|
|
4399
4440
|
function canMigrateBySend(vtxo, now) {
|
|
4400
|
-
if (!
|
|
4441
|
+
if (!chunkKW7ZEWYS_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4401
4442
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4402
4443
|
}
|
|
4403
4444
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4405,7 +4446,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4405
4446
|
if (vtxo.isSwept) return -Infinity;
|
|
4406
4447
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4407
4448
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4408
|
-
return
|
|
4449
|
+
return chunkKW7ZEWYS_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4409
4450
|
}
|
|
4410
4451
|
return Infinity;
|
|
4411
4452
|
};
|
|
@@ -4432,7 +4473,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4432
4473
|
const payable = [];
|
|
4433
4474
|
const net = /* @__PURE__ */ new Map();
|
|
4434
4475
|
for (const vtxo of vtxos) {
|
|
4435
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4476
|
+
const inputFee = estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(vtxo));
|
|
4436
4477
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4437
4478
|
continue;
|
|
4438
4479
|
}
|
|
@@ -4461,7 +4502,7 @@ function offchainOutputFee(amount, estimator, arkAddress) {
|
|
|
4461
4502
|
}
|
|
4462
4503
|
const outputFee = estimator.evalOffchainOutput({
|
|
4463
4504
|
amount,
|
|
4464
|
-
script: base.hex.encode(
|
|
4505
|
+
script: base.hex.encode(chunkKW7ZEWYS_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4465
4506
|
});
|
|
4466
4507
|
return BigInt(outputFee.satoshis);
|
|
4467
4508
|
}
|
|
@@ -4512,10 +4553,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4512
4553
|
};
|
|
4513
4554
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4514
4555
|
return vtxos.filter((vtxo) => {
|
|
4515
|
-
if (
|
|
4556
|
+
if (chunkKW7ZEWYS_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4516
4557
|
return true;
|
|
4517
4558
|
}
|
|
4518
|
-
if (
|
|
4559
|
+
if (chunkKW7ZEWYS_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4519
4560
|
return true;
|
|
4520
4561
|
}
|
|
4521
4562
|
return false;
|
|
@@ -4547,7 +4588,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4547
4588
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4548
4589
|
if (vtxo.isUnrolled) return false;
|
|
4549
4590
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4550
|
-
const expiresAt =
|
|
4591
|
+
const expiresAt = chunkKW7ZEWYS_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4551
4592
|
if (expiresAt === void 0) return false;
|
|
4552
4593
|
const now = Date.now();
|
|
4553
4594
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4558,7 +4599,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4558
4599
|
return vtxos.filter(
|
|
4559
4600
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4560
4601
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4561
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4602
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkKW7ZEWYS_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4562
4603
|
);
|
|
4563
4604
|
}
|
|
4564
4605
|
function isMigrationCapable(wallet) {
|
|
@@ -4618,7 +4659,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4618
4659
|
constructor(wallet, settlementConfig) {
|
|
4619
4660
|
this.wallet = wallet;
|
|
4620
4661
|
if (settlementConfig !== false) {
|
|
4621
|
-
|
|
4662
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
|
|
4622
4663
|
}
|
|
4623
4664
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
4624
4665
|
this.contractEventsSubscriptionReady = this.initializeSubscription();
|
|
@@ -4930,7 +4971,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4930
4971
|
* {@link recoverImportedContracts}).
|
|
4931
4972
|
*/
|
|
4932
4973
|
async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
|
|
4933
|
-
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !
|
|
4974
|
+
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo));
|
|
4934
4975
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
4935
4976
|
const { payable, net } = priceSettlementInputs(recoverable, estimator);
|
|
4936
4977
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
@@ -4952,7 +4993,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4952
4993
|
if (vtxos.length === 0) return;
|
|
4953
4994
|
const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
|
|
4954
4995
|
const stillSpendable = vtxos.some(
|
|
4955
|
-
(vtxo) => !
|
|
4996
|
+
(vtxo) => !chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
4956
4997
|
);
|
|
4957
4998
|
if (!stillSpendable) {
|
|
4958
4999
|
await wallet.removeRecoveryContract(contract.script);
|
|
@@ -5245,11 +5286,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
5245
5286
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
5246
5287
|
);
|
|
5247
5288
|
}
|
|
5248
|
-
const tx = new
|
|
5289
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction();
|
|
5249
5290
|
for (const utxo of expiredUtxos) {
|
|
5250
|
-
const utxoScript =
|
|
5291
|
+
const utxoScript = chunkKW7ZEWYS_cjs.VtxoScript.decode(utxo.tapTree);
|
|
5251
5292
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
5252
|
-
(leaf) =>
|
|
5293
|
+
(leaf) => chunkKW7ZEWYS_cjs.CSVMultisigTapscript.isScriptValid(chunkKW7ZEWYS_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
5253
5294
|
);
|
|
5254
5295
|
if (!utxoExitLeaf) {
|
|
5255
5296
|
throw new Error(
|
|
@@ -5264,7 +5305,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5264
5305
|
amount: BigInt(utxo.value)
|
|
5265
5306
|
},
|
|
5266
5307
|
tapLeafScript: [utxoExitLeaf],
|
|
5267
|
-
sequence:
|
|
5308
|
+
sequence: chunkKW7ZEWYS_cjs.getSequence(utxoExitLeaf)
|
|
5268
5309
|
});
|
|
5269
5310
|
}
|
|
5270
5311
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5491,8 +5532,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5491
5532
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5492
5533
|
if (cls.status === "CURRENT") continue;
|
|
5493
5534
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5494
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5495
|
-
const spendable = live.filter((v) => !
|
|
5535
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkKW7ZEWYS_cjs.isVtxoSpent(v));
|
|
5536
|
+
const spendable = live.filter((v) => !chunkKW7ZEWYS_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
5496
5537
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5497
5538
|
let recoverableCount = 0;
|
|
5498
5539
|
let recoverableValue = 0;
|
|
@@ -5732,7 +5773,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5732
5773
|
}
|
|
5733
5774
|
getBoardingTimelock() {
|
|
5734
5775
|
const wallet = this.getSweepWallet();
|
|
5735
|
-
const exitScript =
|
|
5776
|
+
const exitScript = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.decode(
|
|
5736
5777
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5737
5778
|
);
|
|
5738
5779
|
return exitScript.params.timelock;
|
|
@@ -5840,8 +5881,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5840
5881
|
}
|
|
5841
5882
|
/** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
|
|
5842
5883
|
extractSpentOutpoint(error) {
|
|
5843
|
-
const ark =
|
|
5844
|
-
if (!
|
|
5884
|
+
const ark = chunkKW7ZEWYS_cjs.maybeArkError(error);
|
|
5885
|
+
if (!chunkKW7ZEWYS_cjs.isArkError(ark, chunkKW7ZEWYS_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5845
5886
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5846
5887
|
if (typeof raw !== "string") return void 0;
|
|
5847
5888
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -6015,7 +6056,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6015
6056
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
6016
6057
|
break;
|
|
6017
6058
|
}
|
|
6018
|
-
const inputFee = estimator.evalOffchainInput(
|
|
6059
|
+
const inputFee = estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(v));
|
|
6019
6060
|
if (inputFee.satoshis >= v.value) {
|
|
6020
6061
|
continue;
|
|
6021
6062
|
}
|
|
@@ -6035,7 +6076,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6035
6076
|
const arkAddress = await this.wallet.getAddress();
|
|
6036
6077
|
const outputFee = estimator.evalOffchainOutput({
|
|
6037
6078
|
amount: totalAmount,
|
|
6038
|
-
script: base.hex.encode(
|
|
6079
|
+
script: base.hex.encode(chunkKW7ZEWYS_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
6039
6080
|
});
|
|
6040
6081
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
6041
6082
|
if (totalAmount < dustAmount) return;
|
|
@@ -6119,7 +6160,7 @@ var ArkNote = class _ArkNote {
|
|
|
6119
6160
|
this.value = value;
|
|
6120
6161
|
this.HRP = HRP;
|
|
6121
6162
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
6122
|
-
this.vtxoScript = new
|
|
6163
|
+
this.vtxoScript = new chunkKW7ZEWYS_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
6123
6164
|
const leaf = this.vtxoScript.leaves[0];
|
|
6124
6165
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
6125
6166
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -6292,7 +6333,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6292
6333
|
const privateKey = data.slice(1, 33);
|
|
6293
6334
|
const serverPubKey = data.slice(33, 65);
|
|
6294
6335
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6295
|
-
const csvTimelock2 =
|
|
6336
|
+
const csvTimelock2 = chunkKW7ZEWYS_cjs.sequenceToTimelock(sequence);
|
|
6296
6337
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
|
|
6297
6338
|
}
|
|
6298
6339
|
toString() {
|
|
@@ -6300,7 +6341,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6300
6341
|
data[0] = _ArkadeCash.Version;
|
|
6301
6342
|
data.set(this._privateKey, 1);
|
|
6302
6343
|
data.set(this._serverPubKey, 33);
|
|
6303
|
-
const sequence =
|
|
6344
|
+
const sequence = chunkKW7ZEWYS_cjs.timelockToSequence(this.csvTimelock);
|
|
6304
6345
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
6305
6346
|
const words = base.bech32m.toWords(data);
|
|
6306
6347
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -6309,7 +6350,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6309
6350
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
6310
6351
|
}
|
|
6311
6352
|
get vtxoScript() {
|
|
6312
|
-
return new
|
|
6353
|
+
return new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
6313
6354
|
pubKey: this._publicKey,
|
|
6314
6355
|
serverPubKey: this._serverPubKey,
|
|
6315
6356
|
csvTimelock: this.csvTimelock
|
|
@@ -6325,7 +6366,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
6325
6366
|
(s) => !isTerminalIntentState(s)
|
|
6326
6367
|
);
|
|
6327
6368
|
function isConsumed(vtxo) {
|
|
6328
|
-
return vtxo !== void 0 &&
|
|
6369
|
+
return vtxo !== void 0 && chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo);
|
|
6329
6370
|
}
|
|
6330
6371
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
6331
6372
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -6363,7 +6404,7 @@ async function reconcileIntents(deps) {
|
|
|
6363
6404
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
6364
6405
|
if (outpoints.length > 0) {
|
|
6365
6406
|
try {
|
|
6366
|
-
const { vtxos } = await
|
|
6407
|
+
const { vtxos } = await chunkKW7ZEWYS_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
6367
6408
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
6368
6409
|
} catch (e) {
|
|
6369
6410
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -6423,7 +6464,7 @@ async function releaseFromServer(intent, deps, now) {
|
|
|
6423
6464
|
});
|
|
6424
6465
|
}
|
|
6425
6466
|
function isNoMatchingIntentsError(e) {
|
|
6426
|
-
return
|
|
6467
|
+
return chunkKW7ZEWYS_cjs.isArkError(e, chunkKW7ZEWYS_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
|
|
6427
6468
|
}
|
|
6428
6469
|
function terminal(intent, state, now, patch) {
|
|
6429
6470
|
return { ...intent, ...patch, state, updatedAt: now };
|
|
@@ -6650,7 +6691,7 @@ async function captureExitBranch(params) {
|
|
|
6650
6691
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6651
6692
|
if (nonCommitment.length > 0) {
|
|
6652
6693
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6653
|
-
psbtByTxid.set(
|
|
6694
|
+
psbtByTxid.set(chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6654
6695
|
}
|
|
6655
6696
|
}
|
|
6656
6697
|
}
|
|
@@ -6693,10 +6734,10 @@ var IndexerExitDataSource = class {
|
|
|
6693
6734
|
while (hasMore) {
|
|
6694
6735
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6695
6736
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6696
|
-
{ pageIndex, pageSize:
|
|
6737
|
+
{ pageIndex, pageSize: chunkKW7ZEWYS_cjs.DEFAULT_PAGE_SIZE }
|
|
6697
6738
|
);
|
|
6698
6739
|
chain.push(...page);
|
|
6699
|
-
hasMore = meta ? page.length ===
|
|
6740
|
+
hasMore = meta ? page.length === chunkKW7ZEWYS_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6700
6741
|
pageIndex++;
|
|
6701
6742
|
}
|
|
6702
6743
|
return chain;
|
|
@@ -6708,12 +6749,12 @@ var IndexerExitDataSource = class {
|
|
|
6708
6749
|
while (hasMore) {
|
|
6709
6750
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6710
6751
|
pageIndex,
|
|
6711
|
-
pageSize:
|
|
6752
|
+
pageSize: chunkKW7ZEWYS_cjs.DEFAULT_PAGE_SIZE
|
|
6712
6753
|
});
|
|
6713
6754
|
for (const psbt of txs) {
|
|
6714
|
-
out.set(
|
|
6755
|
+
out.set(chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6715
6756
|
}
|
|
6716
|
-
hasMore = page ? txs.length ===
|
|
6757
|
+
hasMore = page ? txs.length === chunkKW7ZEWYS_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6717
6758
|
pageIndex++;
|
|
6718
6759
|
}
|
|
6719
6760
|
return out;
|
|
@@ -6734,7 +6775,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6734
6775
|
}
|
|
6735
6776
|
}
|
|
6736
6777
|
function psbtInputTxids(psbtBase64) {
|
|
6737
|
-
return txInputTxids(
|
|
6778
|
+
return txInputTxids(chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
|
|
6738
6779
|
}
|
|
6739
6780
|
function txInputTxids(tx) {
|
|
6740
6781
|
const ids = [];
|
|
@@ -7039,10 +7080,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
7039
7080
|
try {
|
|
7040
7081
|
info = await arkProvider.getInfo();
|
|
7041
7082
|
} catch (err) {
|
|
7042
|
-
if (opts?.requireLive || !
|
|
7083
|
+
if (opts?.requireLive || !chunkKW7ZEWYS_cjs.isRetryableProviderError(err)) throw err;
|
|
7043
7084
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
7044
7085
|
if (!snapshot) {
|
|
7045
|
-
throw new
|
|
7086
|
+
throw new chunkKW7ZEWYS_cjs.ProviderUnavailableError(
|
|
7046
7087
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
7047
7088
|
{ cause: err }
|
|
7048
7089
|
);
|
|
@@ -7234,7 +7275,7 @@ function buildGraph(rootTxid, chunksByTxid) {
|
|
|
7234
7275
|
return new TxTree(rootTx, children);
|
|
7235
7276
|
}
|
|
7236
7277
|
function decodeNode(chunk) {
|
|
7237
|
-
const tx =
|
|
7278
|
+
const tx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
|
|
7238
7279
|
return { tx, children: chunk.children };
|
|
7239
7280
|
}
|
|
7240
7281
|
exports.Batch = void 0;
|
|
@@ -7437,7 +7478,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
7437
7478
|
return [...txids];
|
|
7438
7479
|
}
|
|
7439
7480
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
7440
|
-
const normalized = vtxos.map(
|
|
7481
|
+
const normalized = vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7441
7482
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
7442
7483
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
7443
7484
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7615,7 +7656,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7615
7656
|
withRecoverable: false,
|
|
7616
7657
|
genericallySpendableOnly: true
|
|
7617
7658
|
});
|
|
7618
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7659
|
+
const controlAssetRef = params.controlAssetId ? chunkZMSM3NOH_cjs.AssetRef.fromId(chunkZMSM3NOH_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7619
7660
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7620
7661
|
let totalBtcSelected = 0n;
|
|
7621
7662
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7628,8 +7669,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7628
7669
|
}
|
|
7629
7670
|
}
|
|
7630
7671
|
const groups = [];
|
|
7631
|
-
const issuedAssetOutput =
|
|
7632
|
-
const issuedAssetGroup =
|
|
7672
|
+
const issuedAssetOutput = chunkZMSM3NOH_cjs.AssetOutput.create(0, params.amount);
|
|
7673
|
+
const issuedAssetGroup = chunkZMSM3NOH_cjs.AssetGroup.create(
|
|
7633
7674
|
null,
|
|
7634
7675
|
controlAssetRef,
|
|
7635
7676
|
[],
|
|
@@ -7642,11 +7683,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7642
7683
|
for (const [assetId, amount] of assetChanges) {
|
|
7643
7684
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7644
7685
|
groups.push(
|
|
7645
|
-
|
|
7646
|
-
|
|
7686
|
+
chunkZMSM3NOH_cjs.AssetGroup.create(
|
|
7687
|
+
chunkZMSM3NOH_cjs.AssetId.fromString(assetId),
|
|
7647
7688
|
null,
|
|
7648
7689
|
changeInputs,
|
|
7649
|
-
[
|
|
7690
|
+
[chunkZMSM3NOH_cjs.AssetOutput.create(0, amount)],
|
|
7650
7691
|
[]
|
|
7651
7692
|
)
|
|
7652
7693
|
);
|
|
@@ -7661,7 +7702,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7661
7702
|
);
|
|
7662
7703
|
return {
|
|
7663
7704
|
arkTxId: arkTxid,
|
|
7664
|
-
assetId:
|
|
7705
|
+
assetId: chunkZMSM3NOH_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7665
7706
|
};
|
|
7666
7707
|
}
|
|
7667
7708
|
/**
|
|
@@ -7735,23 +7776,23 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7735
7776
|
const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
|
|
7736
7777
|
const reissueInputs = inputsForAsset(assetInputs, params.assetId);
|
|
7737
7778
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7738
|
-
const reissueAssetIdObj =
|
|
7739
|
-
const reissueAssetGroup =
|
|
7779
|
+
const reissueAssetIdObj = chunkZMSM3NOH_cjs.AssetId.fromString(params.assetId);
|
|
7780
|
+
const reissueAssetGroup = chunkZMSM3NOH_cjs.AssetGroup.create(
|
|
7740
7781
|
reissueAssetIdObj,
|
|
7741
7782
|
null,
|
|
7742
7783
|
reissueInputs,
|
|
7743
|
-
[
|
|
7784
|
+
[chunkZMSM3NOH_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7744
7785
|
[]
|
|
7745
7786
|
);
|
|
7746
7787
|
const groups = [reissueAssetGroup];
|
|
7747
7788
|
for (const [assetId, amount] of assetChanges) {
|
|
7748
7789
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7749
7790
|
groups.push(
|
|
7750
|
-
|
|
7751
|
-
|
|
7791
|
+
chunkZMSM3NOH_cjs.AssetGroup.create(
|
|
7792
|
+
chunkZMSM3NOH_cjs.AssetId.fromString(assetId),
|
|
7752
7793
|
null,
|
|
7753
7794
|
changeInputs,
|
|
7754
|
-
[
|
|
7795
|
+
[chunkZMSM3NOH_cjs.AssetOutput.create(0, amount)],
|
|
7755
7796
|
[]
|
|
7756
7797
|
)
|
|
7757
7798
|
);
|
|
@@ -7822,11 +7863,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7822
7863
|
for (const [assetId, amount] of assetChanges) {
|
|
7823
7864
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7824
7865
|
groups.push(
|
|
7825
|
-
|
|
7826
|
-
|
|
7866
|
+
chunkZMSM3NOH_cjs.AssetGroup.create(
|
|
7867
|
+
chunkZMSM3NOH_cjs.AssetId.fromString(assetId),
|
|
7827
7868
|
null,
|
|
7828
7869
|
changeInputs,
|
|
7829
|
-
amount > 0n ? [
|
|
7870
|
+
amount > 0n ? [chunkZMSM3NOH_cjs.AssetOutput.create(0, amount)] : [],
|
|
7830
7871
|
[]
|
|
7831
7872
|
)
|
|
7832
7873
|
);
|
|
@@ -7839,16 +7880,16 @@ function inputsForAsset(assetInputs, assetId) {
|
|
|
7839
7880
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7840
7881
|
for (const asset of assets) {
|
|
7841
7882
|
if (asset.assetId !== assetId) continue;
|
|
7842
|
-
inputs.push(
|
|
7883
|
+
inputs.push(chunkZMSM3NOH_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7843
7884
|
}
|
|
7844
7885
|
}
|
|
7845
7886
|
return inputs;
|
|
7846
7887
|
}
|
|
7847
7888
|
async function submitToSelf(submit, wallet, inputs, amount, groups) {
|
|
7848
|
-
const outputAddress =
|
|
7889
|
+
const outputAddress = chunkKW7ZEWYS_cjs.ArkAddress.decode(await wallet.getAddress());
|
|
7849
7890
|
const outputs = [
|
|
7850
7891
|
{ script: outputAddress.pkScript, amount: BigInt(amount) },
|
|
7851
|
-
Extension.create([
|
|
7892
|
+
Extension.create([chunkZMSM3NOH_cjs.Packet.create(groups)]).txOut()
|
|
7852
7893
|
];
|
|
7853
7894
|
const { arkTxid } = await submit(inputs, outputs);
|
|
7854
7895
|
return arkTxid;
|
|
@@ -7872,7 +7913,7 @@ function castMetadata(metadata) {
|
|
|
7872
7913
|
} else {
|
|
7873
7914
|
throw new Error("Invalid metadata value type");
|
|
7874
7915
|
}
|
|
7875
|
-
md.push(
|
|
7916
|
+
md.push(chunkZMSM3NOH_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7876
7917
|
}
|
|
7877
7918
|
return md;
|
|
7878
7919
|
}
|
|
@@ -7893,12 +7934,12 @@ var DelegateManagerImpl = class {
|
|
|
7893
7934
|
if (vtxos.length === 0) {
|
|
7894
7935
|
return { delegated: [], failed: [] };
|
|
7895
7936
|
}
|
|
7896
|
-
const destinationScript =
|
|
7937
|
+
const destinationScript = chunkKW7ZEWYS_cjs.ArkAddress.decode(destination).pkScript;
|
|
7897
7938
|
const [arkInfo, delegateInfo] = await Promise.all([
|
|
7898
7939
|
this.arkInfoProvider.getInfo(),
|
|
7899
7940
|
this.delegateProvider.getDelegateInfo()
|
|
7900
7941
|
]);
|
|
7901
|
-
const eligible = vtxos.map(
|
|
7942
|
+
const eligible = vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo).filter(
|
|
7902
7943
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7903
7944
|
);
|
|
7904
7945
|
if (eligible.length === 0) {
|
|
@@ -7930,7 +7971,7 @@ var DelegateManagerImpl = class {
|
|
|
7930
7971
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7931
7972
|
let recoverableVtxos = [];
|
|
7932
7973
|
for (const vtxo of eligible) {
|
|
7933
|
-
if (
|
|
7974
|
+
if (chunkKW7ZEWYS_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7934
7975
|
recoverableVtxos.push(vtxo);
|
|
7935
7976
|
continue;
|
|
7936
7977
|
}
|
|
@@ -7982,7 +8023,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7982
8023
|
}
|
|
7983
8024
|
if (!delegateAt) {
|
|
7984
8025
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7985
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
8026
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkKW7ZEWYS_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
7986
8027
|
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
7987
8028
|
Number.MAX_SAFE_INTEGER
|
|
7988
8029
|
);
|
|
@@ -8002,7 +8043,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8002
8043
|
let amount = 0n;
|
|
8003
8044
|
for (const coin of vtxos) {
|
|
8004
8045
|
const inputFee = estimator.evalOffchainInput({
|
|
8005
|
-
...
|
|
8046
|
+
...chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(coin),
|
|
8006
8047
|
type: "vtxo"
|
|
8007
8048
|
});
|
|
8008
8049
|
if (inputFee.satoshis >= coin.value) {
|
|
@@ -8016,7 +8057,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8016
8057
|
const delegateFee = BigInt(Number(fee));
|
|
8017
8058
|
if (delegateFee > 0n) {
|
|
8018
8059
|
outputs.push({
|
|
8019
|
-
script:
|
|
8060
|
+
script: chunkKW7ZEWYS_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
8020
8061
|
amount: delegateFee
|
|
8021
8062
|
});
|
|
8022
8063
|
}
|
|
@@ -8049,10 +8090,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8049
8090
|
destinationScript
|
|
8050
8091
|
);
|
|
8051
8092
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
8052
|
-
btcSigner.Address(
|
|
8093
|
+
btcSigner.Address(chunkKW7ZEWYS_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
8053
8094
|
);
|
|
8054
8095
|
const forfeits = await Promise.all(
|
|
8055
|
-
vtxos.filter((v) =>
|
|
8096
|
+
vtxos.filter((v) => chunkKW7ZEWYS_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
8056
8097
|
const forfeit = await makeDelegateForfeitTx(
|
|
8057
8098
|
coin,
|
|
8058
8099
|
dust,
|
|
@@ -8077,7 +8118,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
8077
8118
|
index: input.vout,
|
|
8078
8119
|
witnessUtxo: {
|
|
8079
8120
|
amount: BigInt(input.value),
|
|
8080
|
-
script:
|
|
8121
|
+
script: chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
8081
8122
|
},
|
|
8082
8123
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
8083
8124
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -8135,7 +8176,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
8135
8176
|
expire_at: 0,
|
|
8136
8177
|
cosigners_public_keys: cosignerPubKeys
|
|
8137
8178
|
};
|
|
8138
|
-
const proof =
|
|
8179
|
+
const proof = chunkKW7ZEWYS_cjs.Intent.create(message, coins, outputs);
|
|
8139
8180
|
const signedProof = await identity.sign(proof);
|
|
8140
8181
|
return {
|
|
8141
8182
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -8153,10 +8194,10 @@ function getDayTimestamp(timestamp) {
|
|
|
8153
8194
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
8154
8195
|
if (!vtxo.tapTree) return void 0;
|
|
8155
8196
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
8156
|
-
const vtxoScript =
|
|
8197
|
+
const vtxoScript = chunkKW7ZEWYS_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
8157
8198
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
8158
|
-
const arkTapscript =
|
|
8159
|
-
if (!
|
|
8199
|
+
const arkTapscript = chunkKW7ZEWYS_cjs.decodeTapscript(chunkKW7ZEWYS_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
8200
|
+
if (!chunkKW7ZEWYS_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
8160
8201
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
8161
8202
|
});
|
|
8162
8203
|
}
|
|
@@ -8720,8 +8761,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
|
|
|
8720
8761
|
}
|
|
8721
8762
|
async function getVtxosForContract(repo, contract, options) {
|
|
8722
8763
|
const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
|
|
8723
|
-
const normalized = vtxos.map(
|
|
8724
|
-
return options?.unspentOnly ? normalized.filter((vtxo) => !
|
|
8764
|
+
const normalized = vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
8765
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
8725
8766
|
}
|
|
8726
8767
|
async function hasVtxosForContract(repo, contract) {
|
|
8727
8768
|
if (repo.getVtxosForScriptPage) {
|
|
@@ -8952,7 +8993,7 @@ function decodeArkContract(encoded) {
|
|
|
8952
8993
|
}
|
|
8953
8994
|
function contractFromArkContract(encoded, options = {}) {
|
|
8954
8995
|
const parsed = decodeArkContract(encoded);
|
|
8955
|
-
const handler =
|
|
8996
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(parsed.type);
|
|
8956
8997
|
if (!handler) {
|
|
8957
8998
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8958
8999
|
}
|
|
@@ -8966,9 +9007,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8966
9007
|
metadata: options.metadata
|
|
8967
9008
|
};
|
|
8968
9009
|
}
|
|
8969
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
9010
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkKW7ZEWYS_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8970
9011
|
const parsed = decodeArkContract(encoded);
|
|
8971
|
-
const handler =
|
|
9012
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8972
9013
|
const params = parsed.data;
|
|
8973
9014
|
const vtxoScript = handler.createScript(params);
|
|
8974
9015
|
return {
|
|
@@ -9025,10 +9066,10 @@ var ContractWatcher = class {
|
|
|
9025
9066
|
eventSourceReported = false;
|
|
9026
9067
|
/** @see ContractWatcherConfig */
|
|
9027
9068
|
constructor(config) {
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9069
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
|
|
9070
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
|
|
9071
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
|
|
9072
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
|
|
9032
9073
|
if (config.subscriptionRequestTimeoutMs === 0) {
|
|
9033
9074
|
throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
|
|
9034
9075
|
}
|
|
@@ -9251,9 +9292,9 @@ var ContractWatcher = class {
|
|
|
9251
9292
|
this.reconnectAttempts = 0;
|
|
9252
9293
|
this.listenLoop().catch((e) => {
|
|
9253
9294
|
if (!this.isWatching || signal?.aborted) return;
|
|
9254
|
-
if (
|
|
9295
|
+
if (chunkKW7ZEWYS_cjs.isEventSourceError(e)) {
|
|
9255
9296
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
9256
|
-
} else if (!
|
|
9297
|
+
} else if (!chunkKW7ZEWYS_cjs.isEventSourceUnavailableError(e)) {
|
|
9257
9298
|
console.error(e);
|
|
9258
9299
|
}
|
|
9259
9300
|
this.connectionState = "disconnected";
|
|
@@ -9263,7 +9304,7 @@ var ContractWatcher = class {
|
|
|
9263
9304
|
});
|
|
9264
9305
|
} catch (error) {
|
|
9265
9306
|
if (!this.isWatching || signal?.aborted) return;
|
|
9266
|
-
if (!
|
|
9307
|
+
if (!chunkKW7ZEWYS_cjs.isEventSourceUnavailableError(error)) {
|
|
9267
9308
|
console.error("ContractWatcher connection failed:", error);
|
|
9268
9309
|
}
|
|
9269
9310
|
this.connectionState = "disconnected";
|
|
@@ -9279,7 +9320,7 @@ var ContractWatcher = class {
|
|
|
9279
9320
|
* few seconds.
|
|
9280
9321
|
*/
|
|
9281
9322
|
reportEventSourceUnavailable(error) {
|
|
9282
|
-
if (!
|
|
9323
|
+
if (!chunkKW7ZEWYS_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9283
9324
|
if (!this.eventSourceReported) {
|
|
9284
9325
|
this.eventSourceReported = true;
|
|
9285
9326
|
console.warn(
|
|
@@ -9344,7 +9385,7 @@ var ContractWatcher = class {
|
|
|
9344
9385
|
const now = Date.now();
|
|
9345
9386
|
let current;
|
|
9346
9387
|
try {
|
|
9347
|
-
current = await
|
|
9388
|
+
current = await chunkKW7ZEWYS_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9348
9389
|
spendableOnly: true
|
|
9349
9390
|
});
|
|
9350
9391
|
} catch (error) {
|
|
@@ -9626,14 +9667,14 @@ var ContractWatcher = class {
|
|
|
9626
9667
|
const timestamp = Date.now();
|
|
9627
9668
|
if (update.newVtxos?.length) {
|
|
9628
9669
|
this.processSubscriptionVtxos(
|
|
9629
|
-
update.newVtxos.map(
|
|
9670
|
+
update.newVtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo),
|
|
9630
9671
|
"vtxo_received",
|
|
9631
9672
|
timestamp
|
|
9632
9673
|
);
|
|
9633
9674
|
}
|
|
9634
9675
|
if (update.spentVtxos?.length) {
|
|
9635
9676
|
this.processSubscriptionVtxos(
|
|
9636
|
-
update.spentVtxos.map(
|
|
9677
|
+
update.spentVtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo),
|
|
9637
9678
|
"vtxo_spent",
|
|
9638
9679
|
timestamp
|
|
9639
9680
|
);
|
|
@@ -9658,8 +9699,8 @@ var ContractWatcher = class {
|
|
|
9658
9699
|
continue;
|
|
9659
9700
|
}
|
|
9660
9701
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9661
|
-
const n =
|
|
9662
|
-
if (
|
|
9702
|
+
const n = chunkKW7ZEWYS_cjs.normalizeVtxo(vtxo);
|
|
9703
|
+
if (chunkKW7ZEWYS_cjs.isVtxoSpent(n) || n.isSwept || chunkKW7ZEWYS_cjs.isPastExpiry(n, now)) continue;
|
|
9663
9704
|
}
|
|
9664
9705
|
let bucket = target.get(vtxo.script);
|
|
9665
9706
|
if (!bucket) {
|
|
@@ -9800,7 +9841,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9800
9841
|
if (!contract) continue;
|
|
9801
9842
|
try {
|
|
9802
9843
|
const key = contractKey(contract);
|
|
9803
|
-
const handler =
|
|
9844
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
9804
9845
|
const hit = memo?.get(script);
|
|
9805
9846
|
let tapscripts;
|
|
9806
9847
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -9821,7 +9862,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9821
9862
|
scripts.add(script);
|
|
9822
9863
|
} catch (err) {
|
|
9823
9864
|
const reason = `'${contract.type}' at ${script}: ${err instanceof Error ? err.message : String(err)}`;
|
|
9824
|
-
if (err instanceof
|
|
9865
|
+
if (err instanceof chunkBYPBVHVA_cjs.UnsupportedProgramVersionError) {
|
|
9825
9866
|
unsupported.set(script, { key: contractKey(contract), reason });
|
|
9826
9867
|
} else {
|
|
9827
9868
|
failures.set(script, reason);
|
|
@@ -9832,7 +9873,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9832
9873
|
}
|
|
9833
9874
|
function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
|
|
9834
9875
|
return vtxos.map(
|
|
9835
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9876
|
+
(vtxo) => extendVirtualCoinForContract(chunkKW7ZEWYS_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
|
|
9836
9877
|
);
|
|
9837
9878
|
}
|
|
9838
9879
|
var SCAN_MAX_INDEX = 1e4;
|
|
@@ -9876,8 +9917,8 @@ var ContractManager = class _ContractManager {
|
|
|
9876
9917
|
* `dispose()`, so it re-checks this at every await rather than run on a torn-down watcher. */
|
|
9877
9918
|
disposed = false;
|
|
9878
9919
|
constructor(config) {
|
|
9879
|
-
|
|
9880
|
-
|
|
9920
|
+
chunkKW7ZEWYS_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
|
|
9921
|
+
chunkKW7ZEWYS_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
|
|
9881
9922
|
this.config = { ...config };
|
|
9882
9923
|
this.watcher = new ContractWatcher({
|
|
9883
9924
|
indexerProvider: config.indexerProvider,
|
|
@@ -9913,12 +9954,12 @@ var ContractManager = class _ContractManager {
|
|
|
9913
9954
|
}
|
|
9914
9955
|
/** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
|
|
9915
9956
|
setVtxoSyncMaxAge(maxAgeMs) {
|
|
9916
|
-
|
|
9957
|
+
chunkKW7ZEWYS_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
|
|
9917
9958
|
this.config.vtxoSyncMaxAgeMs = maxAgeMs;
|
|
9918
9959
|
}
|
|
9919
9960
|
/** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
|
|
9920
9961
|
setVtxoSyncOverlap(overlapMs) {
|
|
9921
|
-
|
|
9962
|
+
chunkKW7ZEWYS_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
|
|
9922
9963
|
this.config.vtxoSyncOverlapMs = overlapMs;
|
|
9923
9964
|
}
|
|
9924
9965
|
markSyncOnline() {
|
|
@@ -9982,10 +10023,10 @@ var ContractManager = class _ContractManager {
|
|
|
9982
10023
|
if (this.unsupportedContracts.get(contract.script) === key) return true;
|
|
9983
10024
|
if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
|
|
9984
10025
|
try {
|
|
9985
|
-
|
|
10026
|
+
chunkBYPBVHVA_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
|
|
9986
10027
|
return false;
|
|
9987
10028
|
} catch (err) {
|
|
9988
|
-
if (!(err instanceof
|
|
10029
|
+
if (!(err instanceof chunkBYPBVHVA_cjs.UnsupportedProgramVersionError)) return false;
|
|
9989
10030
|
this.unsupportedContracts.set(contract.script, key);
|
|
9990
10031
|
return true;
|
|
9991
10032
|
}
|
|
@@ -9998,7 +10039,7 @@ var ContractManager = class _ContractManager {
|
|
|
9998
10039
|
this.markSyncOnline();
|
|
9999
10040
|
return void 0;
|
|
10000
10041
|
} catch (err) {
|
|
10001
|
-
if (!
|
|
10042
|
+
if (!chunkKW7ZEWYS_cjs.isRetryableProviderError(err)) throw err;
|
|
10002
10043
|
this.markSyncDegraded(err);
|
|
10003
10044
|
return err;
|
|
10004
10045
|
}
|
|
@@ -10021,7 +10062,7 @@ var ContractManager = class _ContractManager {
|
|
|
10021
10062
|
try {
|
|
10022
10063
|
await this.scheduleLookAheadDrain();
|
|
10023
10064
|
} catch (err) {
|
|
10024
|
-
if (!
|
|
10065
|
+
if (!chunkKW7ZEWYS_cjs.isRetryableProviderError(err)) throw err;
|
|
10025
10066
|
this.lookAheadRefillOwed = true;
|
|
10026
10067
|
this.markSyncDegraded(err);
|
|
10027
10068
|
}
|
|
@@ -10084,7 +10125,7 @@ var ContractManager = class _ContractManager {
|
|
|
10084
10125
|
/** No throw: construction returned long ago, so the state is the channel. */
|
|
10085
10126
|
reportBackgroundFailure(stage, err) {
|
|
10086
10127
|
this.markSyncDegraded(err);
|
|
10087
|
-
if (!
|
|
10128
|
+
if (!chunkKW7ZEWYS_cjs.isRetryableProviderError(err)) {
|
|
10088
10129
|
console.error(`[contracts] background ${stage} failed`, err);
|
|
10089
10130
|
}
|
|
10090
10131
|
}
|
|
@@ -10186,7 +10227,7 @@ var ContractManager = class _ContractManager {
|
|
|
10186
10227
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10187
10228
|
const to = watermark + lookAhead.size;
|
|
10188
10229
|
const deps = lookAhead.candidateDeps();
|
|
10189
|
-
const handlers =
|
|
10230
|
+
const handlers = chunkBYPBVHVA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkBYPBVHVA_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10190
10231
|
const band = /* @__PURE__ */ new Map();
|
|
10191
10232
|
for (let index = from; index <= to; index++) {
|
|
10192
10233
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -10197,7 +10238,7 @@ var ContractManager = class _ContractManager {
|
|
|
10197
10238
|
index,
|
|
10198
10239
|
params: {
|
|
10199
10240
|
...candidate,
|
|
10200
|
-
...
|
|
10241
|
+
...chunkBYPBVHVA_cjs.speculativeReceiveMetadata(descriptor)
|
|
10201
10242
|
}
|
|
10202
10243
|
});
|
|
10203
10244
|
}
|
|
@@ -10256,7 +10297,7 @@ var ContractManager = class _ContractManager {
|
|
|
10256
10297
|
});
|
|
10257
10298
|
for (const entry of pending) entry.catchUpPending = false;
|
|
10258
10299
|
} catch (err) {
|
|
10259
|
-
if (!
|
|
10300
|
+
if (!chunkKW7ZEWYS_cjs.isRetryableProviderError(err)) throw err;
|
|
10260
10301
|
this.markSyncDegraded(err);
|
|
10261
10302
|
}
|
|
10262
10303
|
}
|
|
@@ -10347,7 +10388,7 @@ var ContractManager = class _ContractManager {
|
|
|
10347
10388
|
return result;
|
|
10348
10389
|
}
|
|
10349
10390
|
async upsertContractRow(params) {
|
|
10350
|
-
const handler =
|
|
10391
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(params.type);
|
|
10351
10392
|
if (!handler) {
|
|
10352
10393
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
10353
10394
|
}
|
|
@@ -10446,7 +10487,7 @@ var ContractManager = class _ContractManager {
|
|
|
10446
10487
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10447
10488
|
);
|
|
10448
10489
|
}
|
|
10449
|
-
const registered =
|
|
10490
|
+
const registered = chunkBYPBVHVA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkBYPBVHVA_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10450
10491
|
const discoverables = [
|
|
10451
10492
|
...registered.filter((h) => h.type === "boarding"),
|
|
10452
10493
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10577,7 +10618,7 @@ var ContractManager = class _ContractManager {
|
|
|
10577
10618
|
return contracts.filter((contract) => this.isUnsupported(contract));
|
|
10578
10619
|
}
|
|
10579
10620
|
async getContractsWithVtxos(filter, pageSize, options) {
|
|
10580
|
-
|
|
10621
|
+
chunkKW7ZEWYS_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
|
|
10581
10622
|
const contracts = await this.getContracts(filter);
|
|
10582
10623
|
if (this.syncedWithin(
|
|
10583
10624
|
contracts,
|
|
@@ -10685,7 +10726,7 @@ var ContractManager = class _ContractManager {
|
|
|
10685
10726
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10686
10727
|
const asking = vtxos.filter((vtxo) => {
|
|
10687
10728
|
const contract = byScript.get(vtxo.script);
|
|
10688
|
-
return contract !== void 0 &&
|
|
10729
|
+
return contract !== void 0 && chunkBYPBVHVA_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10689
10730
|
});
|
|
10690
10731
|
if (asking.length === 0) return refused;
|
|
10691
10732
|
const [tip, walletDescriptorValue] = await Promise.all([
|
|
@@ -10694,7 +10735,7 @@ var ContractManager = class _ContractManager {
|
|
|
10694
10735
|
]);
|
|
10695
10736
|
for (const vtxo of asking) {
|
|
10696
10737
|
const contract = byScript.get(vtxo.script);
|
|
10697
|
-
const handler =
|
|
10738
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
10698
10739
|
if (!handler?.assertSpendableNow) continue;
|
|
10699
10740
|
const context = {
|
|
10700
10741
|
collaborative: true,
|
|
@@ -10704,7 +10745,7 @@ var ContractManager = class _ContractManager {
|
|
|
10704
10745
|
walletDescriptor: walletDescriptorValue,
|
|
10705
10746
|
// `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
|
|
10706
10747
|
// reads `vtxo.status.block_time` unguarded, so require `status` too.
|
|
10707
|
-
vtxo:
|
|
10748
|
+
vtxo: chunkKW7ZEWYS_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10708
10749
|
};
|
|
10709
10750
|
try {
|
|
10710
10751
|
await handler.assertSpendableNow(
|
|
@@ -10817,7 +10858,7 @@ var ContractManager = class _ContractManager {
|
|
|
10817
10858
|
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
10818
10859
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10819
10860
|
if (!contract) return [];
|
|
10820
|
-
const handler =
|
|
10861
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
10821
10862
|
if (!handler) return [];
|
|
10822
10863
|
const script = handler.createScript(contract.params);
|
|
10823
10864
|
const tip = await this.currentChainTip();
|
|
@@ -10839,7 +10880,7 @@ var ContractManager = class _ContractManager {
|
|
|
10839
10880
|
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
10840
10881
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10841
10882
|
if (!contract) return [];
|
|
10842
|
-
const handler =
|
|
10883
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
10843
10884
|
if (!handler) return [];
|
|
10844
10885
|
const script = handler.createScript(contract.params);
|
|
10845
10886
|
const context = {
|
|
@@ -10885,7 +10926,7 @@ var ContractManager = class _ContractManager {
|
|
|
10885
10926
|
}
|
|
10886
10927
|
async refreshOutpoints(outpoints) {
|
|
10887
10928
|
if (outpoints.length === 0) return;
|
|
10888
|
-
const { vtxos } = await
|
|
10929
|
+
const { vtxos } = await chunkKW7ZEWYS_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10889
10930
|
outpoints
|
|
10890
10931
|
});
|
|
10891
10932
|
if (vtxos.length === 0) return;
|
|
@@ -10987,7 +11028,7 @@ var ContractManager = class _ContractManager {
|
|
|
10987
11028
|
break;
|
|
10988
11029
|
}
|
|
10989
11030
|
} catch (err) {
|
|
10990
|
-
if (!
|
|
11031
|
+
if (!chunkKW7ZEWYS_cjs.isRetryableProviderError(err)) throw err;
|
|
10991
11032
|
this.markSyncDegraded(err);
|
|
10992
11033
|
synced = false;
|
|
10993
11034
|
}
|
|
@@ -11075,7 +11116,7 @@ var ContractManager = class _ContractManager {
|
|
|
11075
11116
|
*/
|
|
11076
11117
|
async reconcilePendingFrontier(contracts) {
|
|
11077
11118
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
11078
|
-
const vtxos = await
|
|
11119
|
+
const vtxos = await chunkKW7ZEWYS_cjs.getAllNormalizedVtxos(
|
|
11079
11120
|
this.config.indexerProvider,
|
|
11080
11121
|
contracts.map((c) => c.script),
|
|
11081
11122
|
{ pendingOnly: true }
|
|
@@ -11150,7 +11191,7 @@ var ContractManager = class _ContractManager {
|
|
|
11150
11191
|
}
|
|
11151
11192
|
return result;
|
|
11152
11193
|
}
|
|
11153
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
11194
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkKW7ZEWYS_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
11154
11195
|
if (contracts.length === 0) {
|
|
11155
11196
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
11156
11197
|
}
|
|
@@ -11166,7 +11207,7 @@ var ContractManager = class _ContractManager {
|
|
|
11166
11207
|
before: syncWindow.before
|
|
11167
11208
|
}
|
|
11168
11209
|
} : {};
|
|
11169
|
-
const vtxos = await
|
|
11210
|
+
const vtxos = await chunkKW7ZEWYS_cjs.getAllNormalizedVtxos(
|
|
11170
11211
|
this.config.indexerProvider,
|
|
11171
11212
|
contracts.map((c) => c.script),
|
|
11172
11213
|
{ ...windowOpts, pageSize }
|
|
@@ -11269,7 +11310,7 @@ function parseLegacyExpiry(batchExpiry) {
|
|
|
11269
11310
|
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
11270
11311
|
return {};
|
|
11271
11312
|
}
|
|
11272
|
-
if (batchExpiry >=
|
|
11313
|
+
if (batchExpiry >= chunkKW7ZEWYS_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
11273
11314
|
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
11274
11315
|
}
|
|
11275
11316
|
function legacyVtxoFacts(status) {
|
|
@@ -11507,7 +11548,7 @@ function backfillContractWatchState(store) {
|
|
|
11507
11548
|
};
|
|
11508
11549
|
readPage();
|
|
11509
11550
|
}
|
|
11510
|
-
var unspentFlag = (vtxo) =>
|
|
11551
|
+
var unspentFlag = (vtxo) => chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
11511
11552
|
function backfillVtxoIndexFields(transaction) {
|
|
11512
11553
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
11513
11554
|
const pageSize = 1e3;
|
|
@@ -11538,7 +11579,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
|
|
|
11538
11579
|
var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
|
|
11539
11580
|
function normalizeOptions2(pathOrOptions) {
|
|
11540
11581
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
11541
|
-
|
|
11582
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
11542
11583
|
return {
|
|
11543
11584
|
path: o.path,
|
|
11544
11585
|
activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
|
|
@@ -11759,7 +11800,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
11759
11800
|
const s = base.hex.decode(t.s);
|
|
11760
11801
|
return [cb, s];
|
|
11761
11802
|
};
|
|
11762
|
-
var deserializeVtxo = (o) =>
|
|
11803
|
+
var deserializeVtxo = (o) => chunkKW7ZEWYS_cjs.normalizeVtxo({
|
|
11763
11804
|
...o,
|
|
11764
11805
|
createdAt: new Date(o.createdAt),
|
|
11765
11806
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -12114,7 +12155,7 @@ var RestEmulatorProvider = class {
|
|
|
12114
12155
|
serverUrl;
|
|
12115
12156
|
async getInfo() {
|
|
12116
12157
|
const url = `${this.serverUrl}/v1/info`;
|
|
12117
|
-
const response = await
|
|
12158
|
+
const response = await chunkKW7ZEWYS_cjs.baseFetch(url);
|
|
12118
12159
|
if (!response.ok) {
|
|
12119
12160
|
const errorText2 = await response.text();
|
|
12120
12161
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -12234,11 +12275,11 @@ var RestEmulatorProvider = class {
|
|
|
12234
12275
|
|
|
12235
12276
|
// src/arkade/service.ts
|
|
12236
12277
|
function arkadeServiceUrl(service) {
|
|
12237
|
-
return "operatorUrl" in service ? service.operatorUrl :
|
|
12278
|
+
return "operatorUrl" in service ? service.operatorUrl : chunkKW7ZEWYS_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12238
12279
|
}
|
|
12239
12280
|
async function resolveArkadeService(service, opts = {}) {
|
|
12240
12281
|
const operatorUrl = arkadeServiceUrl(service);
|
|
12241
|
-
const arkProvider = opts.arkProvider ?? new
|
|
12282
|
+
const arkProvider = opts.arkProvider ?? new chunkKW7ZEWYS_cjs.RestArkProvider(operatorUrl);
|
|
12242
12283
|
const info = opts.info ?? await arkProvider.getInfo();
|
|
12243
12284
|
if ("network" in service && service.network !== info.network) {
|
|
12244
12285
|
throw new Error(
|
|
@@ -12251,13 +12292,13 @@ async function resolveArkadeService(service, opts = {}) {
|
|
|
12251
12292
|
}
|
|
12252
12293
|
let emulator;
|
|
12253
12294
|
if ("network" in service) {
|
|
12254
|
-
emulator = new RestEmulatorProvider(
|
|
12295
|
+
emulator = new RestEmulatorProvider(chunkKW7ZEWYS_cjs.DEFAULT_ARKADE_EMULATOR_URL);
|
|
12255
12296
|
} else if (service.emulatorUrl) {
|
|
12256
12297
|
emulator = new RestEmulatorProvider(service.emulatorUrl);
|
|
12257
12298
|
}
|
|
12258
12299
|
return {
|
|
12259
12300
|
arkProvider,
|
|
12260
|
-
indexerProvider: new
|
|
12301
|
+
indexerProvider: new chunkZMSM3NOH_cjs.RestIndexerProvider(operatorUrl),
|
|
12261
12302
|
onchainProvider: new EsploraProvider(esploraUrl),
|
|
12262
12303
|
emulator,
|
|
12263
12304
|
info
|
|
@@ -12341,7 +12382,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
12341
12382
|
*/
|
|
12342
12383
|
materializeDescriptorAt(index) {
|
|
12343
12384
|
const descriptor = this.identity.descriptor;
|
|
12344
|
-
const network =
|
|
12385
|
+
const network = chunkBYPBVHVA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
12345
12386
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
12346
12387
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
12347
12388
|
if (!keyInfo?.keyExpression) {
|
|
@@ -12409,7 +12450,7 @@ function signingDescriptorIndex(descriptor) {
|
|
|
12409
12450
|
}
|
|
12410
12451
|
function newestWalletReceiveContract(contracts, serverPubKeyHex) {
|
|
12411
12452
|
return contracts.filter(
|
|
12412
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12453
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkBYPBVHVA_cjs.WALLET_RECEIVE_SOURCE
|
|
12413
12454
|
).sort((a, b) => {
|
|
12414
12455
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12415
12456
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12460,7 +12501,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12460
12501
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
12461
12502
|
if (!provider) return void 0;
|
|
12462
12503
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
12463
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
12504
|
+
const expectedContractType = setup.offchainTapscript instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
12464
12505
|
const factoryOpts = {
|
|
12465
12506
|
walletRepository: setup.walletRepository,
|
|
12466
12507
|
contractRepository: setup.contractRepository,
|
|
@@ -12620,7 +12661,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12620
12661
|
};
|
|
12621
12662
|
function deriveLeafPubkey(descriptor) {
|
|
12622
12663
|
try {
|
|
12623
|
-
return
|
|
12664
|
+
return chunkBYPBVHVA_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12624
12665
|
} catch (e) {
|
|
12625
12666
|
throw new NonRangeableDescriptorError(
|
|
12626
12667
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -12632,7 +12673,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12632
12673
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
12633
12674
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
12634
12675
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
12635
|
-
const csvTimelock2 =
|
|
12676
|
+
const csvTimelock2 = chunkKW7ZEWYS_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
12636
12677
|
const base$1 = {
|
|
12637
12678
|
script: base.hex.encode(tapscript.pkScript),
|
|
12638
12679
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -12640,11 +12681,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12640
12681
|
// Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
|
|
12641
12682
|
// it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
12642
12683
|
metadata: {
|
|
12643
|
-
...tagSource && { source:
|
|
12684
|
+
...tagSource && { source: chunkBYPBVHVA_cjs.WALLET_RECEIVE_SOURCE },
|
|
12644
12685
|
signingDescriptor: descriptor
|
|
12645
12686
|
}
|
|
12646
12687
|
};
|
|
12647
|
-
const params = tapscript instanceof
|
|
12688
|
+
const params = tapscript instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script ? {
|
|
12648
12689
|
...base$1,
|
|
12649
12690
|
type: "delegate",
|
|
12650
12691
|
params: {
|
|
@@ -12665,10 +12706,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12665
12706
|
return { tapscript, params };
|
|
12666
12707
|
}
|
|
12667
12708
|
function rebuildTapscript(current, pubKey) {
|
|
12668
|
-
if (current instanceof
|
|
12669
|
-
return new
|
|
12709
|
+
if (current instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script) {
|
|
12710
|
+
return new chunkBYPBVHVA_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12670
12711
|
}
|
|
12671
|
-
return new
|
|
12712
|
+
return new chunkBYPBVHVA_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12672
12713
|
}
|
|
12673
12714
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12674
12715
|
const candidates = await collectContracts(contractRepository, {
|
|
@@ -12727,7 +12768,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12727
12768
|
}
|
|
12728
12769
|
};
|
|
12729
12770
|
for (const vtxo of vtxos) {
|
|
12730
|
-
if (
|
|
12771
|
+
if (chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo)) continue;
|
|
12731
12772
|
addAssets(owned, vtxo);
|
|
12732
12773
|
if (vtxo.isUnrolled) {
|
|
12733
12774
|
unrolled += vtxo.value;
|
|
@@ -12737,11 +12778,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12737
12778
|
deprecatedSignerLocked += vtxo.value;
|
|
12738
12779
|
continue;
|
|
12739
12780
|
}
|
|
12740
|
-
if (
|
|
12781
|
+
if (chunkKW7ZEWYS_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12741
12782
|
recoverable += vtxo.value;
|
|
12742
12783
|
continue;
|
|
12743
12784
|
}
|
|
12744
|
-
if (!
|
|
12785
|
+
if (!chunkKW7ZEWYS_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12745
12786
|
if (vtxo.isPreconfirmed) {
|
|
12746
12787
|
preconfirmed += vtxo.value;
|
|
12747
12788
|
} else {
|
|
@@ -12960,7 +13001,7 @@ function intentProofJobs(coins) {
|
|
|
12960
13001
|
if (coins.length === 0) return [];
|
|
12961
13002
|
const coinJobs = coins.map((coin, i) => ({
|
|
12962
13003
|
index: i + 1,
|
|
12963
|
-
lookupScript:
|
|
13004
|
+
lookupScript: chunkKW7ZEWYS_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12964
13005
|
}));
|
|
12965
13006
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12966
13007
|
}
|
|
@@ -13000,7 +13041,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
13000
13041
|
const seen = /* @__PURE__ */ new Set();
|
|
13001
13042
|
const deduped = [];
|
|
13002
13043
|
for (const timelock of timelocks) {
|
|
13003
|
-
const sequence =
|
|
13044
|
+
const sequence = chunkKW7ZEWYS_cjs.timelockToSequence(timelock).toString();
|
|
13004
13045
|
if (seen.has(sequence)) continue;
|
|
13005
13046
|
seen.add(sequence);
|
|
13006
13047
|
deduped.push(timelock);
|
|
@@ -13016,7 +13057,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
13016
13057
|
if (!newest?.params.pubKey) return baseline;
|
|
13017
13058
|
try {
|
|
13018
13059
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
13019
|
-
return new
|
|
13060
|
+
return new chunkBYPBVHVA_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
13020
13061
|
} catch (e) {
|
|
13021
13062
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
13022
13063
|
return baseline;
|
|
@@ -13048,21 +13089,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
|
|
|
13048
13089
|
if (vtxo.isUnrolled) {
|
|
13049
13090
|
return !!f.withUnrolled;
|
|
13050
13091
|
}
|
|
13051
|
-
if (
|
|
13092
|
+
if (chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo)) {
|
|
13052
13093
|
return false;
|
|
13053
13094
|
}
|
|
13054
|
-
if (!f.withRecoverable &&
|
|
13095
|
+
if (!f.withRecoverable && chunkKW7ZEWYS_cjs.canRecoverOnchain(vtxo, now)) {
|
|
13055
13096
|
return false;
|
|
13056
13097
|
}
|
|
13057
13098
|
return true;
|
|
13058
13099
|
});
|
|
13059
13100
|
}
|
|
13060
13101
|
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
13061
|
-
const candidates = inputs.filter(
|
|
13102
|
+
const candidates = inputs.filter(chunkKW7ZEWYS_cjs.isVirtualCoin).map(chunkKW7ZEWYS_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
13062
13103
|
if (candidates.length === 0) return inputs;
|
|
13063
|
-
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await
|
|
13104
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkKW7ZEWYS_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
13064
13105
|
const suspects = candidates.filter(
|
|
13065
|
-
(v) =>
|
|
13106
|
+
(v) => chunkKW7ZEWYS_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
13066
13107
|
);
|
|
13067
13108
|
if (suspects.length === 0) return inputs;
|
|
13068
13109
|
let sweptNow;
|
|
@@ -13076,12 +13117,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
|
13076
13117
|
);
|
|
13077
13118
|
} catch (e) {
|
|
13078
13119
|
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
13079
|
-
throw
|
|
13120
|
+
throw chunkKW7ZEWYS_cjs.isRetryableProviderError(e) ? new chunkKW7ZEWYS_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
13080
13121
|
}
|
|
13081
13122
|
if (sweptNow.size === 0) return inputs;
|
|
13082
13123
|
return inputs.map((input) => {
|
|
13083
|
-
if (!
|
|
13084
|
-
return { ...
|
|
13124
|
+
if (!chunkKW7ZEWYS_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
13125
|
+
return { ...chunkKW7ZEWYS_cjs.normalizeVtxo(input), isSwept: true };
|
|
13085
13126
|
});
|
|
13086
13127
|
}
|
|
13087
13128
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
@@ -13370,7 +13411,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13370
13411
|
async getArkadeReader() {
|
|
13371
13412
|
const indexer = this.indexerProvider;
|
|
13372
13413
|
return {
|
|
13373
|
-
getVtxos: (opts) =>
|
|
13414
|
+
getVtxos: (opts) => chunkKW7ZEWYS_cjs.getNormalizedVtxos(indexer, opts),
|
|
13374
13415
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
13375
13416
|
};
|
|
13376
13417
|
}
|
|
@@ -13410,7 +13451,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13410
13451
|
"Pass either `service` or `arkProvider`/`indexerProvider`/`onchainProvider`, not both"
|
|
13411
13452
|
);
|
|
13412
13453
|
}
|
|
13413
|
-
const arkProvider = config.arkProvider || new
|
|
13454
|
+
const arkProvider = config.arkProvider || new chunkKW7ZEWYS_cjs.RestArkProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
|
|
13414
13455
|
let indexerProvider = config.indexerProvider;
|
|
13415
13456
|
if (!indexerProvider && !config.service) {
|
|
13416
13457
|
const derived = extractArkProviderUrl(arkProvider);
|
|
@@ -13419,11 +13460,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13419
13460
|
"indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
|
|
13420
13461
|
);
|
|
13421
13462
|
}
|
|
13422
|
-
indexerProvider = new
|
|
13463
|
+
indexerProvider = new chunkZMSM3NOH_cjs.RestIndexerProvider(derived ?? chunkKW7ZEWYS_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
13423
13464
|
}
|
|
13424
13465
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
13425
13466
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
13426
|
-
const delegatePubKeyPromise = config.delegateProvider?.getDelegateInfo().then((info2) =>
|
|
13467
|
+
const delegatePubKeyPromise = config.delegateProvider?.getDelegateInfo().then((info2) => chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0);
|
|
13427
13468
|
const {
|
|
13428
13469
|
info,
|
|
13429
13470
|
source: serverInfoSource,
|
|
@@ -13434,7 +13475,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13434
13475
|
if (!resolvedService) throw new Error("indexerProvider is unresolved");
|
|
13435
13476
|
indexerProvider = resolvedService.indexerProvider;
|
|
13436
13477
|
}
|
|
13437
|
-
const network =
|
|
13478
|
+
const network = chunkKW7ZEWYS_cjs.networkFromArkadeInfo(info);
|
|
13438
13479
|
if ("descriptor" in config.identity) {
|
|
13439
13480
|
const descriptor = config.identity.descriptor;
|
|
13440
13481
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -13470,18 +13511,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13470
13511
|
}
|
|
13471
13512
|
}
|
|
13472
13513
|
const boardingTimelock = config.boardingTimelock ?? toTimelock(info.boardingExitDelay);
|
|
13473
|
-
const serverPubKey =
|
|
13514
|
+
const serverPubKey = chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
13474
13515
|
const delegatePubKey = await delegatePubKeyPromise;
|
|
13475
13516
|
const offchainOptions = {
|
|
13476
13517
|
pubKey,
|
|
13477
13518
|
serverPubKey,
|
|
13478
13519
|
csvTimelock: exitTimelock
|
|
13479
13520
|
};
|
|
13480
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
13481
|
-
const boardingTapscript =
|
|
13521
|
+
const offchainTapscript = !delegatePubKey ? new chunkBYPBVHVA_cjs.DefaultVtxo.Script(offchainOptions) : new chunkBYPBVHVA_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
13522
|
+
const boardingTapscript = chunkBYPBVHVA_cjs.BoardingContractHandler.createScript({
|
|
13482
13523
|
pubKey: base.hex.encode(pubKey),
|
|
13483
13524
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13484
|
-
csvTimelock:
|
|
13525
|
+
csvTimelock: chunkKW7ZEWYS_cjs.timelockToSequence(boardingTimelock).toString()
|
|
13485
13526
|
});
|
|
13486
13527
|
return {
|
|
13487
13528
|
arkProvider,
|
|
@@ -13647,7 +13688,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13647
13688
|
if (!filter?.withUnrolled) {
|
|
13648
13689
|
logExcludedVtxos(
|
|
13649
13690
|
"getSpendableVtxos",
|
|
13650
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
13691
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo)),
|
|
13651
13692
|
[() => UNROLLED_REASON]
|
|
13652
13693
|
);
|
|
13653
13694
|
}
|
|
@@ -13790,7 +13831,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13790
13831
|
this.getBoardingTxs()
|
|
13791
13832
|
]);
|
|
13792
13833
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
13793
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13834
|
+
const resolveTxCreatedAt = (txids) => chunkKW7ZEWYS_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13794
13835
|
return buildTransactionHistory(
|
|
13795
13836
|
allVtxos,
|
|
13796
13837
|
boardingTxs,
|
|
@@ -13984,9 +14025,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13984
14025
|
async getBoardingTapscripts(allowedSigners) {
|
|
13985
14026
|
const byScript = /* @__PURE__ */ new Map();
|
|
13986
14027
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13987
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
14028
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkBYPBVHVA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13988
14029
|
add(
|
|
13989
|
-
new
|
|
14030
|
+
new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
13990
14031
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13991
14032
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13992
14033
|
csvTimelock: boardingCsv
|
|
@@ -14001,7 +14042,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14001
14042
|
for (const c of boardingContracts) {
|
|
14002
14043
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
14003
14044
|
try {
|
|
14004
|
-
add(
|
|
14045
|
+
add(chunkBYPBVHVA_cjs.BoardingContractHandler.createScript(c.params));
|
|
14005
14046
|
} catch (e) {
|
|
14006
14047
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
14007
14048
|
}
|
|
@@ -14030,7 +14071,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14030
14071
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
14031
14072
|
// not the wallet's current boarding timelock, which a signer
|
|
14032
14073
|
// rotation may have changed.
|
|
14033
|
-
csvTimelock:
|
|
14074
|
+
csvTimelock: chunkKW7ZEWYS_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
14034
14075
|
coins: utxos
|
|
14035
14076
|
};
|
|
14036
14077
|
})
|
|
@@ -14195,7 +14236,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14195
14236
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
14196
14237
|
async fetchPendingTxs() {
|
|
14197
14238
|
const scripts = await this.getWalletScripts();
|
|
14198
|
-
const vtxos = await
|
|
14239
|
+
const vtxos = await chunkKW7ZEWYS_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
14199
14240
|
return vtxos.filter(
|
|
14200
14241
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
14201
14242
|
).map((_) => _.arkTxId);
|
|
@@ -14226,7 +14267,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14226
14267
|
});
|
|
14227
14268
|
for (const contract of contracts) {
|
|
14228
14269
|
if (map.has(contract.script)) continue;
|
|
14229
|
-
const handler =
|
|
14270
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
14230
14271
|
if (handler) {
|
|
14231
14272
|
const script = handler.createScript(contract.params);
|
|
14232
14273
|
map.set(contract.script, script);
|
|
@@ -14342,7 +14383,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14342
14383
|
}
|
|
14343
14384
|
});
|
|
14344
14385
|
const baselinePubkey = await baselinePubkeyPromise;
|
|
14345
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14386
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14346
14387
|
const baselineSigners = [
|
|
14347
14388
|
this.offchainTapscript.options.serverPubKey,
|
|
14348
14389
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -14351,8 +14392,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14351
14392
|
const baseline = [];
|
|
14352
14393
|
for (const serverPubKey of baselineSigners) {
|
|
14353
14394
|
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
14354
|
-
const csvTimelockStr =
|
|
14355
|
-
const defaultScript = new
|
|
14395
|
+
const csvTimelockStr = chunkKW7ZEWYS_cjs.timelockToSequence(csvTimelock2).toString();
|
|
14396
|
+
const defaultScript = new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
14356
14397
|
pubKey: baselinePubkey,
|
|
14357
14398
|
serverPubKey,
|
|
14358
14399
|
csvTimelock: csvTimelock2
|
|
@@ -14373,7 +14414,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14373
14414
|
});
|
|
14374
14415
|
}
|
|
14375
14416
|
if (delegatePubKey) {
|
|
14376
|
-
const delegateScript = new
|
|
14417
|
+
const delegateScript = new chunkBYPBVHVA_cjs.DelegateVtxo.Script({
|
|
14377
14418
|
pubKey: baselinePubkey,
|
|
14378
14419
|
serverPubKey,
|
|
14379
14420
|
delegatePubKey,
|
|
@@ -14397,9 +14438,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14397
14438
|
}
|
|
14398
14439
|
}
|
|
14399
14440
|
}
|
|
14400
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
14441
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkBYPBVHVA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14401
14442
|
for (const serverPubKey of baselineSigners) {
|
|
14402
|
-
const baselineBoarding = new
|
|
14443
|
+
const baselineBoarding = new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
14403
14444
|
pubKey: baselinePubkey,
|
|
14404
14445
|
serverPubKey,
|
|
14405
14446
|
csvTimelock: boardingCsvTimelock
|
|
@@ -14412,7 +14453,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14412
14453
|
params: {
|
|
14413
14454
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
14414
14455
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14415
|
-
csvTimelock:
|
|
14456
|
+
csvTimelock: chunkKW7ZEWYS_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
14416
14457
|
},
|
|
14417
14458
|
script: boardingScriptHex,
|
|
14418
14459
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -14435,7 +14476,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14435
14476
|
}
|
|
14436
14477
|
};
|
|
14437
14478
|
var Wallet2 = class extends ReadonlyWallet {
|
|
14438
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, keyring, lookAheadWindow, batchExpiryPolicy) {
|
|
14479
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, keyring, lookAheadWindow, batchExpiryPolicy, oneShotSubmit = true) {
|
|
14439
14480
|
super(
|
|
14440
14481
|
identity,
|
|
14441
14482
|
network,
|
|
@@ -14455,6 +14496,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14455
14496
|
this.forfeitOutputScript = forfeitOutputScript;
|
|
14456
14497
|
this.forfeitPubkey = forfeitPubkey;
|
|
14457
14498
|
this.batchExpiryPolicy = batchExpiryPolicy;
|
|
14499
|
+
this.oneShotSubmit = oneShotSubmit;
|
|
14458
14500
|
this.identity = identity;
|
|
14459
14501
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
14460
14502
|
this._delegateManager = delegateProvider ? new DelegateManagerImpl(delegateProvider, arkProvider, identity) : void 0;
|
|
@@ -14476,6 +14518,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14476
14518
|
forfeitOutputScript;
|
|
14477
14519
|
forfeitPubkey;
|
|
14478
14520
|
batchExpiryPolicy;
|
|
14521
|
+
oneShotSubmit;
|
|
14479
14522
|
static MIN_FEE_RATE = 1;
|
|
14480
14523
|
// sats/vbyte
|
|
14481
14524
|
identity;
|
|
@@ -14598,7 +14641,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14598
14641
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
14599
14642
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
14600
14643
|
csvTimelocks: this.walletContractTimelocks,
|
|
14601
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
14644
|
+
delegatePubKey: this.offchainTapscript instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
14602
14645
|
};
|
|
14603
14646
|
}
|
|
14604
14647
|
_signerRouter;
|
|
@@ -14758,7 +14801,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14758
14801
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14759
14802
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14760
14803
|
if (typeof persisted === "string") return persisted;
|
|
14761
|
-
return
|
|
14804
|
+
return chunkBYPBVHVA_cjs.identityDescriptor(this.identity);
|
|
14762
14805
|
}
|
|
14763
14806
|
/**
|
|
14764
14807
|
* Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
|
|
@@ -14768,7 +14811,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14768
14811
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14769
14812
|
if (type === "boarding") {
|
|
14770
14813
|
const built2 = this.buildBoardingContract(
|
|
14771
|
-
|
|
14814
|
+
chunkBYPBVHVA_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14772
14815
|
descriptor,
|
|
14773
14816
|
tagSource
|
|
14774
14817
|
);
|
|
@@ -14805,11 +14848,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14805
14848
|
* (offchain analogue: {@link buildReceiveContract}).
|
|
14806
14849
|
*/
|
|
14807
14850
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14808
|
-
const tapscript = new
|
|
14851
|
+
const tapscript = new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
14809
14852
|
...this._boardingTapscript.options,
|
|
14810
14853
|
pubKey
|
|
14811
14854
|
});
|
|
14812
|
-
const csvTimelock2 = tapscript.options.csvTimelock ??
|
|
14855
|
+
const csvTimelock2 = tapscript.options.csvTimelock ?? chunkBYPBVHVA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14813
14856
|
return {
|
|
14814
14857
|
tapscript,
|
|
14815
14858
|
params: {
|
|
@@ -14817,13 +14860,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14817
14860
|
params: {
|
|
14818
14861
|
pubKey: base.hex.encode(pubKey),
|
|
14819
14862
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14820
|
-
csvTimelock:
|
|
14863
|
+
csvTimelock: chunkKW7ZEWYS_cjs.timelockToSequence(csvTimelock2).toString()
|
|
14821
14864
|
},
|
|
14822
14865
|
script: base.hex.encode(tapscript.pkScript),
|
|
14823
14866
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14824
14867
|
state: "active",
|
|
14825
14868
|
metadata: {
|
|
14826
|
-
...tagSource && { source:
|
|
14869
|
+
...tagSource && { source: chunkBYPBVHVA_cjs.WALLET_RECEIVE_SOURCE },
|
|
14827
14870
|
signingDescriptor: descriptor
|
|
14828
14871
|
}
|
|
14829
14872
|
}
|
|
@@ -14845,7 +14888,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14845
14888
|
if (this._hdProvider) {
|
|
14846
14889
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14847
14890
|
}
|
|
14848
|
-
return
|
|
14891
|
+
return chunkBYPBVHVA_cjs.identityDescriptor(this.identity);
|
|
14849
14892
|
}
|
|
14850
14893
|
/**
|
|
14851
14894
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14921,7 +14964,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14921
14964
|
* the stable public API.
|
|
14922
14965
|
*/
|
|
14923
14966
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14924
|
-
const xonly =
|
|
14967
|
+
const xonly = chunkBYPBVHVA_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14925
14968
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14926
14969
|
checkpointTapscript,
|
|
14927
14970
|
this.network,
|
|
@@ -14951,21 +14994,21 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14951
14994
|
]);
|
|
14952
14995
|
const [currentOffchainRow] = offchainRows;
|
|
14953
14996
|
const [currentBoardingRow] = boardingRows;
|
|
14954
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14997
|
+
const newOffchain = this.offchainTapscript instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script ? new chunkBYPBVHVA_cjs.DelegateVtxo.Script({
|
|
14955
14998
|
...this.offchainTapscript.options,
|
|
14956
14999
|
serverPubKey: xonly
|
|
14957
|
-
}) : new
|
|
15000
|
+
}) : new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
14958
15001
|
...this.offchainTapscript.options,
|
|
14959
15002
|
serverPubKey: xonly
|
|
14960
15003
|
});
|
|
14961
|
-
const newBoarding = new
|
|
15004
|
+
const newBoarding = new chunkBYPBVHVA_cjs.DefaultVtxo.Script({
|
|
14962
15005
|
...this._boardingTapscript.options,
|
|
14963
15006
|
serverPubKey: xonly
|
|
14964
15007
|
});
|
|
14965
|
-
const offchainCsv =
|
|
15008
|
+
const offchainCsv = chunkKW7ZEWYS_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14966
15009
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14967
15010
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14968
|
-
if (newOffchain instanceof
|
|
15011
|
+
if (newOffchain instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script) {
|
|
14969
15012
|
await manager.createContract({
|
|
14970
15013
|
type: "delegate",
|
|
14971
15014
|
params: {
|
|
@@ -14993,13 +15036,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14993
15036
|
metadata: currentOffchainRow?.metadata
|
|
14994
15037
|
});
|
|
14995
15038
|
}
|
|
14996
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
15039
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunkBYPBVHVA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14997
15040
|
await manager.createContract({
|
|
14998
15041
|
type: "boarding",
|
|
14999
15042
|
params: {
|
|
15000
15043
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
15001
15044
|
serverPubKey: base.hex.encode(xonly),
|
|
15002
|
-
csvTimelock:
|
|
15045
|
+
csvTimelock: chunkKW7ZEWYS_cjs.timelockToSequence(boardingCsv).toString()
|
|
15003
15046
|
},
|
|
15004
15047
|
script: base.hex.encode(newBoarding.pkScript),
|
|
15005
15048
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -15027,14 +15070,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15027
15070
|
_restoreInFlight;
|
|
15028
15071
|
_addPendingSpends(inputs) {
|
|
15029
15072
|
for (const input of inputs) {
|
|
15030
|
-
if (
|
|
15073
|
+
if (chunkKW7ZEWYS_cjs.isVirtualCoin(input)) {
|
|
15031
15074
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
15032
15075
|
}
|
|
15033
15076
|
}
|
|
15034
15077
|
}
|
|
15035
15078
|
_removePendingSpends(inputs) {
|
|
15036
15079
|
for (const input of inputs) {
|
|
15037
|
-
if (
|
|
15080
|
+
if (chunkKW7ZEWYS_cjs.isVirtualCoin(input)) {
|
|
15038
15081
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
15039
15082
|
}
|
|
15040
15083
|
}
|
|
@@ -15098,7 +15141,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15098
15141
|
if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
|
|
15099
15142
|
}
|
|
15100
15143
|
_assertNotHeld(inputs) {
|
|
15101
|
-
const held = coinKeys(inputs.filter(
|
|
15144
|
+
const held = coinKeys(inputs.filter(chunkKW7ZEWYS_cjs.isVirtualCoin)).filter(
|
|
15102
15145
|
(key) => this._heldOutpoints.has(key)
|
|
15103
15146
|
);
|
|
15104
15147
|
if (held.length > 0) throw new VtxoReservedError(held, "held");
|
|
@@ -15137,14 +15180,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15137
15180
|
const hd = provider !== void 0;
|
|
15138
15181
|
const [manager, staticDescriptor, arkInfo] = await Promise.all([
|
|
15139
15182
|
this.getContractManager(),
|
|
15140
|
-
hd ? void 0 :
|
|
15183
|
+
hd ? void 0 : chunkBYPBVHVA_cjs.identityDescriptor(this.identity),
|
|
15141
15184
|
this.arkProvider.getInfo()
|
|
15142
15185
|
]);
|
|
15143
15186
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
15144
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
15145
|
-
const currentSignerPubKey =
|
|
15187
|
+
const delegatePubKey = this.offchainTapscript instanceof chunkBYPBVHVA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
15188
|
+
const currentSignerPubKey = chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
15146
15189
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
15147
|
-
(s) =>
|
|
15190
|
+
(s) => chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
15148
15191
|
);
|
|
15149
15192
|
const deps = {
|
|
15150
15193
|
indexerProvider: this.indexerProvider,
|
|
@@ -15156,7 +15199,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15156
15199
|
deprecatedSignerPubKeys,
|
|
15157
15200
|
csvTimelocks: this.walletContractTimelocks,
|
|
15158
15201
|
// Boarding-exit CSV, distinct from the unilateral-exit matrix.
|
|
15159
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
15202
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkBYPBVHVA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
15160
15203
|
delegatePubKey
|
|
15161
15204
|
};
|
|
15162
15205
|
const result = await manager.scanContracts({
|
|
@@ -15273,7 +15316,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15273
15316
|
throw new Error("Invalid configured public key");
|
|
15274
15317
|
}
|
|
15275
15318
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
15276
|
-
const forfeitPubkey =
|
|
15319
|
+
const forfeitPubkey = chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
15277
15320
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
15278
15321
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
15279
15322
|
const serverUnrollScript = assertValidServerUnrollScript(
|
|
@@ -15321,7 +15364,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15321
15364
|
{
|
|
15322
15365
|
advertisedVtxoTreeExpiry: setup.info.vtxoTreeExpiry,
|
|
15323
15366
|
...config.minBatchExpirySeconds !== void 0 ? { minSeconds: config.minBatchExpirySeconds } : {}
|
|
15324
|
-
}
|
|
15367
|
+
},
|
|
15368
|
+
config.oneShotSubmit
|
|
15325
15369
|
);
|
|
15326
15370
|
wallet.lazyInitialization = config.lazyInitialization ?? false;
|
|
15327
15371
|
wallet._serverInfoSource = setup.serverInfoSource;
|
|
@@ -15441,13 +15485,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15441
15485
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
15442
15486
|
}
|
|
15443
15487
|
const offchainAddress = await this.getAddress();
|
|
15444
|
-
const offchainPkScript =
|
|
15488
|
+
const offchainPkScript = chunkKW7ZEWYS_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
15445
15489
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
15446
15490
|
if (!params) {
|
|
15447
15491
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
15448
15492
|
const estimator = new Estimator(fees.intentFee);
|
|
15449
15493
|
let amount = 0;
|
|
15450
|
-
const exitScript =
|
|
15494
|
+
const exitScript = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.decode(
|
|
15451
15495
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
15452
15496
|
);
|
|
15453
15497
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -15479,7 +15523,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15479
15523
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
15480
15524
|
break;
|
|
15481
15525
|
}
|
|
15482
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15526
|
+
const inputFee = estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(vtxo));
|
|
15483
15527
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15484
15528
|
continue;
|
|
15485
15529
|
}
|
|
@@ -15531,7 +15575,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15531
15575
|
let script;
|
|
15532
15576
|
let arkAddress;
|
|
15533
15577
|
try {
|
|
15534
|
-
arkAddress =
|
|
15578
|
+
arkAddress = chunkKW7ZEWYS_cjs.ArkAddress.decode(output.address);
|
|
15535
15579
|
} catch {
|
|
15536
15580
|
arkAddress = void 0;
|
|
15537
15581
|
}
|
|
@@ -15603,11 +15647,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15603
15647
|
]);
|
|
15604
15648
|
let intentTxId;
|
|
15605
15649
|
try {
|
|
15606
|
-
intentTxId =
|
|
15650
|
+
intentTxId = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
|
|
15607
15651
|
} catch {
|
|
15608
15652
|
intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
|
|
15609
15653
|
}
|
|
15610
|
-
const settleInputVtxos = params.inputs.filter(
|
|
15654
|
+
const settleInputVtxos = params.inputs.filter(chunkKW7ZEWYS_cjs.isVirtualCoin);
|
|
15611
15655
|
const contractManager = await this.getContractManager();
|
|
15612
15656
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15613
15657
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15616,7 +15660,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15616
15660
|
);
|
|
15617
15661
|
if (picked) this._assertNotHeld(params.inputs);
|
|
15618
15662
|
this._addPendingSpends(params.inputs);
|
|
15619
|
-
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !
|
|
15663
|
+
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkKW7ZEWYS_cjs.isVirtualCoin(i))) : [];
|
|
15620
15664
|
for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
|
|
15621
15665
|
const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
|
|
15622
15666
|
for (const key of settlingKeys) this._settlingOutpoints.add(key);
|
|
@@ -15735,7 +15779,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15735
15779
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15736
15780
|
if (!this._descriptorProvider) return;
|
|
15737
15781
|
const consumedBoarding = inputs.some(
|
|
15738
|
-
(input) => typeof input !== "string" && !
|
|
15782
|
+
(input) => typeof input !== "string" && !chunkKW7ZEWYS_cjs.isVirtualCoin(input)
|
|
15739
15783
|
);
|
|
15740
15784
|
if (!consumedBoarding) return;
|
|
15741
15785
|
try {
|
|
@@ -15746,7 +15790,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15746
15790
|
}
|
|
15747
15791
|
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
15748
15792
|
const signedForfeits = [];
|
|
15749
|
-
let settlementPsbt =
|
|
15793
|
+
let settlementPsbt = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
15750
15794
|
assertFinalCommitmentMatchesValidated(
|
|
15751
15795
|
settlementPsbt,
|
|
15752
15796
|
validatedCommitmentTxid,
|
|
@@ -15759,7 +15803,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15759
15803
|
let connectorIndex = 0;
|
|
15760
15804
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15761
15805
|
for (const input of inputs) {
|
|
15762
|
-
if (!
|
|
15806
|
+
if (!chunkKW7ZEWYS_cjs.isVirtualCoin(input)) {
|
|
15763
15807
|
let matched = false;
|
|
15764
15808
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15765
15809
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -15797,7 +15841,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15797
15841
|
}
|
|
15798
15842
|
continue;
|
|
15799
15843
|
}
|
|
15800
|
-
if (!
|
|
15844
|
+
if (!chunkKW7ZEWYS_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15801
15845
|
continue;
|
|
15802
15846
|
}
|
|
15803
15847
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15825,7 +15869,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15825
15869
|
index: input.vout,
|
|
15826
15870
|
witnessUtxo: {
|
|
15827
15871
|
amount: BigInt(input.value),
|
|
15828
|
-
script:
|
|
15872
|
+
script: chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15829
15873
|
},
|
|
15830
15874
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15831
15875
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15844,7 +15888,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15844
15888
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15845
15889
|
{
|
|
15846
15890
|
index: 0,
|
|
15847
|
-
lookupScript:
|
|
15891
|
+
lookupScript: chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15848
15892
|
}
|
|
15849
15893
|
]);
|
|
15850
15894
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15902,7 +15946,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15902
15946
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15903
15947
|
);
|
|
15904
15948
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15905
|
-
const sweepTapscript =
|
|
15949
|
+
const sweepTapscript = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.encode({
|
|
15906
15950
|
timelock,
|
|
15907
15951
|
pubkeys: [this.forfeitPubkey]
|
|
15908
15952
|
}).script;
|
|
@@ -15917,14 +15961,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15917
15961
|
throw new Error("Sweep tap tree root not set");
|
|
15918
15962
|
}
|
|
15919
15963
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15920
|
-
(k) => base.hex.encode(
|
|
15964
|
+
(k) => base.hex.encode(chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15921
15965
|
);
|
|
15922
15966
|
const signerPublicKey = await session.getPublicKey();
|
|
15923
|
-
const xonlySignerPublicKey =
|
|
15967
|
+
const xonlySignerPublicKey = chunkBYPBVHVA_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15924
15968
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15925
15969
|
return { skip: true };
|
|
15926
15970
|
}
|
|
15927
|
-
const commitmentTx =
|
|
15971
|
+
const commitmentTx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(
|
|
15928
15972
|
base.base64.decode(event.unsignedCommitmentTx)
|
|
15929
15973
|
);
|
|
15930
15974
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
@@ -16006,9 +16050,9 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16006
16050
|
...existing ?? {},
|
|
16007
16051
|
intentTxId,
|
|
16008
16052
|
registerProof: intent.proof,
|
|
16009
|
-
registerProofMessage:
|
|
16053
|
+
registerProofMessage: chunkKW7ZEWYS_cjs.Intent.encodeMessage(intent.message),
|
|
16010
16054
|
deleteProof: deleteIntent.proof,
|
|
16011
|
-
deleteProofMessage:
|
|
16055
|
+
deleteProofMessage: chunkKW7ZEWYS_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
16012
16056
|
intentVtxos: inputs.map((i) => ({
|
|
16013
16057
|
txid: i.txid,
|
|
16014
16058
|
vout: i.vout
|
|
@@ -16041,7 +16085,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16041
16085
|
try {
|
|
16042
16086
|
return await this.arkProvider.registerIntent(intent);
|
|
16043
16087
|
} catch (error) {
|
|
16044
|
-
if (error instanceof
|
|
16088
|
+
if (error instanceof chunkKW7ZEWYS_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
16045
16089
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
16046
16090
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
16047
16091
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -16057,7 +16101,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16057
16101
|
expire_at: 0,
|
|
16058
16102
|
cosigners_public_keys: cosignerPubKeys
|
|
16059
16103
|
};
|
|
16060
|
-
const proof =
|
|
16104
|
+
const proof = chunkKW7ZEWYS_cjs.Intent.create(message, coins, outputs);
|
|
16061
16105
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16062
16106
|
return {
|
|
16063
16107
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16069,7 +16113,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16069
16113
|
type: "delete",
|
|
16070
16114
|
expire_at: 0
|
|
16071
16115
|
};
|
|
16072
|
-
const proof =
|
|
16116
|
+
const proof = chunkKW7ZEWYS_cjs.Intent.create(message, coins, []);
|
|
16073
16117
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16074
16118
|
return {
|
|
16075
16119
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16081,7 +16125,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16081
16125
|
type: "get-pending-tx",
|
|
16082
16126
|
expire_at: 0
|
|
16083
16127
|
};
|
|
16084
|
-
const proof =
|
|
16128
|
+
const proof = chunkKW7ZEWYS_cjs.Intent.create(message, coins, []);
|
|
16085
16129
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16086
16130
|
return {
|
|
16087
16131
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16102,7 +16146,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16102
16146
|
if (!vtxos || vtxos.length === 0) {
|
|
16103
16147
|
const scriptMap = await this.getScriptMap();
|
|
16104
16148
|
const allExtended = [];
|
|
16105
|
-
const fetchedVtxos = await
|
|
16149
|
+
const fetchedVtxos = await chunkKW7ZEWYS_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
16106
16150
|
...scriptMap.keys()
|
|
16107
16151
|
]);
|
|
16108
16152
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -16145,8 +16189,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16145
16189
|
batchPending.push(pendingTx.arkTxid);
|
|
16146
16190
|
try {
|
|
16147
16191
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
16148
|
-
const tx =
|
|
16149
|
-
|
|
16192
|
+
const tx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
16193
|
+
chunkKW7ZEWYS_cjs.assertAllowedSighashTypes(tx);
|
|
16150
16194
|
return tx;
|
|
16151
16195
|
});
|
|
16152
16196
|
assertCheckpointsMatchInputs(
|
|
@@ -16215,11 +16259,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16215
16259
|
* and one per deprecated signer — else a pre-rotation tx would stay pending forever.
|
|
16216
16260
|
*/
|
|
16217
16261
|
checkpointUnrollCandidates(info) {
|
|
16218
|
-
const current =
|
|
16262
|
+
const current = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
16219
16263
|
const candidates = [this._serverUnrollScript, current];
|
|
16220
16264
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
16221
16265
|
candidates.push(
|
|
16222
|
-
|
|
16266
|
+
chunkKW7ZEWYS_cjs.CSVMultisigTapscript.encode({
|
|
16223
16267
|
...current.params,
|
|
16224
16268
|
pubkeys: [base.hex.decode(deprecated)]
|
|
16225
16269
|
})
|
|
@@ -16314,7 +16358,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16314
16358
|
if (vtxos.length === 0) {
|
|
16315
16359
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
16316
16360
|
}
|
|
16317
|
-
const myPkScript =
|
|
16361
|
+
const myPkScript = chunkKW7ZEWYS_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
16318
16362
|
let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
16319
16363
|
let swept = 0;
|
|
16320
16364
|
const drainable = vtxos.filter(
|
|
@@ -16362,7 +16406,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16362
16406
|
}
|
|
16363
16407
|
],
|
|
16364
16408
|
outputs: [{ script: myPkScript, amount: BigInt(vtxo.value) }],
|
|
16365
|
-
serverUnrollScript
|
|
16409
|
+
serverUnrollScript,
|
|
16410
|
+
oneShot: this.oneShotSubmit
|
|
16366
16411
|
});
|
|
16367
16412
|
swept += vtxo.value;
|
|
16368
16413
|
} catch (error) {
|
|
@@ -16441,7 +16486,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16441
16486
|
params: {
|
|
16442
16487
|
pubKey: base.hex.encode(cash.publicKey),
|
|
16443
16488
|
serverPubKey: base.hex.encode(cash.serverPubKey),
|
|
16444
|
-
csvTimelock:
|
|
16489
|
+
csvTimelock: chunkKW7ZEWYS_cjs.timelockToSequence(cash.csvTimelock).toString()
|
|
16445
16490
|
},
|
|
16446
16491
|
script: base.hex.encode(cashScript.pkScript),
|
|
16447
16492
|
address: cashAddress.encode(),
|
|
@@ -16522,7 +16567,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16522
16567
|
const recoverable = [];
|
|
16523
16568
|
const unclaimed = [];
|
|
16524
16569
|
for (const vtxo of vtxos) {
|
|
16525
|
-
if (
|
|
16570
|
+
if (chunkKW7ZEWYS_cjs.isVtxoSpent(vtxo)) {
|
|
16526
16571
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
16527
16572
|
} else if (vtxo.isUnrolled) {
|
|
16528
16573
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -16544,7 +16589,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16544
16589
|
const all = [];
|
|
16545
16590
|
const seen = /* @__PURE__ */ new Set();
|
|
16546
16591
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
16547
|
-
const { vtxos, page } = await
|
|
16592
|
+
const { vtxos, page } = await chunkKW7ZEWYS_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
16548
16593
|
scripts,
|
|
16549
16594
|
pageIndex,
|
|
16550
16595
|
pageSize
|
|
@@ -16582,7 +16627,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16582
16627
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
16583
16628
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
16584
16629
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
16585
|
-
const proof =
|
|
16630
|
+
const proof = chunkKW7ZEWYS_cjs.Intent.create(message, batch, []);
|
|
16586
16631
|
const signedProof = await identity.sign(
|
|
16587
16632
|
proof,
|
|
16588
16633
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -16603,8 +16648,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16603
16648
|
for (const pendingTx of pendingTxs) {
|
|
16604
16649
|
try {
|
|
16605
16650
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
16606
|
-
const tx =
|
|
16607
|
-
|
|
16651
|
+
const tx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
16652
|
+
chunkKW7ZEWYS_cjs.assertAllowedSighashTypes(tx);
|
|
16608
16653
|
return tx;
|
|
16609
16654
|
});
|
|
16610
16655
|
assertCheckpointsMatchInputs(
|
|
@@ -16644,7 +16689,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16644
16689
|
}
|
|
16645
16690
|
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
16646
16691
|
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
16647
|
-
const arkTx =
|
|
16692
|
+
const arkTx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
16648
16693
|
let total = 0;
|
|
16649
16694
|
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
16650
16695
|
const output = arkTx.getOutput(i);
|
|
@@ -16703,7 +16748,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16703
16748
|
throw new Error("send({ maxChangeFee }): expected a non-negative safe integer");
|
|
16704
16749
|
}
|
|
16705
16750
|
if (selectedVtxos) {
|
|
16706
|
-
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(
|
|
16751
|
+
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
16707
16752
|
if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
|
|
16708
16753
|
throw new Error("send({ selectedVtxos }): input expiry floor not met");
|
|
16709
16754
|
}
|
|
@@ -16838,7 +16883,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16838
16883
|
script: recipient.script,
|
|
16839
16884
|
amount: BigInt(recipient.amount),
|
|
16840
16885
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16841
|
-
...recipient.tapTree ? { tapTree:
|
|
16886
|
+
...recipient.tapTree ? { tapTree: chunkKW7ZEWYS_cjs.toBIP371TapTree(recipient.tapTree) } : {}
|
|
16842
16887
|
}));
|
|
16843
16888
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16844
16889
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -17030,10 +17075,10 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17030
17075
|
const serverPubKey = this.arkServerPublicKey;
|
|
17031
17076
|
const serverUnrollScript = this.serverUnrollScript;
|
|
17032
17077
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
17033
|
-
const normalizedInputs = inputs.map(
|
|
17034
|
-
const at = now ?? await
|
|
17078
|
+
const normalizedInputs = inputs.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
17079
|
+
const at = now ?? await chunkKW7ZEWYS_cjs.resolveTimeHeight(this.onchainProvider);
|
|
17035
17080
|
for (const input of normalizedInputs) {
|
|
17036
|
-
if (!
|
|
17081
|
+
if (!chunkKW7ZEWYS_cjs.canSpendOffchain(input, at)) {
|
|
17037
17082
|
throw new Error(
|
|
17038
17083
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
17039
17084
|
);
|
|
@@ -17117,7 +17162,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17117
17162
|
);
|
|
17118
17163
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
17119
17164
|
index,
|
|
17120
|
-
lookupScript:
|
|
17165
|
+
lookupScript: chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
17121
17166
|
}));
|
|
17122
17167
|
const identity = this.identity;
|
|
17123
17168
|
const signer = {
|
|
@@ -17204,7 +17249,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17204
17249
|
deprecatedServerPubkeys: [...this._deprecatedSigners.keys()].map(
|
|
17205
17250
|
(h) => base.hex.decode(h)
|
|
17206
17251
|
)
|
|
17207
|
-
}
|
|
17252
|
+
},
|
|
17253
|
+
oneShot: this.oneShotSubmit
|
|
17208
17254
|
}
|
|
17209
17255
|
);
|
|
17210
17256
|
} finally {
|
|
@@ -17226,7 +17272,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17226
17272
|
}
|
|
17227
17273
|
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
17228
17274
|
for (const encoded of signedCheckpointTxs) {
|
|
17229
|
-
const checkpoint =
|
|
17275
|
+
const checkpoint = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
17230
17276
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
17231
17277
|
const input = checkpoint.getInput(i);
|
|
17232
17278
|
if (!input.txid) continue;
|
|
@@ -17342,12 +17388,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17342
17388
|
const spentVtxos = [];
|
|
17343
17389
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
17344
17390
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
17345
|
-
const vtxoInputs = inputs.filter(
|
|
17391
|
+
const vtxoInputs = inputs.filter(chunkKW7ZEWYS_cjs.isVirtualCoin);
|
|
17346
17392
|
const cm = await this.getContractManager();
|
|
17347
17393
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
17348
17394
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
17349
17395
|
for (const input of inputs) {
|
|
17350
|
-
if (
|
|
17396
|
+
if (chunkKW7ZEWYS_cjs.isVirtualCoin(input)) {
|
|
17351
17397
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
17352
17398
|
const vtxo = annotatedByKey.get(outpoint);
|
|
17353
17399
|
if (!vtxo) {
|
|
@@ -17364,7 +17410,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17364
17410
|
} else {
|
|
17365
17411
|
let sourceAddress;
|
|
17366
17412
|
try {
|
|
17367
|
-
sourceAddress =
|
|
17413
|
+
sourceAddress = chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
17368
17414
|
this.network
|
|
17369
17415
|
);
|
|
17370
17416
|
} catch {
|
|
@@ -17436,7 +17482,7 @@ function bySelectionOrder(a, b) {
|
|
|
17436
17482
|
return b.value - a.value;
|
|
17437
17483
|
}
|
|
17438
17484
|
function selectVirtualCoins(coins, targetAmount) {
|
|
17439
|
-
const sortedCoins = coins.map(
|
|
17485
|
+
const sortedCoins = coins.map(chunkKW7ZEWYS_cjs.normalizeVtxo).sort(bySelectionOrder);
|
|
17440
17486
|
const selectedCoins = [];
|
|
17441
17487
|
let selectedAmount = 0;
|
|
17442
17488
|
for (const coin of sortedCoins) {
|
|
@@ -17553,7 +17599,7 @@ function assertTimeoutMap(name, timeouts) {
|
|
|
17553
17599
|
if (value === void 0) {
|
|
17554
17600
|
throw new Error(`${name}.${key} must be a non-negative safe integer`);
|
|
17555
17601
|
}
|
|
17556
|
-
|
|
17602
|
+
chunkKW7ZEWYS_cjs.assertTimerMs(`${name}.${key}`, value);
|
|
17557
17603
|
}
|
|
17558
17604
|
}
|
|
17559
17605
|
var MessageBus = class {
|
|
@@ -17570,8 +17616,8 @@ var MessageBus = class {
|
|
|
17570
17616
|
}) {
|
|
17571
17617
|
this.walletRepository = walletRepository;
|
|
17572
17618
|
this.contractRepository = contractRepository;
|
|
17573
|
-
|
|
17574
|
-
|
|
17619
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
|
|
17620
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
|
|
17575
17621
|
assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
|
|
17576
17622
|
this.intentRepository = intentRepository;
|
|
17577
17623
|
this.onchainProvider = onchainProvider;
|
|
@@ -17827,14 +17873,14 @@ var MessageBus = class {
|
|
|
17827
17873
|
this.initialized = true;
|
|
17828
17874
|
}
|
|
17829
17875
|
async buildServices(config) {
|
|
17830
|
-
const arkProvider = new
|
|
17876
|
+
const arkProvider = new chunkKW7ZEWYS_cjs.RestArkProvider(config.arkServer.url);
|
|
17831
17877
|
const storage = {
|
|
17832
17878
|
walletRepository: this.walletRepository,
|
|
17833
17879
|
contractRepository: this.contractRepository,
|
|
17834
17880
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
17835
17881
|
};
|
|
17836
17882
|
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
17837
|
-
const indexerProvider = new
|
|
17883
|
+
const indexerProvider = new chunkZMSM3NOH_cjs.RestIndexerProvider(config.arkServer.url);
|
|
17838
17884
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
17839
17885
|
if (isSigningSerialized(serialized)) {
|
|
17840
17886
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -17852,6 +17898,7 @@ var MessageBus = class {
|
|
|
17852
17898
|
lazyInitialization: config.lazyInitialization,
|
|
17853
17899
|
watcherConfig: config.watcherConfig,
|
|
17854
17900
|
lookAheadWindow: config.lookAheadWindow,
|
|
17901
|
+
oneShotSubmit: config.oneShotSubmit,
|
|
17855
17902
|
minBatchExpirySeconds: config.minBatchExpirySeconds
|
|
17856
17903
|
});
|
|
17857
17904
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
@@ -18176,7 +18223,7 @@ var offboardNetworkNames = [
|
|
|
18176
18223
|
function offboardDestinationScript(destinationAddress) {
|
|
18177
18224
|
for (const networkName of offboardNetworkNames) {
|
|
18178
18225
|
try {
|
|
18179
|
-
const network =
|
|
18226
|
+
const network = chunkKW7ZEWYS_cjs.networks[networkName];
|
|
18180
18227
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
18181
18228
|
return btcSigner.OutScript.encode(addr);
|
|
18182
18229
|
} catch {
|
|
@@ -18216,7 +18263,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
18216
18263
|
const inputs = [];
|
|
18217
18264
|
let subtotal = 0n;
|
|
18218
18265
|
for (const vtxo of vtxos) {
|
|
18219
|
-
const inputFee = estimator.evalOffchainInput(
|
|
18266
|
+
const inputFee = estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(vtxo));
|
|
18220
18267
|
if (inputFee.satoshis >= vtxo.value) {
|
|
18221
18268
|
if (named) {
|
|
18222
18269
|
throw new Error(
|
|
@@ -18313,7 +18360,7 @@ var Ramps = class {
|
|
|
18313
18360
|
}
|
|
18314
18361
|
amount = amount ?? totalAmount;
|
|
18315
18362
|
const offchainAddress = await this.wallet.getAddress();
|
|
18316
|
-
const offchainAddr =
|
|
18363
|
+
const offchainAddr = chunkKW7ZEWYS_cjs.ArkAddress.decode(offchainAddress);
|
|
18317
18364
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
18318
18365
|
const outputFee = estimator.evalOffchainOutput({
|
|
18319
18366
|
amount,
|
|
@@ -18463,7 +18510,7 @@ var Ramps = class {
|
|
|
18463
18510
|
const ordered = [...candidates].sort(bySelectionOrder);
|
|
18464
18511
|
let covered = 0n;
|
|
18465
18512
|
for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
|
|
18466
|
-
const fee = estimator.evalOffchainInput(
|
|
18513
|
+
const fee = estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
|
|
18467
18514
|
covered += BigInt(ordered[i].value) - BigInt(fee);
|
|
18468
18515
|
if (covered < needed) continue;
|
|
18469
18516
|
try {
|
|
@@ -18497,7 +18544,7 @@ var Ramps = class {
|
|
|
18497
18544
|
async fundChange(left, estimator) {
|
|
18498
18545
|
if (left <= 0n) return { change: 0n };
|
|
18499
18546
|
const changeAddress = await this.wallet.getAddress();
|
|
18500
|
-
const changeScript = base.hex.encode(
|
|
18547
|
+
const changeScript = base.hex.encode(chunkKW7ZEWYS_cjs.ArkAddress.decode(changeAddress).pkScript);
|
|
18501
18548
|
const { change } = changeAfterOutputFee(
|
|
18502
18549
|
left,
|
|
18503
18550
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
|
|
@@ -19440,7 +19487,7 @@ var WalletMessageHandler = class {
|
|
|
19440
19487
|
this.lazyBoardingInit = payload.lazyBoarding ?? false;
|
|
19441
19488
|
this.boardingEpoch++;
|
|
19442
19489
|
this.boardingLoaded = false;
|
|
19443
|
-
this.indexerProvider = new
|
|
19490
|
+
this.indexerProvider = new chunkZMSM3NOH_cjs.RestIndexerProvider(arkServerUrl);
|
|
19444
19491
|
await this.onWalletInitialized();
|
|
19445
19492
|
}
|
|
19446
19493
|
/** @see RequestInitWallet.payload.lazyBoarding */
|
|
@@ -19909,7 +19956,7 @@ var WalletMessageHandler = class {
|
|
|
19909
19956
|
this.readonlyWallet.getBoardingTxs()
|
|
19910
19957
|
]);
|
|
19911
19958
|
const indexerProvider = this.indexerProvider;
|
|
19912
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
19959
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkKW7ZEWYS_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
19913
19960
|
return buildTransactionHistory(
|
|
19914
19961
|
vtxos,
|
|
19915
19962
|
boardingTxs,
|
|
@@ -19978,7 +20025,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
19978
20025
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
19979
20026
|
// page deadline fires — lowering it below the budget would time the page
|
|
19980
20027
|
// out while the worker is still seconds from answering from cache.
|
|
19981
|
-
GET_ARKADE_INFO:
|
|
20028
|
+
GET_ARKADE_INFO: chunkKW7ZEWYS_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
19982
20029
|
INDEXER_GET_VTXOS: 2e4,
|
|
19983
20030
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
19984
20031
|
GET_VTXOS: 2e4,
|
|
@@ -20123,7 +20170,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
|
|
|
20123
20170
|
}
|
|
20124
20171
|
};
|
|
20125
20172
|
var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
|
|
20126
|
-
|
|
20173
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
|
|
20127
20174
|
const initCmd = {
|
|
20128
20175
|
tag: "INITIALIZE_MESSAGE_BUS",
|
|
20129
20176
|
id: getRandomId(),
|
|
@@ -20211,7 +20258,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20211
20258
|
}
|
|
20212
20259
|
/** Shared tail of both `create()` factories: boot the bus, INIT_WALLET, cache for reinit. */
|
|
20213
20260
|
static async bootstrap(wallet, options, serializedWallet, busConfig) {
|
|
20214
|
-
const arkServer = options.arkServer ?? { url:
|
|
20261
|
+
const arkServer = options.arkServer ?? { url: chunkKW7ZEWYS_cjs.DEFAULT_ARKADE_SERVER_URL };
|
|
20215
20262
|
const initWalletPayload = {
|
|
20216
20263
|
lazyBoarding: options.lazyBoarding,
|
|
20217
20264
|
arkServerUrl: arkServer.url,
|
|
@@ -20221,7 +20268,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20221
20268
|
Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
|
|
20222
20269
|
);
|
|
20223
20270
|
for (const [key, value] of Object.entries(overrides)) {
|
|
20224
|
-
|
|
20271
|
+
chunkKW7ZEWYS_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
|
|
20225
20272
|
}
|
|
20226
20273
|
const messageTimeouts = {
|
|
20227
20274
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -20561,7 +20608,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20561
20608
|
try {
|
|
20562
20609
|
const response = await this.sendMessage(message);
|
|
20563
20610
|
const { vtxos, page } = response.payload;
|
|
20564
|
-
return { vtxos: vtxos.map(
|
|
20611
|
+
return { vtxos: vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo), page: page && { ...page } };
|
|
20565
20612
|
} catch (cause) {
|
|
20566
20613
|
throw new Error(`Failed to get vtxos: ${cause}`, { cause });
|
|
20567
20614
|
}
|
|
@@ -20670,7 +20717,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20670
20717
|
};
|
|
20671
20718
|
try {
|
|
20672
20719
|
const response = await this.sendMessage(message);
|
|
20673
|
-
return response.payload.vtxos.map(
|
|
20720
|
+
return response.payload.vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
20674
20721
|
} catch (error) {
|
|
20675
20722
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
20676
20723
|
}
|
|
@@ -20701,7 +20748,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20701
20748
|
"Service worker does not support the requested contract scope or freshness check"
|
|
20702
20749
|
);
|
|
20703
20750
|
}
|
|
20704
|
-
return payload.vtxos.map(
|
|
20751
|
+
return payload.vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
20705
20752
|
} catch (error) {
|
|
20706
20753
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
20707
20754
|
}
|
|
@@ -20896,7 +20943,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20896
20943
|
};
|
|
20897
20944
|
try {
|
|
20898
20945
|
const response = await sendContractMessage(message);
|
|
20899
|
-
return response.payload.vtxos.map(
|
|
20946
|
+
return response.payload.vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
20900
20947
|
} catch (cause) {
|
|
20901
20948
|
throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
|
|
20902
20949
|
}
|
|
@@ -21093,9 +21140,10 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
21093
21140
|
}
|
|
21094
21141
|
};
|
|
21095
21142
|
var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadonlyWallet {
|
|
21096
|
-
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegate) {
|
|
21143
|
+
constructor(serviceWorker, identity, walletRepository, contractRepository, messageTag, hasDelegate, oneShotSubmit) {
|
|
21097
21144
|
super(serviceWorker, identity, walletRepository, contractRepository, messageTag);
|
|
21098
21145
|
this.serviceWorker = serviceWorker;
|
|
21146
|
+
this.oneShotSubmit = oneShotSubmit;
|
|
21099
21147
|
this.identity = identity;
|
|
21100
21148
|
this.walletRepository = walletRepository;
|
|
21101
21149
|
this.contractRepository = contractRepository;
|
|
@@ -21106,6 +21154,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21106
21154
|
this.hasDelegate = hasDelegate;
|
|
21107
21155
|
}
|
|
21108
21156
|
serviceWorker;
|
|
21157
|
+
oneShotSubmit;
|
|
21109
21158
|
walletRepository;
|
|
21110
21159
|
contractRepository;
|
|
21111
21160
|
identity;
|
|
@@ -21142,7 +21191,8 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21142
21191
|
walletRepository,
|
|
21143
21192
|
contractRepository,
|
|
21144
21193
|
messageTag,
|
|
21145
|
-
!!options.delegateUrl
|
|
21194
|
+
!!options.delegateUrl,
|
|
21195
|
+
options.oneShotSubmit
|
|
21146
21196
|
);
|
|
21147
21197
|
wallet._concurrentSpending = options.concurrentSpending === true;
|
|
21148
21198
|
return _ServiceWorkerWallet.bootstrap(wallet, options, serializedWallet, {
|
|
@@ -21153,6 +21203,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21153
21203
|
lazyInitialization: options.lazyInitialization,
|
|
21154
21204
|
watcherConfig: options.watcherConfig,
|
|
21155
21205
|
lookAheadWindow: options.lookAheadWindow,
|
|
21206
|
+
oneShotSubmit: options.oneShotSubmit,
|
|
21156
21207
|
minBatchExpirySeconds: options.minBatchExpirySeconds
|
|
21157
21208
|
});
|
|
21158
21209
|
}
|
|
@@ -21536,7 +21587,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21536
21587
|
};
|
|
21537
21588
|
try {
|
|
21538
21589
|
const response = await wallet.sendMessage(message);
|
|
21539
|
-
return response.payload.vtxos.map(
|
|
21590
|
+
return response.payload.vtxos.map(chunkKW7ZEWYS_cjs.normalizeVtxo);
|
|
21540
21591
|
} catch (e) {
|
|
21541
21592
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
21542
21593
|
}
|
|
@@ -21653,12 +21704,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21653
21704
|
* @returns Configured onchain wallet
|
|
21654
21705
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
21655
21706
|
*/
|
|
21656
|
-
static async create(identity, networkName =
|
|
21707
|
+
static async create(identity, networkName = chunkKW7ZEWYS_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
21657
21708
|
const pubkey = await identity.xOnlyPublicKey();
|
|
21658
21709
|
if (!pubkey) {
|
|
21659
21710
|
throw new Error("Invalid configured public key");
|
|
21660
21711
|
}
|
|
21661
|
-
const network =
|
|
21712
|
+
const network = chunkKW7ZEWYS_cjs.getNetwork(networkName);
|
|
21662
21713
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
21663
21714
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
21664
21715
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -21758,7 +21809,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21758
21809
|
feeRate,
|
|
21759
21810
|
params.address
|
|
21760
21811
|
);
|
|
21761
|
-
let tx = new
|
|
21812
|
+
let tx = new chunkKW7ZEWYS_cjs.Transaction();
|
|
21762
21813
|
for (const input of inputs) {
|
|
21763
21814
|
tx.addInput({
|
|
21764
21815
|
txid: input.txid,
|
|
@@ -21816,7 +21867,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21816
21867
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
21817
21868
|
*/
|
|
21818
21869
|
async bumpAnchor(parentHex, feeRate) {
|
|
21819
|
-
const parent =
|
|
21870
|
+
const parent = chunkKW7ZEWYS_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
21820
21871
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
21821
21872
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
21822
21873
|
return [parent.hex, child.hex];
|
|
@@ -22643,7 +22694,7 @@ var CachingArkProvider = class {
|
|
|
22643
22694
|
constructor(inner, ttlMs = DEFAULT_TTL_MS) {
|
|
22644
22695
|
this.inner = inner;
|
|
22645
22696
|
this.ttlMs = ttlMs;
|
|
22646
|
-
|
|
22697
|
+
chunkKW7ZEWYS_cjs.assertNonNegativeMs("ttlMs", ttlMs);
|
|
22647
22698
|
this.unsubscribe = inner.onServerInfoChanged?.((info) => {
|
|
22648
22699
|
this.cached = info;
|
|
22649
22700
|
this.expiresAt = Date.now() + this.ttlMs;
|
|
@@ -22735,7 +22786,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22735
22786
|
try {
|
|
22736
22787
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
22737
22788
|
for (const psbt of txs) {
|
|
22738
|
-
const tx =
|
|
22789
|
+
const tx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
22739
22790
|
resolved.set(tx.id, tx.toBytes());
|
|
22740
22791
|
}
|
|
22741
22792
|
} catch (err) {
|
|
@@ -22768,7 +22819,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22768
22819
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
22769
22820
|
const pending = [];
|
|
22770
22821
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22771
|
-
if (
|
|
22822
|
+
if (chunkKW7ZEWYS_cjs.getArkPsbtFields(tx, i, chunkKW7ZEWYS_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
22772
22823
|
}
|
|
22773
22824
|
if (pending.length === 0) return;
|
|
22774
22825
|
const resolved = await resolvePrevTxs(
|
|
@@ -22777,13 +22828,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
22777
22828
|
onchain
|
|
22778
22829
|
);
|
|
22779
22830
|
for (const i of pending) {
|
|
22780
|
-
|
|
22831
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(tx, i, chunkKW7ZEWYS_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
22781
22832
|
}
|
|
22782
22833
|
}
|
|
22783
22834
|
async function attachPrevoutTxs(tx, source) {
|
|
22784
22835
|
const pending = [];
|
|
22785
22836
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22786
|
-
if (
|
|
22837
|
+
if (chunkKW7ZEWYS_cjs.getArkPsbtFields(tx, i, chunkKW7ZEWYS_cjs.PrevoutTxField).length > 0) continue;
|
|
22787
22838
|
const input = tx.getInput(i);
|
|
22788
22839
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
22789
22840
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -22798,7 +22849,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
22798
22849
|
resolved.set(txids[i], result.value);
|
|
22799
22850
|
}
|
|
22800
22851
|
for (const { index, txid } of pending) {
|
|
22801
|
-
|
|
22852
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(tx, index, chunkKW7ZEWYS_cjs.PrevoutTxField, resolved.get(txid));
|
|
22802
22853
|
}
|
|
22803
22854
|
}
|
|
22804
22855
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -22824,7 +22875,7 @@ exports.BIP322 = void 0;
|
|
|
22824
22875
|
async function sign2(message, identity, network) {
|
|
22825
22876
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
22826
22877
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
22827
|
-
const toSpend =
|
|
22878
|
+
const toSpend = chunkKW7ZEWYS_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
22828
22879
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
22829
22880
|
const signed = await identity.sign(toSign, [0]);
|
|
22830
22881
|
signed.finalizeIdx(0);
|
|
@@ -22882,7 +22933,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
22882
22933
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
22883
22934
|
return false;
|
|
22884
22935
|
}
|
|
22885
|
-
const toSpend =
|
|
22936
|
+
const toSpend = chunkKW7ZEWYS_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22886
22937
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
|
|
22887
22938
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
22888
22939
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -22903,7 +22954,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
22903
22954
|
}
|
|
22904
22955
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
22905
22956
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
22906
|
-
const toSpend =
|
|
22957
|
+
const toSpend = chunkKW7ZEWYS_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22907
22958
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
22908
22959
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
22909
22960
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -22956,7 +23007,7 @@ function encodeCompactSize(n) {
|
|
|
22956
23007
|
return buf;
|
|
22957
23008
|
}
|
|
22958
23009
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
22959
|
-
const tx = new
|
|
23010
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction({ version: 0 });
|
|
22960
23011
|
tx.addInput({
|
|
22961
23012
|
txid: toSpend.id,
|
|
22962
23013
|
index: 0,
|
|
@@ -22970,12 +23021,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
22970
23021
|
});
|
|
22971
23022
|
tx.addOutput({
|
|
22972
23023
|
amount: 0n,
|
|
22973
|
-
script:
|
|
23024
|
+
script: chunkKW7ZEWYS_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22974
23025
|
});
|
|
22975
23026
|
return tx;
|
|
22976
23027
|
}
|
|
22977
23028
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
22978
|
-
const tx = new
|
|
23029
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction({ version: 0 });
|
|
22979
23030
|
tx.addInput({
|
|
22980
23031
|
txid: toSpend.id,
|
|
22981
23032
|
index: 0,
|
|
@@ -22987,12 +23038,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
22987
23038
|
});
|
|
22988
23039
|
tx.addOutput({
|
|
22989
23040
|
amount: 0n,
|
|
22990
|
-
script:
|
|
23041
|
+
script: chunkKW7ZEWYS_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22991
23042
|
});
|
|
22992
23043
|
return tx;
|
|
22993
23044
|
}
|
|
22994
23045
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
22995
|
-
const tx =
|
|
23046
|
+
const tx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
22996
23047
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
22997
23048
|
const input = tx.getInput(0);
|
|
22998
23049
|
if (!input) {
|
|
@@ -23019,14 +23070,14 @@ var ExitPathError = class extends Error {
|
|
|
23019
23070
|
reason;
|
|
23020
23071
|
};
|
|
23021
23072
|
function delayWeight(sequence) {
|
|
23022
|
-
const t =
|
|
23073
|
+
const t = chunkKW7ZEWYS_cjs.sequenceToTimelock(sequence);
|
|
23023
23074
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
23024
23075
|
}
|
|
23025
23076
|
async function resolveUnilateralPath(params) {
|
|
23026
23077
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
23027
23078
|
const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
|
|
23028
23079
|
if (contract) {
|
|
23029
|
-
const handler =
|
|
23080
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
23030
23081
|
if (!handler) {
|
|
23031
23082
|
throw new ExitPathError(
|
|
23032
23083
|
"no-handler",
|
|
@@ -23048,12 +23099,12 @@ async function resolveUnilateralPath(params) {
|
|
|
23048
23099
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
23049
23100
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
23050
23101
|
}
|
|
23051
|
-
const decoded =
|
|
23102
|
+
const decoded = chunkKW7ZEWYS_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
23052
23103
|
let best;
|
|
23053
23104
|
for (const exit of decoded.exitPaths()) {
|
|
23054
23105
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
23055
23106
|
if (!leaf) continue;
|
|
23056
|
-
const sequence =
|
|
23107
|
+
const sequence = chunkKW7ZEWYS_cjs.timelockToSequence(exit.params.timelock);
|
|
23057
23108
|
const weight = delayWeight(sequence);
|
|
23058
23109
|
if (!best || weight < best.weight) {
|
|
23059
23110
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -23262,7 +23313,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23262
23313
|
let totalAmount = 0n;
|
|
23263
23314
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
23264
23315
|
for (const vtxo of vtxos) {
|
|
23265
|
-
if (!
|
|
23316
|
+
if (!chunkKW7ZEWYS_cjs.canSweepOnchain(vtxo)) {
|
|
23266
23317
|
throw new Error(
|
|
23267
23318
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
23268
23319
|
);
|
|
@@ -23274,7 +23325,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23274
23325
|
wallet.onchainProvider.getTxStatus(vtxo.txid),
|
|
23275
23326
|
resolveUnilateralPath({
|
|
23276
23327
|
vtxo,
|
|
23277
|
-
scriptHex: base.hex.encode(
|
|
23328
|
+
scriptHex: base.hex.encode(chunkKW7ZEWYS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
23278
23329
|
contractRepository: wallet.contractRepository,
|
|
23279
23330
|
walletDescriptor,
|
|
23280
23331
|
currentTime: Date.now()
|
|
@@ -23285,7 +23336,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23285
23336
|
}
|
|
23286
23337
|
const spendingLeaf = resolved.selection.leaf;
|
|
23287
23338
|
const sequence = resolved.selection.sequence;
|
|
23288
|
-
const timelock =
|
|
23339
|
+
const timelock = chunkKW7ZEWYS_cjs.sequenceToTimelock(sequence);
|
|
23289
23340
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
23290
23341
|
if (!elapsed) {
|
|
23291
23342
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -23304,7 +23355,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23304
23355
|
sequence,
|
|
23305
23356
|
witnessUtxo: {
|
|
23306
23357
|
amount: BigInt(vtxo.value),
|
|
23307
|
-
script:
|
|
23358
|
+
script: chunkKW7ZEWYS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
23308
23359
|
},
|
|
23309
23360
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
23310
23361
|
});
|
|
@@ -23314,7 +23365,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23314
23365
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
23315
23366
|
);
|
|
23316
23367
|
}
|
|
23317
|
-
const tx = new
|
|
23368
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction({ version: 2 });
|
|
23318
23369
|
for (const input of inputs) {
|
|
23319
23370
|
tx.addInput(input);
|
|
23320
23371
|
}
|
|
@@ -23397,7 +23448,7 @@ async function buildSignedSweep(params) {
|
|
|
23397
23448
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
23398
23449
|
);
|
|
23399
23450
|
}
|
|
23400
|
-
const tx = new
|
|
23451
|
+
const tx = new chunkKW7ZEWYS_cjs.Transaction({ version: 2 });
|
|
23401
23452
|
tx.addInput({
|
|
23402
23453
|
txid: vtxo.txid,
|
|
23403
23454
|
index: vtxo.vout,
|
|
@@ -23422,7 +23473,7 @@ async function buildSignedSweep(params) {
|
|
|
23422
23473
|
finalScriptWitness: [
|
|
23423
23474
|
tapScriptSig[0][1],
|
|
23424
23475
|
...path.extraWitness,
|
|
23425
|
-
|
|
23476
|
+
chunkKW7ZEWYS_cjs.scriptFromTapLeafScript(path.leaf),
|
|
23426
23477
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
23427
23478
|
]
|
|
23428
23479
|
});
|
|
@@ -23452,7 +23503,7 @@ async function resolveFeeRate(opts) {
|
|
|
23452
23503
|
}
|
|
23453
23504
|
async function selectExitVtxos(opts) {
|
|
23454
23505
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
23455
|
-
const res = await
|
|
23506
|
+
const res = await chunkKW7ZEWYS_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
23456
23507
|
const scripts = [
|
|
23457
23508
|
...new Set(res.vtxos.filter((vtxo) => !vtxo.isSpent).map((vtxo) => vtxo.script))
|
|
23458
23509
|
];
|
|
@@ -23470,7 +23521,7 @@ async function selectExitVtxos(opts) {
|
|
|
23470
23521
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
23471
23522
|
);
|
|
23472
23523
|
}
|
|
23473
|
-
const handler =
|
|
23524
|
+
const handler = chunkBYPBVHVA_cjs.contractHandlers.get(contract.type);
|
|
23474
23525
|
if (!handler) {
|
|
23475
23526
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
23476
23527
|
}
|
|
@@ -23504,7 +23555,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23504
23555
|
if (pendingNodes.length > 0) {
|
|
23505
23556
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
23506
23557
|
for (const psbt of txs) {
|
|
23507
|
-
psbts.set(
|
|
23558
|
+
psbts.set(chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
23508
23559
|
}
|
|
23509
23560
|
}
|
|
23510
23561
|
const childVsize = Number(
|
|
@@ -23532,7 +23583,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23532
23583
|
vtxo,
|
|
23533
23584
|
resolved: await resolveUnilateralPath({
|
|
23534
23585
|
vtxo,
|
|
23535
|
-
scriptHex: base.hex.encode(
|
|
23586
|
+
scriptHex: base.hex.encode(chunkKW7ZEWYS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
23536
23587
|
contractRepository: wallet.contractRepository,
|
|
23537
23588
|
walletDescriptor,
|
|
23538
23589
|
currentTime: Date.now()
|
|
@@ -23569,7 +23620,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23569
23620
|
});
|
|
23570
23621
|
continue;
|
|
23571
23622
|
}
|
|
23572
|
-
const t =
|
|
23623
|
+
const t = chunkKW7ZEWYS_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
23573
23624
|
const delay = { type: t.type, value: Number(t.value) };
|
|
23574
23625
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
23575
23626
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -23669,7 +23720,7 @@ var Executor = class {
|
|
|
23669
23720
|
constructor(pkg, provider, opts) {
|
|
23670
23721
|
this.pkg = pkg;
|
|
23671
23722
|
this.provider = provider;
|
|
23672
|
-
|
|
23723
|
+
chunkKW7ZEWYS_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
|
|
23673
23724
|
this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
|
|
23674
23725
|
this.feeWallet = opts?.feeWallet;
|
|
23675
23726
|
this.signal = opts?.signal;
|
|
@@ -23964,7 +24015,7 @@ async function prepare(opts) {
|
|
|
23964
24015
|
txid: sweep.vtxo.txid,
|
|
23965
24016
|
vout: sweep.vtxo.vout,
|
|
23966
24017
|
value: sweep.vtxo.value,
|
|
23967
|
-
pkScript:
|
|
24018
|
+
pkScript: chunkKW7ZEWYS_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
23968
24019
|
},
|
|
23969
24020
|
path: sweep.resolved.selection,
|
|
23970
24021
|
outputAddress: opts.sweepAddress,
|
|
@@ -24053,7 +24104,7 @@ async function prepare(opts) {
|
|
|
24053
24104
|
if (newFee <= splitterFee) break;
|
|
24054
24105
|
splitterFee = newFee;
|
|
24055
24106
|
}
|
|
24056
|
-
const splitter = new
|
|
24107
|
+
const splitter = new chunkKW7ZEWYS_cjs.Transaction({ version: 2 });
|
|
24057
24108
|
for (const coin of selected.inputs) {
|
|
24058
24109
|
splitter.addInput({
|
|
24059
24110
|
txid: coin.txid,
|
|
@@ -24192,46 +24243,46 @@ var UnilateralExit = {
|
|
|
24192
24243
|
|
|
24193
24244
|
// src/arkade/index.ts
|
|
24194
24245
|
var arkade_exports = {};
|
|
24195
|
-
|
|
24196
|
-
ARKADE_OP: () =>
|
|
24197
|
-
ARKADE_OPCODES: () =>
|
|
24198
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
24199
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
24200
|
-
ARKADE_OPS: () =>
|
|
24246
|
+
chunkKW7ZEWYS_cjs.__export(arkade_exports, {
|
|
24247
|
+
ARKADE_OP: () => chunkBYPBVHVA_cjs.ARKADE_OP,
|
|
24248
|
+
ARKADE_OPCODES: () => chunkBYPBVHVA_cjs.ARKADE_OPCODES,
|
|
24249
|
+
ARKADE_OPCODE_NAMES: () => chunkBYPBVHVA_cjs.ARKADE_OPCODE_NAMES,
|
|
24250
|
+
ARKADE_OPCODE_VALUES: () => chunkBYPBVHVA_cjs.ARKADE_OPCODE_VALUES,
|
|
24251
|
+
ARKADE_OPS: () => chunkBYPBVHVA_cjs.ARKADE_OPS,
|
|
24201
24252
|
Arkade: () => Arkade,
|
|
24202
24253
|
ArkadeContract: () => ArkadeContract,
|
|
24203
|
-
ArkadeProgramScript: () =>
|
|
24204
|
-
ArkadeScript: () =>
|
|
24254
|
+
ArkadeProgramScript: () => chunkBYPBVHVA_cjs.ArkadeProgramScript,
|
|
24255
|
+
ArkadeScript: () => chunkBYPBVHVA_cjs.ArkadeScript,
|
|
24205
24256
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
24206
|
-
BigNum: () =>
|
|
24257
|
+
BigNum: () => chunkBYPBVHVA_cjs.bignum_exports,
|
|
24207
24258
|
OP: () => btcSigner.OP,
|
|
24208
|
-
OPCODE_NAMES: () =>
|
|
24209
|
-
OPCODE_VALUES: () =>
|
|
24210
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
24259
|
+
OPCODE_NAMES: () => chunkBYPBVHVA_cjs.OPCODE_NAMES,
|
|
24260
|
+
OPCODE_VALUES: () => chunkBYPBVHVA_cjs.OPCODE_VALUES,
|
|
24261
|
+
SUPPORTED_PROGRAM_VERSION: () => chunkBYPBVHVA_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
24211
24262
|
Script: () => btcSigner.Script,
|
|
24212
|
-
UnsupportedProgramVersionError: () =>
|
|
24213
|
-
arkadeScriptHash: () =>
|
|
24214
|
-
arkadeWitnessHash: () =>
|
|
24215
|
-
asmToBytes: () =>
|
|
24216
|
-
bytesToASM: () =>
|
|
24217
|
-
computeArkadeScriptPublicKey: () =>
|
|
24263
|
+
UnsupportedProgramVersionError: () => chunkBYPBVHVA_cjs.UnsupportedProgramVersionError,
|
|
24264
|
+
arkadeScriptHash: () => chunkBYPBVHVA_cjs.arkadeScriptHash,
|
|
24265
|
+
arkadeWitnessHash: () => chunkBYPBVHVA_cjs.arkadeWitnessHash,
|
|
24266
|
+
asmToBytes: () => chunkBYPBVHVA_cjs.asmToBytes,
|
|
24267
|
+
bytesToASM: () => chunkBYPBVHVA_cjs.bytesToASM,
|
|
24268
|
+
computeArkadeScriptPublicKey: () => chunkBYPBVHVA_cjs.computeArkadeScriptPublicKey,
|
|
24218
24269
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
24219
|
-
deserializeArkadeContractParams: () =>
|
|
24220
|
-
fromASM: () =>
|
|
24221
|
-
getOpcodeName: () =>
|
|
24222
|
-
getOpcodeValue: () =>
|
|
24270
|
+
deserializeArkadeContractParams: () => chunkBYPBVHVA_cjs.deserializeArkadeContractParams,
|
|
24271
|
+
fromASM: () => chunkBYPBVHVA_cjs.fromASM,
|
|
24272
|
+
getOpcodeName: () => chunkBYPBVHVA_cjs.getOpcodeName,
|
|
24273
|
+
getOpcodeValue: () => chunkBYPBVHVA_cjs.getOpcodeValue,
|
|
24223
24274
|
isContractArtifact: () => isContractArtifact,
|
|
24224
|
-
parseArtifact: () =>
|
|
24275
|
+
parseArtifact: () => chunkBYPBVHVA_cjs.parseArtifact,
|
|
24225
24276
|
programFromArtifact: () => programFromArtifact,
|
|
24226
24277
|
resolveArkadeService: () => resolveArkadeService,
|
|
24227
|
-
resolveAsm: () =>
|
|
24228
|
-
serializeArkadeContractParams: () =>
|
|
24229
|
-
stringifyArtifact: () =>
|
|
24230
|
-
toASM: () =>
|
|
24231
|
-
validateProgram: () =>
|
|
24232
|
-
witnessRefToBytes: () =>
|
|
24278
|
+
resolveAsm: () => chunkBYPBVHVA_cjs.resolveAsm,
|
|
24279
|
+
serializeArkadeContractParams: () => chunkBYPBVHVA_cjs.serializeArkadeContractParams,
|
|
24280
|
+
stringifyArtifact: () => chunkBYPBVHVA_cjs.stringifyArtifact,
|
|
24281
|
+
toASM: () => chunkBYPBVHVA_cjs.toASM,
|
|
24282
|
+
validateProgram: () => chunkBYPBVHVA_cjs.validateProgram,
|
|
24283
|
+
witnessRefToBytes: () => chunkBYPBVHVA_cjs.witnessRefToBytes
|
|
24233
24284
|
});
|
|
24234
|
-
var isVtxoCoin = (input) =>
|
|
24285
|
+
var isVtxoCoin = (input) => chunkKW7ZEWYS_cjs.isVirtualCoin(input);
|
|
24235
24286
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
24236
24287
|
let batchId;
|
|
24237
24288
|
let sweepTapTreeRoot;
|
|
@@ -24252,23 +24303,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24252
24303
|
);
|
|
24253
24304
|
await arkProvider.confirmRegistration(intentId);
|
|
24254
24305
|
batchId = event.id;
|
|
24255
|
-
const sweepTapscript =
|
|
24306
|
+
const sweepTapscript = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.encode({
|
|
24256
24307
|
timelock,
|
|
24257
|
-
pubkeys: [
|
|
24308
|
+
pubkeys: [chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
24258
24309
|
}).script;
|
|
24259
24310
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
24260
24311
|
return { skip: false };
|
|
24261
24312
|
},
|
|
24262
24313
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
24263
24314
|
const signerPubKey = await session.getPublicKey();
|
|
24264
|
-
const xonlySignerPubKey =
|
|
24315
|
+
const xonlySignerPubKey = chunkBYPBVHVA_cjs.toXOnly(signerPubKey, "signer key");
|
|
24265
24316
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
24266
|
-
(k) => base.hex.encode(
|
|
24317
|
+
(k) => base.hex.encode(chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
24267
24318
|
);
|
|
24268
24319
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
24269
24320
|
return { skip: true };
|
|
24270
24321
|
}
|
|
24271
|
-
const commitmentTx =
|
|
24322
|
+
const commitmentTx = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
24272
24323
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
24273
24324
|
if (recipients && recipients.length > 0) {
|
|
24274
24325
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -24306,7 +24357,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24306
24357
|
if (connectorTree) {
|
|
24307
24358
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
24308
24359
|
}
|
|
24309
|
-
let commitmentPsbt =
|
|
24360
|
+
let commitmentPsbt = chunkKW7ZEWYS_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
24310
24361
|
assertFinalCommitmentMatchesValidated(
|
|
24311
24362
|
commitmentPsbt,
|
|
24312
24363
|
validatedCommitmentTxid,
|
|
@@ -24348,7 +24399,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24348
24399
|
boardingIndices.push(boardingIdx);
|
|
24349
24400
|
continue;
|
|
24350
24401
|
}
|
|
24351
|
-
if (!
|
|
24402
|
+
if (!chunkKW7ZEWYS_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
24352
24403
|
continue;
|
|
24353
24404
|
}
|
|
24354
24405
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -24369,7 +24420,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24369
24420
|
index: input.vout,
|
|
24370
24421
|
witnessUtxo: {
|
|
24371
24422
|
amount: BigInt(input.value),
|
|
24372
|
-
script:
|
|
24423
|
+
script: chunkKW7ZEWYS_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
24373
24424
|
},
|
|
24374
24425
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
24375
24426
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -24480,7 +24531,7 @@ function inputDef(name, type) {
|
|
|
24480
24531
|
return { name, type: argType(type) };
|
|
24481
24532
|
}
|
|
24482
24533
|
function argType(arkType) {
|
|
24483
|
-
if (!Object.hasOwn(
|
|
24534
|
+
if (!Object.hasOwn(chunkBYPBVHVA_cjs.ARKADE_TYPE_ENCODINGS, arkType)) fail(`unknown type '${arkType}'`);
|
|
24484
24535
|
return arkType;
|
|
24485
24536
|
}
|
|
24486
24537
|
function arrayParts(type) {
|
|
@@ -24521,7 +24572,7 @@ function flatten(param, structs, stack = []) {
|
|
|
24521
24572
|
function opcodeToken(token) {
|
|
24522
24573
|
const base = token.slice(3);
|
|
24523
24574
|
const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
|
|
24524
|
-
if (!Object.hasOwn(
|
|
24575
|
+
if (!Object.hasOwn(chunkBYPBVHVA_cjs.ARKADE_OPS, name)) {
|
|
24525
24576
|
fail(`opcode '${token}' is not in this SDK's table`);
|
|
24526
24577
|
}
|
|
24527
24578
|
return name;
|
|
@@ -24568,7 +24619,7 @@ function providedWitness(witness) {
|
|
|
24568
24619
|
fail(`witness '${item.name}': injected must be boolean`);
|
|
24569
24620
|
if (item.injected && item.type !== "signature")
|
|
24570
24621
|
fail(`witness '${item.name}': only infrastructure signatures can be injected`);
|
|
24571
|
-
if (item.encoding !== void 0 && item.encoding !==
|
|
24622
|
+
if (item.encoding !== void 0 && item.encoding !== chunkBYPBVHVA_cjs.ARKADE_TYPE_ENCODINGS[type])
|
|
24572
24623
|
fail(
|
|
24573
24624
|
`witness '${item.name}': encoding '${item.encoding}' does not match type '${item.type}'`
|
|
24574
24625
|
);
|
|
@@ -24577,7 +24628,7 @@ function providedWitness(witness) {
|
|
|
24577
24628
|
}
|
|
24578
24629
|
function csvTimelock(leafName, operand) {
|
|
24579
24630
|
if (typeof operand === "string") return { type: "sequence", value: operand };
|
|
24580
|
-
const timelock =
|
|
24631
|
+
const timelock = chunkKW7ZEWYS_cjs.sequenceToCanonicalTimelock(operand);
|
|
24581
24632
|
if (!timelock) {
|
|
24582
24633
|
fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
|
|
24583
24634
|
}
|
|
@@ -24671,7 +24722,7 @@ function programFromArtifact(artifact) {
|
|
|
24671
24722
|
if (!isNamed(field)) fail(`struct '${struct.name}': field needs a name and type`);
|
|
24672
24723
|
claim(fields, field.name, "struct field");
|
|
24673
24724
|
}
|
|
24674
|
-
if (Object.hasOwn(
|
|
24725
|
+
if (Object.hasOwn(chunkBYPBVHVA_cjs.ARKADE_TYPE_ENCODINGS, struct.name) || Object.hasOwn(NATIVE_STRUCTS, struct.name)) {
|
|
24675
24726
|
fail(`struct name '${struct.name}' shadows a built-in type`);
|
|
24676
24727
|
}
|
|
24677
24728
|
claim(structNames, struct.name, "struct");
|
|
@@ -24754,7 +24805,7 @@ function programFromArtifact(artifact) {
|
|
|
24754
24805
|
const paramNames = /* @__PURE__ */ new Set();
|
|
24755
24806
|
for (const param of params) claim(paramNames, param.name, "program parameter");
|
|
24756
24807
|
return {
|
|
24757
|
-
version:
|
|
24808
|
+
version: chunkBYPBVHVA_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
24758
24809
|
name: artifact.contractName,
|
|
24759
24810
|
params,
|
|
24760
24811
|
functions
|
|
@@ -24782,6 +24833,7 @@ var Arkade = class _Arkade {
|
|
|
24782
24833
|
userKey;
|
|
24783
24834
|
/** The contract manager, when contract persistence is wired up (passed in or owned). */
|
|
24784
24835
|
contractManager;
|
|
24836
|
+
oneShotSubmit;
|
|
24785
24837
|
/** Whether {@link connect} built {@link contractManager}, so {@link dispose} must stop it. */
|
|
24786
24838
|
ownsContractManager;
|
|
24787
24839
|
/** {@link ArkadeContract.on} handles by contract script (hex). */
|
|
@@ -24801,6 +24853,7 @@ var Arkade = class _Arkade {
|
|
|
24801
24853
|
this.identity = fields.identity;
|
|
24802
24854
|
this.userKey = fields.userKey;
|
|
24803
24855
|
this.contractManager = fields.contractManager;
|
|
24856
|
+
this.oneShotSubmit = fields.oneShotSubmit;
|
|
24804
24857
|
this.ownsContractManager = fields.ownsContractManager ?? false;
|
|
24805
24858
|
}
|
|
24806
24859
|
/**
|
|
@@ -24836,16 +24889,16 @@ var Arkade = class _Arkade {
|
|
|
24836
24889
|
indexer = opts.indexer;
|
|
24837
24890
|
info = await opts.arkade.getInfo();
|
|
24838
24891
|
}
|
|
24839
|
-
const serverKey =
|
|
24840
|
-
const checkpoint =
|
|
24841
|
-
const network = opts.network ?? (Object.hasOwn(
|
|
24892
|
+
const serverKey = chunkBYPBVHVA_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
24893
|
+
const checkpoint = chunkKW7ZEWYS_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
24894
|
+
const network = opts.network ?? (Object.hasOwn(chunkKW7ZEWYS_cjs.networks, info.network) ? chunkKW7ZEWYS_cjs.getNetwork(info.network) : chunkKW7ZEWYS_cjs.DEFAULT_NETWORK);
|
|
24842
24895
|
let emulatorKey;
|
|
24843
24896
|
if (emulator) {
|
|
24844
|
-
emulatorKey = base.hex.decode(
|
|
24897
|
+
emulatorKey = base.hex.decode(chunkKW7ZEWYS_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
24845
24898
|
}
|
|
24846
24899
|
let userKey;
|
|
24847
24900
|
if (opts.identity) {
|
|
24848
|
-
userKey =
|
|
24901
|
+
userKey = chunkBYPBVHVA_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
24849
24902
|
}
|
|
24850
24903
|
let contractManager = opts.contractManager;
|
|
24851
24904
|
let ownsContractManager = false;
|
|
@@ -24877,7 +24930,8 @@ var Arkade = class _Arkade {
|
|
|
24877
24930
|
identity: opts.identity,
|
|
24878
24931
|
userKey,
|
|
24879
24932
|
contractManager,
|
|
24880
|
-
ownsContractManager
|
|
24933
|
+
ownsContractManager,
|
|
24934
|
+
oneShotSubmit: opts.oneShotSubmit
|
|
24881
24935
|
});
|
|
24882
24936
|
}
|
|
24883
24937
|
/**
|
|
@@ -24964,7 +25018,7 @@ var Arkade = class _Arkade {
|
|
|
24964
25018
|
`compiler artifact: server exit delay ${delay}s must be a multiple of 512 seconds`
|
|
24965
25019
|
);
|
|
24966
25020
|
}
|
|
24967
|
-
const sequence = BigInt(
|
|
25021
|
+
const sequence = BigInt(chunkKW7ZEWYS_cjs.timelockToSequence(typed));
|
|
24968
25022
|
if (args.SERVER_EXIT_DELAY !== void 0 && args.SERVER_EXIT_DELAY !== sequence && args.SERVER_EXIT_DELAY !== Number(sequence)) {
|
|
24969
25023
|
throw new Error(
|
|
24970
25024
|
"compiler artifact: reserved SERVER_EXIT_DELAY must match the connected server"
|
|
@@ -24992,7 +25046,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24992
25046
|
userKey: client.userKey,
|
|
24993
25047
|
emulatorKey: client.emulatorKey
|
|
24994
25048
|
};
|
|
24995
|
-
this.vtxoScript = new
|
|
25049
|
+
this.vtxoScript = new chunkBYPBVHVA_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
24996
25050
|
this.tapTree = this.vtxoScript.encode();
|
|
24997
25051
|
this.compiled = this.vtxoScript.compiled;
|
|
24998
25052
|
}
|
|
@@ -25017,7 +25071,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
25017
25071
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
25018
25072
|
);
|
|
25019
25073
|
}
|
|
25020
|
-
const typed =
|
|
25074
|
+
const typed = chunkBYPBVHVA_cjs.deserializeArkadeContractParams(contract.params);
|
|
25021
25075
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
25022
25076
|
serverKey: typed.serverKey,
|
|
25023
25077
|
userKey: typed.userKey,
|
|
@@ -25069,7 +25123,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
25069
25123
|
toContractParams() {
|
|
25070
25124
|
return {
|
|
25071
25125
|
type: "arkade",
|
|
25072
|
-
params:
|
|
25126
|
+
params: chunkBYPBVHVA_cjs.serializeArkadeContractParams({
|
|
25073
25127
|
program: this.program,
|
|
25074
25128
|
args: this.args,
|
|
25075
25129
|
serverKey: this.keys.serverKey,
|
|
@@ -25156,17 +25210,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
25156
25210
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
25157
25211
|
if (registered) {
|
|
25158
25212
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
25159
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
25213
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkKW7ZEWYS_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
25160
25214
|
}
|
|
25161
25215
|
}
|
|
25162
25216
|
if (!this.client.indexer) {
|
|
25163
25217
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
25164
25218
|
}
|
|
25165
|
-
const { vtxos } = await
|
|
25219
|
+
const { vtxos } = await chunkKW7ZEWYS_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
25166
25220
|
scripts: [scriptHex],
|
|
25167
25221
|
spendableOnly: true
|
|
25168
25222
|
});
|
|
25169
|
-
return vtxos.filter((v) => !
|
|
25223
|
+
return vtxos.filter((v) => !chunkKW7ZEWYS_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
25170
25224
|
}
|
|
25171
25225
|
/** Total spendable balance (requires an indexer). */
|
|
25172
25226
|
async getBalance() {
|
|
@@ -25326,7 +25380,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
25326
25380
|
this.client.checkpoint
|
|
25327
25381
|
);
|
|
25328
25382
|
inputs.forEach(({ coin }, i) => {
|
|
25329
|
-
if (coin.sourceTx)
|
|
25383
|
+
if (coin.sourceTx) chunkKW7ZEWYS_cjs.setArkPsbtField(arkTx, i, chunkKW7ZEWYS_cjs.PrevArkTxField, coin.sourceTx);
|
|
25330
25384
|
});
|
|
25331
25385
|
if (inputs.some(({ unlocker }) => unlocker.fn.arkadeScript)) {
|
|
25332
25386
|
const indexer = this.client.indexer;
|
|
@@ -25346,8 +25400,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
25346
25400
|
(w) => witnessBytes(unlocker, w)
|
|
25347
25401
|
);
|
|
25348
25402
|
if (condition.length === 0) return;
|
|
25349
|
-
|
|
25350
|
-
|
|
25403
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(arkTx, i, chunkKW7ZEWYS_cjs.ConditionWitness, condition);
|
|
25404
|
+
chunkKW7ZEWYS_cjs.setArkPsbtField(checkpoints[i], 0, chunkKW7ZEWYS_cjs.ConditionWitness, condition);
|
|
25351
25405
|
});
|
|
25352
25406
|
const packets = [];
|
|
25353
25407
|
if (this.assetSpecs.length > 0) {
|
|
@@ -25414,7 +25468,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
25414
25468
|
inputIndexes: userInputs
|
|
25415
25469
|
});
|
|
25416
25470
|
}
|
|
25417
|
-
|
|
25471
|
+
const identity = client.identity;
|
|
25472
|
+
if (!identity) {
|
|
25418
25473
|
throw new Error("a signing identity is required for non-covenant spends");
|
|
25419
25474
|
}
|
|
25420
25475
|
const ark = client.arkProvider;
|
|
@@ -25423,26 +25478,19 @@ var ArkadeTransactionBuilder = class {
|
|
|
25423
25478
|
"broadcasting requires an `arkade` provider with `submitTx`/`finalizeTx` on the Arkade client"
|
|
25424
25479
|
);
|
|
25425
25480
|
}
|
|
25426
|
-
const
|
|
25427
|
-
|
|
25428
|
-
|
|
25429
|
-
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
25433
|
-
|
|
25434
|
-
|
|
25435
|
-
const signed = await client.identity.sign(server, [0]);
|
|
25436
|
-
const [condition] = chunkGGKR4O5X_cjs.getArkPsbtFields(local, 0, chunkGGKR4O5X_cjs.ConditionWitness);
|
|
25437
|
-
if (condition && chunkGGKR4O5X_cjs.getArkPsbtFields(signed, 0, chunkGGKR4O5X_cjs.ConditionWitness).length === 0) {
|
|
25438
|
-
chunkGGKR4O5X_cjs.setArkPsbtField(signed, 0, chunkGGKR4O5X_cjs.ConditionWitness, condition);
|
|
25439
|
-
}
|
|
25440
|
-
return base.base64.encode(signed.toPSBT());
|
|
25441
|
-
})
|
|
25481
|
+
const res = await submitOffchainTx(
|
|
25482
|
+
ark,
|
|
25483
|
+
{ arkTx, checkpoints },
|
|
25484
|
+
{
|
|
25485
|
+
signArkTx: async (tx) => ({ arkTx: await this.signArk(tx, userInputs) }),
|
|
25486
|
+
signCheckpoint: (checkpoint) => identity.sign(checkpoint, [0])
|
|
25487
|
+
},
|
|
25488
|
+
void 0,
|
|
25489
|
+
{ oneShot: client.oneShotSubmit }
|
|
25442
25490
|
);
|
|
25443
|
-
await ark.finalizeTx(res.arkTxid, finalCps);
|
|
25444
25491
|
return {
|
|
25445
25492
|
txid: res.arkTxid,
|
|
25493
|
+
// Required by ArkadeBroadcaster; RestArkProvider.submitTx rejects a response without it.
|
|
25446
25494
|
signedArkTx: res.finalArkTx,
|
|
25447
25495
|
signedCheckpointTxs: res.signedCheckpointTxs
|
|
25448
25496
|
};
|
|
@@ -25486,20 +25534,20 @@ var ArkadeTransactionBuilder = class {
|
|
|
25486
25534
|
* A caller's packet counts for every input, unread; arkd checks what it actually routes.
|
|
25487
25535
|
*/
|
|
25488
25536
|
routesAssetsFrom(vin) {
|
|
25489
|
-
return this.extraPackets.some((p) => p.type() ===
|
|
25537
|
+
return this.extraPackets.some((p) => p.type() === chunkZMSM3NOH_cjs.Packet.PACKET_TYPE) || this.assetSpecs.some((spec) => spec.inputs.some((i) => i.vin === vin));
|
|
25490
25538
|
}
|
|
25491
25539
|
buildAssetPacket() {
|
|
25492
25540
|
const groups = this.assetSpecs.map((s) => {
|
|
25493
|
-
const id = typeof s.assetId === "string" ?
|
|
25494
|
-
return
|
|
25541
|
+
const id = typeof s.assetId === "string" ? chunkZMSM3NOH_cjs.AssetId.fromString(s.assetId) : chunkZMSM3NOH_cjs.AssetId.fromBytes(s.assetId);
|
|
25542
|
+
return chunkZMSM3NOH_cjs.AssetGroup.create(
|
|
25495
25543
|
id,
|
|
25496
25544
|
null,
|
|
25497
|
-
s.inputs.map((i) =>
|
|
25498
|
-
s.outputs.map((o) =>
|
|
25499
|
-
(s.metadata ?? []).map((m) =>
|
|
25545
|
+
s.inputs.map((i) => chunkZMSM3NOH_cjs.AssetInput.create(i.vin, i.amount)),
|
|
25546
|
+
s.outputs.map((o) => chunkZMSM3NOH_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
25547
|
+
(s.metadata ?? []).map((m) => chunkZMSM3NOH_cjs.Metadata.create(m.key, m.value))
|
|
25500
25548
|
);
|
|
25501
25549
|
});
|
|
25502
|
-
return
|
|
25550
|
+
return chunkZMSM3NOH_cjs.Packet.create(groups);
|
|
25503
25551
|
}
|
|
25504
25552
|
};
|
|
25505
25553
|
function unspendable(coin, now) {
|
|
@@ -25508,7 +25556,7 @@ function unspendable(coin, now) {
|
|
|
25508
25556
|
return void 0;
|
|
25509
25557
|
}
|
|
25510
25558
|
function witnessBytes({ contract, args }, ref) {
|
|
25511
|
-
return
|
|
25559
|
+
return chunkBYPBVHVA_cjs.witnessRefToBytes(ref, args, contract.args);
|
|
25512
25560
|
}
|
|
25513
25561
|
function bindInputs(fn, callArgs) {
|
|
25514
25562
|
const inputs = fn.def.inputs ?? [];
|
|
@@ -25521,7 +25569,7 @@ function bindInputs(fn, callArgs) {
|
|
|
25521
25569
|
inputs.forEach((def, i) => {
|
|
25522
25570
|
if (Object.hasOwn(bound, def.name))
|
|
25523
25571
|
throw new Error(`${fn.name}: duplicate input '${def.name}'`);
|
|
25524
|
-
|
|
25572
|
+
chunkBYPBVHVA_cjs.validateParamValue(def, callArgs[i]);
|
|
25525
25573
|
bound[def.name] = callArgs[i];
|
|
25526
25574
|
});
|
|
25527
25575
|
return bound;
|
|
@@ -25932,17 +25980,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
25932
25980
|
function offchainInputFees(vtxos, fees) {
|
|
25933
25981
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25934
25982
|
return vtxos.reduce(
|
|
25935
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
25983
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
25936
25984
|
0
|
|
25937
25985
|
);
|
|
25938
25986
|
}
|
|
25939
25987
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
25940
25988
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25941
25989
|
const net = inputs.reduce(
|
|
25942
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
25990
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkKW7ZEWYS_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
25943
25991
|
0n
|
|
25944
25992
|
);
|
|
25945
|
-
const script = base.hex.encode(
|
|
25993
|
+
const script = base.hex.encode(chunkKW7ZEWYS_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
25946
25994
|
return changeAfterOutputFee(
|
|
25947
25995
|
net - needed,
|
|
25948
25996
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
|
|
@@ -26245,5 +26293,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
26245
26293
|
exports.walletFeeSource = walletFeeSource;
|
|
26246
26294
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
26247
26295
|
exports.withPrevTxs = withPrevTxs;
|
|
26248
|
-
//# sourceMappingURL=chunk-
|
|
26249
|
-
//# sourceMappingURL=chunk-
|
|
26296
|
+
//# sourceMappingURL=chunk-OUTWUYJ4.cjs.map
|
|
26297
|
+
//# sourceMappingURL=chunk-OUTWUYJ4.cjs.map
|