@arkade-os/sdk 0.5.0-rc.29 → 0.5.0-rc.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-7UQpcjqM.d.ts → asyncStorageTaskQueue-DAVf4Fyy.d.ts} +1 -1
- package/dist/{asyncStorageTaskQueue-QiOMZQRD.d.cts → asyncStorageTaskQueue-fkkUPrhz.d.cts} +1 -1
- package/dist/{chunk-4CU5CECR.cjs → chunk-3SM7BMIE.cjs} +518 -551
- package/dist/chunk-3SM7BMIE.cjs.map +1 -0
- package/dist/{chunk-DE7HV5LJ.cjs → chunk-4MCQZYH6.cjs} +48 -48
- package/dist/{chunk-DE7HV5LJ.cjs.map → chunk-4MCQZYH6.cjs.map} +1 -1
- package/dist/{chunk-7UFHC75B.cjs → chunk-6BTZ6KFI.cjs} +10 -10
- package/dist/{chunk-7UFHC75B.cjs.map → chunk-6BTZ6KFI.cjs.map} +1 -1
- package/dist/{chunk-D57OWBZH.cjs → chunk-AICUNREA.cjs} +18 -18
- package/dist/{chunk-D57OWBZH.cjs.map → chunk-AICUNREA.cjs.map} +1 -1
- package/dist/{chunk-VYRZXLKM.cjs → chunk-ASKOHVGX.cjs} +3 -3
- package/dist/{chunk-VYRZXLKM.cjs.map → chunk-ASKOHVGX.cjs.map} +1 -1
- package/dist/{chunk-QRAQSUCE.cjs → chunk-DLHE4RCH.cjs} +16 -16
- package/dist/{chunk-QRAQSUCE.cjs.map → chunk-DLHE4RCH.cjs.map} +1 -1
- package/dist/{chunk-WNHMY5ET.js → chunk-ESEHYZAY.js} +3 -3
- package/dist/{chunk-WNHMY5ET.js.map → chunk-ESEHYZAY.js.map} +1 -1
- package/dist/{chunk-44E37WPJ.js → chunk-G6ZPX2GL.js} +3 -3
- package/dist/{chunk-44E37WPJ.js.map → chunk-G6ZPX2GL.js.map} +1 -1
- package/dist/{chunk-N6RJDTPX.js → chunk-KK6GXY4L.js} +4 -4
- package/dist/{chunk-N6RJDTPX.js.map → chunk-KK6GXY4L.js.map} +1 -1
- package/dist/{chunk-CVJXASA2.js → chunk-PY3YQNHP.js} +3 -3
- package/dist/{chunk-CVJXASA2.js.map → chunk-PY3YQNHP.js.map} +1 -1
- package/dist/{chunk-34G7TDUS.js → chunk-XW72DWYO.js} +24 -51
- package/dist/chunk-XW72DWYO.js.map +1 -0
- package/dist/{chunk-KLXLTJEG.js → chunk-YML2N4SC.js} +4 -4
- package/dist/{chunk-KLXLTJEG.js.map → chunk-YML2N4SC.js.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-2k8MG5qy.d.cts → delegate-BYoNu3lf.d.cts} +1 -1
- package/dist/{delegate---DiIqfr.d.ts → delegate-DsqzUVId.d.ts} +1 -1
- package/dist/{index-DJ3xIDCG.d.cts → index-CXNTURO_.d.cts} +2 -2
- package/dist/{index-8BQ5L5js.d.cts → index-DhP68WBD.d.cts} +1 -7
- package/dist/{index-8BQ5L5js.d.ts → index-DhP68WBD.d.ts} +1 -7
- package/dist/{index-cG9JYLX4.d.ts → index-pQr5y77P.d.ts} +2 -2
- package/dist/index.cjs +313 -337
- package/dist/index.d.cts +24 -18
- package/dist/index.d.ts +24 -18
- 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-Ba2InBIA.d.cts → taskRunner-C8H3bSsk.d.cts} +1 -1
- package/dist/{taskRunner-SHwLCckR.d.ts → taskRunner-DKtBy8Yo.d.ts} +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 +15 -15
- package/dist/wallet/expo/index.d.cts +4 -4
- package/dist/wallet/expo/index.d.ts +4 -4
- package/dist/wallet/expo/index.js +5 -5
- package/dist/{wallet-o8UkwASU.d.ts → wallet-BmAHDzK3.d.cts} +4 -64
- package/dist/{wallet-Bfe7QdhT.d.cts → wallet-C0W8EOnA.d.ts} +4 -64
- 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-34G7TDUS.js.map +0 -1
- package/dist/chunk-4CU5CECR.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkAICUNREA_cjs = require('./chunk-AICUNREA.cjs');
|
|
4
|
+
var chunk4MCQZYH6_cjs = require('./chunk-4MCQZYH6.cjs');
|
|
5
|
+
var chunkASKOHVGX_cjs = require('./chunk-ASKOHVGX.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 = chunkASKOHVGX_cjs.getArkPsbtFields(tx.root, 0, chunkASKOHVGX_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 = chunkASKOHVGX_cjs.getArkPsbtFields(g.root, 0, chunkASKOHVGX_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
|
+
chunkASKOHVGX_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 = chunk4MCQZYH6_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 chunk4MCQZYH6_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 = chunk4MCQZYH6_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
|
+
chunkASKOHVGX_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 = chunk4MCQZYH6_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 chunk4MCQZYH6_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 chunk4MCQZYH6_cjs.deriveDescriptorLeafPubKey(this.descriptor);
|
|
797
797
|
}
|
|
798
798
|
async compressedPublicKey() {
|
|
799
|
-
return
|
|
799
|
+
return chunk4MCQZYH6_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 = chunk4MCQZYH6_cjs.normalizeToDescriptor(descriptor);
|
|
860
|
+
const pubKey = chunk4MCQZYH6_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 chunk4MCQZYH6_cjs.extractPubKey(chunk4MCQZYH6_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 && chunk4MCQZYH6_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 = chunk4MCQZYH6_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 chunk4MCQZYH6_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 chunk4MCQZYH6_cjs.identityDescriptor(wallet.identity);
|
|
1351
1351
|
}
|
|
1352
1352
|
async function provisionRefundKey(wallet) {
|
|
1353
|
-
const descriptor = await
|
|
1353
|
+
const descriptor = await chunk4MCQZYH6_cjs.identityDescriptor(wallet.identity);
|
|
1354
1354
|
const signer = await contractSigner(wallet, descriptor);
|
|
1355
1355
|
const pubkey = await signer.xOnlyPublicKey();
|
|
1356
1356
|
const identityPubkey = await wallet.identity.xOnlyPublicKey();
|
|
@@ -1360,7 +1360,7 @@ async function provisionRefundKey(wallet) {
|
|
|
1360
1360
|
);
|
|
1361
1361
|
}
|
|
1362
1362
|
const address = await wallet.getAddress();
|
|
1363
|
-
const { pkScript } =
|
|
1363
|
+
const { pkScript } = chunkASKOHVGX_cjs.ArkAddress.decode(address);
|
|
1364
1364
|
return { descriptor, pubkey, pkScript, address };
|
|
1365
1365
|
}
|
|
1366
1366
|
async function provisionClaimSecret(wallet, opts = {}) {
|
|
@@ -1406,7 +1406,7 @@ async function contractSigner(wallet, descriptor) {
|
|
|
1406
1406
|
const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
|
|
1407
1407
|
let expected;
|
|
1408
1408
|
try {
|
|
1409
|
-
expected =
|
|
1409
|
+
expected = chunk4MCQZYH6_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
1410
1410
|
} catch (cause) {
|
|
1411
1411
|
throw new ForeignDescriptorError(descriptor, { cause });
|
|
1412
1412
|
}
|
|
@@ -1488,7 +1488,7 @@ function debugLog(debug, ...args) {
|
|
|
1488
1488
|
}
|
|
1489
1489
|
function normalizeOptions(pathOrOptions) {
|
|
1490
1490
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
1491
|
-
|
|
1491
|
+
chunkASKOHVGX_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
1492
1492
|
return {
|
|
1493
1493
|
path: o.path,
|
|
1494
1494
|
updateViaCache: o.updateViaCache ?? "none",
|
|
@@ -1611,14 +1611,14 @@ var RestDelegateProvider = class {
|
|
|
1611
1611
|
*/
|
|
1612
1612
|
async delegate(intent, forfeitTxs, options) {
|
|
1613
1613
|
const url = `${this.url}/v1/delegate`;
|
|
1614
|
-
const response = await
|
|
1614
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(url, {
|
|
1615
1615
|
method: "POST",
|
|
1616
1616
|
headers: {
|
|
1617
1617
|
"Content-Type": "application/json"
|
|
1618
1618
|
},
|
|
1619
1619
|
body: JSON.stringify({
|
|
1620
1620
|
intent: {
|
|
1621
|
-
message:
|
|
1621
|
+
message: chunkASKOHVGX_cjs.Intent.encodeMessage(intent.message),
|
|
1622
1622
|
proof: intent.proof
|
|
1623
1623
|
},
|
|
1624
1624
|
forfeit_txs: forfeitTxs,
|
|
@@ -1637,7 +1637,7 @@ var RestDelegateProvider = class {
|
|
|
1637
1637
|
*/
|
|
1638
1638
|
async getDelegateInfo() {
|
|
1639
1639
|
const url = `${this.url}/v1/delegator/info`;
|
|
1640
|
-
const response = await
|
|
1640
|
+
const response = await chunkASKOHVGX_cjs.rateGate.runHttp(url, () => chunkASKOHVGX_cjs.baseFetch(url));
|
|
1641
1641
|
if (!response.ok) {
|
|
1642
1642
|
const errorText2 = await response.text();
|
|
1643
1643
|
throw new Error(`Failed to get delegate info: ${errorText2}`);
|
|
@@ -1693,7 +1693,7 @@ async function collectPages(read) {
|
|
|
1693
1693
|
return items;
|
|
1694
1694
|
}
|
|
1695
1695
|
function scriptFromArkAddress(address) {
|
|
1696
|
-
return base.hex.encode(
|
|
1696
|
+
return base.hex.encode(chunkASKOHVGX_cjs.ArkAddress.decode(address).pkScript);
|
|
1697
1697
|
}
|
|
1698
1698
|
|
|
1699
1699
|
// src/repositories/walletRepository.ts
|
|
@@ -1755,9 +1755,9 @@ async function collectScriptVtxos(repository, script, options) {
|
|
|
1755
1755
|
return [...byOutpoint.values()].map((row) => row.vtxo);
|
|
1756
1756
|
}
|
|
1757
1757
|
function unspentScriptVtxos(rows, copies) {
|
|
1758
|
-
const spent = copies.filter((copy) =>
|
|
1758
|
+
const spent = copies.filter((copy) => chunkASKOHVGX_cjs.isVtxoSpent(copy.vtxo));
|
|
1759
1759
|
return rows.filter(
|
|
1760
|
-
(row) => !
|
|
1760
|
+
(row) => !chunkASKOHVGX_cjs.isVtxoSpent(row.vtxo) && !spent.some(
|
|
1761
1761
|
(copy) => copy.address !== row.address && copy.vtxo.txid === row.vtxo.txid && copy.vtxo.vout === row.vtxo.vout && shouldReplaceScriptVtxo(row, copy)
|
|
1762
1762
|
)
|
|
1763
1763
|
);
|
|
@@ -1840,7 +1840,7 @@ var ESPLORA_URL = {
|
|
|
1840
1840
|
regtest: "http://localhost:3000/api"
|
|
1841
1841
|
};
|
|
1842
1842
|
var EsploraProvider = class {
|
|
1843
|
-
constructor(baseUrl = ESPLORA_URL[
|
|
1843
|
+
constructor(baseUrl = ESPLORA_URL[chunkASKOHVGX_cjs.DEFAULT_NETWORK_NAME], opts) {
|
|
1844
1844
|
this.baseUrl = baseUrl;
|
|
1845
1845
|
this.pollingInterval = opts?.pollingInterval ?? 15e3;
|
|
1846
1846
|
this.forcePolling = opts?.forcePolling ?? false;
|
|
@@ -1855,7 +1855,7 @@ var EsploraProvider = class {
|
|
|
1855
1855
|
*/
|
|
1856
1856
|
addressWatches = /* @__PURE__ */ new Map();
|
|
1857
1857
|
async getCoins(address) {
|
|
1858
|
-
const response = await
|
|
1858
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
|
|
1859
1859
|
if (!response.ok) {
|
|
1860
1860
|
throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
|
|
1861
1861
|
}
|
|
@@ -1864,12 +1864,12 @@ var EsploraProvider = class {
|
|
|
1864
1864
|
async getFeeRate() {
|
|
1865
1865
|
let url = `${this.baseUrl}/fee-estimates`;
|
|
1866
1866
|
let key = "1";
|
|
1867
|
-
let response = await
|
|
1867
|
+
let response = await chunkASKOHVGX_cjs.baseFetch(url);
|
|
1868
1868
|
if (response.status === 404) {
|
|
1869
1869
|
await response.body?.cancel();
|
|
1870
1870
|
url = `${this.baseUrl}/v1/fees/recommended`;
|
|
1871
1871
|
key = "fastestFee";
|
|
1872
|
-
response = await
|
|
1872
|
+
response = await chunkASKOHVGX_cjs.baseFetch(url);
|
|
1873
1873
|
}
|
|
1874
1874
|
if (response.status === 404) {
|
|
1875
1875
|
await response.body?.cancel();
|
|
@@ -1906,7 +1906,7 @@ var EsploraProvider = class {
|
|
|
1906
1906
|
}
|
|
1907
1907
|
}
|
|
1908
1908
|
async getTxOutspends(txid) {
|
|
1909
|
-
const response = await
|
|
1909
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
|
|
1910
1910
|
if (!response.ok) {
|
|
1911
1911
|
const error = await response.text();
|
|
1912
1912
|
throw new Error(`Failed to get transaction outspends: ${error}`);
|
|
@@ -1914,7 +1914,7 @@ var EsploraProvider = class {
|
|
|
1914
1914
|
return response.json();
|
|
1915
1915
|
}
|
|
1916
1916
|
async getTransactions(address) {
|
|
1917
|
-
const response = await
|
|
1917
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
|
|
1918
1918
|
if (!response.ok) {
|
|
1919
1919
|
const error = await response.text();
|
|
1920
1920
|
throw new Error(`Failed to get transactions: ${error}`);
|
|
@@ -1923,14 +1923,14 @@ var EsploraProvider = class {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
/** Orders of magnitude smaller than `/address/{addr}/txs`: the polling fallback's probe. */
|
|
1925
1925
|
async getAddressStats(address) {
|
|
1926
|
-
const response = await
|
|
1926
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
|
|
1927
1927
|
if (!response.ok) {
|
|
1928
1928
|
throw new Error(`Failed to get address stats: ${response.statusText}`);
|
|
1929
1929
|
}
|
|
1930
1930
|
return response.json();
|
|
1931
1931
|
}
|
|
1932
1932
|
async getRawTransaction(txid) {
|
|
1933
|
-
const response = await
|
|
1933
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
|
|
1934
1934
|
if (!response.ok) {
|
|
1935
1935
|
const error = await response.text();
|
|
1936
1936
|
throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
|
|
@@ -1938,7 +1938,7 @@ var EsploraProvider = class {
|
|
|
1938
1938
|
return base.hex.decode((await response.text()).trim());
|
|
1939
1939
|
}
|
|
1940
1940
|
async getTxStatus(txid) {
|
|
1941
|
-
const txresponse = await
|
|
1941
|
+
const txresponse = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
|
|
1942
1942
|
if (!txresponse.ok) {
|
|
1943
1943
|
throw new Error(txresponse.statusText);
|
|
1944
1944
|
}
|
|
@@ -1946,7 +1946,7 @@ var EsploraProvider = class {
|
|
|
1946
1946
|
if (!tx.status.confirmed) {
|
|
1947
1947
|
return { confirmed: false };
|
|
1948
1948
|
}
|
|
1949
|
-
const response = await
|
|
1949
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
|
|
1950
1950
|
if (!response.ok) {
|
|
1951
1951
|
throw new Error(`Failed to get transaction status: ${response.statusText}`);
|
|
1952
1952
|
}
|
|
@@ -2220,9 +2220,9 @@ var EsploraProvider = class {
|
|
|
2220
2220
|
return { subscribers, teardown, started };
|
|
2221
2221
|
}
|
|
2222
2222
|
async getChainTip() {
|
|
2223
|
-
let tipBlocks = await
|
|
2223
|
+
let tipBlocks = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/blocks`);
|
|
2224
2224
|
if (tipBlocks.status === 404) {
|
|
2225
|
-
tipBlocks = await
|
|
2225
|
+
tipBlocks = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
|
|
2226
2226
|
}
|
|
2227
2227
|
if (!tipBlocks.ok) {
|
|
2228
2228
|
throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
|
|
@@ -2243,7 +2243,7 @@ var EsploraProvider = class {
|
|
|
2243
2243
|
};
|
|
2244
2244
|
}
|
|
2245
2245
|
async broadcastPackage(parent, child) {
|
|
2246
|
-
const response = await
|
|
2246
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
|
|
2247
2247
|
method: "POST",
|
|
2248
2248
|
headers: {
|
|
2249
2249
|
"Content-Type": "application/json"
|
|
@@ -2259,7 +2259,7 @@ var EsploraProvider = class {
|
|
|
2259
2259
|
return result;
|
|
2260
2260
|
}
|
|
2261
2261
|
async broadcastTx(tx) {
|
|
2262
|
-
const response = await
|
|
2262
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(`${this.baseUrl}/tx`, {
|
|
2263
2263
|
method: "POST",
|
|
2264
2264
|
headers: {
|
|
2265
2265
|
"Content-Type": "text/plain"
|
|
@@ -2431,7 +2431,7 @@ function findP2AOutput(tx) {
|
|
|
2431
2431
|
var CHILD_DUST_AMOUNT = 546;
|
|
2432
2432
|
function buildAnchorChild(params) {
|
|
2433
2433
|
const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
|
|
2434
|
-
const child = new
|
|
2434
|
+
const child = new chunkASKOHVGX_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
|
|
2435
2435
|
const anchor = findP2AOutput(parent);
|
|
2436
2436
|
child.addInput(anchor);
|
|
2437
2437
|
const estimator = TxWeightEstimator.create().addP2AInput();
|
|
@@ -2480,7 +2480,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
|
|
|
2480
2480
|
);
|
|
2481
2481
|
}
|
|
2482
2482
|
function buildForfeitTxWithOutput(inputs, output, txLocktime) {
|
|
2483
|
-
const tx = new
|
|
2483
|
+
const tx = new chunkASKOHVGX_cjs.Transaction({
|
|
2484
2484
|
version: 3,
|
|
2485
2485
|
lockTime: txLocktime
|
|
2486
2486
|
});
|
|
@@ -2507,7 +2507,7 @@ function validateConnectorsTxGraph(settlementTxB64, connectorsGraph) {
|
|
|
2507
2507
|
connectorsGraph.validate();
|
|
2508
2508
|
if (connectorsGraph.root.inputsLength !== 1) throw ErrNumberOfInputs;
|
|
2509
2509
|
const rootInput = connectorsGraph.root.getInput(0);
|
|
2510
|
-
const settlementTx =
|
|
2510
|
+
const settlementTx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(settlementTxB64));
|
|
2511
2511
|
if (settlementTx.outputsLength <= BATCH_OUTPUT_CONNECTORS_INDEX)
|
|
2512
2512
|
throw ErrInvalidSettlementTxOutputs;
|
|
2513
2513
|
const expectedRootTxid = settlementTx.id;
|
|
@@ -2556,7 +2556,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
|
|
|
2556
2556
|
if (previousScriptKey.length !== 32) {
|
|
2557
2557
|
throw new Error(`parent output ${childIndex} has invalid script`);
|
|
2558
2558
|
}
|
|
2559
|
-
const cosigners =
|
|
2559
|
+
const cosigners = chunkASKOHVGX_cjs.getArkPsbtFields(child.root, 0, chunkASKOHVGX_cjs.CosignerPublicKey);
|
|
2560
2560
|
if (cosigners.length === 0) {
|
|
2561
2561
|
throw ErrMissingCosignersPublicKeys;
|
|
2562
2562
|
}
|
|
@@ -2614,7 +2614,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2614
2614
|
return new _EmulatorPacket(entries);
|
|
2615
2615
|
}
|
|
2616
2616
|
static fromBytes(data) {
|
|
2617
|
-
const reader = new
|
|
2617
|
+
const reader = new chunkAICUNREA_cjs.BufferReader(data);
|
|
2618
2618
|
const entryCount = reader.readCompactSize();
|
|
2619
2619
|
const entries = [];
|
|
2620
2620
|
for (let i = 0; i < entryCount; i++) {
|
|
@@ -2632,7 +2632,7 @@ var EmulatorPacket = class _EmulatorPacket {
|
|
|
2632
2632
|
return _EmulatorPacket.PACKET_TYPE;
|
|
2633
2633
|
}
|
|
2634
2634
|
serialize() {
|
|
2635
|
-
const writer = new
|
|
2635
|
+
const writer = new chunkAICUNREA_cjs.BufferWriter();
|
|
2636
2636
|
writer.writeCompactSize(this.entries.length);
|
|
2637
2637
|
for (const entry of this.entries) {
|
|
2638
2638
|
writer.writeUint16LE(entry.vin);
|
|
@@ -2719,7 +2719,7 @@ var Extension = class _Extension {
|
|
|
2719
2719
|
`expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
|
|
2720
2720
|
);
|
|
2721
2721
|
}
|
|
2722
|
-
const reader = new
|
|
2722
|
+
const reader = new chunkAICUNREA_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
|
|
2723
2723
|
const packets = [];
|
|
2724
2724
|
while (reader.remaining() > 0) {
|
|
2725
2725
|
const packetType = reader.readByte();
|
|
@@ -2792,7 +2792,7 @@ var Extension = class _Extension {
|
|
|
2792
2792
|
* getAssetPacket returns the embedded Packet, or null if not present.
|
|
2793
2793
|
*/
|
|
2794
2794
|
getAssetPacket() {
|
|
2795
|
-
return this.packets.find((p) => p instanceof
|
|
2795
|
+
return this.packets.find((p) => p instanceof chunkAICUNREA_cjs.Packet) ?? null;
|
|
2796
2796
|
}
|
|
2797
2797
|
/**
|
|
2798
2798
|
* getEmulatorPacket returns the embedded EmulatorPacket, or null if not present.
|
|
@@ -2816,8 +2816,8 @@ var Extension = class _Extension {
|
|
|
2816
2816
|
};
|
|
2817
2817
|
function parsePacket(packetType, data) {
|
|
2818
2818
|
switch (packetType) {
|
|
2819
|
-
case
|
|
2820
|
-
return
|
|
2819
|
+
case chunkAICUNREA_cjs.Packet.PACKET_TYPE:
|
|
2820
|
+
return chunkAICUNREA_cjs.Packet.fromBytes(data);
|
|
2821
2821
|
case EmulatorPacket.PACKET_TYPE:
|
|
2822
2822
|
return EmulatorPacket.fromBytes(data);
|
|
2823
2823
|
default:
|
|
@@ -2864,22 +2864,22 @@ function buildOpReturnScript(data) {
|
|
|
2864
2864
|
}
|
|
2865
2865
|
return script;
|
|
2866
2866
|
}
|
|
2867
|
-
var ErrOffchainOutputNotFound = (address) => new
|
|
2868
|
-
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new
|
|
2867
|
+
var ErrOffchainOutputNotFound = (address) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
|
|
2868
|
+
var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
2869
2869
|
`invalid asset output amount for ${assetId}: got ${got}, want ${want}`
|
|
2870
2870
|
);
|
|
2871
|
-
var ErrAssetGroupNotFound = (assetId) => new
|
|
2872
|
-
var ErrAssetOutputNotFound = (assetId, outputIndex) => new
|
|
2871
|
+
var ErrAssetGroupNotFound = (assetId) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
|
|
2872
|
+
var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
2873
2873
|
`asset output not found in asset group ${assetId} at index ${outputIndex}`
|
|
2874
2874
|
);
|
|
2875
|
-
var ErrOnchainOutputNotFound = (address) => new
|
|
2876
|
-
var ErrUnvalidatedOffchainOutput = (address) => new
|
|
2875
|
+
var ErrOnchainOutputNotFound = (address) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
|
|
2876
|
+
var ErrUnvalidatedOffchainOutput = (address) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
2877
2877
|
`offchain output ${address} cannot be validated: virtual output tree signing did not run`
|
|
2878
2878
|
);
|
|
2879
|
-
var ErrIntentOutputNotFound = (index, kind) => new
|
|
2879
|
+
var ErrIntentOutputNotFound = (index, kind) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
2880
2880
|
`${kind} output ${index} of the intent proof is not present in what the server built`
|
|
2881
2881
|
);
|
|
2882
|
-
var ErrUnvalidatedIntentOutput = (index) => new
|
|
2882
|
+
var ErrUnvalidatedIntentOutput = (index) => new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
2883
2883
|
`offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
|
|
2884
2884
|
);
|
|
2885
2885
|
var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
|
|
@@ -2888,7 +2888,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
|
|
|
2888
2888
|
function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
|
|
2889
2889
|
if (!validatedCommitmentTxid) return;
|
|
2890
2890
|
if (finalCommitmentTx.id === validatedCommitmentTxid) return;
|
|
2891
|
-
throw new
|
|
2891
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
2892
2892
|
`${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
|
|
2893
2893
|
);
|
|
2894
2894
|
}
|
|
@@ -2898,7 +2898,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
|
|
|
2898
2898
|
for (const recipient of recipients) {
|
|
2899
2899
|
let arkAddress;
|
|
2900
2900
|
try {
|
|
2901
|
-
arkAddress =
|
|
2901
|
+
arkAddress = chunkASKOHVGX_cjs.ArkAddress.decode(recipient.address);
|
|
2902
2902
|
} catch {
|
|
2903
2903
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2904
2904
|
continue;
|
|
@@ -2910,7 +2910,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2910
2910
|
const usedOnchainOutputs = /* @__PURE__ */ new Set();
|
|
2911
2911
|
for (const recipient of recipients) {
|
|
2912
2912
|
try {
|
|
2913
|
-
|
|
2913
|
+
chunkASKOHVGX_cjs.ArkAddress.decode(recipient.address);
|
|
2914
2914
|
} catch {
|
|
2915
2915
|
validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
|
|
2916
2916
|
continue;
|
|
@@ -2919,7 +2919,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
|
|
|
2919
2919
|
}
|
|
2920
2920
|
}
|
|
2921
2921
|
function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
|
|
2922
|
-
const proof =
|
|
2922
|
+
const proof = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
|
|
2923
2923
|
const onchain = new Set(onchainOutputIndexes);
|
|
2924
2924
|
const declared = [];
|
|
2925
2925
|
for (let i = 0; i < proof.outputsLength; i++) {
|
|
@@ -3211,7 +3211,7 @@ function assetMintResolver() {
|
|
|
3211
3211
|
if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
|
|
3212
3212
|
const minted = tx.assets.filter((a) => {
|
|
3213
3213
|
try {
|
|
3214
|
-
return base.hex.encode(
|
|
3214
|
+
return base.hex.encode(chunkAICUNREA_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
|
|
3215
3215
|
} catch {
|
|
3216
3216
|
return false;
|
|
3217
3217
|
}
|
|
@@ -3288,7 +3288,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3288
3288
|
const existing = inputsByAssetId.get(asset.assetId);
|
|
3289
3289
|
inputsByAssetId.set(asset.assetId, [
|
|
3290
3290
|
...existing ?? [],
|
|
3291
|
-
|
|
3291
|
+
chunkAICUNREA_cjs.AssetInput.create(inputIndex, asset.amount)
|
|
3292
3292
|
]);
|
|
3293
3293
|
}
|
|
3294
3294
|
}
|
|
@@ -3300,7 +3300,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3300
3300
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3301
3301
|
outputsByAssetId.set(asset.assetId, [
|
|
3302
3302
|
...existing ?? [],
|
|
3303
|
-
|
|
3303
|
+
chunkAICUNREA_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3304
3304
|
]);
|
|
3305
3305
|
}
|
|
3306
3306
|
}
|
|
@@ -3311,7 +3311,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3311
3311
|
const existing = outputsByAssetId.get(asset.assetId);
|
|
3312
3312
|
outputsByAssetId.set(asset.assetId, [
|
|
3313
3313
|
...existing ?? [],
|
|
3314
|
-
|
|
3314
|
+
chunkAICUNREA_cjs.AssetOutput.create(outputIndex, asset.amount)
|
|
3315
3315
|
]);
|
|
3316
3316
|
}
|
|
3317
3317
|
}
|
|
@@ -3320,11 +3320,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
|
|
|
3320
3320
|
for (const assetIdStr of allAssetIds) {
|
|
3321
3321
|
const inputs = inputsByAssetId.get(assetIdStr);
|
|
3322
3322
|
const outputs = outputsByAssetId.get(assetIdStr);
|
|
3323
|
-
const assetId =
|
|
3324
|
-
const group =
|
|
3323
|
+
const assetId = chunkAICUNREA_cjs.AssetId.fromString(assetIdStr);
|
|
3324
|
+
const group = chunkAICUNREA_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
|
|
3325
3325
|
groups.push(group);
|
|
3326
3326
|
}
|
|
3327
|
-
return
|
|
3327
|
+
return chunkAICUNREA_cjs.Packet.create(groups);
|
|
3328
3328
|
}
|
|
3329
3329
|
function selectCoinsWithAsset(coins, assetId, requiredAmount) {
|
|
3330
3330
|
const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
|
|
@@ -3408,7 +3408,7 @@ function meetsInputExpiryFloor(coin, floor) {
|
|
|
3408
3408
|
}
|
|
3409
3409
|
function toXOnlySignerHex(pubkeyHex) {
|
|
3410
3410
|
const bytes = base.hex.decode(pubkeyHex);
|
|
3411
|
-
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(
|
|
3411
|
+
if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunk4MCQZYH6_cjs.toXOnly(bytes, "signer key"));
|
|
3412
3412
|
throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
|
|
3413
3413
|
}
|
|
3414
3414
|
function signerSetFromInfo(info) {
|
|
@@ -3455,14 +3455,15 @@ var toTimelock = (value) => ({
|
|
|
3455
3455
|
var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
|
|
3456
3456
|
function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
|
|
3457
3457
|
if (policy.requireSeconds && timelock.type === "blocks") {
|
|
3458
|
-
throw new
|
|
3458
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3459
3459
|
`${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
|
|
3460
3460
|
);
|
|
3461
3461
|
}
|
|
3462
3462
|
const seconds = toSeconds(timelock);
|
|
3463
3463
|
if (seconds < policy.minSeconds) {
|
|
3464
|
-
|
|
3465
|
-
|
|
3464
|
+
const remedy = overrideOption ? `; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it` : "";
|
|
3465
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3466
|
+
`${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor${remedy}`
|
|
3466
3467
|
);
|
|
3467
3468
|
}
|
|
3468
3469
|
return timelock;
|
|
@@ -3482,60 +3483,38 @@ function resolveBatchExpiryPolicy(network, overrides) {
|
|
|
3482
3483
|
}
|
|
3483
3484
|
function assertValidBatchExpiry(batchExpiry, policy) {
|
|
3484
3485
|
if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
|
|
3485
|
-
throw new
|
|
3486
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3486
3487
|
`batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
|
|
3487
3488
|
);
|
|
3488
3489
|
}
|
|
3489
3490
|
return assertTimelockWithinFloor(batchExpiry, policy, "batch expiry", "minBatchExpirySeconds");
|
|
3490
3491
|
}
|
|
3491
|
-
|
|
3492
|
-
var REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 1200n;
|
|
3493
|
-
var MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 4096n;
|
|
3494
|
-
var SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = 86016n;
|
|
3495
|
-
var HOSTED_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = {
|
|
3496
|
-
signet: SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS,
|
|
3497
|
-
mutinynet: MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS
|
|
3498
|
-
};
|
|
3499
|
-
function defaultCheckpointExitDelayPolicy(network) {
|
|
3500
|
-
if (isRegtest(network)) {
|
|
3501
|
-
return { minSeconds: REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS, requireSeconds: false };
|
|
3502
|
-
}
|
|
3503
|
-
const hosted = network.name ? HOSTED_MIN_CHECKPOINT_EXIT_DELAY_SECONDS[network.name] : void 0;
|
|
3504
|
-
return {
|
|
3505
|
-
minSeconds: hosted ?? DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS,
|
|
3506
|
-
requireSeconds: true
|
|
3507
|
-
};
|
|
3508
|
-
}
|
|
3509
|
-
function resolveCheckpointExitDelayPolicy(network, overrides) {
|
|
3510
|
-
return { ...defaultCheckpointExitDelayPolicy(network), ...overrides };
|
|
3511
|
-
}
|
|
3512
|
-
function assertValidServerUnrollScript(checkpointTapscript, policy) {
|
|
3492
|
+
function assertValidServerUnrollScript(checkpointTapscript, network, advertisedForfeitPubkey) {
|
|
3513
3493
|
let script;
|
|
3514
3494
|
try {
|
|
3515
|
-
script =
|
|
3495
|
+
script = chunkASKOHVGX_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
|
|
3516
3496
|
} catch (e) {
|
|
3517
|
-
throw new
|
|
3497
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3518
3498
|
`checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
|
|
3519
3499
|
);
|
|
3520
3500
|
}
|
|
3521
|
-
if (
|
|
3501
|
+
if (advertisedForfeitPubkey !== void 0) {
|
|
3522
3502
|
const { pubkeys } = script.params;
|
|
3523
3503
|
if (pubkeys.length !== 1) {
|
|
3524
|
-
throw new
|
|
3504
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3525
3505
|
`checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
|
|
3526
3506
|
);
|
|
3527
3507
|
}
|
|
3528
|
-
if (!utils_js.equalBytes(pubkeys[0],
|
|
3529
|
-
throw new
|
|
3530
|
-
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(
|
|
3508
|
+
if (!utils_js.equalBytes(pubkeys[0], advertisedForfeitPubkey)) {
|
|
3509
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3510
|
+
`checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(advertisedForfeitPubkey)}`
|
|
3531
3511
|
);
|
|
3532
3512
|
}
|
|
3533
3513
|
}
|
|
3534
3514
|
assertTimelockInPolicy(
|
|
3535
3515
|
script.params.timelock,
|
|
3536
|
-
|
|
3537
|
-
"checkpoint exit delay"
|
|
3538
|
-
"minCheckpointExitDelaySeconds"
|
|
3516
|
+
{ minSeconds: 512n, requireSeconds: !isRegtest(network) },
|
|
3517
|
+
"checkpoint exit delay"
|
|
3539
3518
|
);
|
|
3540
3519
|
return script;
|
|
3541
3520
|
}
|
|
@@ -3570,8 +3549,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
|
|
|
3570
3549
|
function buildVirtualTx(inputs, outputs) {
|
|
3571
3550
|
let lockTime = 0n;
|
|
3572
3551
|
for (const input of inputs) {
|
|
3573
|
-
const tapscript =
|
|
3574
|
-
if (
|
|
3552
|
+
const tapscript = chunkASKOHVGX_cjs.decodeTapscript(chunkASKOHVGX_cjs.scriptFromTapLeafScript(input.tapLeafScript));
|
|
3553
|
+
if (chunkASKOHVGX_cjs.CLTVMultisigTapscript.is(tapscript)) {
|
|
3575
3554
|
if (lockTime !== 0n) {
|
|
3576
3555
|
if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
|
|
3577
3556
|
throw new Error("cannot mix seconds and blocks locktime");
|
|
@@ -3582,7 +3561,7 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3582
3561
|
}
|
|
3583
3562
|
}
|
|
3584
3563
|
}
|
|
3585
|
-
const tx = new
|
|
3564
|
+
const tx = new chunkASKOHVGX_cjs.Transaction({
|
|
3586
3565
|
version: 3,
|
|
3587
3566
|
lockTime: Number(lockTime)
|
|
3588
3567
|
});
|
|
@@ -3592,12 +3571,12 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3592
3571
|
index: input.vout,
|
|
3593
3572
|
sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
|
|
3594
3573
|
witnessUtxo: {
|
|
3595
|
-
script:
|
|
3574
|
+
script: chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).pkScript,
|
|
3596
3575
|
amount: BigInt(input.value)
|
|
3597
3576
|
},
|
|
3598
3577
|
tapLeafScript: [input.tapLeafScript]
|
|
3599
3578
|
});
|
|
3600
|
-
|
|
3579
|
+
chunkASKOHVGX_cjs.setArkPsbtField(tx, i, chunkASKOHVGX_cjs.VtxoTaprootTree, input.tapTree);
|
|
3601
3580
|
}
|
|
3602
3581
|
for (const output of outputs) {
|
|
3603
3582
|
tx.addOutput(output);
|
|
@@ -3608,8 +3587,8 @@ function buildVirtualTx(inputs, outputs) {
|
|
|
3608
3587
|
return tx;
|
|
3609
3588
|
}
|
|
3610
3589
|
function buildCheckpointTx(vtxo, serverUnrollScript) {
|
|
3611
|
-
const collaborativeClosure =
|
|
3612
|
-
const checkpointVtxoScript = new
|
|
3590
|
+
const collaborativeClosure = chunkASKOHVGX_cjs.decodeTapscript(chunkASKOHVGX_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
|
|
3591
|
+
const checkpointVtxoScript = new chunkASKOHVGX_cjs.VtxoScript([
|
|
3613
3592
|
serverUnrollScript.script,
|
|
3614
3593
|
collaborativeClosure.script
|
|
3615
3594
|
]);
|
|
@@ -3685,7 +3664,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
|
|
|
3685
3664
|
const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
|
|
3686
3665
|
const sig = signature.subarray(0, 64);
|
|
3687
3666
|
if (!allowedSighashTypes.includes(sighashType)) {
|
|
3688
|
-
const sighashName =
|
|
3667
|
+
const sighashName = chunkASKOHVGX_cjs.formatSighash(sighashType);
|
|
3689
3668
|
throw new Error(
|
|
3690
3669
|
`Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
|
|
3691
3670
|
);
|
|
@@ -3759,7 +3738,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
|
|
|
3759
3738
|
}
|
|
3760
3739
|
function isValidArkAddress(address) {
|
|
3761
3740
|
try {
|
|
3762
|
-
|
|
3741
|
+
chunkASKOHVGX_cjs.ArkAddress.decode(address);
|
|
3763
3742
|
return true;
|
|
3764
3743
|
} catch (e) {
|
|
3765
3744
|
return false;
|
|
@@ -3767,16 +3746,16 @@ function isValidArkAddress(address) {
|
|
|
3767
3746
|
}
|
|
3768
3747
|
function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
|
|
3769
3748
|
if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
|
|
3770
|
-
throw new
|
|
3749
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3771
3750
|
`${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
|
|
3772
3751
|
);
|
|
3773
3752
|
}
|
|
3774
3753
|
const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
|
|
3775
3754
|
return serverCheckpointTxs.map((encoded, index) => {
|
|
3776
|
-
const server =
|
|
3755
|
+
const server = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
3777
3756
|
const local = byTxid.get(server.id);
|
|
3778
3757
|
if (!local) {
|
|
3779
|
-
throw new
|
|
3758
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3780
3759
|
`${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
|
|
3781
3760
|
);
|
|
3782
3761
|
}
|
|
@@ -3786,14 +3765,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
|
|
|
3786
3765
|
}
|
|
3787
3766
|
function assertSubmittedArkTxid(response, signedArkTx, context) {
|
|
3788
3767
|
if (response.arkTxid !== signedArkTx.id) {
|
|
3789
|
-
throw new
|
|
3768
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3790
3769
|
`${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
|
|
3791
3770
|
);
|
|
3792
3771
|
}
|
|
3793
3772
|
if (response.finalArkTx === void 0) return;
|
|
3794
|
-
const finalTxid =
|
|
3773
|
+
const finalTxid = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
|
|
3795
3774
|
if (finalTxid !== signedArkTx.id) {
|
|
3796
|
-
throw new
|
|
3775
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3797
3776
|
`${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
|
|
3798
3777
|
);
|
|
3799
3778
|
}
|
|
@@ -3805,20 +3784,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3805
3784
|
`${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
|
|
3806
3785
|
);
|
|
3807
3786
|
}
|
|
3808
|
-
const script =
|
|
3787
|
+
const script = chunkASKOHVGX_cjs.scriptFromTapLeafScript(leaf);
|
|
3809
3788
|
let leafPubkeys;
|
|
3810
3789
|
try {
|
|
3811
|
-
leafPubkeys =
|
|
3812
|
-
(key) => base.hex.encode(
|
|
3790
|
+
leafPubkeys = chunkASKOHVGX_cjs.decodeTapscript(script).params.pubkeys.map(
|
|
3791
|
+
(key) => base.hex.encode(chunk4MCQZYH6_cjs.toXOnly(key, "leaf key"))
|
|
3813
3792
|
);
|
|
3814
3793
|
} catch (error) {
|
|
3815
|
-
throw new
|
|
3794
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3816
3795
|
`${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
|
|
3817
3796
|
);
|
|
3818
3797
|
}
|
|
3819
3798
|
const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
|
|
3820
3799
|
if (!signer) {
|
|
3821
|
-
throw new
|
|
3800
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3822
3801
|
`${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
|
|
3823
3802
|
);
|
|
3824
3803
|
}
|
|
@@ -3832,7 +3811,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
|
|
|
3832
3811
|
payment_js.tapLeafHash(script)
|
|
3833
3812
|
);
|
|
3834
3813
|
} catch (error) {
|
|
3835
|
-
throw new
|
|
3814
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3836
3815
|
`${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
|
|
3837
3816
|
);
|
|
3838
3817
|
}
|
|
@@ -3841,20 +3820,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3841
3820
|
const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
|
|
3842
3821
|
for (const [index, checkpoint] of checkpoints.entries()) {
|
|
3843
3822
|
if (checkpoint.inputsLength !== 1) {
|
|
3844
|
-
throw new
|
|
3823
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3845
3824
|
`${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
|
|
3846
3825
|
);
|
|
3847
3826
|
}
|
|
3848
3827
|
const spent = checkpoint.getInput(0);
|
|
3849
3828
|
if (!spent.txid || spent.index === void 0) {
|
|
3850
|
-
throw new
|
|
3829
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3851
3830
|
`${context}: checkpoint ${index} has no input outpoint`
|
|
3852
3831
|
);
|
|
3853
3832
|
}
|
|
3854
3833
|
const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
|
|
3855
3834
|
const input = byOutpoint.get(outpoint);
|
|
3856
3835
|
if (!input) {
|
|
3857
|
-
throw new
|
|
3836
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3858
3837
|
`${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
|
|
3859
3838
|
);
|
|
3860
3839
|
}
|
|
@@ -3862,7 +3841,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
|
|
|
3862
3841
|
(unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
|
|
3863
3842
|
);
|
|
3864
3843
|
if (!rebuilt) {
|
|
3865
|
-
throw new
|
|
3844
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3866
3845
|
`${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
|
|
3867
3846
|
);
|
|
3868
3847
|
}
|
|
@@ -3888,9 +3867,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3888
3867
|
const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
|
|
3889
3868
|
matched.forEach(({ server }, index) => {
|
|
3890
3869
|
try {
|
|
3891
|
-
|
|
3870
|
+
chunkASKOHVGX_cjs.assertAllowedSighashTypes(server);
|
|
3892
3871
|
} catch (error) {
|
|
3893
|
-
throw new
|
|
3872
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3894
3873
|
`submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
|
|
3895
3874
|
);
|
|
3896
3875
|
}
|
|
@@ -3898,14 +3877,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
|
|
|
3898
3877
|
const verify = options?.verifyServerSignatures;
|
|
3899
3878
|
if (verify) {
|
|
3900
3879
|
if (response.finalArkTx === void 0) {
|
|
3901
|
-
throw new
|
|
3880
|
+
throw new chunkASKOHVGX_cjs.ServerResponseMismatchError(
|
|
3902
3881
|
"submitTx: server returned no final ark tx to verify its signatures against"
|
|
3903
3882
|
);
|
|
3904
3883
|
}
|
|
3905
|
-
const finalArkTx =
|
|
3884
|
+
const finalArkTx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
|
|
3906
3885
|
const serverPubkeys = new Set(
|
|
3907
3886
|
[verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
|
|
3908
|
-
(key) => base.hex.encode(
|
|
3887
|
+
(key) => base.hex.encode(chunk4MCQZYH6_cjs.toXOnly(key, "server key"))
|
|
3909
3888
|
)
|
|
3910
3889
|
);
|
|
3911
3890
|
for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
|
|
@@ -3969,7 +3948,7 @@ async function submitViaEmulator(emulator, offchainTx, signer, opts) {
|
|
|
3969
3948
|
base.base64.encode(arkTx.toPSBT()),
|
|
3970
3949
|
checkpoints.map((c) => base.base64.encode(c.toPSBT()))
|
|
3971
3950
|
);
|
|
3972
|
-
const txid =
|
|
3951
|
+
const txid = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(res.signedArkTx)).id;
|
|
3973
3952
|
assertSubmittedArkTxid({ arkTxid: txid }, arkTx, "emulator submitTx");
|
|
3974
3953
|
return { txid, signedArkTx: res.signedArkTx, signedCheckpointTxs: res.signedCheckpointTxs };
|
|
3975
3954
|
}
|
|
@@ -3977,12 +3956,12 @@ function claimWithPreimageIdentity(identity, preimage) {
|
|
|
3977
3956
|
return {
|
|
3978
3957
|
...identity,
|
|
3979
3958
|
sign: async (tx, inputIndexes) => {
|
|
3980
|
-
const signed =
|
|
3959
|
+
const signed = chunkASKOHVGX_cjs.Transaction.fromPSBT(
|
|
3981
3960
|
(await identity.sign(tx.clone(), inputIndexes)).toPSBT()
|
|
3982
3961
|
);
|
|
3983
3962
|
const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
|
|
3984
3963
|
for (const index of indexes) {
|
|
3985
|
-
|
|
3964
|
+
chunkASKOHVGX_cjs.setArkPsbtField(signed, index, chunkASKOHVGX_cjs.ConditionWitness, [preimage]);
|
|
3986
3965
|
}
|
|
3987
3966
|
return signed;
|
|
3988
3967
|
}
|
|
@@ -4165,7 +4144,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
|
|
|
4165
4144
|
};
|
|
4166
4145
|
}
|
|
4167
4146
|
function deriveContractTapscripts(contract) {
|
|
4168
|
-
const handler =
|
|
4147
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
4169
4148
|
if (!handler) {
|
|
4170
4149
|
throw new Error(`No handler for contract type '${contract.type}'`);
|
|
4171
4150
|
}
|
|
@@ -4268,7 +4247,7 @@ function assertRecipientArkadeAddress(encoded, address, context) {
|
|
|
4268
4247
|
function assertTapTreeDerivesAddress(encoded, tapTree, address) {
|
|
4269
4248
|
let derived;
|
|
4270
4249
|
try {
|
|
4271
|
-
derived =
|
|
4250
|
+
derived = chunkASKOHVGX_cjs.VtxoScript.decode(tapTree).pkScript;
|
|
4272
4251
|
} catch (e) {
|
|
4273
4252
|
throw new Error(
|
|
4274
4253
|
`Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
|
|
@@ -4285,7 +4264,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4285
4264
|
for (const recipient of recipients) {
|
|
4286
4265
|
let address;
|
|
4287
4266
|
try {
|
|
4288
|
-
address =
|
|
4267
|
+
address = chunkASKOHVGX_cjs.ArkAddress.decode(recipient.address);
|
|
4289
4268
|
} catch (e) {
|
|
4290
4269
|
throw new Error(`Invalid Arkade address: ${recipient.address}`);
|
|
4291
4270
|
}
|
|
@@ -4310,7 +4289,7 @@ function validateRecipients(recipients, dustAmount, context) {
|
|
|
4310
4289
|
|
|
4311
4290
|
// src/contracts/spendability.ts
|
|
4312
4291
|
function isContractGenericallySpendable(contract) {
|
|
4313
|
-
return
|
|
4292
|
+
return chunk4MCQZYH6_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
|
|
4314
4293
|
}
|
|
4315
4294
|
function gatedContracts(contracts) {
|
|
4316
4295
|
const gated = /* @__PURE__ */ new Map();
|
|
@@ -4332,7 +4311,7 @@ function gateExclusion(gated) {
|
|
|
4332
4311
|
return (vtxo) => {
|
|
4333
4312
|
const type = gatedTypeOf(vtxo, gated);
|
|
4334
4313
|
if (type === void 0) return void 0;
|
|
4335
|
-
if (!
|
|
4314
|
+
if (!chunk4MCQZYH6_cjs.contractHandlers.has(type)) {
|
|
4336
4315
|
return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
|
|
4337
4316
|
}
|
|
4338
4317
|
return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
|
|
@@ -4368,7 +4347,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
|
|
|
4368
4347
|
continue;
|
|
4369
4348
|
}
|
|
4370
4349
|
for (const v of vtxos) {
|
|
4371
|
-
if (!
|
|
4350
|
+
if (!chunkASKOHVGX_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
|
|
4372
4351
|
out.add(`${v.txid}:${v.vout}`);
|
|
4373
4352
|
}
|
|
4374
4353
|
}
|
|
@@ -4404,14 +4383,14 @@ function byValueDescending(vtxos) {
|
|
|
4404
4383
|
return [...vtxos].sort((a, b) => b.value - a.value);
|
|
4405
4384
|
}
|
|
4406
4385
|
async function fetchTimeHeight(wallet) {
|
|
4407
|
-
return
|
|
4386
|
+
return chunkASKOHVGX_cjs.resolveTimeHeight(wallet.onchainProvider);
|
|
4408
4387
|
}
|
|
4409
4388
|
function heldVtxosOf(wallet) {
|
|
4410
4389
|
const held = wallet.getHeldVtxos;
|
|
4411
4390
|
return typeof held === "function" ? held.call(wallet) : Promise.resolve([]);
|
|
4412
4391
|
}
|
|
4413
4392
|
function canMigrateBySend(vtxo, now) {
|
|
4414
|
-
if (!
|
|
4393
|
+
if (!chunkASKOHVGX_cjs.canSpendOffchain(vtxo, now)) return false;
|
|
4415
4394
|
return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
|
|
4416
4395
|
}
|
|
4417
4396
|
function byExpiryAscending(vtxos, now) {
|
|
@@ -4419,7 +4398,7 @@ function byExpiryAscending(vtxos, now) {
|
|
|
4419
4398
|
if (vtxo.isSwept) return -Infinity;
|
|
4420
4399
|
if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
|
|
4421
4400
|
if (vtxo.expiresAtHeight !== void 0) {
|
|
4422
|
-
return
|
|
4401
|
+
return chunkASKOHVGX_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
|
|
4423
4402
|
}
|
|
4424
4403
|
return Infinity;
|
|
4425
4404
|
};
|
|
@@ -4446,7 +4425,7 @@ function priceSettlementInputs(vtxos, estimator) {
|
|
|
4446
4425
|
const payable = [];
|
|
4447
4426
|
const net = /* @__PURE__ */ new Map();
|
|
4448
4427
|
for (const vtxo of vtxos) {
|
|
4449
|
-
const inputFee = estimator.evalOffchainInput(
|
|
4428
|
+
const inputFee = estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(vtxo));
|
|
4450
4429
|
if (inputFee.satoshis >= vtxo.value) {
|
|
4451
4430
|
continue;
|
|
4452
4431
|
}
|
|
@@ -4475,7 +4454,7 @@ function offchainOutputFee(amount, estimator, arkAddress) {
|
|
|
4475
4454
|
}
|
|
4476
4455
|
const outputFee = estimator.evalOffchainOutput({
|
|
4477
4456
|
amount,
|
|
4478
|
-
script: base.hex.encode(
|
|
4457
|
+
script: base.hex.encode(chunkASKOHVGX_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
4479
4458
|
});
|
|
4480
4459
|
return BigInt(outputFee.satoshis);
|
|
4481
4460
|
}
|
|
@@ -4526,10 +4505,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
|
|
|
4526
4505
|
};
|
|
4527
4506
|
function getRecoverableVtxos(vtxos, dustAmount, now) {
|
|
4528
4507
|
return vtxos.filter((vtxo) => {
|
|
4529
|
-
if (
|
|
4508
|
+
if (chunkASKOHVGX_cjs.canRecoverOnchain(vtxo, now)) {
|
|
4530
4509
|
return true;
|
|
4531
4510
|
}
|
|
4532
|
-
if (
|
|
4511
|
+
if (chunkASKOHVGX_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
|
|
4533
4512
|
return true;
|
|
4534
4513
|
}
|
|
4535
4514
|
return false;
|
|
@@ -4561,7 +4540,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
|
|
|
4561
4540
|
function isVtxoExpiringSoon(vtxo, thresholdMs) {
|
|
4562
4541
|
if (vtxo.isUnrolled) return false;
|
|
4563
4542
|
const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
|
|
4564
|
-
const expiresAt =
|
|
4543
|
+
const expiresAt = chunkASKOHVGX_cjs.normalizeVtxo(vtxo).expiresAt;
|
|
4565
4544
|
if (expiresAt === void 0) return false;
|
|
4566
4545
|
const now = Date.now();
|
|
4567
4546
|
const batchExpiry = expiresAt.getTime();
|
|
@@ -4572,7 +4551,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
|
|
|
4572
4551
|
return vtxos.filter(
|
|
4573
4552
|
// The leading exclusion covers the `isSubdust` arm too, which is a value
|
|
4574
4553
|
// property and would otherwise re-admit an exited coin on its own.
|
|
4575
|
-
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) ||
|
|
4554
|
+
(vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkASKOHVGX_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
|
|
4576
4555
|
);
|
|
4577
4556
|
}
|
|
4578
4557
|
function isMigrationCapable(wallet) {
|
|
@@ -4632,7 +4611,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4632
4611
|
constructor(wallet, settlementConfig) {
|
|
4633
4612
|
this.wallet = wallet;
|
|
4634
4613
|
if (settlementConfig !== false) {
|
|
4635
|
-
|
|
4614
|
+
chunkASKOHVGX_cjs.assertTimerMs("pollIntervalMs", settlementConfig?.pollIntervalMs);
|
|
4636
4615
|
}
|
|
4637
4616
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
4638
4617
|
this.contractEventsSubscriptionReady = this.initializeSubscription();
|
|
@@ -4939,7 +4918,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4939
4918
|
* {@link recoverImportedContracts}).
|
|
4940
4919
|
*/
|
|
4941
4920
|
async recoverOneImportedContract(wallet, contract, vtxos, info, dustAmount) {
|
|
4942
|
-
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !
|
|
4921
|
+
const recoverable = vtxos.filter((vtxo) => vtxo.isSwept && !chunkASKOHVGX_cjs.isVtxoSpent(vtxo));
|
|
4943
4922
|
const estimator = new Estimator(info?.fees.intentFee ?? {});
|
|
4944
4923
|
const { payable, net } = priceSettlementInputs(recoverable, estimator);
|
|
4945
4924
|
const vtxoMaxAmount = info?.vtxoMaxAmount ?? -1n;
|
|
@@ -4961,7 +4940,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
4961
4940
|
if (vtxos.length === 0) return;
|
|
4962
4941
|
const spent = new Set(batch.map((vtxo) => `${vtxo.txid}:${vtxo.vout}`));
|
|
4963
4942
|
const stillSpendable = vtxos.some(
|
|
4964
|
-
(vtxo) => !
|
|
4943
|
+
(vtxo) => !chunkASKOHVGX_cjs.isVtxoSpent(vtxo) && !spent.has(`${vtxo.txid}:${vtxo.vout}`)
|
|
4965
4944
|
);
|
|
4966
4945
|
if (!stillSpendable) {
|
|
4967
4946
|
await wallet.removeRecoveryContract(contract.script);
|
|
@@ -5253,11 +5232,11 @@ var VtxoManager = class _VtxoManager {
|
|
|
5253
5232
|
`Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
|
|
5254
5233
|
);
|
|
5255
5234
|
}
|
|
5256
|
-
const tx = new
|
|
5235
|
+
const tx = new chunkASKOHVGX_cjs.Transaction();
|
|
5257
5236
|
for (const utxo of expiredUtxos) {
|
|
5258
|
-
const utxoScript =
|
|
5237
|
+
const utxoScript = chunkASKOHVGX_cjs.VtxoScript.decode(utxo.tapTree);
|
|
5259
5238
|
const utxoExitLeaf = utxoScript.leaves.find(
|
|
5260
|
-
(leaf) =>
|
|
5239
|
+
(leaf) => chunkASKOHVGX_cjs.CSVMultisigTapscript.isScriptValid(chunkASKOHVGX_cjs.scriptFromTapLeafScript(leaf)) === true
|
|
5261
5240
|
);
|
|
5262
5241
|
if (!utxoExitLeaf) {
|
|
5263
5242
|
throw new Error(
|
|
@@ -5272,7 +5251,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5272
5251
|
amount: BigInt(utxo.value)
|
|
5273
5252
|
},
|
|
5274
5253
|
tapLeafScript: [utxoExitLeaf],
|
|
5275
|
-
sequence:
|
|
5254
|
+
sequence: chunkASKOHVGX_cjs.getSequence(utxoExitLeaf)
|
|
5276
5255
|
});
|
|
5277
5256
|
}
|
|
5278
5257
|
tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
|
|
@@ -5498,8 +5477,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5498
5477
|
const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
|
|
5499
5478
|
if (cls.status === "CURRENT") continue;
|
|
5500
5479
|
const live = vtxos.filter((v) => !v.isUnrolled);
|
|
5501
|
-
const recoverable = live.filter((v) => v.isSwept && !
|
|
5502
|
-
const spendable = live.filter((v) => !
|
|
5480
|
+
const recoverable = live.filter((v) => v.isSwept && !chunkASKOHVGX_cjs.isVtxoSpent(v));
|
|
5481
|
+
const spendable = live.filter((v) => !chunkASKOHVGX_cjs.isVtxoSpent(v) && !v.isSwept);
|
|
5503
5482
|
const value = spendable.reduce((sum, v) => sum + v.value, 0);
|
|
5504
5483
|
let recoverableCount = 0;
|
|
5505
5484
|
let recoverableValue = 0;
|
|
@@ -5739,7 +5718,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
5739
5718
|
}
|
|
5740
5719
|
getBoardingTimelock() {
|
|
5741
5720
|
const wallet = this.getSweepWallet();
|
|
5742
|
-
const exitScript =
|
|
5721
|
+
const exitScript = chunkASKOHVGX_cjs.CSVMultisigTapscript.decode(
|
|
5743
5722
|
base.hex.decode(wallet.boardingTapscript.exitScript)
|
|
5744
5723
|
);
|
|
5745
5724
|
return exitScript.params.timelock;
|
|
@@ -5847,8 +5826,8 @@ var VtxoManager = class _VtxoManager {
|
|
|
5847
5826
|
}
|
|
5848
5827
|
/** The outpoint a `VTXO_ALREADY_SPENT` error carries in `metadata.vtxo_outpoint`, if any. */
|
|
5849
5828
|
extractSpentOutpoint(error) {
|
|
5850
|
-
const ark =
|
|
5851
|
-
if (!
|
|
5829
|
+
const ark = chunkASKOHVGX_cjs.maybeArkError(error);
|
|
5830
|
+
if (!chunkASKOHVGX_cjs.isArkError(ark, chunkASKOHVGX_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
|
|
5852
5831
|
const raw = ark.metadata?.vtxo_outpoint;
|
|
5853
5832
|
if (typeof raw !== "string") return void 0;
|
|
5854
5833
|
const [txid, voutStr] = raw.split(":");
|
|
@@ -6022,7 +6001,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6022
6001
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
6023
6002
|
break;
|
|
6024
6003
|
}
|
|
6025
|
-
const inputFee = estimator.evalOffchainInput(
|
|
6004
|
+
const inputFee = estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(v));
|
|
6026
6005
|
if (inputFee.satoshis >= v.value) {
|
|
6027
6006
|
continue;
|
|
6028
6007
|
}
|
|
@@ -6042,7 +6021,7 @@ var VtxoManager = class _VtxoManager {
|
|
|
6042
6021
|
const arkAddress = await this.wallet.getAddress();
|
|
6043
6022
|
const outputFee = estimator.evalOffchainOutput({
|
|
6044
6023
|
amount: totalAmount,
|
|
6045
|
-
script: base.hex.encode(
|
|
6024
|
+
script: base.hex.encode(chunkASKOHVGX_cjs.ArkAddress.decode(arkAddress).pkScript)
|
|
6046
6025
|
});
|
|
6047
6026
|
totalAmount -= BigInt(outputFee.satoshis);
|
|
6048
6027
|
if (totalAmount < dustAmount) return;
|
|
@@ -6126,7 +6105,7 @@ var ArkNote = class _ArkNote {
|
|
|
6126
6105
|
this.value = value;
|
|
6127
6106
|
this.HRP = HRP;
|
|
6128
6107
|
const preimageHash = utils_js.sha256(this.preimage);
|
|
6129
|
-
this.vtxoScript = new
|
|
6108
|
+
this.vtxoScript = new chunkASKOHVGX_cjs.VtxoScript([noteTapscript(preimageHash)]);
|
|
6130
6109
|
const leaf = this.vtxoScript.leaves[0];
|
|
6131
6110
|
this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
|
|
6132
6111
|
this.tapTree = this.vtxoScript.encode();
|
|
@@ -6299,7 +6278,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6299
6278
|
const privateKey = data.slice(1, 33);
|
|
6300
6279
|
const serverPubKey = data.slice(33, 65);
|
|
6301
6280
|
const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
|
|
6302
|
-
const csvTimelock2 =
|
|
6281
|
+
const csvTimelock2 = chunkASKOHVGX_cjs.sequenceToTimelock(sequence);
|
|
6303
6282
|
return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
|
|
6304
6283
|
}
|
|
6305
6284
|
toString() {
|
|
@@ -6307,7 +6286,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6307
6286
|
data[0] = _ArkadeCash.Version;
|
|
6308
6287
|
data.set(this._privateKey, 1);
|
|
6309
6288
|
data.set(this._serverPubKey, 33);
|
|
6310
|
-
const sequence =
|
|
6289
|
+
const sequence = chunkASKOHVGX_cjs.timelockToSequence(this.csvTimelock);
|
|
6311
6290
|
new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
|
|
6312
6291
|
const words = base.bech32m.toWords(data);
|
|
6313
6292
|
return base.bech32m.encode(this.hrp, words, 1023);
|
|
@@ -6316,7 +6295,7 @@ var ArkadeCash = class _ArkadeCash {
|
|
|
6316
6295
|
return SingleKey.fromPrivateKey(this._privateKey);
|
|
6317
6296
|
}
|
|
6318
6297
|
get vtxoScript() {
|
|
6319
|
-
return new
|
|
6298
|
+
return new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
6320
6299
|
pubKey: this._publicKey,
|
|
6321
6300
|
serverPubKey: this._serverPubKey,
|
|
6322
6301
|
csvTimelock: this.csvTimelock
|
|
@@ -6332,7 +6311,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
|
|
|
6332
6311
|
(s) => !isTerminalIntentState(s)
|
|
6333
6312
|
);
|
|
6334
6313
|
function isConsumed(vtxo) {
|
|
6335
|
-
return vtxo !== void 0 &&
|
|
6314
|
+
return vtxo !== void 0 && chunkASKOHVGX_cjs.isVtxoSpent(vtxo);
|
|
6336
6315
|
}
|
|
6337
6316
|
async function classifyIntent(intent, vtxosByOutpoint, now) {
|
|
6338
6317
|
if (isTerminalIntentState(intent.state)) return void 0;
|
|
@@ -6375,7 +6354,7 @@ async function reconcileIntents(deps) {
|
|
|
6375
6354
|
let vtxosByOutpoint = /* @__PURE__ */ new Map();
|
|
6376
6355
|
if (outpoints.length > 0) {
|
|
6377
6356
|
try {
|
|
6378
|
-
const { vtxos } = await
|
|
6357
|
+
const { vtxos } = await chunkASKOHVGX_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
|
|
6379
6358
|
vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
|
|
6380
6359
|
} catch (e) {
|
|
6381
6360
|
console.error("reconcileIntents: failed to fetch input VTXO state", e);
|
|
@@ -6435,7 +6414,7 @@ async function releaseFromServer(intent, deps, now) {
|
|
|
6435
6414
|
});
|
|
6436
6415
|
}
|
|
6437
6416
|
function isNoMatchingIntentsError(e) {
|
|
6438
|
-
return
|
|
6417
|
+
return chunkASKOHVGX_cjs.isArkError(e, chunkASKOHVGX_cjs.ArkErrorName.INVALID_INTENT_PROOF) && e.message.includes("no matching intents found");
|
|
6439
6418
|
}
|
|
6440
6419
|
function terminal(intent, state, now, patch) {
|
|
6441
6420
|
return { ...intent, ...patch, state, updatedAt: now };
|
|
@@ -6654,7 +6633,7 @@ async function captureExitBranch(params) {
|
|
|
6654
6633
|
const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
|
|
6655
6634
|
if (nonCommitment.length > 0) {
|
|
6656
6635
|
for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
|
|
6657
|
-
psbtByTxid.set(
|
|
6636
|
+
psbtByTxid.set(chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6658
6637
|
}
|
|
6659
6638
|
}
|
|
6660
6639
|
}
|
|
@@ -6697,10 +6676,10 @@ var IndexerExitDataSource = class {
|
|
|
6697
6676
|
while (hasMore) {
|
|
6698
6677
|
const { chain: page, page: meta } = await this.indexer.getVtxoChain(
|
|
6699
6678
|
{ txid: vtxo.txid, vout: vtxo.vout },
|
|
6700
|
-
{ pageIndex, pageSize:
|
|
6679
|
+
{ pageIndex, pageSize: chunkASKOHVGX_cjs.DEFAULT_PAGE_SIZE }
|
|
6701
6680
|
);
|
|
6702
6681
|
chain.push(...page);
|
|
6703
|
-
hasMore = meta ? page.length ===
|
|
6682
|
+
hasMore = meta ? page.length === chunkASKOHVGX_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6704
6683
|
pageIndex++;
|
|
6705
6684
|
}
|
|
6706
6685
|
return chain;
|
|
@@ -6712,12 +6691,12 @@ var IndexerExitDataSource = class {
|
|
|
6712
6691
|
while (hasMore) {
|
|
6713
6692
|
const { txs, page } = await this.indexer.getVirtualTxs(txids, {
|
|
6714
6693
|
pageIndex,
|
|
6715
|
-
pageSize:
|
|
6694
|
+
pageSize: chunkASKOHVGX_cjs.DEFAULT_PAGE_SIZE
|
|
6716
6695
|
});
|
|
6717
6696
|
for (const psbt of txs) {
|
|
6718
|
-
out.set(
|
|
6697
|
+
out.set(chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
6719
6698
|
}
|
|
6720
|
-
hasMore = page ? txs.length ===
|
|
6699
|
+
hasMore = page ? txs.length === chunkASKOHVGX_cjs.DEFAULT_PAGE_SIZE : false;
|
|
6721
6700
|
pageIndex++;
|
|
6722
6701
|
}
|
|
6723
6702
|
return out;
|
|
@@ -6738,7 +6717,7 @@ function chainedTxTypeToChainTxType(t) {
|
|
|
6738
6717
|
}
|
|
6739
6718
|
}
|
|
6740
6719
|
function psbtInputTxids(psbtBase64) {
|
|
6741
|
-
return txInputTxids(
|
|
6720
|
+
return txInputTxids(chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64)));
|
|
6742
6721
|
}
|
|
6743
6722
|
function txInputTxids(tx) {
|
|
6744
6723
|
const ids = [];
|
|
@@ -7042,10 +7021,10 @@ async function resolveArkInfo(arkProvider, walletRepository, opts) {
|
|
|
7042
7021
|
try {
|
|
7043
7022
|
info = await arkProvider.getInfo();
|
|
7044
7023
|
} catch (err) {
|
|
7045
|
-
if (opts?.requireLive || !
|
|
7024
|
+
if (opts?.requireLive || !chunkASKOHVGX_cjs.isRetryableProviderError(err)) throw err;
|
|
7046
7025
|
const snapshot = await loadArkInfoSnapshot(walletRepository);
|
|
7047
7026
|
if (!snapshot) {
|
|
7048
|
-
throw new
|
|
7027
|
+
throw new chunkASKOHVGX_cjs.ProviderUnavailableError(
|
|
7049
7028
|
"Arkade server info is unavailable and no cached snapshot exists",
|
|
7050
7029
|
{ cause: err }
|
|
7051
7030
|
);
|
|
@@ -7237,7 +7216,7 @@ function buildGraph(rootTxid, chunksByTxid) {
|
|
|
7237
7216
|
return new TxTree(rootTx, children);
|
|
7238
7217
|
}
|
|
7239
7218
|
function decodeNode(chunk) {
|
|
7240
|
-
const tx =
|
|
7219
|
+
const tx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(chunk.tx));
|
|
7241
7220
|
return { tx, children: chunk.children };
|
|
7242
7221
|
}
|
|
7243
7222
|
exports.Batch = void 0;
|
|
@@ -7440,7 +7419,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
|
|
|
7440
7419
|
return [...txids];
|
|
7441
7420
|
}
|
|
7442
7421
|
async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
|
|
7443
|
-
const normalized = vtxos.map(
|
|
7422
|
+
const normalized = vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
7444
7423
|
const localCreatedAt = localCreatedAtByTxid(normalized);
|
|
7445
7424
|
const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
|
|
7446
7425
|
const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
|
|
@@ -7618,7 +7597,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7618
7597
|
withRecoverable: false,
|
|
7619
7598
|
genericallySpendableOnly: true
|
|
7620
7599
|
});
|
|
7621
|
-
const controlAssetRef = params.controlAssetId ?
|
|
7600
|
+
const controlAssetRef = params.controlAssetId ? chunkAICUNREA_cjs.AssetRef.fromId(chunkAICUNREA_cjs.AssetId.fromString(params.controlAssetId)) : null;
|
|
7622
7601
|
const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
|
|
7623
7602
|
let totalBtcSelected = 0n;
|
|
7624
7603
|
const assetChanges = /* @__PURE__ */ new Map();
|
|
@@ -7631,8 +7610,8 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7631
7610
|
}
|
|
7632
7611
|
}
|
|
7633
7612
|
const groups = [];
|
|
7634
|
-
const issuedAssetOutput =
|
|
7635
|
-
const issuedAssetGroup =
|
|
7613
|
+
const issuedAssetOutput = chunkAICUNREA_cjs.AssetOutput.create(0, params.amount);
|
|
7614
|
+
const issuedAssetGroup = chunkAICUNREA_cjs.AssetGroup.create(
|
|
7636
7615
|
null,
|
|
7637
7616
|
controlAssetRef,
|
|
7638
7617
|
[],
|
|
@@ -7645,11 +7624,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7645
7624
|
for (const [assetId, amount] of assetChanges) {
|
|
7646
7625
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7647
7626
|
groups.push(
|
|
7648
|
-
|
|
7649
|
-
|
|
7627
|
+
chunkAICUNREA_cjs.AssetGroup.create(
|
|
7628
|
+
chunkAICUNREA_cjs.AssetId.fromString(assetId),
|
|
7650
7629
|
null,
|
|
7651
7630
|
changeInputs,
|
|
7652
|
-
[
|
|
7631
|
+
[chunkAICUNREA_cjs.AssetOutput.create(0, amount)],
|
|
7653
7632
|
[]
|
|
7654
7633
|
)
|
|
7655
7634
|
);
|
|
@@ -7664,7 +7643,7 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7664
7643
|
);
|
|
7665
7644
|
return {
|
|
7666
7645
|
arkTxId: arkTxid,
|
|
7667
|
-
assetId:
|
|
7646
|
+
assetId: chunkAICUNREA_cjs.AssetId.create(arkTxid, 0).toString()
|
|
7668
7647
|
};
|
|
7669
7648
|
}
|
|
7670
7649
|
/**
|
|
@@ -7738,23 +7717,23 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7738
7717
|
const assetInputs = selectedCoinsToAssetInputs(selectedCoins);
|
|
7739
7718
|
const reissueInputs = inputsForAsset(assetInputs, params.assetId);
|
|
7740
7719
|
const totalAssetAmount = assetToReissueAmount + params.amount;
|
|
7741
|
-
const reissueAssetIdObj =
|
|
7742
|
-
const reissueAssetGroup =
|
|
7720
|
+
const reissueAssetIdObj = chunkAICUNREA_cjs.AssetId.fromString(params.assetId);
|
|
7721
|
+
const reissueAssetGroup = chunkAICUNREA_cjs.AssetGroup.create(
|
|
7743
7722
|
reissueAssetIdObj,
|
|
7744
7723
|
null,
|
|
7745
7724
|
reissueInputs,
|
|
7746
|
-
[
|
|
7725
|
+
[chunkAICUNREA_cjs.AssetOutput.create(0, totalAssetAmount)],
|
|
7747
7726
|
[]
|
|
7748
7727
|
);
|
|
7749
7728
|
const groups = [reissueAssetGroup];
|
|
7750
7729
|
for (const [assetId, amount] of assetChanges) {
|
|
7751
7730
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7752
7731
|
groups.push(
|
|
7753
|
-
|
|
7754
|
-
|
|
7732
|
+
chunkAICUNREA_cjs.AssetGroup.create(
|
|
7733
|
+
chunkAICUNREA_cjs.AssetId.fromString(assetId),
|
|
7755
7734
|
null,
|
|
7756
7735
|
changeInputs,
|
|
7757
|
-
[
|
|
7736
|
+
[chunkAICUNREA_cjs.AssetOutput.create(0, amount)],
|
|
7758
7737
|
[]
|
|
7759
7738
|
)
|
|
7760
7739
|
);
|
|
@@ -7825,11 +7804,11 @@ var AssetManager = class extends ReadonlyAssetManager {
|
|
|
7825
7804
|
for (const [assetId, amount] of assetChanges) {
|
|
7826
7805
|
const changeInputs = inputsForAsset(assetInputs, assetId);
|
|
7827
7806
|
groups.push(
|
|
7828
|
-
|
|
7829
|
-
|
|
7807
|
+
chunkAICUNREA_cjs.AssetGroup.create(
|
|
7808
|
+
chunkAICUNREA_cjs.AssetId.fromString(assetId),
|
|
7830
7809
|
null,
|
|
7831
7810
|
changeInputs,
|
|
7832
|
-
amount > 0n ? [
|
|
7811
|
+
amount > 0n ? [chunkAICUNREA_cjs.AssetOutput.create(0, amount)] : [],
|
|
7833
7812
|
[]
|
|
7834
7813
|
)
|
|
7835
7814
|
);
|
|
@@ -7842,16 +7821,16 @@ function inputsForAsset(assetInputs, assetId) {
|
|
|
7842
7821
|
for (const [inputIndex, assets] of assetInputs) {
|
|
7843
7822
|
for (const asset of assets) {
|
|
7844
7823
|
if (asset.assetId !== assetId) continue;
|
|
7845
|
-
inputs.push(
|
|
7824
|
+
inputs.push(chunkAICUNREA_cjs.AssetInput.create(inputIndex, asset.amount));
|
|
7846
7825
|
}
|
|
7847
7826
|
}
|
|
7848
7827
|
return inputs;
|
|
7849
7828
|
}
|
|
7850
7829
|
async function submitToSelf(submit, wallet, inputs, amount, groups) {
|
|
7851
|
-
const outputAddress =
|
|
7830
|
+
const outputAddress = chunkASKOHVGX_cjs.ArkAddress.decode(await wallet.getAddress());
|
|
7852
7831
|
const outputs = [
|
|
7853
7832
|
{ script: outputAddress.pkScript, amount: BigInt(amount) },
|
|
7854
|
-
Extension.create([
|
|
7833
|
+
Extension.create([chunkAICUNREA_cjs.Packet.create(groups)]).txOut()
|
|
7855
7834
|
];
|
|
7856
7835
|
const { arkTxid } = await submit(inputs, outputs);
|
|
7857
7836
|
return arkTxid;
|
|
@@ -7875,7 +7854,7 @@ function castMetadata(metadata) {
|
|
|
7875
7854
|
} else {
|
|
7876
7855
|
throw new Error("Invalid metadata value type");
|
|
7877
7856
|
}
|
|
7878
|
-
md.push(
|
|
7857
|
+
md.push(chunkAICUNREA_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
|
|
7879
7858
|
}
|
|
7880
7859
|
return md;
|
|
7881
7860
|
}
|
|
@@ -7896,10 +7875,10 @@ var DelegateManagerImpl = class {
|
|
|
7896
7875
|
if (vtxos.length === 0) {
|
|
7897
7876
|
return { delegated: [], failed: [] };
|
|
7898
7877
|
}
|
|
7899
|
-
const destinationScript =
|
|
7878
|
+
const destinationScript = chunkASKOHVGX_cjs.ArkAddress.decode(destination).pkScript;
|
|
7900
7879
|
const arkInfo = await this.arkInfoProvider.getInfo();
|
|
7901
7880
|
const delegateInfo = await this.delegateProvider.getDelegateInfo();
|
|
7902
|
-
const eligible = vtxos.map(
|
|
7881
|
+
const eligible = vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo).filter(
|
|
7903
7882
|
(v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
|
|
7904
7883
|
);
|
|
7905
7884
|
if (eligible.length === 0) {
|
|
@@ -7931,7 +7910,7 @@ var DelegateManagerImpl = class {
|
|
|
7931
7910
|
const groupByExpiry = /* @__PURE__ */ new Map();
|
|
7932
7911
|
let recoverableVtxos = [];
|
|
7933
7912
|
for (const vtxo of eligible) {
|
|
7934
|
-
if (
|
|
7913
|
+
if (chunkASKOHVGX_cjs.canRecoverOnchain(vtxo, now)) {
|
|
7935
7914
|
recoverableVtxos.push(vtxo);
|
|
7936
7915
|
continue;
|
|
7937
7916
|
}
|
|
@@ -7983,7 +7962,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
7983
7962
|
}
|
|
7984
7963
|
if (!delegateAt) {
|
|
7985
7964
|
const now = { timestamp: /* @__PURE__ */ new Date() };
|
|
7986
|
-
const expiryTimestamp = vtxos.filter((coin) => !
|
|
7965
|
+
const expiryTimestamp = vtxos.filter((coin) => !chunkASKOHVGX_cjs.canRecoverOnchain(coin, now) && coin.expiresAt).reduce(
|
|
7987
7966
|
(min, coin) => Math.min(min, coin.expiresAt.getTime()),
|
|
7988
7967
|
Number.MAX_SAFE_INTEGER
|
|
7989
7968
|
);
|
|
@@ -8010,7 +7989,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8010
7989
|
let amount = 0n;
|
|
8011
7990
|
for (const coin of vtxos) {
|
|
8012
7991
|
const inputFee = estimator.evalOffchainInput({
|
|
8013
|
-
...
|
|
7992
|
+
...chunkASKOHVGX_cjs.toOffchainInputFeeParams(coin),
|
|
8014
7993
|
type: "vtxo"
|
|
8015
7994
|
});
|
|
8016
7995
|
if (inputFee.satoshis >= coin.value) {
|
|
@@ -8024,7 +8003,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8024
8003
|
const delegateFee = BigInt(Number(fee));
|
|
8025
8004
|
if (delegateFee > 0n) {
|
|
8026
8005
|
outputs.push({
|
|
8027
|
-
script:
|
|
8006
|
+
script: chunkASKOHVGX_cjs.ArkAddress.decode(delegateAddress).pkScript,
|
|
8028
8007
|
amount: delegateFee
|
|
8029
8008
|
});
|
|
8030
8009
|
}
|
|
@@ -8057,10 +8036,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
|
|
|
8057
8036
|
destinationScript
|
|
8058
8037
|
);
|
|
8059
8038
|
const forfeitOutputScript = btcSigner.OutScript.encode(
|
|
8060
|
-
btcSigner.Address(
|
|
8039
|
+
btcSigner.Address(chunkASKOHVGX_cjs.getNetwork(network)).decode(forfeitAddress)
|
|
8061
8040
|
);
|
|
8062
8041
|
const forfeits = await Promise.all(
|
|
8063
|
-
vtxos.filter((v) =>
|
|
8042
|
+
vtxos.filter((v) => chunkASKOHVGX_cjs.requiresForfeit(v)).map(async (coin) => {
|
|
8064
8043
|
const forfeit = await makeDelegateForfeitTx(
|
|
8065
8044
|
coin,
|
|
8066
8045
|
dust,
|
|
@@ -8085,7 +8064,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
|
|
|
8085
8064
|
index: input.vout,
|
|
8086
8065
|
witnessUtxo: {
|
|
8087
8066
|
amount: BigInt(input.value),
|
|
8088
|
-
script:
|
|
8067
|
+
script: chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
8089
8068
|
},
|
|
8090
8069
|
sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
|
|
8091
8070
|
tapLeafScript: [delegateTapLeaf]
|
|
@@ -8143,7 +8122,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
|
|
|
8143
8122
|
expire_at: 0,
|
|
8144
8123
|
cosigners_public_keys: cosignerPubKeys
|
|
8145
8124
|
};
|
|
8146
|
-
const proof =
|
|
8125
|
+
const proof = chunkASKOHVGX_cjs.Intent.create(message, coins, outputs);
|
|
8147
8126
|
const signedProof = await identity.sign(proof);
|
|
8148
8127
|
return {
|
|
8149
8128
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -8169,10 +8148,10 @@ function getDayTimestamp(timestamp) {
|
|
|
8169
8148
|
function findDelegateTapLeaf(vtxo, delegatePubkey) {
|
|
8170
8149
|
if (!vtxo.tapTree) return void 0;
|
|
8171
8150
|
const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
|
|
8172
|
-
const vtxoScript =
|
|
8151
|
+
const vtxoScript = chunkASKOHVGX_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
8173
8152
|
return vtxoScript.leaves.find((tapLeaf) => {
|
|
8174
|
-
const arkTapscript =
|
|
8175
|
-
if (!
|
|
8153
|
+
const arkTapscript = chunkASKOHVGX_cjs.decodeTapscript(chunkASKOHVGX_cjs.scriptFromTapLeafScript(tapLeaf));
|
|
8154
|
+
if (!chunkASKOHVGX_cjs.MultisigTapscript.is(arkTapscript)) return false;
|
|
8176
8155
|
return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
|
|
8177
8156
|
});
|
|
8178
8157
|
}
|
|
@@ -8728,8 +8707,8 @@ function checkSaveVtxosForScript(backend, key, vtxos) {
|
|
|
8728
8707
|
}
|
|
8729
8708
|
async function getVtxosForContract(repo, contract, options) {
|
|
8730
8709
|
const vtxos = repo.getVtxosForScriptPage ? await collectScriptVtxos(repo, contract.script, options) : filterVtxosForScript(await collectVtxos(repo, contract.address), contract.script);
|
|
8731
|
-
const normalized = vtxos.map(
|
|
8732
|
-
return options?.unspentOnly ? normalized.filter((vtxo) => !
|
|
8710
|
+
const normalized = vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
8711
|
+
return options?.unspentOnly ? normalized.filter((vtxo) => !chunkASKOHVGX_cjs.isVtxoSpent(vtxo)) : normalized;
|
|
8733
8712
|
}
|
|
8734
8713
|
async function hasVtxosForContract(repo, contract) {
|
|
8735
8714
|
if (repo.getVtxosForScriptPage) {
|
|
@@ -8960,7 +8939,7 @@ function decodeArkContract(encoded) {
|
|
|
8960
8939
|
}
|
|
8961
8940
|
function contractFromArkContract(encoded, options = {}) {
|
|
8962
8941
|
const parsed = decodeArkContract(encoded);
|
|
8963
|
-
const handler =
|
|
8942
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(parsed.type);
|
|
8964
8943
|
if (!handler) {
|
|
8965
8944
|
throw new Error(`No handler registered for contract type '${parsed.type}'`);
|
|
8966
8945
|
}
|
|
@@ -8974,9 +8953,9 @@ function contractFromArkContract(encoded, options = {}) {
|
|
|
8974
8953
|
metadata: options.metadata
|
|
8975
8954
|
};
|
|
8976
8955
|
}
|
|
8977
|
-
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix =
|
|
8956
|
+
function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkASKOHVGX_cjs.DEFAULT_NETWORK.hrp, options = {}) {
|
|
8978
8957
|
const parsed = decodeArkContract(encoded);
|
|
8979
|
-
const handler =
|
|
8958
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.getOrThrow(parsed.type);
|
|
8980
8959
|
const params = parsed.data;
|
|
8981
8960
|
const vtxoScript = handler.createScript(params);
|
|
8982
8961
|
return {
|
|
@@ -9033,10 +9012,10 @@ var ContractWatcher = class {
|
|
|
9033
9012
|
eventSourceReported = false;
|
|
9034
9013
|
/** @see ContractWatcherConfig */
|
|
9035
9014
|
constructor(config) {
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9015
|
+
chunkASKOHVGX_cjs.assertTimerMs("failsafePollIntervalMs", config.failsafePollIntervalMs);
|
|
9016
|
+
chunkASKOHVGX_cjs.assertTimerMs("reconnectDelayMs", config.reconnectDelayMs);
|
|
9017
|
+
chunkASKOHVGX_cjs.assertTimerMs("maxReconnectDelayMs", config.maxReconnectDelayMs);
|
|
9018
|
+
chunkASKOHVGX_cjs.assertTimerMs("subscriptionRequestTimeoutMs", config.subscriptionRequestTimeoutMs);
|
|
9040
9019
|
if (config.subscriptionRequestTimeoutMs === 0) {
|
|
9041
9020
|
throw new Error("subscriptionRequestTimeoutMs must be greater than 0");
|
|
9042
9021
|
}
|
|
@@ -9259,9 +9238,9 @@ var ContractWatcher = class {
|
|
|
9259
9238
|
this.reconnectAttempts = 0;
|
|
9260
9239
|
this.listenLoop().catch((e) => {
|
|
9261
9240
|
if (!this.isWatching || signal?.aborted) return;
|
|
9262
|
-
if (
|
|
9241
|
+
if (chunkASKOHVGX_cjs.isEventSourceError(e)) {
|
|
9263
9242
|
console.debug("ContractWatcher subscription disconnected; reconnecting");
|
|
9264
|
-
} else if (!
|
|
9243
|
+
} else if (!chunkASKOHVGX_cjs.isEventSourceUnavailableError(e)) {
|
|
9265
9244
|
console.error(e);
|
|
9266
9245
|
}
|
|
9267
9246
|
this.connectionState = "disconnected";
|
|
@@ -9271,7 +9250,7 @@ var ContractWatcher = class {
|
|
|
9271
9250
|
});
|
|
9272
9251
|
} catch (error) {
|
|
9273
9252
|
if (!this.isWatching || signal?.aborted) return;
|
|
9274
|
-
if (!
|
|
9253
|
+
if (!chunkASKOHVGX_cjs.isEventSourceUnavailableError(error)) {
|
|
9275
9254
|
console.error("ContractWatcher connection failed:", error);
|
|
9276
9255
|
}
|
|
9277
9256
|
this.connectionState = "disconnected";
|
|
@@ -9287,7 +9266,7 @@ var ContractWatcher = class {
|
|
|
9287
9266
|
* few seconds.
|
|
9288
9267
|
*/
|
|
9289
9268
|
reportEventSourceUnavailable(error) {
|
|
9290
|
-
if (!
|
|
9269
|
+
if (!chunkASKOHVGX_cjs.isEventSourceUnavailableError(error)) return false;
|
|
9291
9270
|
if (!this.eventSourceReported) {
|
|
9292
9271
|
this.eventSourceReported = true;
|
|
9293
9272
|
console.warn(
|
|
@@ -9352,7 +9331,7 @@ var ContractWatcher = class {
|
|
|
9352
9331
|
const now = Date.now();
|
|
9353
9332
|
let current;
|
|
9354
9333
|
try {
|
|
9355
|
-
current = await
|
|
9334
|
+
current = await chunkASKOHVGX_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
|
|
9356
9335
|
spendableOnly: true
|
|
9357
9336
|
});
|
|
9358
9337
|
} catch (error) {
|
|
@@ -9634,14 +9613,14 @@ var ContractWatcher = class {
|
|
|
9634
9613
|
const timestamp = Date.now();
|
|
9635
9614
|
if (update.newVtxos?.length) {
|
|
9636
9615
|
this.processSubscriptionVtxos(
|
|
9637
|
-
update.newVtxos.map(
|
|
9616
|
+
update.newVtxos.map(chunkASKOHVGX_cjs.normalizeVtxo),
|
|
9638
9617
|
"vtxo_received",
|
|
9639
9618
|
timestamp
|
|
9640
9619
|
);
|
|
9641
9620
|
}
|
|
9642
9621
|
if (update.spentVtxos?.length) {
|
|
9643
9622
|
this.processSubscriptionVtxos(
|
|
9644
|
-
update.spentVtxos.map(
|
|
9623
|
+
update.spentVtxos.map(chunkASKOHVGX_cjs.normalizeVtxo),
|
|
9645
9624
|
"vtxo_spent",
|
|
9646
9625
|
timestamp
|
|
9647
9626
|
);
|
|
@@ -9666,8 +9645,8 @@ var ContractWatcher = class {
|
|
|
9666
9645
|
continue;
|
|
9667
9646
|
}
|
|
9668
9647
|
if (target === byWatchedScript && eventType === "vtxo_received") {
|
|
9669
|
-
const n =
|
|
9670
|
-
if (
|
|
9648
|
+
const n = chunkASKOHVGX_cjs.normalizeVtxo(vtxo);
|
|
9649
|
+
if (chunkASKOHVGX_cjs.isVtxoSpent(n) || n.isSwept || chunkASKOHVGX_cjs.isPastExpiry(n, now)) continue;
|
|
9671
9650
|
}
|
|
9672
9651
|
let bucket = target.get(vtxo.script);
|
|
9673
9652
|
if (!bucket) {
|
|
@@ -9808,7 +9787,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9808
9787
|
if (!contract) continue;
|
|
9809
9788
|
try {
|
|
9810
9789
|
const key = contractKey(contract);
|
|
9811
|
-
const handler =
|
|
9790
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
9812
9791
|
const hit = memo?.get(script);
|
|
9813
9792
|
let tapscripts;
|
|
9814
9793
|
if (hit && hit.key === key && hit.handler === handler) {
|
|
@@ -9829,7 +9808,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9829
9808
|
scripts.add(script);
|
|
9830
9809
|
} catch (err) {
|
|
9831
9810
|
const reason = `'${contract.type}' at ${script}: ${err instanceof Error ? err.message : String(err)}`;
|
|
9832
|
-
if (err instanceof
|
|
9811
|
+
if (err instanceof chunk4MCQZYH6_cjs.UnsupportedProgramVersionError) {
|
|
9833
9812
|
unsupported.set(script, { key: contractKey(contract), reason });
|
|
9834
9813
|
} else {
|
|
9835
9814
|
failures.set(script, reason);
|
|
@@ -9840,7 +9819,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
|
|
|
9840
9819
|
}
|
|
9841
9820
|
function annotateAgainst(vtxos, byScript, tapscripts = /* @__PURE__ */ new Map()) {
|
|
9842
9821
|
return vtxos.map(
|
|
9843
|
-
(vtxo) => extendVirtualCoinForContract(
|
|
9822
|
+
(vtxo) => extendVirtualCoinForContract(chunkASKOHVGX_cjs.normalizeVtxo(vtxo), byScript, tapscripts)
|
|
9844
9823
|
);
|
|
9845
9824
|
}
|
|
9846
9825
|
var SCAN_MAX_INDEX = 1e4;
|
|
@@ -9884,8 +9863,8 @@ var ContractManager = class _ContractManager {
|
|
|
9884
9863
|
* `dispose()`, so it re-checks this at every await rather than run on a torn-down watcher. */
|
|
9885
9864
|
disposed = false;
|
|
9886
9865
|
constructor(config) {
|
|
9887
|
-
|
|
9888
|
-
|
|
9866
|
+
chunkASKOHVGX_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", config.vtxoSyncMaxAgeMs);
|
|
9867
|
+
chunkASKOHVGX_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", config.vtxoSyncOverlapMs);
|
|
9889
9868
|
this.config = { ...config };
|
|
9890
9869
|
this.watcher = new ContractWatcher({
|
|
9891
9870
|
indexerProvider: config.indexerProvider,
|
|
@@ -9921,12 +9900,12 @@ var ContractManager = class _ContractManager {
|
|
|
9921
9900
|
}
|
|
9922
9901
|
/** @see ContractManagerConfig.vtxoSyncMaxAgeMs — for factory-built managers. */
|
|
9923
9902
|
setVtxoSyncMaxAge(maxAgeMs) {
|
|
9924
|
-
|
|
9903
|
+
chunkASKOHVGX_cjs.assertNonNegativeMs("vtxoSyncMaxAgeMs", maxAgeMs);
|
|
9925
9904
|
this.config.vtxoSyncMaxAgeMs = maxAgeMs;
|
|
9926
9905
|
}
|
|
9927
9906
|
/** @see ContractManagerConfig.vtxoSyncOverlapMs — for factory-built managers. */
|
|
9928
9907
|
setVtxoSyncOverlap(overlapMs) {
|
|
9929
|
-
|
|
9908
|
+
chunkASKOHVGX_cjs.assertNonNegativeMs("vtxoSyncOverlapMs", overlapMs);
|
|
9930
9909
|
this.config.vtxoSyncOverlapMs = overlapMs;
|
|
9931
9910
|
}
|
|
9932
9911
|
markSyncOnline() {
|
|
@@ -9990,10 +9969,10 @@ var ContractManager = class _ContractManager {
|
|
|
9990
9969
|
if (this.unsupportedContracts.get(contract.script) === key) return true;
|
|
9991
9970
|
if (this.tapscriptMemo.get(contract.script)?.key === key) return false;
|
|
9992
9971
|
try {
|
|
9993
|
-
|
|
9972
|
+
chunk4MCQZYH6_cjs.contractHandlers.get(contract.type)?.createScript(contract.params);
|
|
9994
9973
|
return false;
|
|
9995
9974
|
} catch (err) {
|
|
9996
|
-
if (!(err instanceof
|
|
9975
|
+
if (!(err instanceof chunk4MCQZYH6_cjs.UnsupportedProgramVersionError)) return false;
|
|
9997
9976
|
this.unsupportedContracts.set(contract.script, key);
|
|
9998
9977
|
return true;
|
|
9999
9978
|
}
|
|
@@ -10006,7 +9985,7 @@ var ContractManager = class _ContractManager {
|
|
|
10006
9985
|
this.markSyncOnline();
|
|
10007
9986
|
return void 0;
|
|
10008
9987
|
} catch (err) {
|
|
10009
|
-
if (!
|
|
9988
|
+
if (!chunkASKOHVGX_cjs.isRetryableProviderError(err)) throw err;
|
|
10010
9989
|
this.markSyncDegraded(err);
|
|
10011
9990
|
return err;
|
|
10012
9991
|
}
|
|
@@ -10029,7 +10008,7 @@ var ContractManager = class _ContractManager {
|
|
|
10029
10008
|
try {
|
|
10030
10009
|
await this.scheduleLookAheadDrain();
|
|
10031
10010
|
} catch (err) {
|
|
10032
|
-
if (!
|
|
10011
|
+
if (!chunkASKOHVGX_cjs.isRetryableProviderError(err)) throw err;
|
|
10033
10012
|
this.lookAheadRefillOwed = true;
|
|
10034
10013
|
this.markSyncDegraded(err);
|
|
10035
10014
|
}
|
|
@@ -10092,7 +10071,7 @@ var ContractManager = class _ContractManager {
|
|
|
10092
10071
|
/** No throw: construction returned long ago, so the state is the channel. */
|
|
10093
10072
|
reportBackgroundFailure(stage, err) {
|
|
10094
10073
|
this.markSyncDegraded(err);
|
|
10095
|
-
if (!
|
|
10074
|
+
if (!chunkASKOHVGX_cjs.isRetryableProviderError(err)) {
|
|
10096
10075
|
console.error(`[contracts] background ${stage} failed`, err);
|
|
10097
10076
|
}
|
|
10098
10077
|
}
|
|
@@ -10194,7 +10173,7 @@ var ContractManager = class _ContractManager {
|
|
|
10194
10173
|
const from = Math.max(0, watermark - lookAhead.size);
|
|
10195
10174
|
const to = watermark + lookAhead.size;
|
|
10196
10175
|
const deps = lookAhead.candidateDeps();
|
|
10197
|
-
const handlers =
|
|
10176
|
+
const handlers = chunk4MCQZYH6_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk4MCQZYH6_cjs.contractHandlers.get(t)).filter(hasCandidates);
|
|
10198
10177
|
const band = /* @__PURE__ */ new Map();
|
|
10199
10178
|
for (let index = from; index <= to; index++) {
|
|
10200
10179
|
const descriptor = lookAhead.materialize(index);
|
|
@@ -10205,7 +10184,7 @@ var ContractManager = class _ContractManager {
|
|
|
10205
10184
|
index,
|
|
10206
10185
|
params: {
|
|
10207
10186
|
...candidate,
|
|
10208
|
-
...
|
|
10187
|
+
...chunk4MCQZYH6_cjs.speculativeReceiveMetadata(descriptor)
|
|
10209
10188
|
}
|
|
10210
10189
|
});
|
|
10211
10190
|
}
|
|
@@ -10264,7 +10243,7 @@ var ContractManager = class _ContractManager {
|
|
|
10264
10243
|
});
|
|
10265
10244
|
for (const entry of pending) entry.catchUpPending = false;
|
|
10266
10245
|
} catch (err) {
|
|
10267
|
-
if (!
|
|
10246
|
+
if (!chunkASKOHVGX_cjs.isRetryableProviderError(err)) throw err;
|
|
10268
10247
|
this.markSyncDegraded(err);
|
|
10269
10248
|
}
|
|
10270
10249
|
}
|
|
@@ -10355,7 +10334,7 @@ var ContractManager = class _ContractManager {
|
|
|
10355
10334
|
return result;
|
|
10356
10335
|
}
|
|
10357
10336
|
async upsertContractRow(params) {
|
|
10358
|
-
const handler =
|
|
10337
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(params.type);
|
|
10359
10338
|
if (!handler) {
|
|
10360
10339
|
throw new Error(`No handler registered for contract type '${params.type}'`);
|
|
10361
10340
|
}
|
|
@@ -10454,7 +10433,7 @@ var ContractManager = class _ContractManager {
|
|
|
10454
10433
|
`scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
|
|
10455
10434
|
);
|
|
10456
10435
|
}
|
|
10457
|
-
const registered =
|
|
10436
|
+
const registered = chunk4MCQZYH6_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk4MCQZYH6_cjs.contractHandlers.get(t)).filter(isDiscoverable);
|
|
10458
10437
|
const discoverables = [
|
|
10459
10438
|
...registered.filter((h) => h.type === "boarding"),
|
|
10460
10439
|
...registered.filter((h) => h.type !== "boarding")
|
|
@@ -10585,7 +10564,7 @@ var ContractManager = class _ContractManager {
|
|
|
10585
10564
|
return contracts.filter((contract) => this.isUnsupported(contract));
|
|
10586
10565
|
}
|
|
10587
10566
|
async getContractsWithVtxos(filter, pageSize, options) {
|
|
10588
|
-
|
|
10567
|
+
chunkASKOHVGX_cjs.assertNonNegativeMs("maxSyncAgeMs", options?.maxSyncAgeMs);
|
|
10589
10568
|
const contracts = await this.getContracts(filter);
|
|
10590
10569
|
if (this.syncedWithin(
|
|
10591
10570
|
contracts,
|
|
@@ -10693,14 +10672,14 @@ var ContractManager = class _ContractManager {
|
|
|
10693
10672
|
const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
|
|
10694
10673
|
const asking = vtxos.filter((vtxo) => {
|
|
10695
10674
|
const contract = byScript.get(vtxo.script);
|
|
10696
|
-
return contract !== void 0 &&
|
|
10675
|
+
return contract !== void 0 && chunk4MCQZYH6_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
|
|
10697
10676
|
});
|
|
10698
10677
|
if (asking.length === 0) return refused;
|
|
10699
10678
|
const tip = await this.currentChainTip();
|
|
10700
10679
|
const walletDescriptorValue = await walletDescriptor?.();
|
|
10701
10680
|
for (const vtxo of asking) {
|
|
10702
10681
|
const contract = byScript.get(vtxo.script);
|
|
10703
|
-
const handler =
|
|
10682
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
10704
10683
|
if (!handler?.assertSpendableNow) continue;
|
|
10705
10684
|
const context = {
|
|
10706
10685
|
collaborative: true,
|
|
@@ -10710,7 +10689,7 @@ var ContractManager = class _ContractManager {
|
|
|
10710
10689
|
walletDescriptor: walletDescriptorValue,
|
|
10711
10690
|
// `isVirtualCoin` only checks `script`, which every input has; `isCsvSpendable`
|
|
10712
10691
|
// reads `vtxo.status.block_time` unguarded, so require `status` too.
|
|
10713
|
-
vtxo:
|
|
10692
|
+
vtxo: chunkASKOHVGX_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
|
|
10714
10693
|
};
|
|
10715
10694
|
try {
|
|
10716
10695
|
await handler.assertSpendableNow(
|
|
@@ -10823,7 +10802,7 @@ var ContractManager = class _ContractManager {
|
|
|
10823
10802
|
const { contractScript, collaborative = true, walletDescriptor, vtxo } = options;
|
|
10824
10803
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10825
10804
|
if (!contract) return [];
|
|
10826
|
-
const handler =
|
|
10805
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
10827
10806
|
if (!handler) return [];
|
|
10828
10807
|
const script = handler.createScript(contract.params);
|
|
10829
10808
|
const tip = await this.currentChainTip();
|
|
@@ -10845,7 +10824,7 @@ var ContractManager = class _ContractManager {
|
|
|
10845
10824
|
const { contractScript, collaborative = true, walletDescriptor } = options;
|
|
10846
10825
|
const [contract] = await this.getContracts({ script: contractScript });
|
|
10847
10826
|
if (!contract) return [];
|
|
10848
|
-
const handler =
|
|
10827
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
10849
10828
|
if (!handler) return [];
|
|
10850
10829
|
const script = handler.createScript(contract.params);
|
|
10851
10830
|
const context = {
|
|
@@ -10891,7 +10870,7 @@ var ContractManager = class _ContractManager {
|
|
|
10891
10870
|
}
|
|
10892
10871
|
async refreshOutpoints(outpoints) {
|
|
10893
10872
|
if (outpoints.length === 0) return;
|
|
10894
|
-
const { vtxos } = await
|
|
10873
|
+
const { vtxos } = await chunkASKOHVGX_cjs.getNormalizedVtxos(this.config.indexerProvider, {
|
|
10895
10874
|
outpoints
|
|
10896
10875
|
});
|
|
10897
10876
|
if (vtxos.length === 0) return;
|
|
@@ -10993,7 +10972,7 @@ var ContractManager = class _ContractManager {
|
|
|
10993
10972
|
break;
|
|
10994
10973
|
}
|
|
10995
10974
|
} catch (err) {
|
|
10996
|
-
if (!
|
|
10975
|
+
if (!chunkASKOHVGX_cjs.isRetryableProviderError(err)) throw err;
|
|
10997
10976
|
this.markSyncDegraded(err);
|
|
10998
10977
|
synced = false;
|
|
10999
10978
|
}
|
|
@@ -11081,7 +11060,7 @@ var ContractManager = class _ContractManager {
|
|
|
11081
11060
|
*/
|
|
11082
11061
|
async reconcilePendingFrontier(contracts) {
|
|
11083
11062
|
const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
|
|
11084
|
-
const vtxos = await
|
|
11063
|
+
const vtxos = await chunkASKOHVGX_cjs.getAllNormalizedVtxos(
|
|
11085
11064
|
this.config.indexerProvider,
|
|
11086
11065
|
contracts.map((c) => c.script),
|
|
11087
11066
|
{ pendingOnly: true }
|
|
@@ -11156,7 +11135,7 @@ var ContractManager = class _ContractManager {
|
|
|
11156
11135
|
}
|
|
11157
11136
|
return result;
|
|
11158
11137
|
}
|
|
11159
|
-
async fetchContractVtxosBulk(contracts, pageSize =
|
|
11138
|
+
async fetchContractVtxosBulk(contracts, pageSize = chunkASKOHVGX_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
|
|
11160
11139
|
if (contracts.length === 0) {
|
|
11161
11140
|
return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
|
|
11162
11141
|
}
|
|
@@ -11172,7 +11151,7 @@ var ContractManager = class _ContractManager {
|
|
|
11172
11151
|
before: syncWindow.before
|
|
11173
11152
|
}
|
|
11174
11153
|
} : {};
|
|
11175
|
-
const vtxos = await
|
|
11154
|
+
const vtxos = await chunkASKOHVGX_cjs.getAllNormalizedVtxos(
|
|
11176
11155
|
this.config.indexerProvider,
|
|
11177
11156
|
contracts.map((c) => c.script),
|
|
11178
11157
|
{ ...windowOpts, pageSize }
|
|
@@ -11275,7 +11254,7 @@ function parseLegacyExpiry(batchExpiry) {
|
|
|
11275
11254
|
if (typeof batchExpiry !== "number" || !Number.isFinite(batchExpiry) || batchExpiry <= 0) {
|
|
11276
11255
|
return {};
|
|
11277
11256
|
}
|
|
11278
|
-
if (batchExpiry >=
|
|
11257
|
+
if (batchExpiry >= chunkASKOHVGX_cjs.EXPIRY_MIN_PLAUSIBLE_MS) return { expiresAt: new Date(batchExpiry) };
|
|
11279
11258
|
return { expiresAtHeight: batchExpiry / 1e3 };
|
|
11280
11259
|
}
|
|
11281
11260
|
function legacyVtxoFacts(status) {
|
|
@@ -11513,7 +11492,7 @@ function backfillContractWatchState(store) {
|
|
|
11513
11492
|
};
|
|
11514
11493
|
readPage();
|
|
11515
11494
|
}
|
|
11516
|
-
var unspentFlag = (vtxo) =>
|
|
11495
|
+
var unspentFlag = (vtxo) => chunkASKOHVGX_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
|
|
11517
11496
|
function backfillVtxoIndexFields(transaction) {
|
|
11518
11497
|
const store = transaction.objectStore(STORE_VTXOS);
|
|
11519
11498
|
const pageSize = 1e3;
|
|
@@ -11544,7 +11523,7 @@ var DEFAULT_DB_NAME = "arkade-service-worker";
|
|
|
11544
11523
|
var DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS = 1e4;
|
|
11545
11524
|
function normalizeOptions2(pathOrOptions) {
|
|
11546
11525
|
const o = typeof pathOrOptions === "string" ? { path: pathOrOptions } : pathOrOptions;
|
|
11547
|
-
|
|
11526
|
+
chunkASKOHVGX_cjs.assertTimerMs("activationTimeoutMs", o.activationTimeoutMs);
|
|
11548
11527
|
return {
|
|
11549
11528
|
path: o.path,
|
|
11550
11529
|
activationTimeoutMs: o.activationTimeoutMs ?? DEFAULT_SERVICE_WORKER_ACTIVATION_TIMEOUT_MS
|
|
@@ -11763,7 +11742,7 @@ var deserializeTapLeaf = (t) => {
|
|
|
11763
11742
|
const s = base.hex.decode(t.s);
|
|
11764
11743
|
return [cb, s];
|
|
11765
11744
|
};
|
|
11766
|
-
var deserializeVtxo = (o) =>
|
|
11745
|
+
var deserializeVtxo = (o) => chunkASKOHVGX_cjs.normalizeVtxo({
|
|
11767
11746
|
...o,
|
|
11768
11747
|
createdAt: new Date(o.createdAt),
|
|
11769
11748
|
tapTree: base.hex.decode(o.tapTree),
|
|
@@ -12118,7 +12097,7 @@ var RestEmulatorProvider = class {
|
|
|
12118
12097
|
serverUrl;
|
|
12119
12098
|
async getInfo() {
|
|
12120
12099
|
const url = `${this.serverUrl}/v1/info`;
|
|
12121
|
-
const response = await
|
|
12100
|
+
const response = await chunkASKOHVGX_cjs.baseFetch(url);
|
|
12122
12101
|
if (!response.ok) {
|
|
12123
12102
|
const errorText2 = await response.text();
|
|
12124
12103
|
throw new Error(`Failed to get emulator info: ${errorText2}`);
|
|
@@ -12238,11 +12217,11 @@ var RestEmulatorProvider = class {
|
|
|
12238
12217
|
|
|
12239
12218
|
// src/arkade/service.ts
|
|
12240
12219
|
function arkadeServiceUrl(service) {
|
|
12241
|
-
return "operatorUrl" in service ? service.operatorUrl :
|
|
12220
|
+
return "operatorUrl" in service ? service.operatorUrl : chunkASKOHVGX_cjs.DEFAULT_ARKADE_SERVER_URL;
|
|
12242
12221
|
}
|
|
12243
12222
|
async function resolveArkadeService(service, opts = {}) {
|
|
12244
12223
|
const operatorUrl = arkadeServiceUrl(service);
|
|
12245
|
-
const arkProvider = opts.arkProvider ?? new
|
|
12224
|
+
const arkProvider = opts.arkProvider ?? new chunkASKOHVGX_cjs.RestArkProvider(operatorUrl);
|
|
12246
12225
|
const info = opts.info ?? await arkProvider.getInfo();
|
|
12247
12226
|
if ("network" in service && service.network !== info.network) {
|
|
12248
12227
|
throw new Error(
|
|
@@ -12255,13 +12234,13 @@ async function resolveArkadeService(service, opts = {}) {
|
|
|
12255
12234
|
}
|
|
12256
12235
|
let emulator;
|
|
12257
12236
|
if ("network" in service) {
|
|
12258
|
-
emulator = new RestEmulatorProvider(
|
|
12237
|
+
emulator = new RestEmulatorProvider(chunkASKOHVGX_cjs.DEFAULT_ARKADE_EMULATOR_URL);
|
|
12259
12238
|
} else if (service.emulatorUrl) {
|
|
12260
12239
|
emulator = new RestEmulatorProvider(service.emulatorUrl);
|
|
12261
12240
|
}
|
|
12262
12241
|
return {
|
|
12263
12242
|
arkProvider,
|
|
12264
|
-
indexerProvider: new
|
|
12243
|
+
indexerProvider: new chunkAICUNREA_cjs.RestIndexerProvider(operatorUrl),
|
|
12265
12244
|
onchainProvider: new EsploraProvider(esploraUrl),
|
|
12266
12245
|
emulator,
|
|
12267
12246
|
info
|
|
@@ -12345,7 +12324,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
|
|
|
12345
12324
|
*/
|
|
12346
12325
|
materializeDescriptorAt(index) {
|
|
12347
12326
|
const descriptor = this.identity.descriptor;
|
|
12348
|
-
const network =
|
|
12327
|
+
const network = chunk4MCQZYH6_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
|
|
12349
12328
|
const expansion = descriptorsScure.expand({ descriptor, network, index });
|
|
12350
12329
|
const keyInfo = expansion.expansionMap?.["@0"];
|
|
12351
12330
|
if (!keyInfo?.keyExpression) {
|
|
@@ -12413,7 +12392,7 @@ function signingDescriptorIndex(descriptor) {
|
|
|
12413
12392
|
}
|
|
12414
12393
|
function newestWalletReceiveContract(contracts, serverPubKeyHex) {
|
|
12415
12394
|
return contracts.filter(
|
|
12416
|
-
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source ===
|
|
12395
|
+
(c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk4MCQZYH6_cjs.WALLET_RECEIVE_SOURCE
|
|
12417
12396
|
).sort((a, b) => {
|
|
12418
12397
|
if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
|
|
12419
12398
|
return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
|
|
@@ -12464,7 +12443,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12464
12443
|
const provider = await resolveDescriptorProvider(config, setup.walletRepository);
|
|
12465
12444
|
if (!provider) return void 0;
|
|
12466
12445
|
const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
|
|
12467
|
-
const expectedContractType = setup.offchainTapscript instanceof
|
|
12446
|
+
const expectedContractType = setup.offchainTapscript instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script ? "delegate" : "default";
|
|
12468
12447
|
const factoryOpts = {
|
|
12469
12448
|
walletRepository: setup.walletRepository,
|
|
12470
12449
|
contractRepository: setup.contractRepository,
|
|
@@ -12621,7 +12600,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
|
|
|
12621
12600
|
};
|
|
12622
12601
|
function deriveLeafPubkey(descriptor) {
|
|
12623
12602
|
try {
|
|
12624
|
-
return
|
|
12603
|
+
return chunk4MCQZYH6_cjs.deriveDescriptorLeafPubKey(descriptor);
|
|
12625
12604
|
} catch (e) {
|
|
12626
12605
|
throw new NonRangeableDescriptorError(
|
|
12627
12606
|
"Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
|
|
@@ -12633,7 +12612,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12633
12612
|
const pubKey = deriveLeafPubkey(descriptor);
|
|
12634
12613
|
const tapscript = rebuildTapscript(current, pubKey);
|
|
12635
12614
|
const serverPubKey = tapscript.options.serverPubKey;
|
|
12636
|
-
const csvTimelock2 =
|
|
12615
|
+
const csvTimelock2 = chunkASKOHVGX_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
|
|
12637
12616
|
const base$1 = {
|
|
12638
12617
|
script: base.hex.encode(tapscript.pkScript),
|
|
12639
12618
|
address: tapscript.address(hrp, serverPubKey).encode(),
|
|
@@ -12641,11 +12620,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12641
12620
|
// Read at sign time to route rotated-pubkey inputs through `signWithDescriptor`; without
|
|
12642
12621
|
// it spends are rejected with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
|
|
12643
12622
|
metadata: {
|
|
12644
|
-
...tagSource && { source:
|
|
12623
|
+
...tagSource && { source: chunk4MCQZYH6_cjs.WALLET_RECEIVE_SOURCE },
|
|
12645
12624
|
signingDescriptor: descriptor
|
|
12646
12625
|
}
|
|
12647
12626
|
};
|
|
12648
|
-
const params = tapscript instanceof
|
|
12627
|
+
const params = tapscript instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script ? {
|
|
12649
12628
|
...base$1,
|
|
12650
12629
|
type: "delegate",
|
|
12651
12630
|
params: {
|
|
@@ -12666,10 +12645,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
|
|
|
12666
12645
|
return { tapscript, params };
|
|
12667
12646
|
}
|
|
12668
12647
|
function rebuildTapscript(current, pubKey) {
|
|
12669
|
-
if (current instanceof
|
|
12670
|
-
return new
|
|
12648
|
+
if (current instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script) {
|
|
12649
|
+
return new chunk4MCQZYH6_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
|
|
12671
12650
|
}
|
|
12672
|
-
return new
|
|
12651
|
+
return new chunk4MCQZYH6_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
|
|
12673
12652
|
}
|
|
12674
12653
|
async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
|
|
12675
12654
|
const candidates = await collectContracts(contractRepository, {
|
|
@@ -12728,7 +12707,7 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12728
12707
|
}
|
|
12729
12708
|
};
|
|
12730
12709
|
for (const vtxo of vtxos) {
|
|
12731
|
-
if (
|
|
12710
|
+
if (chunkASKOHVGX_cjs.isVtxoSpent(vtxo)) continue;
|
|
12732
12711
|
addAssets(owned, vtxo);
|
|
12733
12712
|
if (vtxo.isUnrolled) {
|
|
12734
12713
|
unrolled += vtxo.value;
|
|
@@ -12738,11 +12717,11 @@ function computeOffchainBalance(vtxos, caps) {
|
|
|
12738
12717
|
pendingRecovery += vtxo.value;
|
|
12739
12718
|
continue;
|
|
12740
12719
|
}
|
|
12741
|
-
if (
|
|
12720
|
+
if (chunkASKOHVGX_cjs.canRecoverOnchain(vtxo, now)) {
|
|
12742
12721
|
recoverable += vtxo.value;
|
|
12743
12722
|
continue;
|
|
12744
12723
|
}
|
|
12745
|
-
if (!
|
|
12724
|
+
if (!chunkASKOHVGX_cjs.canSpendOffchain(vtxo, now)) continue;
|
|
12746
12725
|
if (vtxo.isPreconfirmed) {
|
|
12747
12726
|
preconfirmed += vtxo.value;
|
|
12748
12727
|
} else {
|
|
@@ -12957,7 +12936,7 @@ function intentProofJobs(coins) {
|
|
|
12957
12936
|
if (coins.length === 0) return [];
|
|
12958
12937
|
const coinJobs = coins.map((coin, i) => ({
|
|
12959
12938
|
index: i + 1,
|
|
12960
|
-
lookupScript:
|
|
12939
|
+
lookupScript: chunkASKOHVGX_cjs.VtxoScript.decode(coin.tapTree).pkScript
|
|
12961
12940
|
}));
|
|
12962
12941
|
return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
|
|
12963
12942
|
}
|
|
@@ -12997,7 +12976,7 @@ function dedupeTimelocks(timelocks) {
|
|
|
12997
12976
|
const seen = /* @__PURE__ */ new Set();
|
|
12998
12977
|
const deduped = [];
|
|
12999
12978
|
for (const timelock of timelocks) {
|
|
13000
|
-
const sequence =
|
|
12979
|
+
const sequence = chunkASKOHVGX_cjs.timelockToSequence(timelock).toString();
|
|
13001
12980
|
if (seen.has(sequence)) continue;
|
|
13002
12981
|
seen.add(sequence);
|
|
13003
12982
|
deduped.push(timelock);
|
|
@@ -13013,7 +12992,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
|
|
|
13013
12992
|
if (!newest?.params.pubKey) return baseline;
|
|
13014
12993
|
try {
|
|
13015
12994
|
const pubKey = base.hex.decode(newest.params.pubKey);
|
|
13016
|
-
return new
|
|
12995
|
+
return new chunk4MCQZYH6_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
|
|
13017
12996
|
} catch (e) {
|
|
13018
12997
|
console.warn("Skipping malformed boarding contract at boot", newest.script, e);
|
|
13019
12998
|
return baseline;
|
|
@@ -13045,21 +13024,21 @@ function filterFlatVtxos(vtxos, filter, pendingSpendOutpoints) {
|
|
|
13045
13024
|
if (vtxo.isUnrolled) {
|
|
13046
13025
|
return !!f.withUnrolled;
|
|
13047
13026
|
}
|
|
13048
|
-
if (
|
|
13027
|
+
if (chunkASKOHVGX_cjs.isVtxoSpent(vtxo)) {
|
|
13049
13028
|
return false;
|
|
13050
13029
|
}
|
|
13051
|
-
if (!f.withRecoverable &&
|
|
13030
|
+
if (!f.withRecoverable && chunkASKOHVGX_cjs.canRecoverOnchain(vtxo, now)) {
|
|
13052
13031
|
return false;
|
|
13053
13032
|
}
|
|
13054
13033
|
return true;
|
|
13055
13034
|
});
|
|
13056
13035
|
}
|
|
13057
13036
|
async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
13058
|
-
const candidates = inputs.filter(
|
|
13037
|
+
const candidates = inputs.filter(chunkASKOHVGX_cjs.isVirtualCoin).map(chunkASKOHVGX_cjs.normalizeVtxo).filter((v) => !v.isSwept);
|
|
13059
13038
|
if (candidates.length === 0) return inputs;
|
|
13060
|
-
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await
|
|
13039
|
+
const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkASKOHVGX_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
|
|
13061
13040
|
const suspects = candidates.filter(
|
|
13062
|
-
(v) =>
|
|
13041
|
+
(v) => chunkASKOHVGX_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
|
|
13063
13042
|
);
|
|
13064
13043
|
if (suspects.length === 0) return inputs;
|
|
13065
13044
|
let sweptNow;
|
|
@@ -13073,12 +13052,12 @@ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
|
|
|
13073
13052
|
);
|
|
13074
13053
|
} catch (e) {
|
|
13075
13054
|
const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
|
|
13076
|
-
throw
|
|
13055
|
+
throw chunkASKOHVGX_cjs.isRetryableProviderError(e) ? new chunkASKOHVGX_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
|
|
13077
13056
|
}
|
|
13078
13057
|
if (sweptNow.size === 0) return inputs;
|
|
13079
13058
|
return inputs.map((input) => {
|
|
13080
|
-
if (!
|
|
13081
|
-
return { ...
|
|
13059
|
+
if (!chunkASKOHVGX_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
|
|
13060
|
+
return { ...chunkASKOHVGX_cjs.normalizeVtxo(input), isSwept: true };
|
|
13082
13061
|
});
|
|
13083
13062
|
}
|
|
13084
13063
|
var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
|
|
@@ -13367,7 +13346,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13367
13346
|
async getArkadeReader() {
|
|
13368
13347
|
const indexer = this.indexerProvider;
|
|
13369
13348
|
return {
|
|
13370
|
-
getVtxos: (opts) =>
|
|
13349
|
+
getVtxos: (opts) => chunkASKOHVGX_cjs.getNormalizedVtxos(indexer, opts),
|
|
13371
13350
|
getVirtualTxs: (txids, opts) => indexer.getVirtualTxs(txids, opts)
|
|
13372
13351
|
};
|
|
13373
13352
|
}
|
|
@@ -13407,7 +13386,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13407
13386
|
"Pass either `service` or `arkProvider`/`indexerProvider`/`onchainProvider`, not both"
|
|
13408
13387
|
);
|
|
13409
13388
|
}
|
|
13410
|
-
const arkProvider = config.arkProvider || new
|
|
13389
|
+
const arkProvider = config.arkProvider || new chunkASKOHVGX_cjs.RestArkProvider(config.service ? arkadeServiceUrl(config.service) : void 0);
|
|
13411
13390
|
let indexerProvider = config.indexerProvider;
|
|
13412
13391
|
if (!indexerProvider && !config.service) {
|
|
13413
13392
|
const derived = extractArkProviderUrl(arkProvider);
|
|
@@ -13416,7 +13395,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13416
13395
|
"indexerProvider is required when arkProvider is provided without a discoverable serverUrl"
|
|
13417
13396
|
);
|
|
13418
13397
|
}
|
|
13419
|
-
indexerProvider = new
|
|
13398
|
+
indexerProvider = new chunkAICUNREA_cjs.RestIndexerProvider(derived ?? chunkASKOHVGX_cjs.DEFAULT_ARKADE_SERVER_URL);
|
|
13420
13399
|
}
|
|
13421
13400
|
const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
|
|
13422
13401
|
const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
|
|
@@ -13430,7 +13409,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13430
13409
|
if (!resolvedService) throw new Error("indexerProvider is unresolved");
|
|
13431
13410
|
indexerProvider = resolvedService.indexerProvider;
|
|
13432
13411
|
}
|
|
13433
|
-
const network =
|
|
13412
|
+
const network = chunkASKOHVGX_cjs.networkFromArkadeInfo(info);
|
|
13434
13413
|
if ("descriptor" in config.identity) {
|
|
13435
13414
|
const descriptor = config.identity.descriptor;
|
|
13436
13415
|
const identityIsMainnet = !descriptor.includes("tpub");
|
|
@@ -13466,18 +13445,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13466
13445
|
}
|
|
13467
13446
|
}
|
|
13468
13447
|
const boardingTimelock = config.boardingTimelock ?? toTimelock(info.boardingExitDelay);
|
|
13469
|
-
const serverPubKey =
|
|
13470
|
-
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) =>
|
|
13448
|
+
const serverPubKey = chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
13449
|
+
const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
|
|
13471
13450
|
const offchainOptions = {
|
|
13472
13451
|
pubKey,
|
|
13473
13452
|
serverPubKey,
|
|
13474
13453
|
csvTimelock: exitTimelock
|
|
13475
13454
|
};
|
|
13476
|
-
const offchainTapscript = !delegatePubKey ? new
|
|
13477
|
-
const boardingTapscript =
|
|
13455
|
+
const offchainTapscript = !delegatePubKey ? new chunk4MCQZYH6_cjs.DefaultVtxo.Script(offchainOptions) : new chunk4MCQZYH6_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
|
|
13456
|
+
const boardingTapscript = chunk4MCQZYH6_cjs.BoardingContractHandler.createScript({
|
|
13478
13457
|
pubKey: base.hex.encode(pubKey),
|
|
13479
13458
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
13480
|
-
csvTimelock:
|
|
13459
|
+
csvTimelock: chunkASKOHVGX_cjs.timelockToSequence(boardingTimelock).toString()
|
|
13481
13460
|
});
|
|
13482
13461
|
return {
|
|
13483
13462
|
arkProvider,
|
|
@@ -13643,7 +13622,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13643
13622
|
if (!filter?.withUnrolled) {
|
|
13644
13623
|
logExcludedVtxos(
|
|
13645
13624
|
"getSpendableVtxos",
|
|
13646
|
-
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !
|
|
13625
|
+
snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkASKOHVGX_cjs.isVtxoSpent(vtxo)),
|
|
13647
13626
|
[() => UNROLLED_REASON]
|
|
13648
13627
|
);
|
|
13649
13628
|
}
|
|
@@ -13786,7 +13765,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13786
13765
|
this.getBoardingTxs()
|
|
13787
13766
|
]);
|
|
13788
13767
|
const allVtxos = snapshot.flatMap((_) => _.vtxos);
|
|
13789
|
-
const resolveTxCreatedAt = (txids) =>
|
|
13768
|
+
const resolveTxCreatedAt = (txids) => chunkASKOHVGX_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
|
|
13790
13769
|
return buildTransactionHistory(
|
|
13791
13770
|
allVtxos,
|
|
13792
13771
|
boardingTxs,
|
|
@@ -13940,9 +13919,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13940
13919
|
async getBoardingTapscripts(allowedSigners) {
|
|
13941
13920
|
const byScript = /* @__PURE__ */ new Map();
|
|
13942
13921
|
const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
|
|
13943
|
-
const boardingCsv = this.boardingTapscript.options.csvTimelock ??
|
|
13922
|
+
const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunk4MCQZYH6_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
13944
13923
|
add(
|
|
13945
|
-
new
|
|
13924
|
+
new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
13946
13925
|
pubKey: await this.identity.xOnlyPublicKey(),
|
|
13947
13926
|
serverPubKey: this.boardingTapscript.options.serverPubKey,
|
|
13948
13927
|
csvTimelock: boardingCsv
|
|
@@ -13957,7 +13936,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13957
13936
|
for (const c of boardingContracts) {
|
|
13958
13937
|
if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
|
|
13959
13938
|
try {
|
|
13960
|
-
add(
|
|
13939
|
+
add(chunk4MCQZYH6_cjs.BoardingContractHandler.createScript(c.params));
|
|
13961
13940
|
} catch (e) {
|
|
13962
13941
|
console.warn("Skipping malformed boarding contract", c.script, e);
|
|
13963
13942
|
}
|
|
@@ -13986,7 +13965,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
13986
13965
|
// Per-row CSV delay decoded from THIS tapscript's exit leaf —
|
|
13987
13966
|
// not the wallet's current boarding timelock, which a signer
|
|
13988
13967
|
// rotation may have changed.
|
|
13989
|
-
csvTimelock:
|
|
13968
|
+
csvTimelock: chunkASKOHVGX_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
|
|
13990
13969
|
coins: utxos
|
|
13991
13970
|
};
|
|
13992
13971
|
})
|
|
@@ -14142,7 +14121,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14142
14121
|
/** Fetch Arkade transaction ids that are still pending final settlement. */
|
|
14143
14122
|
async fetchPendingTxs() {
|
|
14144
14123
|
const scripts = await this.getWalletScripts();
|
|
14145
|
-
const vtxos = await
|
|
14124
|
+
const vtxos = await chunkASKOHVGX_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
|
|
14146
14125
|
return vtxos.filter(
|
|
14147
14126
|
(vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
|
|
14148
14127
|
).map((_) => _.arkTxId);
|
|
@@ -14173,7 +14152,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14173
14152
|
});
|
|
14174
14153
|
for (const contract of contracts) {
|
|
14175
14154
|
if (map.has(contract.script)) continue;
|
|
14176
|
-
const handler =
|
|
14155
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
14177
14156
|
if (handler) {
|
|
14178
14157
|
const script = handler.createScript(contract.params);
|
|
14179
14158
|
map.set(contract.script, script);
|
|
@@ -14285,7 +14264,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14285
14264
|
}
|
|
14286
14265
|
});
|
|
14287
14266
|
const baselinePubkey = await this.identity.xOnlyPublicKey();
|
|
14288
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
14267
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
14289
14268
|
const baselineSigners = [
|
|
14290
14269
|
this.offchainTapscript.options.serverPubKey,
|
|
14291
14270
|
...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
|
|
@@ -14293,8 +14272,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14293
14272
|
const seenBaselineScripts = /* @__PURE__ */ new Set();
|
|
14294
14273
|
for (const serverPubKey of baselineSigners) {
|
|
14295
14274
|
for (const csvTimelock2 of this.walletContractTimelocks) {
|
|
14296
|
-
const csvTimelockStr =
|
|
14297
|
-
const defaultScript = new
|
|
14275
|
+
const csvTimelockStr = chunkASKOHVGX_cjs.timelockToSequence(csvTimelock2).toString();
|
|
14276
|
+
const defaultScript = new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
14298
14277
|
pubKey: baselinePubkey,
|
|
14299
14278
|
serverPubKey,
|
|
14300
14279
|
csvTimelock: csvTimelock2
|
|
@@ -14315,7 +14294,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14315
14294
|
});
|
|
14316
14295
|
}
|
|
14317
14296
|
if (delegatePubKey) {
|
|
14318
|
-
const delegateScript = new
|
|
14297
|
+
const delegateScript = new chunk4MCQZYH6_cjs.DelegateVtxo.Script({
|
|
14319
14298
|
pubKey: baselinePubkey,
|
|
14320
14299
|
serverPubKey,
|
|
14321
14300
|
delegatePubKey,
|
|
@@ -14339,9 +14318,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14339
14318
|
}
|
|
14340
14319
|
}
|
|
14341
14320
|
}
|
|
14342
|
-
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ??
|
|
14321
|
+
const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunk4MCQZYH6_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14343
14322
|
for (const serverPubKey of baselineSigners) {
|
|
14344
|
-
const baselineBoarding = new
|
|
14323
|
+
const baselineBoarding = new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
14345
14324
|
pubKey: baselinePubkey,
|
|
14346
14325
|
serverPubKey,
|
|
14347
14326
|
csvTimelock: boardingCsvTimelock
|
|
@@ -14354,7 +14333,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14354
14333
|
params: {
|
|
14355
14334
|
pubKey: base.hex.encode(baselineBoarding.options.pubKey),
|
|
14356
14335
|
serverPubKey: base.hex.encode(serverPubKey),
|
|
14357
|
-
csvTimelock:
|
|
14336
|
+
csvTimelock: chunkASKOHVGX_cjs.timelockToSequence(boardingCsvTimelock).toString()
|
|
14358
14337
|
},
|
|
14359
14338
|
script: boardingScriptHex,
|
|
14360
14339
|
address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
|
|
@@ -14376,7 +14355,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
|
|
|
14376
14355
|
}
|
|
14377
14356
|
};
|
|
14378
14357
|
var Wallet2 = class extends ReadonlyWallet {
|
|
14379
|
-
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, keyring, lookAheadWindow, batchExpiryPolicy
|
|
14358
|
+
constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, keyring, lookAheadWindow, batchExpiryPolicy) {
|
|
14380
14359
|
super(
|
|
14381
14360
|
identity,
|
|
14382
14361
|
network,
|
|
@@ -14396,7 +14375,6 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14396
14375
|
this.forfeitOutputScript = forfeitOutputScript;
|
|
14397
14376
|
this.forfeitPubkey = forfeitPubkey;
|
|
14398
14377
|
this.batchExpiryPolicy = batchExpiryPolicy;
|
|
14399
|
-
this.checkpointExitDelayPolicy = checkpointExitDelayPolicy;
|
|
14400
14378
|
this.identity = identity;
|
|
14401
14379
|
this.settlementConfig = settlementConfig !== void 0 ? settlementConfig : { ...DEFAULT_SETTLEMENT_CONFIG };
|
|
14402
14380
|
this._delegateManager = delegateProvider ? new DelegateManagerImpl(delegateProvider, arkProvider, identity) : void 0;
|
|
@@ -14418,7 +14396,6 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14418
14396
|
forfeitOutputScript;
|
|
14419
14397
|
forfeitPubkey;
|
|
14420
14398
|
batchExpiryPolicy;
|
|
14421
|
-
checkpointExitDelayPolicy;
|
|
14422
14399
|
static MIN_FEE_RATE = 1;
|
|
14423
14400
|
// sats/vbyte
|
|
14424
14401
|
identity;
|
|
@@ -14541,7 +14518,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14541
14518
|
serverPubKey: this.offchainTapscript.options.serverPubKey,
|
|
14542
14519
|
deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
|
|
14543
14520
|
csvTimelocks: this.walletContractTimelocks,
|
|
14544
|
-
delegatePubKey: this.offchainTapscript instanceof
|
|
14521
|
+
delegatePubKey: this.offchainTapscript instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
|
|
14545
14522
|
};
|
|
14546
14523
|
}
|
|
14547
14524
|
_signerRouter;
|
|
@@ -14701,7 +14678,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14701
14678
|
const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
|
|
14702
14679
|
const persisted = row?.metadata?.signingDescriptor;
|
|
14703
14680
|
if (typeof persisted === "string") return persisted;
|
|
14704
|
-
return
|
|
14681
|
+
return chunk4MCQZYH6_cjs.identityDescriptor(this.identity);
|
|
14705
14682
|
}
|
|
14706
14683
|
/**
|
|
14707
14684
|
* Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
|
|
@@ -14711,7 +14688,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14711
14688
|
async mintAddress(manager, type, descriptor, tagSource, allocated) {
|
|
14712
14689
|
if (type === "boarding") {
|
|
14713
14690
|
const built2 = this.buildBoardingContract(
|
|
14714
|
-
|
|
14691
|
+
chunk4MCQZYH6_cjs.deriveDescriptorLeafPubKey(descriptor),
|
|
14715
14692
|
descriptor,
|
|
14716
14693
|
tagSource
|
|
14717
14694
|
);
|
|
@@ -14748,11 +14725,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14748
14725
|
* (offchain analogue: {@link buildReceiveContract}).
|
|
14749
14726
|
*/
|
|
14750
14727
|
buildBoardingContract(pubKey, descriptor, tagSource) {
|
|
14751
|
-
const tapscript = new
|
|
14728
|
+
const tapscript = new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
14752
14729
|
...this._boardingTapscript.options,
|
|
14753
14730
|
pubKey
|
|
14754
14731
|
});
|
|
14755
|
-
const csvTimelock2 = tapscript.options.csvTimelock ??
|
|
14732
|
+
const csvTimelock2 = tapscript.options.csvTimelock ?? chunk4MCQZYH6_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14756
14733
|
return {
|
|
14757
14734
|
tapscript,
|
|
14758
14735
|
params: {
|
|
@@ -14760,13 +14737,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14760
14737
|
params: {
|
|
14761
14738
|
pubKey: base.hex.encode(pubKey),
|
|
14762
14739
|
serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
|
|
14763
|
-
csvTimelock:
|
|
14740
|
+
csvTimelock: chunkASKOHVGX_cjs.timelockToSequence(csvTimelock2).toString()
|
|
14764
14741
|
},
|
|
14765
14742
|
script: base.hex.encode(tapscript.pkScript),
|
|
14766
14743
|
address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
|
|
14767
14744
|
state: "active",
|
|
14768
14745
|
metadata: {
|
|
14769
|
-
...tagSource && { source:
|
|
14746
|
+
...tagSource && { source: chunk4MCQZYH6_cjs.WALLET_RECEIVE_SOURCE },
|
|
14770
14747
|
signingDescriptor: descriptor
|
|
14771
14748
|
}
|
|
14772
14749
|
}
|
|
@@ -14788,7 +14765,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14788
14765
|
if (this._hdProvider) {
|
|
14789
14766
|
return (await this.getContractManager()).getNextSigningDescriptor();
|
|
14790
14767
|
}
|
|
14791
|
-
return
|
|
14768
|
+
return chunk4MCQZYH6_cjs.identityDescriptor(this.identity);
|
|
14792
14769
|
}
|
|
14793
14770
|
/**
|
|
14794
14771
|
* @see HDAllocationCapable.advanceSigningDescriptorWatermark
|
|
@@ -14864,10 +14841,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14864
14841
|
* the stable public API.
|
|
14865
14842
|
*/
|
|
14866
14843
|
async rotateServerSigner(newServerPubKey, checkpointTapscript) {
|
|
14867
|
-
const xonly =
|
|
14844
|
+
const xonly = chunk4MCQZYH6_cjs.toXOnly(newServerPubKey, "ark signer key");
|
|
14868
14845
|
const newServerUnrollScript = assertValidServerUnrollScript(
|
|
14869
14846
|
checkpointTapscript,
|
|
14870
|
-
|
|
14847
|
+
this.network,
|
|
14848
|
+
this.forfeitPubkey
|
|
14871
14849
|
);
|
|
14872
14850
|
if (utils_js.equalBytes(xonly, this.arkServerPublicKey)) return;
|
|
14873
14851
|
if (this._receiveRotator) {
|
|
@@ -14893,21 +14871,21 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14893
14871
|
const [currentBoardingRow] = await manager.getContracts({
|
|
14894
14872
|
script: currentBoardingScript
|
|
14895
14873
|
});
|
|
14896
|
-
const newOffchain = this.offchainTapscript instanceof
|
|
14874
|
+
const newOffchain = this.offchainTapscript instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script ? new chunk4MCQZYH6_cjs.DelegateVtxo.Script({
|
|
14897
14875
|
...this.offchainTapscript.options,
|
|
14898
14876
|
serverPubKey: xonly
|
|
14899
|
-
}) : new
|
|
14877
|
+
}) : new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
14900
14878
|
...this.offchainTapscript.options,
|
|
14901
14879
|
serverPubKey: xonly
|
|
14902
14880
|
});
|
|
14903
|
-
const newBoarding = new
|
|
14881
|
+
const newBoarding = new chunk4MCQZYH6_cjs.DefaultVtxo.Script({
|
|
14904
14882
|
...this._boardingTapscript.options,
|
|
14905
14883
|
serverPubKey: xonly
|
|
14906
14884
|
});
|
|
14907
|
-
const offchainCsv =
|
|
14885
|
+
const offchainCsv = chunkASKOHVGX_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
|
|
14908
14886
|
const newOffchainScript = base.hex.encode(newOffchain.pkScript);
|
|
14909
14887
|
const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
|
|
14910
|
-
if (newOffchain instanceof
|
|
14888
|
+
if (newOffchain instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script) {
|
|
14911
14889
|
await manager.createContract({
|
|
14912
14890
|
type: "delegate",
|
|
14913
14891
|
params: {
|
|
@@ -14935,13 +14913,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14935
14913
|
metadata: currentOffchainRow?.metadata
|
|
14936
14914
|
});
|
|
14937
14915
|
}
|
|
14938
|
-
const boardingCsv = newBoarding.options.csvTimelock ??
|
|
14916
|
+
const boardingCsv = newBoarding.options.csvTimelock ?? chunk4MCQZYH6_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
|
|
14939
14917
|
await manager.createContract({
|
|
14940
14918
|
type: "boarding",
|
|
14941
14919
|
params: {
|
|
14942
14920
|
pubKey: base.hex.encode(newBoarding.options.pubKey),
|
|
14943
14921
|
serverPubKey: base.hex.encode(xonly),
|
|
14944
|
-
csvTimelock:
|
|
14922
|
+
csvTimelock: chunkASKOHVGX_cjs.timelockToSequence(boardingCsv).toString()
|
|
14945
14923
|
},
|
|
14946
14924
|
script: base.hex.encode(newBoarding.pkScript),
|
|
14947
14925
|
address: newBoarding.address(this.network.hrp, xonly).encode(),
|
|
@@ -14969,14 +14947,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
14969
14947
|
_restoreInFlight;
|
|
14970
14948
|
_addPendingSpends(inputs) {
|
|
14971
14949
|
for (const input of inputs) {
|
|
14972
|
-
if (
|
|
14950
|
+
if (chunkASKOHVGX_cjs.isVirtualCoin(input)) {
|
|
14973
14951
|
this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
|
|
14974
14952
|
}
|
|
14975
14953
|
}
|
|
14976
14954
|
}
|
|
14977
14955
|
_removePendingSpends(inputs) {
|
|
14978
14956
|
for (const input of inputs) {
|
|
14979
|
-
if (
|
|
14957
|
+
if (chunkASKOHVGX_cjs.isVirtualCoin(input)) {
|
|
14980
14958
|
this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
|
|
14981
14959
|
}
|
|
14982
14960
|
}
|
|
@@ -15040,7 +15018,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15040
15018
|
if (clashing.length > 0) throw new VtxoReservedError(clashing, "in-flight");
|
|
15041
15019
|
}
|
|
15042
15020
|
_assertNotHeld(inputs) {
|
|
15043
|
-
const held = coinKeys(inputs.filter(
|
|
15021
|
+
const held = coinKeys(inputs.filter(chunkASKOHVGX_cjs.isVirtualCoin)).filter(
|
|
15044
15022
|
(key) => this._heldOutpoints.has(key)
|
|
15045
15023
|
);
|
|
15046
15024
|
if (held.length > 0) throw new VtxoReservedError(held, "held");
|
|
@@ -15078,13 +15056,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15078
15056
|
const manager = await this.getContractManager();
|
|
15079
15057
|
const provider = this._hdProvider;
|
|
15080
15058
|
const hd = provider !== void 0;
|
|
15081
|
-
const staticDescriptor = hd ? void 0 : await
|
|
15059
|
+
const staticDescriptor = hd ? void 0 : await chunk4MCQZYH6_cjs.identityDescriptor(this.identity);
|
|
15082
15060
|
const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
|
|
15083
|
-
const delegatePubKey = this.offchainTapscript instanceof
|
|
15061
|
+
const delegatePubKey = this.offchainTapscript instanceof chunk4MCQZYH6_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
|
|
15084
15062
|
const arkInfo = await this.arkProvider.getInfo();
|
|
15085
|
-
const currentSignerPubKey =
|
|
15063
|
+
const currentSignerPubKey = chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
|
|
15086
15064
|
const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
|
|
15087
|
-
(s) =>
|
|
15065
|
+
(s) => chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
|
|
15088
15066
|
);
|
|
15089
15067
|
const deps = {
|
|
15090
15068
|
indexerProvider: this.indexerProvider,
|
|
@@ -15096,7 +15074,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15096
15074
|
deprecatedSignerPubKeys,
|
|
15097
15075
|
csvTimelocks: this.walletContractTimelocks,
|
|
15098
15076
|
// Boarding-exit CSV, distinct from the unilateral-exit matrix.
|
|
15099
|
-
boardingTimelock: this.boardingTapscript.options.csvTimelock ??
|
|
15077
|
+
boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunk4MCQZYH6_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
|
|
15100
15078
|
delegatePubKey
|
|
15101
15079
|
};
|
|
15102
15080
|
const result = await manager.scanContracts({
|
|
@@ -15213,16 +15191,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15213
15191
|
throw new Error("Invalid configured public key");
|
|
15214
15192
|
}
|
|
15215
15193
|
const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
|
|
15216
|
-
const forfeitPubkey =
|
|
15194
|
+
const forfeitPubkey = chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
|
|
15217
15195
|
const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
|
|
15218
15196
|
const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
|
|
15219
|
-
const checkpointExitDelayOverrides = {
|
|
15220
|
-
advertisedForfeitPubkey: forfeitPubkey,
|
|
15221
|
-
...config.minCheckpointExitDelaySeconds !== void 0 ? { minSeconds: config.minCheckpointExitDelaySeconds } : {}
|
|
15222
|
-
};
|
|
15223
15197
|
const serverUnrollScript = assertValidServerUnrollScript(
|
|
15224
15198
|
setup.info.checkpointTapscript,
|
|
15225
|
-
|
|
15199
|
+
setup.network,
|
|
15200
|
+
forfeitPubkey
|
|
15226
15201
|
);
|
|
15227
15202
|
const boot = await WalletReceiveRotator.resolveBoot(config, setup);
|
|
15228
15203
|
let keyring;
|
|
@@ -15264,8 +15239,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15264
15239
|
{
|
|
15265
15240
|
advertisedVtxoTreeExpiry: setup.info.vtxoTreeExpiry,
|
|
15266
15241
|
...config.minBatchExpirySeconds !== void 0 ? { minSeconds: config.minBatchExpirySeconds } : {}
|
|
15267
|
-
}
|
|
15268
|
-
checkpointExitDelayOverrides
|
|
15242
|
+
}
|
|
15269
15243
|
);
|
|
15270
15244
|
wallet.lazyInitialization = config.lazyInitialization ?? false;
|
|
15271
15245
|
wallet._serverInfoSource = setup.serverInfoSource;
|
|
@@ -15385,13 +15359,13 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15385
15359
|
void this.logUngatedInputs("settle({ inputs })", params.inputs);
|
|
15386
15360
|
}
|
|
15387
15361
|
const offchainAddress = await this.getAddress();
|
|
15388
|
-
const offchainPkScript =
|
|
15362
|
+
const offchainPkScript = chunkASKOHVGX_cjs.ArkAddress.decode(offchainAddress).pkScript;
|
|
15389
15363
|
const offchainOutputScript = base.hex.encode(offchainPkScript);
|
|
15390
15364
|
if (!params) {
|
|
15391
15365
|
const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
|
|
15392
15366
|
const estimator = new Estimator(fees.intentFee);
|
|
15393
15367
|
let amount = 0;
|
|
15394
|
-
const exitScript =
|
|
15368
|
+
const exitScript = chunkASKOHVGX_cjs.CSVMultisigTapscript.decode(
|
|
15395
15369
|
base.hex.decode(this.boardingTapscript.exitScript)
|
|
15396
15370
|
);
|
|
15397
15371
|
const boardingTimelock = exitScript.params.timelock;
|
|
@@ -15423,7 +15397,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15423
15397
|
if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
|
|
15424
15398
|
break;
|
|
15425
15399
|
}
|
|
15426
|
-
const inputFee = estimator.evalOffchainInput(
|
|
15400
|
+
const inputFee = estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(vtxo));
|
|
15427
15401
|
if (inputFee.satoshis >= vtxo.value) {
|
|
15428
15402
|
continue;
|
|
15429
15403
|
}
|
|
@@ -15475,7 +15449,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15475
15449
|
let script;
|
|
15476
15450
|
let arkAddress;
|
|
15477
15451
|
try {
|
|
15478
|
-
arkAddress =
|
|
15452
|
+
arkAddress = chunkASKOHVGX_cjs.ArkAddress.decode(output.address);
|
|
15479
15453
|
} catch {
|
|
15480
15454
|
arkAddress = void 0;
|
|
15481
15455
|
}
|
|
@@ -15547,11 +15521,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15547
15521
|
]);
|
|
15548
15522
|
let intentTxId;
|
|
15549
15523
|
try {
|
|
15550
|
-
intentTxId =
|
|
15524
|
+
intentTxId = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(intent.proof)).id;
|
|
15551
15525
|
} catch {
|
|
15552
15526
|
intentTxId = params.inputs.map((i) => `${i.txid}:${i.vout}`).sort().join("|");
|
|
15553
15527
|
}
|
|
15554
|
-
const settleInputVtxos = params.inputs.filter(
|
|
15528
|
+
const settleInputVtxos = params.inputs.filter(chunkASKOHVGX_cjs.isVirtualCoin);
|
|
15555
15529
|
const contractManager = await this.getContractManager();
|
|
15556
15530
|
await contractManager.assertAnnotatable(settleInputVtxos);
|
|
15557
15531
|
await contractManager.assertSpendableNow?.(
|
|
@@ -15560,7 +15534,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15560
15534
|
);
|
|
15561
15535
|
if (picked) this._assertNotHeld(params.inputs);
|
|
15562
15536
|
this._addPendingSpends(params.inputs);
|
|
15563
|
-
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !
|
|
15537
|
+
const boardingKeys = onReserved ? coinKeys(params.inputs.filter((i) => !chunkASKOHVGX_cjs.isVirtualCoin(i))) : [];
|
|
15564
15538
|
for (const key of boardingKeys) this._pendingSpendOutpoints.add(key);
|
|
15565
15539
|
const settlingKeys = params.inputs.map((i) => `${i.txid}:${i.vout}`);
|
|
15566
15540
|
for (const key of settlingKeys) this._settlingOutpoints.add(key);
|
|
@@ -15671,7 +15645,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15671
15645
|
async maybeRotateBoardingAfterBoard(inputs) {
|
|
15672
15646
|
if (!this._descriptorProvider) return;
|
|
15673
15647
|
const consumedBoarding = inputs.some(
|
|
15674
|
-
(input) => typeof input !== "string" && !
|
|
15648
|
+
(input) => typeof input !== "string" && !chunkASKOHVGX_cjs.isVirtualCoin(input)
|
|
15675
15649
|
);
|
|
15676
15650
|
if (!consumedBoarding) return;
|
|
15677
15651
|
try {
|
|
@@ -15682,7 +15656,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15682
15656
|
}
|
|
15683
15657
|
async handleSettlementFinalizationEvent(event, inputs, forfeitOutputScript, expectedRecipients, connectorsGraph, validatedCommitmentTxid) {
|
|
15684
15658
|
const signedForfeits = [];
|
|
15685
|
-
let settlementPsbt =
|
|
15659
|
+
let settlementPsbt = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
15686
15660
|
assertFinalCommitmentMatchesValidated(
|
|
15687
15661
|
settlementPsbt,
|
|
15688
15662
|
validatedCommitmentTxid,
|
|
@@ -15695,7 +15669,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15695
15669
|
let connectorIndex = 0;
|
|
15696
15670
|
const connectorsLeaves = connectorsGraph?.leaves() || [];
|
|
15697
15671
|
for (const input of inputs) {
|
|
15698
|
-
if (!
|
|
15672
|
+
if (!chunkASKOHVGX_cjs.isVirtualCoin(input)) {
|
|
15699
15673
|
let matched = false;
|
|
15700
15674
|
for (let i = 0; i < settlementPsbt.inputsLength; i++) {
|
|
15701
15675
|
const settlementInput = settlementPsbt.getInput(i);
|
|
@@ -15733,7 +15707,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15733
15707
|
}
|
|
15734
15708
|
continue;
|
|
15735
15709
|
}
|
|
15736
|
-
if (!
|
|
15710
|
+
if (!chunkASKOHVGX_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
|
|
15737
15711
|
continue;
|
|
15738
15712
|
}
|
|
15739
15713
|
if (connectorsLeaves.length === 0) {
|
|
@@ -15761,7 +15735,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15761
15735
|
index: input.vout,
|
|
15762
15736
|
witnessUtxo: {
|
|
15763
15737
|
amount: BigInt(input.value),
|
|
15764
|
-
script:
|
|
15738
|
+
script: chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15765
15739
|
},
|
|
15766
15740
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
15767
15741
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -15780,7 +15754,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15780
15754
|
forfeitTx = await this._signerRouter.sign(forfeitTx, [
|
|
15781
15755
|
{
|
|
15782
15756
|
index: 0,
|
|
15783
|
-
lookupScript:
|
|
15757
|
+
lookupScript: chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
15784
15758
|
}
|
|
15785
15759
|
]);
|
|
15786
15760
|
signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
|
|
@@ -15838,7 +15812,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15838
15812
|
resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
|
|
15839
15813
|
);
|
|
15840
15814
|
await this.arkProvider.confirmRegistration(intentId);
|
|
15841
|
-
const sweepTapscript =
|
|
15815
|
+
const sweepTapscript = chunkASKOHVGX_cjs.CSVMultisigTapscript.encode({
|
|
15842
15816
|
timelock,
|
|
15843
15817
|
pubkeys: [this.forfeitPubkey]
|
|
15844
15818
|
}).script;
|
|
@@ -15853,14 +15827,14 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15853
15827
|
throw new Error("Sweep tap tree root not set");
|
|
15854
15828
|
}
|
|
15855
15829
|
const xOnlyPublicKeys = event.cosignersPublicKeys.map(
|
|
15856
|
-
(k) => base.hex.encode(
|
|
15830
|
+
(k) => base.hex.encode(chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
15857
15831
|
);
|
|
15858
15832
|
const signerPublicKey = await session.getPublicKey();
|
|
15859
|
-
const xonlySignerPublicKey =
|
|
15833
|
+
const xonlySignerPublicKey = chunk4MCQZYH6_cjs.toXOnly(signerPublicKey, "signer key");
|
|
15860
15834
|
if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
|
|
15861
15835
|
return { skip: true };
|
|
15862
15836
|
}
|
|
15863
|
-
const commitmentTx =
|
|
15837
|
+
const commitmentTx = chunkASKOHVGX_cjs.Transaction.fromPSBT(
|
|
15864
15838
|
base.base64.decode(event.unsignedCommitmentTx)
|
|
15865
15839
|
);
|
|
15866
15840
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
@@ -15942,9 +15916,9 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15942
15916
|
...existing ?? {},
|
|
15943
15917
|
intentTxId,
|
|
15944
15918
|
registerProof: intent.proof,
|
|
15945
|
-
registerProofMessage:
|
|
15919
|
+
registerProofMessage: chunkASKOHVGX_cjs.Intent.encodeMessage(intent.message),
|
|
15946
15920
|
deleteProof: deleteIntent.proof,
|
|
15947
|
-
deleteProofMessage:
|
|
15921
|
+
deleteProofMessage: chunkASKOHVGX_cjs.Intent.encodeMessage(deleteIntent.message),
|
|
15948
15922
|
intentVtxos: inputs.map((i) => ({
|
|
15949
15923
|
txid: i.txid,
|
|
15950
15924
|
vout: i.vout
|
|
@@ -15977,7 +15951,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15977
15951
|
try {
|
|
15978
15952
|
return await this.arkProvider.registerIntent(intent);
|
|
15979
15953
|
} catch (error) {
|
|
15980
|
-
if (error instanceof
|
|
15954
|
+
if (error instanceof chunkASKOHVGX_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
|
|
15981
15955
|
const deleteIntent = await this.makeDeleteIntentSignature(inputs);
|
|
15982
15956
|
await this.arkProvider.deleteIntent(deleteIntent);
|
|
15983
15957
|
return this.arkProvider.registerIntent(intent);
|
|
@@ -15993,7 +15967,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
15993
15967
|
expire_at: 0,
|
|
15994
15968
|
cosigners_public_keys: cosignerPubKeys
|
|
15995
15969
|
};
|
|
15996
|
-
const proof =
|
|
15970
|
+
const proof = chunkASKOHVGX_cjs.Intent.create(message, coins, outputs);
|
|
15997
15971
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
15998
15972
|
return {
|
|
15999
15973
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16005,7 +15979,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16005
15979
|
type: "delete",
|
|
16006
15980
|
expire_at: 0
|
|
16007
15981
|
};
|
|
16008
|
-
const proof =
|
|
15982
|
+
const proof = chunkASKOHVGX_cjs.Intent.create(message, coins, []);
|
|
16009
15983
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16010
15984
|
return {
|
|
16011
15985
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16017,7 +15991,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16017
15991
|
type: "get-pending-tx",
|
|
16018
15992
|
expire_at: 0
|
|
16019
15993
|
};
|
|
16020
|
-
const proof =
|
|
15994
|
+
const proof = chunkASKOHVGX_cjs.Intent.create(message, coins, []);
|
|
16021
15995
|
const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
|
|
16022
15996
|
return {
|
|
16023
15997
|
proof: base.base64.encode(signedProof.toPSBT()),
|
|
@@ -16038,7 +16012,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16038
16012
|
if (!vtxos || vtxos.length === 0) {
|
|
16039
16013
|
const scriptMap = await this.getScriptMap();
|
|
16040
16014
|
const allExtended = [];
|
|
16041
|
-
const fetchedVtxos = await
|
|
16015
|
+
const fetchedVtxos = await chunkASKOHVGX_cjs.getAllNormalizedVtxos(this.indexerProvider, [
|
|
16042
16016
|
...scriptMap.keys()
|
|
16043
16017
|
]);
|
|
16044
16018
|
for (const vtxo of fetchedVtxos) {
|
|
@@ -16081,8 +16055,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16081
16055
|
batchPending.push(pendingTx.arkTxid);
|
|
16082
16056
|
try {
|
|
16083
16057
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
|
|
16084
|
-
const tx =
|
|
16085
|
-
|
|
16058
|
+
const tx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(c));
|
|
16059
|
+
chunkASKOHVGX_cjs.assertAllowedSighashTypes(tx);
|
|
16086
16060
|
return tx;
|
|
16087
16061
|
});
|
|
16088
16062
|
assertCheckpointsMatchInputs(
|
|
@@ -16151,11 +16125,11 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16151
16125
|
* and one per deprecated signer — else a pre-rotation tx would stay pending forever.
|
|
16152
16126
|
*/
|
|
16153
16127
|
checkpointUnrollCandidates(info) {
|
|
16154
|
-
const current =
|
|
16128
|
+
const current = chunkASKOHVGX_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
16155
16129
|
const candidates = [this._serverUnrollScript, current];
|
|
16156
16130
|
for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
|
|
16157
16131
|
candidates.push(
|
|
16158
|
-
|
|
16132
|
+
chunkASKOHVGX_cjs.CSVMultisigTapscript.encode({
|
|
16159
16133
|
...current.params,
|
|
16160
16134
|
pubkeys: [base.hex.decode(deprecated)]
|
|
16161
16135
|
})
|
|
@@ -16250,7 +16224,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16250
16224
|
if (vtxos.length === 0) {
|
|
16251
16225
|
throw new Error("No VTXOs found for this arkadeCash");
|
|
16252
16226
|
}
|
|
16253
|
-
const myPkScript =
|
|
16227
|
+
const myPkScript = chunkASKOHVGX_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
|
|
16254
16228
|
let { spendable, recoverable, unclaimed } = this.classifyCashVtxos(vtxos);
|
|
16255
16229
|
let swept = 0;
|
|
16256
16230
|
const drainable = vtxos.filter(
|
|
@@ -16280,7 +16254,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16280
16254
|
if (spendable.length > 0) {
|
|
16281
16255
|
const serverUnrollScript = assertValidServerUnrollScript(
|
|
16282
16256
|
info.checkpointTapscript,
|
|
16283
|
-
|
|
16257
|
+
this.network,
|
|
16258
|
+
this.forfeitPubkey
|
|
16284
16259
|
);
|
|
16285
16260
|
for (const vtxo of spendable) {
|
|
16286
16261
|
try {
|
|
@@ -16376,7 +16351,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16376
16351
|
params: {
|
|
16377
16352
|
pubKey: base.hex.encode(cash.publicKey),
|
|
16378
16353
|
serverPubKey: base.hex.encode(cash.serverPubKey),
|
|
16379
|
-
csvTimelock:
|
|
16354
|
+
csvTimelock: chunkASKOHVGX_cjs.timelockToSequence(cash.csvTimelock).toString()
|
|
16380
16355
|
},
|
|
16381
16356
|
script: base.hex.encode(cashScript.pkScript),
|
|
16382
16357
|
address: cashAddress.encode(),
|
|
@@ -16457,7 +16432,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16457
16432
|
const recoverable = [];
|
|
16458
16433
|
const unclaimed = [];
|
|
16459
16434
|
for (const vtxo of vtxos) {
|
|
16460
|
-
if (
|
|
16435
|
+
if (chunkASKOHVGX_cjs.isVtxoSpent(vtxo)) {
|
|
16461
16436
|
unclaimed.push(cashReport(vtxo, "already-spent"));
|
|
16462
16437
|
} else if (vtxo.isUnrolled) {
|
|
16463
16438
|
unclaimed.push(cashReport(vtxo, "exited"));
|
|
@@ -16479,7 +16454,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16479
16454
|
const all = [];
|
|
16480
16455
|
const seen = /* @__PURE__ */ new Set();
|
|
16481
16456
|
for (let pageIndex = 0; ; pageIndex++) {
|
|
16482
|
-
const { vtxos, page } = await
|
|
16457
|
+
const { vtxos, page } = await chunkASKOHVGX_cjs.getNormalizedVtxos(this.indexerProvider, {
|
|
16483
16458
|
scripts,
|
|
16484
16459
|
pageIndex,
|
|
16485
16460
|
pageSize
|
|
@@ -16517,7 +16492,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16517
16492
|
for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
|
|
16518
16493
|
const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
|
|
16519
16494
|
const message = { type: "get-pending-tx", expire_at: 0 };
|
|
16520
|
-
const proof =
|
|
16495
|
+
const proof = chunkASKOHVGX_cjs.Intent.create(message, batch, []);
|
|
16521
16496
|
const signedProof = await identity.sign(
|
|
16522
16497
|
proof,
|
|
16523
16498
|
Array.from({ length: batch.length + 1 }, (_, j) => j)
|
|
@@ -16538,8 +16513,8 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16538
16513
|
for (const pendingTx of pendingTxs) {
|
|
16539
16514
|
try {
|
|
16540
16515
|
const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
|
|
16541
|
-
const tx =
|
|
16542
|
-
|
|
16516
|
+
const tx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(checkpoint));
|
|
16517
|
+
chunkASKOHVGX_cjs.assertAllowedSighashTypes(tx);
|
|
16543
16518
|
return tx;
|
|
16544
16519
|
});
|
|
16545
16520
|
assertCheckpointsMatchInputs(
|
|
@@ -16579,7 +16554,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16579
16554
|
}
|
|
16580
16555
|
/** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
|
|
16581
16556
|
arkTxAmountPaidTo(arkTxPsbt, pkScriptHex) {
|
|
16582
|
-
const arkTx =
|
|
16557
|
+
const arkTx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(arkTxPsbt));
|
|
16583
16558
|
let total = 0;
|
|
16584
16559
|
for (let i = 0; i < arkTx.outputsLength; i++) {
|
|
16585
16560
|
const output = arkTx.getOutput(i);
|
|
@@ -16638,7 +16613,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16638
16613
|
throw new Error("send({ maxChangeFee }): expected a non-negative safe integer");
|
|
16639
16614
|
}
|
|
16640
16615
|
if (selectedVtxos) {
|
|
16641
|
-
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(
|
|
16616
|
+
if (inputExpiryFloor) selectedVtxos = selectedVtxos.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
16642
16617
|
if (inputExpiryFloor && selectedVtxos.some((coin) => !meetsInputExpiryFloor(coin, inputExpiryFloor))) {
|
|
16643
16618
|
throw new Error("send({ selectedVtxos }): input expiry floor not met");
|
|
16644
16619
|
}
|
|
@@ -16773,7 +16748,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16773
16748
|
script: recipient.script,
|
|
16774
16749
|
amount: BigInt(recipient.amount),
|
|
16775
16750
|
// Already checked against the recipient address in `validateRecipients`.
|
|
16776
|
-
...recipient.tapTree ? { tapTree:
|
|
16751
|
+
...recipient.tapTree ? { tapTree: chunkASKOHVGX_cjs.toBIP371TapTree(recipient.tapTree) } : {}
|
|
16777
16752
|
}));
|
|
16778
16753
|
const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
|
|
16779
16754
|
let changeAmount = totalBtcSelected - totalBtcOutput;
|
|
@@ -16965,10 +16940,10 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
16965
16940
|
const serverPubKey = this.arkServerPublicKey;
|
|
16966
16941
|
const serverUnrollScript = this.serverUnrollScript;
|
|
16967
16942
|
const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
|
|
16968
|
-
const normalizedInputs = inputs.map(
|
|
16969
|
-
const at = now ?? await
|
|
16943
|
+
const normalizedInputs = inputs.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
16944
|
+
const at = now ?? await chunkASKOHVGX_cjs.resolveTimeHeight(this.onchainProvider);
|
|
16970
16945
|
for (const input of normalizedInputs) {
|
|
16971
|
-
if (!
|
|
16946
|
+
if (!chunkASKOHVGX_cjs.canSpendOffchain(input, at)) {
|
|
16972
16947
|
throw new Error(
|
|
16973
16948
|
`sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
|
|
16974
16949
|
);
|
|
@@ -17052,7 +17027,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17052
17027
|
);
|
|
17053
17028
|
const arkTxJobs = inputs.map((input, index) => ({
|
|
17054
17029
|
index,
|
|
17055
|
-
lookupScript:
|
|
17030
|
+
lookupScript: chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
17056
17031
|
}));
|
|
17057
17032
|
const identity = this.identity;
|
|
17058
17033
|
const signer = {
|
|
@@ -17161,7 +17136,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17161
17136
|
}
|
|
17162
17137
|
const checkpointIdByOutpoint = /* @__PURE__ */ new Map();
|
|
17163
17138
|
for (const encoded of signedCheckpointTxs) {
|
|
17164
|
-
const checkpoint =
|
|
17139
|
+
const checkpoint = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
|
|
17165
17140
|
for (let i = 0; i < checkpoint.inputsLength; i++) {
|
|
17166
17141
|
const input = checkpoint.getInput(i);
|
|
17167
17142
|
if (!input.txid) continue;
|
|
@@ -17277,12 +17252,12 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17277
17252
|
const spentVtxos = [];
|
|
17278
17253
|
const inputArkTxIds = /* @__PURE__ */ new Set();
|
|
17279
17254
|
const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
|
|
17280
|
-
const vtxoInputs = inputs.filter(
|
|
17255
|
+
const vtxoInputs = inputs.filter(chunkASKOHVGX_cjs.isVirtualCoin);
|
|
17281
17256
|
const cm = await this.getContractManager();
|
|
17282
17257
|
const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
|
|
17283
17258
|
const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
|
|
17284
17259
|
for (const input of inputs) {
|
|
17285
|
-
if (
|
|
17260
|
+
if (chunkASKOHVGX_cjs.isVirtualCoin(input)) {
|
|
17286
17261
|
const outpoint = `${input.txid}:${input.vout}`;
|
|
17287
17262
|
const vtxo = annotatedByKey.get(outpoint);
|
|
17288
17263
|
if (!vtxo) {
|
|
@@ -17299,7 +17274,7 @@ var Wallet2 = class extends ReadonlyWallet {
|
|
|
17299
17274
|
} else {
|
|
17300
17275
|
let sourceAddress;
|
|
17301
17276
|
try {
|
|
17302
|
-
sourceAddress =
|
|
17277
|
+
sourceAddress = chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
|
|
17303
17278
|
this.network
|
|
17304
17279
|
);
|
|
17305
17280
|
} catch {
|
|
@@ -17371,7 +17346,7 @@ function bySelectionOrder(a, b) {
|
|
|
17371
17346
|
return b.value - a.value;
|
|
17372
17347
|
}
|
|
17373
17348
|
function selectVirtualCoins(coins, targetAmount) {
|
|
17374
|
-
const sortedCoins = coins.map(
|
|
17349
|
+
const sortedCoins = coins.map(chunkASKOHVGX_cjs.normalizeVtxo).sort(bySelectionOrder);
|
|
17375
17350
|
const selectedCoins = [];
|
|
17376
17351
|
let selectedAmount = 0;
|
|
17377
17352
|
for (const coin of sortedCoins) {
|
|
@@ -17488,7 +17463,7 @@ function assertTimeoutMap(name, timeouts) {
|
|
|
17488
17463
|
if (value === void 0) {
|
|
17489
17464
|
throw new Error(`${name}.${key} must be a non-negative safe integer`);
|
|
17490
17465
|
}
|
|
17491
|
-
|
|
17466
|
+
chunkASKOHVGX_cjs.assertTimerMs(`${name}.${key}`, value);
|
|
17492
17467
|
}
|
|
17493
17468
|
}
|
|
17494
17469
|
var MessageBus = class {
|
|
@@ -17505,8 +17480,8 @@ var MessageBus = class {
|
|
|
17505
17480
|
}) {
|
|
17506
17481
|
this.walletRepository = walletRepository;
|
|
17507
17482
|
this.contractRepository = contractRepository;
|
|
17508
|
-
|
|
17509
|
-
|
|
17483
|
+
chunkASKOHVGX_cjs.assertTimerMs("tickIntervalMs", tickIntervalMs);
|
|
17484
|
+
chunkASKOHVGX_cjs.assertTimerMs("messageTimeoutMs", messageTimeoutMs);
|
|
17510
17485
|
assertTimeoutMap("messageTimeoutOverrides", messageTimeoutOverrides);
|
|
17511
17486
|
this.intentRepository = intentRepository;
|
|
17512
17487
|
this.onchainProvider = onchainProvider;
|
|
@@ -17762,14 +17737,14 @@ var MessageBus = class {
|
|
|
17762
17737
|
this.initialized = true;
|
|
17763
17738
|
}
|
|
17764
17739
|
async buildServices(config) {
|
|
17765
|
-
const arkProvider = new
|
|
17740
|
+
const arkProvider = new chunkASKOHVGX_cjs.RestArkProvider(config.arkServer.url);
|
|
17766
17741
|
const storage = {
|
|
17767
17742
|
walletRepository: this.walletRepository,
|
|
17768
17743
|
contractRepository: this.contractRepository,
|
|
17769
17744
|
...this.intentRepository && { intentRepository: this.intentRepository }
|
|
17770
17745
|
};
|
|
17771
17746
|
const delegateProvider = config.delegateUrl ? new RestDelegateProvider(config.delegateUrl) : void 0;
|
|
17772
|
-
const indexerProvider = new
|
|
17747
|
+
const indexerProvider = new chunkAICUNREA_cjs.RestIndexerProvider(config.arkServer.url);
|
|
17773
17748
|
const serialized = normalizeSerializedIdentity(config.wallet);
|
|
17774
17749
|
if (isSigningSerialized(serialized)) {
|
|
17775
17750
|
const identity2 = hydrateIdentity(serialized);
|
|
@@ -17787,8 +17762,7 @@ var MessageBus = class {
|
|
|
17787
17762
|
lazyInitialization: config.lazyInitialization,
|
|
17788
17763
|
watcherConfig: config.watcherConfig,
|
|
17789
17764
|
lookAheadWindow: config.lookAheadWindow,
|
|
17790
|
-
minBatchExpirySeconds: config.minBatchExpirySeconds
|
|
17791
|
-
minCheckpointExitDelaySeconds: config.minCheckpointExitDelaySeconds
|
|
17765
|
+
minBatchExpirySeconds: config.minBatchExpirySeconds
|
|
17792
17766
|
});
|
|
17793
17767
|
return { wallet, arkProvider, readonlyWallet: wallet };
|
|
17794
17768
|
}
|
|
@@ -18112,7 +18086,7 @@ var offboardNetworkNames = [
|
|
|
18112
18086
|
function offboardDestinationScript(destinationAddress) {
|
|
18113
18087
|
for (const networkName of offboardNetworkNames) {
|
|
18114
18088
|
try {
|
|
18115
|
-
const network =
|
|
18089
|
+
const network = chunkASKOHVGX_cjs.networks[networkName];
|
|
18116
18090
|
const addr = btcSigner.Address(network).decode(destinationAddress);
|
|
18117
18091
|
return btcSigner.OutScript.encode(addr);
|
|
18118
18092
|
} catch {
|
|
@@ -18152,7 +18126,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
|
|
|
18152
18126
|
const inputs = [];
|
|
18153
18127
|
let subtotal = 0n;
|
|
18154
18128
|
for (const vtxo of vtxos) {
|
|
18155
|
-
const inputFee = estimator.evalOffchainInput(
|
|
18129
|
+
const inputFee = estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(vtxo));
|
|
18156
18130
|
if (inputFee.satoshis >= vtxo.value) {
|
|
18157
18131
|
if (named) {
|
|
18158
18132
|
throw new Error(
|
|
@@ -18249,7 +18223,7 @@ var Ramps = class {
|
|
|
18249
18223
|
}
|
|
18250
18224
|
amount = amount ?? totalAmount;
|
|
18251
18225
|
const offchainAddress = await this.wallet.getAddress();
|
|
18252
|
-
const offchainAddr =
|
|
18226
|
+
const offchainAddr = chunkASKOHVGX_cjs.ArkAddress.decode(offchainAddress);
|
|
18253
18227
|
const offchainScript = base.hex.encode(offchainAddr.pkScript);
|
|
18254
18228
|
const outputFee = estimator.evalOffchainOutput({
|
|
18255
18229
|
amount,
|
|
@@ -18399,7 +18373,7 @@ var Ramps = class {
|
|
|
18399
18373
|
const ordered = [...candidates].sort(bySelectionOrder);
|
|
18400
18374
|
let covered = 0n;
|
|
18401
18375
|
for (let i = 0; i < ordered.length && i < MAX_VTXOS_PER_SETTLEMENT; i++) {
|
|
18402
|
-
const fee = estimator.evalOffchainInput(
|
|
18376
|
+
const fee = estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(ordered[i])).satoshis;
|
|
18403
18377
|
covered += BigInt(ordered[i].value) - BigInt(fee);
|
|
18404
18378
|
if (covered < needed) continue;
|
|
18405
18379
|
try {
|
|
@@ -18433,7 +18407,7 @@ var Ramps = class {
|
|
|
18433
18407
|
async fundChange(left, estimator) {
|
|
18434
18408
|
if (left <= 0n) return { change: 0n };
|
|
18435
18409
|
const changeAddress = await this.wallet.getAddress();
|
|
18436
|
-
const changeScript = base.hex.encode(
|
|
18410
|
+
const changeScript = base.hex.encode(chunkASKOHVGX_cjs.ArkAddress.decode(changeAddress).pkScript);
|
|
18437
18411
|
const { change } = changeAfterOutputFee(
|
|
18438
18412
|
left,
|
|
18439
18413
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
|
|
@@ -19367,7 +19341,7 @@ var WalletMessageHandler = class {
|
|
|
19367
19341
|
this.lazyBoardingInit = payload.lazyBoarding ?? false;
|
|
19368
19342
|
this.boardingEpoch++;
|
|
19369
19343
|
this.boardingLoaded = false;
|
|
19370
|
-
this.indexerProvider = new
|
|
19344
|
+
this.indexerProvider = new chunkAICUNREA_cjs.RestIndexerProvider(arkServerUrl);
|
|
19371
19345
|
await this.onWalletInitialized();
|
|
19372
19346
|
}
|
|
19373
19347
|
/** @see RequestInitWallet.payload.lazyBoarding */
|
|
@@ -19789,7 +19763,7 @@ var WalletMessageHandler = class {
|
|
|
19789
19763
|
this.readonlyWallet.getBoardingTxs()
|
|
19790
19764
|
]);
|
|
19791
19765
|
const indexerProvider = this.indexerProvider;
|
|
19792
|
-
const resolveTxCreatedAt = indexerProvider ? (txids) =>
|
|
19766
|
+
const resolveTxCreatedAt = indexerProvider ? (txids) => chunkASKOHVGX_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
|
|
19793
19767
|
return buildTransactionHistory(
|
|
19794
19768
|
vtxos,
|
|
19795
19769
|
boardingTxs,
|
|
@@ -19858,7 +19832,7 @@ var DEFAULT_MESSAGE_TIMEOUTS = {
|
|
|
19858
19832
|
// budget so the worker's snapshot fallback stays reachable before this
|
|
19859
19833
|
// page deadline fires — lowering it below the budget would time the page
|
|
19860
19834
|
// out while the worker is still seconds from answering from cache.
|
|
19861
|
-
GET_ARKADE_INFO:
|
|
19835
|
+
GET_ARKADE_INFO: chunkASKOHVGX_cjs.INFO_FETCH_TIMEOUT_MS + 8e3,
|
|
19862
19836
|
INDEXER_GET_VTXOS: 2e4,
|
|
19863
19837
|
INDEXER_GET_VIRTUAL_TXS: 2e4,
|
|
19864
19838
|
GET_VTXOS: 2e4,
|
|
@@ -20003,7 +19977,7 @@ var ServiceWorkerAssetManager = class extends ServiceWorkerReadonlyAssetManager
|
|
|
20003
19977
|
}
|
|
20004
19978
|
};
|
|
20005
19979
|
var initializeMessageBus = (serviceWorker, config, timeoutMs = 2e3) => {
|
|
20006
|
-
|
|
19980
|
+
chunkASKOHVGX_cjs.assertTimerMs("messageBusTimeoutMs", timeoutMs);
|
|
20007
19981
|
const initCmd = {
|
|
20008
19982
|
tag: "INITIALIZE_MESSAGE_BUS",
|
|
20009
19983
|
id: getRandomId(),
|
|
@@ -20091,7 +20065,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20091
20065
|
}
|
|
20092
20066
|
/** Shared tail of both `create()` factories: boot the bus, INIT_WALLET, cache for reinit. */
|
|
20093
20067
|
static async bootstrap(wallet, options, serializedWallet, busConfig) {
|
|
20094
|
-
const arkServer = options.arkServer ?? { url:
|
|
20068
|
+
const arkServer = options.arkServer ?? { url: chunkASKOHVGX_cjs.DEFAULT_ARKADE_SERVER_URL };
|
|
20095
20069
|
const initWalletPayload = {
|
|
20096
20070
|
lazyBoarding: options.lazyBoarding,
|
|
20097
20071
|
arkServerUrl: arkServer.url,
|
|
@@ -20101,7 +20075,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20101
20075
|
Object.entries(options.messageTimeouts ?? {}).filter(([, ms]) => ms !== void 0)
|
|
20102
20076
|
);
|
|
20103
20077
|
for (const [key, value] of Object.entries(overrides)) {
|
|
20104
|
-
|
|
20078
|
+
chunkASKOHVGX_cjs.assertTimerMs(`messageTimeouts.${key}`, value);
|
|
20105
20079
|
}
|
|
20106
20080
|
const messageTimeouts = {
|
|
20107
20081
|
...DEFAULT_MESSAGE_TIMEOUTS,
|
|
@@ -20441,7 +20415,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20441
20415
|
try {
|
|
20442
20416
|
const response = await this.sendMessage(message);
|
|
20443
20417
|
const { vtxos, page } = response.payload;
|
|
20444
|
-
return { vtxos: vtxos.map(
|
|
20418
|
+
return { vtxos: vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo), page: page && { ...page } };
|
|
20445
20419
|
} catch (cause) {
|
|
20446
20420
|
throw new Error(`Failed to get vtxos: ${cause}`, { cause });
|
|
20447
20421
|
}
|
|
@@ -20545,7 +20519,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20545
20519
|
};
|
|
20546
20520
|
try {
|
|
20547
20521
|
const response = await this.sendMessage(message);
|
|
20548
|
-
return response.payload.vtxos.map(
|
|
20522
|
+
return response.payload.vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
20549
20523
|
} catch (error) {
|
|
20550
20524
|
throw new Error(`Failed to get vtxos: ${error}`);
|
|
20551
20525
|
}
|
|
@@ -20576,7 +20550,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20576
20550
|
"Service worker does not support the requested contract scope or freshness check"
|
|
20577
20551
|
);
|
|
20578
20552
|
}
|
|
20579
|
-
return payload.vtxos.map(
|
|
20553
|
+
return payload.vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
20580
20554
|
} catch (error) {
|
|
20581
20555
|
throw new Error(`Failed to get spendable vtxos: ${error}`);
|
|
20582
20556
|
}
|
|
@@ -20771,7 +20745,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
|
|
|
20771
20745
|
};
|
|
20772
20746
|
try {
|
|
20773
20747
|
const response = await sendContractMessage(message);
|
|
20774
|
-
return response.payload.vtxos.map(
|
|
20748
|
+
return response.payload.vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
20775
20749
|
} catch (cause) {
|
|
20776
20750
|
throw new Error(`Failed to annotate vtxos: ${cause}`, { cause });
|
|
20777
20751
|
}
|
|
@@ -21028,8 +21002,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21028
21002
|
lazyInitialization: options.lazyInitialization,
|
|
21029
21003
|
watcherConfig: options.watcherConfig,
|
|
21030
21004
|
lookAheadWindow: options.lookAheadWindow,
|
|
21031
|
-
minBatchExpirySeconds: options.minBatchExpirySeconds
|
|
21032
|
-
minCheckpointExitDelaySeconds: options.minCheckpointExitDelaySeconds
|
|
21005
|
+
minBatchExpirySeconds: options.minBatchExpirySeconds
|
|
21033
21006
|
});
|
|
21034
21007
|
}
|
|
21035
21008
|
/**
|
|
@@ -21412,7 +21385,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
|
|
|
21412
21385
|
};
|
|
21413
21386
|
try {
|
|
21414
21387
|
const response = await wallet.sendMessage(message);
|
|
21415
|
-
return response.payload.vtxos.map(
|
|
21388
|
+
return response.payload.vtxos.map(chunkASKOHVGX_cjs.normalizeVtxo);
|
|
21416
21389
|
} catch (e) {
|
|
21417
21390
|
throw new Error(`Failed to get expiring vtxos: ${e}`);
|
|
21418
21391
|
}
|
|
@@ -21529,12 +21502,12 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21529
21502
|
* @returns Configured onchain wallet
|
|
21530
21503
|
* @throws Error if the configured identity cannot produce a valid x-only public key
|
|
21531
21504
|
*/
|
|
21532
|
-
static async create(identity, networkName =
|
|
21505
|
+
static async create(identity, networkName = chunkASKOHVGX_cjs.DEFAULT_NETWORK_NAME, provider) {
|
|
21533
21506
|
const pubkey = await identity.xOnlyPublicKey();
|
|
21534
21507
|
if (!pubkey) {
|
|
21535
21508
|
throw new Error("Invalid configured public key");
|
|
21536
21509
|
}
|
|
21537
|
-
const network =
|
|
21510
|
+
const network = chunkASKOHVGX_cjs.getNetwork(networkName);
|
|
21538
21511
|
const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
|
|
21539
21512
|
const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
|
|
21540
21513
|
return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
|
|
@@ -21634,7 +21607,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21634
21607
|
feeRate,
|
|
21635
21608
|
params.address
|
|
21636
21609
|
);
|
|
21637
|
-
let tx = new
|
|
21610
|
+
let tx = new chunkASKOHVGX_cjs.Transaction();
|
|
21638
21611
|
for (const input of inputs) {
|
|
21639
21612
|
tx.addInput({
|
|
21640
21613
|
txid: input.txid,
|
|
@@ -21692,7 +21665,7 @@ var OnchainWallet = class _OnchainWallet {
|
|
|
21692
21665
|
* @throws If the parent has no anchor, or funding cannot be selected/signed
|
|
21693
21666
|
*/
|
|
21694
21667
|
async bumpAnchor(parentHex, feeRate) {
|
|
21695
|
-
const parent =
|
|
21668
|
+
const parent = chunkASKOHVGX_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
|
|
21696
21669
|
const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
|
|
21697
21670
|
const child = await this.buildBumpPackage(parent, feeRate, coins);
|
|
21698
21671
|
return [parent.hex, child.hex];
|
|
@@ -22508,7 +22481,7 @@ var CachingArkProvider = class {
|
|
|
22508
22481
|
constructor(inner, ttlMs = DEFAULT_TTL_MS) {
|
|
22509
22482
|
this.inner = inner;
|
|
22510
22483
|
this.ttlMs = ttlMs;
|
|
22511
|
-
|
|
22484
|
+
chunkASKOHVGX_cjs.assertNonNegativeMs("ttlMs", ttlMs);
|
|
22512
22485
|
this.unsubscribe = inner.onServerInfoChanged?.((info) => {
|
|
22513
22486
|
this.cached = info;
|
|
22514
22487
|
this.expiresAt = Date.now() + this.ttlMs;
|
|
@@ -22600,7 +22573,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22600
22573
|
try {
|
|
22601
22574
|
const { txs } = await source.getVirtualTxs(wanted);
|
|
22602
22575
|
for (const psbt of txs) {
|
|
22603
|
-
const tx =
|
|
22576
|
+
const tx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
|
|
22604
22577
|
resolved.set(tx.id, tx.toBytes());
|
|
22605
22578
|
}
|
|
22606
22579
|
} catch (err) {
|
|
@@ -22633,7 +22606,7 @@ async function resolvePrevTxs(txids, source, onchain) {
|
|
|
22633
22606
|
async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
22634
22607
|
const pending = [];
|
|
22635
22608
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22636
|
-
if (
|
|
22609
|
+
if (chunkASKOHVGX_cjs.getArkPsbtFields(tx, i, chunkASKOHVGX_cjs.PrevArkTxField).length === 0) pending.push(i);
|
|
22637
22610
|
}
|
|
22638
22611
|
if (pending.length === 0) return;
|
|
22639
22612
|
const resolved = await resolvePrevTxs(
|
|
@@ -22642,13 +22615,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
|
|
|
22642
22615
|
onchain
|
|
22643
22616
|
);
|
|
22644
22617
|
for (const i of pending) {
|
|
22645
|
-
|
|
22618
|
+
chunkASKOHVGX_cjs.setArkPsbtField(tx, i, chunkASKOHVGX_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
|
|
22646
22619
|
}
|
|
22647
22620
|
}
|
|
22648
22621
|
async function attachPrevoutTxs(tx, source) {
|
|
22649
22622
|
const pending = [];
|
|
22650
22623
|
for (let i = 0; i < tx.inputsLength; i++) {
|
|
22651
|
-
if (
|
|
22624
|
+
if (chunkASKOHVGX_cjs.getArkPsbtFields(tx, i, chunkASKOHVGX_cjs.PrevoutTxField).length > 0) continue;
|
|
22652
22625
|
const input = tx.getInput(i);
|
|
22653
22626
|
if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
|
|
22654
22627
|
pending.push({ index: i, txid: base.hex.encode(input.txid) });
|
|
@@ -22659,7 +22632,7 @@ async function attachPrevoutTxs(tx, source) {
|
|
|
22659
22632
|
resolved.set(txid, await source.getRawTransaction(txid));
|
|
22660
22633
|
}
|
|
22661
22634
|
for (const { index, txid } of pending) {
|
|
22662
|
-
|
|
22635
|
+
chunkASKOHVGX_cjs.setArkPsbtField(tx, index, chunkASKOHVGX_cjs.PrevoutTxField, resolved.get(txid));
|
|
22663
22636
|
}
|
|
22664
22637
|
}
|
|
22665
22638
|
async function withPrevTxs(coins, source, onchain) {
|
|
@@ -22685,7 +22658,7 @@ exports.BIP322 = void 0;
|
|
|
22685
22658
|
async function sign2(message, identity, network) {
|
|
22686
22659
|
const xOnlyPubKey = await identity.xOnlyPublicKey();
|
|
22687
22660
|
const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
|
|
22688
|
-
const toSpend =
|
|
22661
|
+
const toSpend = chunkASKOHVGX_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
|
|
22689
22662
|
const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
|
|
22690
22663
|
const signed = await identity.sign(toSign, [0]);
|
|
22691
22664
|
signed.finalizeIdx(0);
|
|
@@ -22743,7 +22716,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
|
|
|
22743
22716
|
if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
|
|
22744
22717
|
return false;
|
|
22745
22718
|
}
|
|
22746
|
-
const toSpend =
|
|
22719
|
+
const toSpend = chunkASKOHVGX_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22747
22720
|
const toSign = craftBIP322ToSignP2TR(toSpend, pkScript);
|
|
22748
22721
|
const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
|
|
22749
22722
|
const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
|
|
@@ -22764,7 +22737,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
|
|
|
22764
22737
|
}
|
|
22765
22738
|
const sighashType = sigWithHash[sigWithHash.length - 1];
|
|
22766
22739
|
const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
|
|
22767
|
-
const toSpend =
|
|
22740
|
+
const toSpend = chunkASKOHVGX_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
|
|
22768
22741
|
const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
|
|
22769
22742
|
const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
|
|
22770
22743
|
const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
|
|
@@ -22817,7 +22790,7 @@ function encodeCompactSize(n) {
|
|
|
22817
22790
|
return buf;
|
|
22818
22791
|
}
|
|
22819
22792
|
function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
22820
|
-
const tx = new
|
|
22793
|
+
const tx = new chunkASKOHVGX_cjs.Transaction({ version: 0 });
|
|
22821
22794
|
tx.addInput({
|
|
22822
22795
|
txid: toSpend.id,
|
|
22823
22796
|
index: 0,
|
|
@@ -22831,12 +22804,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
|
|
|
22831
22804
|
});
|
|
22832
22805
|
tx.addOutput({
|
|
22833
22806
|
amount: 0n,
|
|
22834
|
-
script:
|
|
22807
|
+
script: chunkASKOHVGX_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22835
22808
|
});
|
|
22836
22809
|
return tx;
|
|
22837
22810
|
}
|
|
22838
22811
|
function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
22839
|
-
const tx = new
|
|
22812
|
+
const tx = new chunkASKOHVGX_cjs.Transaction({ version: 0 });
|
|
22840
22813
|
tx.addInput({
|
|
22841
22814
|
txid: toSpend.id,
|
|
22842
22815
|
index: 0,
|
|
@@ -22848,12 +22821,12 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
|
|
|
22848
22821
|
});
|
|
22849
22822
|
tx.addOutput({
|
|
22850
22823
|
amount: 0n,
|
|
22851
|
-
script:
|
|
22824
|
+
script: chunkASKOHVGX_cjs.OP_RETURN_EMPTY_PKSCRIPT
|
|
22852
22825
|
});
|
|
22853
22826
|
return tx;
|
|
22854
22827
|
}
|
|
22855
22828
|
function finalizeVirtualTx(type, psbtBase64) {
|
|
22856
|
-
const tx =
|
|
22829
|
+
const tx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
|
|
22857
22830
|
if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
|
|
22858
22831
|
const input = tx.getInput(0);
|
|
22859
22832
|
if (!input) {
|
|
@@ -22880,14 +22853,14 @@ var ExitPathError = class extends Error {
|
|
|
22880
22853
|
reason;
|
|
22881
22854
|
};
|
|
22882
22855
|
function delayWeight(sequence) {
|
|
22883
|
-
const t =
|
|
22856
|
+
const t = chunkASKOHVGX_cjs.sequenceToTimelock(sequence);
|
|
22884
22857
|
return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
|
|
22885
22858
|
}
|
|
22886
22859
|
async function resolveUnilateralPath(params) {
|
|
22887
22860
|
const { vtxo, scriptHex, contractRepository } = params;
|
|
22888
22861
|
const contract = contractRepository ? (await collectContracts(contractRepository, { script: scriptHex }))[0] : void 0;
|
|
22889
22862
|
if (contract) {
|
|
22890
|
-
const handler =
|
|
22863
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
22891
22864
|
if (!handler) {
|
|
22892
22865
|
throw new ExitPathError(
|
|
22893
22866
|
"no-handler",
|
|
@@ -22909,12 +22882,12 @@ async function resolveUnilateralPath(params) {
|
|
|
22909
22882
|
paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
|
|
22910
22883
|
return { selection: paths[0], label: `${contract.type}:unilateral` };
|
|
22911
22884
|
}
|
|
22912
|
-
const decoded =
|
|
22885
|
+
const decoded = chunkASKOHVGX_cjs.VtxoScript.decode(vtxo.tapTree);
|
|
22913
22886
|
let best;
|
|
22914
22887
|
for (const exit of decoded.exitPaths()) {
|
|
22915
22888
|
const leaf = decoded.findLeaf(base.hex.encode(exit.script));
|
|
22916
22889
|
if (!leaf) continue;
|
|
22917
|
-
const sequence =
|
|
22890
|
+
const sequence = chunkASKOHVGX_cjs.timelockToSequence(exit.params.timelock);
|
|
22918
22891
|
const weight = delayWeight(sequence);
|
|
22919
22892
|
if (!best || weight < best.weight) {
|
|
22920
22893
|
best = { selection: { leaf, sequence }, weight };
|
|
@@ -23121,7 +23094,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23121
23094
|
const txWeightEstimator = TxWeightEstimator.create();
|
|
23122
23095
|
const walletDescriptor = base.hex.encode(await wallet.identity.xOnlyPublicKey());
|
|
23123
23096
|
for (const vtxo of vtxos) {
|
|
23124
|
-
if (!
|
|
23097
|
+
if (!chunkASKOHVGX_cjs.canSweepOnchain(vtxo)) {
|
|
23125
23098
|
throw new Error(
|
|
23126
23099
|
`Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
|
|
23127
23100
|
);
|
|
@@ -23132,14 +23105,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23132
23105
|
}
|
|
23133
23106
|
const resolved = await resolveUnilateralPath({
|
|
23134
23107
|
vtxo,
|
|
23135
|
-
scriptHex: base.hex.encode(
|
|
23108
|
+
scriptHex: base.hex.encode(chunkASKOHVGX_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
23136
23109
|
contractRepository: wallet.contractRepository,
|
|
23137
23110
|
walletDescriptor,
|
|
23138
23111
|
currentTime: Date.now()
|
|
23139
23112
|
});
|
|
23140
23113
|
const spendingLeaf = resolved.selection.leaf;
|
|
23141
23114
|
const sequence = resolved.selection.sequence;
|
|
23142
|
-
const timelock =
|
|
23115
|
+
const timelock = chunkASKOHVGX_cjs.sequenceToTimelock(sequence);
|
|
23143
23116
|
const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
|
|
23144
23117
|
if (!elapsed) {
|
|
23145
23118
|
throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
|
|
@@ -23152,7 +23125,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23152
23125
|
sequence,
|
|
23153
23126
|
witnessUtxo: {
|
|
23154
23127
|
amount: BigInt(vtxo.value),
|
|
23155
|
-
script:
|
|
23128
|
+
script: chunkASKOHVGX_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
|
|
23156
23129
|
},
|
|
23157
23130
|
sighashType: btcSigner.SigHash.DEFAULT
|
|
23158
23131
|
});
|
|
@@ -23162,7 +23135,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
|
|
|
23162
23135
|
btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
|
|
23163
23136
|
);
|
|
23164
23137
|
}
|
|
23165
|
-
const tx = new
|
|
23138
|
+
const tx = new chunkASKOHVGX_cjs.Transaction({ version: 2 });
|
|
23166
23139
|
for (const input of inputs) {
|
|
23167
23140
|
tx.addInput(input);
|
|
23168
23141
|
}
|
|
@@ -23245,7 +23218,7 @@ async function buildSignedSweep(params) {
|
|
|
23245
23218
|
`uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
|
|
23246
23219
|
);
|
|
23247
23220
|
}
|
|
23248
|
-
const tx = new
|
|
23221
|
+
const tx = new chunkASKOHVGX_cjs.Transaction({ version: 2 });
|
|
23249
23222
|
tx.addInput({
|
|
23250
23223
|
txid: vtxo.txid,
|
|
23251
23224
|
index: vtxo.vout,
|
|
@@ -23270,7 +23243,7 @@ async function buildSignedSweep(params) {
|
|
|
23270
23243
|
finalScriptWitness: [
|
|
23271
23244
|
tapScriptSig[0][1],
|
|
23272
23245
|
...path.extraWitness,
|
|
23273
|
-
|
|
23246
|
+
chunkASKOHVGX_cjs.scriptFromTapLeafScript(path.leaf),
|
|
23274
23247
|
btcSigner.TaprootControlBlock.encode(controlBlock)
|
|
23275
23248
|
]
|
|
23276
23249
|
});
|
|
@@ -23300,7 +23273,7 @@ async function resolveFeeRate(opts) {
|
|
|
23300
23273
|
}
|
|
23301
23274
|
async function selectExitVtxos(opts) {
|
|
23302
23275
|
if (!opts.vtxos) return opts.wallet.getVtxos();
|
|
23303
|
-
const res = await
|
|
23276
|
+
const res = await chunkASKOHVGX_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
|
|
23304
23277
|
const tapTrees = /* @__PURE__ */ new Map();
|
|
23305
23278
|
const out = [];
|
|
23306
23279
|
for (const vtxo of res.vtxos) {
|
|
@@ -23315,7 +23288,7 @@ async function selectExitVtxos(opts) {
|
|
|
23315
23288
|
`no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
|
|
23316
23289
|
);
|
|
23317
23290
|
}
|
|
23318
|
-
const handler =
|
|
23291
|
+
const handler = chunk4MCQZYH6_cjs.contractHandlers.get(contract.type);
|
|
23319
23292
|
if (!handler) {
|
|
23320
23293
|
throw new Error(`no contract handler registered for type '${contract.type}'`);
|
|
23321
23294
|
}
|
|
@@ -23345,7 +23318,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23345
23318
|
if (pendingNodes.length > 0) {
|
|
23346
23319
|
const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
|
|
23347
23320
|
for (const psbt of txs) {
|
|
23348
|
-
psbts.set(
|
|
23321
|
+
psbts.set(chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
|
|
23349
23322
|
}
|
|
23350
23323
|
}
|
|
23351
23324
|
const childVsize = Number(
|
|
@@ -23373,7 +23346,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23373
23346
|
try {
|
|
23374
23347
|
const resolved = await resolveUnilateralPath({
|
|
23375
23348
|
vtxo,
|
|
23376
|
-
scriptHex: base.hex.encode(
|
|
23349
|
+
scriptHex: base.hex.encode(chunkASKOHVGX_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
|
|
23377
23350
|
contractRepository: wallet.contractRepository,
|
|
23378
23351
|
walletDescriptor,
|
|
23379
23352
|
currentTime: Date.now()
|
|
@@ -23392,7 +23365,7 @@ async function computeExitLayout(opts, feeRate) {
|
|
|
23392
23365
|
});
|
|
23393
23366
|
continue;
|
|
23394
23367
|
}
|
|
23395
|
-
const t =
|
|
23368
|
+
const t = chunkASKOHVGX_cjs.sequenceToTimelock(resolved.selection.sequence);
|
|
23396
23369
|
const delay = { type: t.type, value: Number(t.value) };
|
|
23397
23370
|
infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
|
|
23398
23371
|
sweeps.push({ vtxo, resolved, sweepFee, delay });
|
|
@@ -23499,7 +23472,7 @@ var Executor = class {
|
|
|
23499
23472
|
constructor(pkg, provider, opts) {
|
|
23500
23473
|
this.pkg = pkg;
|
|
23501
23474
|
this.provider = provider;
|
|
23502
|
-
|
|
23475
|
+
chunkASKOHVGX_cjs.assertTimerMs("pollIntervalMs", opts?.pollIntervalMs);
|
|
23503
23476
|
this.pollIntervalMs = opts?.pollIntervalMs ?? 5e3;
|
|
23504
23477
|
this.feeWallet = opts?.feeWallet;
|
|
23505
23478
|
this.signal = opts?.signal;
|
|
@@ -23794,7 +23767,7 @@ async function prepare(opts) {
|
|
|
23794
23767
|
txid: sweep.vtxo.txid,
|
|
23795
23768
|
vout: sweep.vtxo.vout,
|
|
23796
23769
|
value: sweep.vtxo.value,
|
|
23797
|
-
pkScript:
|
|
23770
|
+
pkScript: chunkASKOHVGX_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
|
|
23798
23771
|
},
|
|
23799
23772
|
path: sweep.resolved.selection,
|
|
23800
23773
|
outputAddress: opts.sweepAddress,
|
|
@@ -23883,7 +23856,7 @@ async function prepare(opts) {
|
|
|
23883
23856
|
if (newFee <= splitterFee) break;
|
|
23884
23857
|
splitterFee = newFee;
|
|
23885
23858
|
}
|
|
23886
|
-
const splitter = new
|
|
23859
|
+
const splitter = new chunkASKOHVGX_cjs.Transaction({ version: 2 });
|
|
23887
23860
|
for (const coin of selected.inputs) {
|
|
23888
23861
|
splitter.addInput({
|
|
23889
23862
|
txid: coin.txid,
|
|
@@ -24022,46 +23995,46 @@ var UnilateralExit = {
|
|
|
24022
23995
|
|
|
24023
23996
|
// src/arkade/index.ts
|
|
24024
23997
|
var arkade_exports = {};
|
|
24025
|
-
|
|
24026
|
-
ARKADE_OP: () =>
|
|
24027
|
-
ARKADE_OPCODES: () =>
|
|
24028
|
-
ARKADE_OPCODE_NAMES: () =>
|
|
24029
|
-
ARKADE_OPCODE_VALUES: () =>
|
|
24030
|
-
ARKADE_OPS: () =>
|
|
23998
|
+
chunkASKOHVGX_cjs.__export(arkade_exports, {
|
|
23999
|
+
ARKADE_OP: () => chunk4MCQZYH6_cjs.ARKADE_OP,
|
|
24000
|
+
ARKADE_OPCODES: () => chunk4MCQZYH6_cjs.ARKADE_OPCODES,
|
|
24001
|
+
ARKADE_OPCODE_NAMES: () => chunk4MCQZYH6_cjs.ARKADE_OPCODE_NAMES,
|
|
24002
|
+
ARKADE_OPCODE_VALUES: () => chunk4MCQZYH6_cjs.ARKADE_OPCODE_VALUES,
|
|
24003
|
+
ARKADE_OPS: () => chunk4MCQZYH6_cjs.ARKADE_OPS,
|
|
24031
24004
|
Arkade: () => Arkade,
|
|
24032
24005
|
ArkadeContract: () => ArkadeContract,
|
|
24033
|
-
ArkadeProgramScript: () =>
|
|
24034
|
-
ArkadeScript: () =>
|
|
24006
|
+
ArkadeProgramScript: () => chunk4MCQZYH6_cjs.ArkadeProgramScript,
|
|
24007
|
+
ArkadeScript: () => chunk4MCQZYH6_cjs.ArkadeScript,
|
|
24035
24008
|
ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
|
|
24036
|
-
BigNum: () =>
|
|
24009
|
+
BigNum: () => chunk4MCQZYH6_cjs.bignum_exports,
|
|
24037
24010
|
OP: () => btcSigner.OP,
|
|
24038
|
-
OPCODE_NAMES: () =>
|
|
24039
|
-
OPCODE_VALUES: () =>
|
|
24040
|
-
SUPPORTED_PROGRAM_VERSION: () =>
|
|
24011
|
+
OPCODE_NAMES: () => chunk4MCQZYH6_cjs.OPCODE_NAMES,
|
|
24012
|
+
OPCODE_VALUES: () => chunk4MCQZYH6_cjs.OPCODE_VALUES,
|
|
24013
|
+
SUPPORTED_PROGRAM_VERSION: () => chunk4MCQZYH6_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
24041
24014
|
Script: () => btcSigner.Script,
|
|
24042
|
-
UnsupportedProgramVersionError: () =>
|
|
24043
|
-
arkadeScriptHash: () =>
|
|
24044
|
-
arkadeWitnessHash: () =>
|
|
24045
|
-
asmToBytes: () =>
|
|
24046
|
-
bytesToASM: () =>
|
|
24047
|
-
computeArkadeScriptPublicKey: () =>
|
|
24015
|
+
UnsupportedProgramVersionError: () => chunk4MCQZYH6_cjs.UnsupportedProgramVersionError,
|
|
24016
|
+
arkadeScriptHash: () => chunk4MCQZYH6_cjs.arkadeScriptHash,
|
|
24017
|
+
arkadeWitnessHash: () => chunk4MCQZYH6_cjs.arkadeWitnessHash,
|
|
24018
|
+
asmToBytes: () => chunk4MCQZYH6_cjs.asmToBytes,
|
|
24019
|
+
bytesToASM: () => chunk4MCQZYH6_cjs.bytesToASM,
|
|
24020
|
+
computeArkadeScriptPublicKey: () => chunk4MCQZYH6_cjs.computeArkadeScriptPublicKey,
|
|
24048
24021
|
createArkadeBatchHandler: () => createArkadeBatchHandler,
|
|
24049
|
-
deserializeArkadeContractParams: () =>
|
|
24050
|
-
fromASM: () =>
|
|
24051
|
-
getOpcodeName: () =>
|
|
24052
|
-
getOpcodeValue: () =>
|
|
24022
|
+
deserializeArkadeContractParams: () => chunk4MCQZYH6_cjs.deserializeArkadeContractParams,
|
|
24023
|
+
fromASM: () => chunk4MCQZYH6_cjs.fromASM,
|
|
24024
|
+
getOpcodeName: () => chunk4MCQZYH6_cjs.getOpcodeName,
|
|
24025
|
+
getOpcodeValue: () => chunk4MCQZYH6_cjs.getOpcodeValue,
|
|
24053
24026
|
isContractArtifact: () => isContractArtifact,
|
|
24054
|
-
parseArtifact: () =>
|
|
24027
|
+
parseArtifact: () => chunk4MCQZYH6_cjs.parseArtifact,
|
|
24055
24028
|
programFromArtifact: () => programFromArtifact,
|
|
24056
24029
|
resolveArkadeService: () => resolveArkadeService,
|
|
24057
|
-
resolveAsm: () =>
|
|
24058
|
-
serializeArkadeContractParams: () =>
|
|
24059
|
-
stringifyArtifact: () =>
|
|
24060
|
-
toASM: () =>
|
|
24061
|
-
validateProgram: () =>
|
|
24062
|
-
witnessRefToBytes: () =>
|
|
24030
|
+
resolveAsm: () => chunk4MCQZYH6_cjs.resolveAsm,
|
|
24031
|
+
serializeArkadeContractParams: () => chunk4MCQZYH6_cjs.serializeArkadeContractParams,
|
|
24032
|
+
stringifyArtifact: () => chunk4MCQZYH6_cjs.stringifyArtifact,
|
|
24033
|
+
toASM: () => chunk4MCQZYH6_cjs.toASM,
|
|
24034
|
+
validateProgram: () => chunk4MCQZYH6_cjs.validateProgram,
|
|
24035
|
+
witnessRefToBytes: () => chunk4MCQZYH6_cjs.witnessRefToBytes
|
|
24063
24036
|
});
|
|
24064
|
-
var isVtxoCoin = (input) =>
|
|
24037
|
+
var isVtxoCoin = (input) => chunkASKOHVGX_cjs.isVirtualCoin(input);
|
|
24065
24038
|
function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
|
|
24066
24039
|
let batchId;
|
|
24067
24040
|
let sweepTapTreeRoot;
|
|
@@ -24082,23 +24055,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24082
24055
|
);
|
|
24083
24056
|
await arkProvider.confirmRegistration(intentId);
|
|
24084
24057
|
batchId = event.id;
|
|
24085
|
-
const sweepTapscript =
|
|
24058
|
+
const sweepTapscript = chunkASKOHVGX_cjs.CSVMultisigTapscript.encode({
|
|
24086
24059
|
timelock,
|
|
24087
|
-
pubkeys: [
|
|
24060
|
+
pubkeys: [chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
|
|
24088
24061
|
}).script;
|
|
24089
24062
|
sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
|
|
24090
24063
|
return { skip: false };
|
|
24091
24064
|
},
|
|
24092
24065
|
onTreeSigningStarted: async (event, vtxoTree) => {
|
|
24093
24066
|
const signerPubKey = await session.getPublicKey();
|
|
24094
|
-
const xonlySignerPubKey =
|
|
24067
|
+
const xonlySignerPubKey = chunk4MCQZYH6_cjs.toXOnly(signerPubKey, "signer key");
|
|
24095
24068
|
const xOnlyPubkeys = event.cosignersPublicKeys.map(
|
|
24096
|
-
(k) => base.hex.encode(
|
|
24069
|
+
(k) => base.hex.encode(chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
|
|
24097
24070
|
);
|
|
24098
24071
|
if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
|
|
24099
24072
|
return { skip: true };
|
|
24100
24073
|
}
|
|
24101
|
-
const commitmentTx =
|
|
24074
|
+
const commitmentTx = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
|
|
24102
24075
|
validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
|
|
24103
24076
|
if (recipients && recipients.length > 0) {
|
|
24104
24077
|
validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
|
|
@@ -24136,7 +24109,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24136
24109
|
if (connectorTree) {
|
|
24137
24110
|
validateConnectorsTxGraph(event.commitmentTx, connectorTree);
|
|
24138
24111
|
}
|
|
24139
|
-
let commitmentPsbt =
|
|
24112
|
+
let commitmentPsbt = chunkASKOHVGX_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
|
|
24140
24113
|
assertFinalCommitmentMatchesValidated(
|
|
24141
24114
|
commitmentPsbt,
|
|
24142
24115
|
validatedCommitmentTxid,
|
|
@@ -24178,7 +24151,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24178
24151
|
boardingIndices.push(boardingIdx);
|
|
24179
24152
|
continue;
|
|
24180
24153
|
}
|
|
24181
|
-
if (!
|
|
24154
|
+
if (!chunkASKOHVGX_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
|
|
24182
24155
|
continue;
|
|
24183
24156
|
}
|
|
24184
24157
|
if (connectorIndex >= connectorLeaves.length) {
|
|
@@ -24199,7 +24172,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
|
|
|
24199
24172
|
index: input.vout,
|
|
24200
24173
|
witnessUtxo: {
|
|
24201
24174
|
amount: BigInt(input.value),
|
|
24202
|
-
script:
|
|
24175
|
+
script: chunkASKOHVGX_cjs.VtxoScript.decode(input.tapTree).pkScript
|
|
24203
24176
|
},
|
|
24204
24177
|
sighashType: btcSigner.SigHash.DEFAULT,
|
|
24205
24178
|
tapLeafScript: [input.forfeitTapLeafScript]
|
|
@@ -24310,7 +24283,7 @@ function inputDef(name, type) {
|
|
|
24310
24283
|
return { name, type: argType(type) };
|
|
24311
24284
|
}
|
|
24312
24285
|
function argType(arkType) {
|
|
24313
|
-
if (!Object.hasOwn(
|
|
24286
|
+
if (!Object.hasOwn(chunk4MCQZYH6_cjs.ARKADE_TYPE_ENCODINGS, arkType)) fail(`unknown type '${arkType}'`);
|
|
24314
24287
|
return arkType;
|
|
24315
24288
|
}
|
|
24316
24289
|
function arrayParts(type) {
|
|
@@ -24351,7 +24324,7 @@ function flatten(param, structs, stack = []) {
|
|
|
24351
24324
|
function opcodeToken(token) {
|
|
24352
24325
|
const base = token.slice(3);
|
|
24353
24326
|
const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
|
|
24354
|
-
if (!Object.hasOwn(
|
|
24327
|
+
if (!Object.hasOwn(chunk4MCQZYH6_cjs.ARKADE_OPS, name)) {
|
|
24355
24328
|
fail(`opcode '${token}' is not in this SDK's table`);
|
|
24356
24329
|
}
|
|
24357
24330
|
return name;
|
|
@@ -24398,7 +24371,7 @@ function providedWitness(witness) {
|
|
|
24398
24371
|
fail(`witness '${item.name}': injected must be boolean`);
|
|
24399
24372
|
if (item.injected && item.type !== "signature")
|
|
24400
24373
|
fail(`witness '${item.name}': only infrastructure signatures can be injected`);
|
|
24401
|
-
if (item.encoding !== void 0 && item.encoding !==
|
|
24374
|
+
if (item.encoding !== void 0 && item.encoding !== chunk4MCQZYH6_cjs.ARKADE_TYPE_ENCODINGS[type])
|
|
24402
24375
|
fail(
|
|
24403
24376
|
`witness '${item.name}': encoding '${item.encoding}' does not match type '${item.type}'`
|
|
24404
24377
|
);
|
|
@@ -24407,7 +24380,7 @@ function providedWitness(witness) {
|
|
|
24407
24380
|
}
|
|
24408
24381
|
function csvTimelock(leafName, operand) {
|
|
24409
24382
|
if (typeof operand === "string") return { type: "sequence", value: operand };
|
|
24410
|
-
const timelock =
|
|
24383
|
+
const timelock = chunkASKOHVGX_cjs.sequenceToCanonicalTimelock(operand);
|
|
24411
24384
|
if (!timelock) {
|
|
24412
24385
|
fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
|
|
24413
24386
|
}
|
|
@@ -24501,7 +24474,7 @@ function programFromArtifact(artifact) {
|
|
|
24501
24474
|
if (!isNamed(field)) fail(`struct '${struct.name}': field needs a name and type`);
|
|
24502
24475
|
claim(fields, field.name, "struct field");
|
|
24503
24476
|
}
|
|
24504
|
-
if (Object.hasOwn(
|
|
24477
|
+
if (Object.hasOwn(chunk4MCQZYH6_cjs.ARKADE_TYPE_ENCODINGS, struct.name) || Object.hasOwn(NATIVE_STRUCTS, struct.name)) {
|
|
24505
24478
|
fail(`struct name '${struct.name}' shadows a built-in type`);
|
|
24506
24479
|
}
|
|
24507
24480
|
claim(structNames, struct.name, "struct");
|
|
@@ -24584,7 +24557,7 @@ function programFromArtifact(artifact) {
|
|
|
24584
24557
|
const paramNames = /* @__PURE__ */ new Set();
|
|
24585
24558
|
for (const param of params) claim(paramNames, param.name, "program parameter");
|
|
24586
24559
|
return {
|
|
24587
|
-
version:
|
|
24560
|
+
version: chunk4MCQZYH6_cjs.SUPPORTED_PROGRAM_VERSION,
|
|
24588
24561
|
name: artifact.contractName,
|
|
24589
24562
|
params,
|
|
24590
24563
|
functions
|
|
@@ -24666,16 +24639,16 @@ var Arkade = class _Arkade {
|
|
|
24666
24639
|
indexer = opts.indexer;
|
|
24667
24640
|
info = await opts.arkade.getInfo();
|
|
24668
24641
|
}
|
|
24669
|
-
const serverKey =
|
|
24670
|
-
const checkpoint =
|
|
24671
|
-
const network = opts.network ?? (Object.hasOwn(
|
|
24642
|
+
const serverKey = chunk4MCQZYH6_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
|
|
24643
|
+
const checkpoint = chunkASKOHVGX_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
|
|
24644
|
+
const network = opts.network ?? (Object.hasOwn(chunkASKOHVGX_cjs.networks, info.network) ? chunkASKOHVGX_cjs.getNetwork(info.network) : chunkASKOHVGX_cjs.DEFAULT_NETWORK);
|
|
24672
24645
|
let emulatorKey;
|
|
24673
24646
|
if (emulator) {
|
|
24674
|
-
emulatorKey = base.hex.decode(
|
|
24647
|
+
emulatorKey = base.hex.decode(chunkASKOHVGX_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
|
|
24675
24648
|
}
|
|
24676
24649
|
let userKey;
|
|
24677
24650
|
if (opts.identity) {
|
|
24678
|
-
userKey =
|
|
24651
|
+
userKey = chunk4MCQZYH6_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
|
|
24679
24652
|
}
|
|
24680
24653
|
let contractManager = opts.contractManager;
|
|
24681
24654
|
let ownsContractManager = false;
|
|
@@ -24794,7 +24767,7 @@ var Arkade = class _Arkade {
|
|
|
24794
24767
|
`compiler artifact: server exit delay ${delay}s must be a multiple of 512 seconds`
|
|
24795
24768
|
);
|
|
24796
24769
|
}
|
|
24797
|
-
const sequence = BigInt(
|
|
24770
|
+
const sequence = BigInt(chunkASKOHVGX_cjs.timelockToSequence(typed));
|
|
24798
24771
|
if (args.SERVER_EXIT_DELAY !== void 0 && args.SERVER_EXIT_DELAY !== sequence && args.SERVER_EXIT_DELAY !== Number(sequence)) {
|
|
24799
24772
|
throw new Error(
|
|
24800
24773
|
"compiler artifact: reserved SERVER_EXIT_DELAY must match the connected server"
|
|
@@ -24815,7 +24788,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24815
24788
|
userKey: client.userKey,
|
|
24816
24789
|
emulatorKey: client.emulatorKey
|
|
24817
24790
|
};
|
|
24818
|
-
this.vtxoScript = new
|
|
24791
|
+
this.vtxoScript = new chunk4MCQZYH6_cjs.ArkadeProgramScript(program, args, this.keys);
|
|
24819
24792
|
this.tapTree = this.vtxoScript.encode();
|
|
24820
24793
|
this.compiled = this.vtxoScript.compiled;
|
|
24821
24794
|
}
|
|
@@ -24840,7 +24813,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24840
24813
|
`ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
|
|
24841
24814
|
);
|
|
24842
24815
|
}
|
|
24843
|
-
const typed =
|
|
24816
|
+
const typed = chunk4MCQZYH6_cjs.deserializeArkadeContractParams(contract.params);
|
|
24844
24817
|
return new _ArkadeContract(client, typed.program, typed.args, {
|
|
24845
24818
|
serverKey: typed.serverKey,
|
|
24846
24819
|
userKey: typed.userKey,
|
|
@@ -24876,7 +24849,7 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24876
24849
|
toContractParams() {
|
|
24877
24850
|
return {
|
|
24878
24851
|
type: "arkade",
|
|
24879
|
-
params:
|
|
24852
|
+
params: chunk4MCQZYH6_cjs.serializeArkadeContractParams({
|
|
24880
24853
|
program: this.program,
|
|
24881
24854
|
args: this.args,
|
|
24882
24855
|
serverKey: this.keys.serverKey,
|
|
@@ -24963,17 +24936,17 @@ var ArkadeContract = class _ArkadeContract {
|
|
|
24963
24936
|
const [registered] = await manager.getContracts({ script: scriptHex });
|
|
24964
24937
|
if (registered) {
|
|
24965
24938
|
const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
|
|
24966
|
-
return (withVtxos?.vtxos ?? []).filter((v) => !
|
|
24939
|
+
return (withVtxos?.vtxos ?? []).filter((v) => !chunkASKOHVGX_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
24967
24940
|
}
|
|
24968
24941
|
}
|
|
24969
24942
|
if (!this.client.indexer) {
|
|
24970
24943
|
throw new Error("ArkadeContract.getUtxos: an indexer is required");
|
|
24971
24944
|
}
|
|
24972
|
-
const { vtxos } = await
|
|
24945
|
+
const { vtxos } = await chunkASKOHVGX_cjs.getNormalizedVtxos(this.client.indexer, {
|
|
24973
24946
|
scripts: [scriptHex],
|
|
24974
24947
|
spendableOnly: true
|
|
24975
24948
|
});
|
|
24976
|
-
return vtxos.filter((v) => !
|
|
24949
|
+
return vtxos.filter((v) => !chunkASKOHVGX_cjs.isVtxoSpent(v) && !v.isUnrolled);
|
|
24977
24950
|
}
|
|
24978
24951
|
/** Total spendable balance (requires an indexer). */
|
|
24979
24952
|
async getBalance() {
|
|
@@ -25082,7 +25055,7 @@ var ArkadeTransactionBuilder = class {
|
|
|
25082
25055
|
this.contract.client.checkpoint
|
|
25083
25056
|
);
|
|
25084
25057
|
if (coin.sourceTx) {
|
|
25085
|
-
|
|
25058
|
+
chunkASKOHVGX_cjs.setArkPsbtField(arkTx, 0, chunkASKOHVGX_cjs.PrevArkTxField, coin.sourceTx);
|
|
25086
25059
|
}
|
|
25087
25060
|
if (this.fn.arkadeScript) {
|
|
25088
25061
|
const indexer = this.contract.client.indexer;
|
|
@@ -25099,8 +25072,8 @@ var ArkadeTransactionBuilder = class {
|
|
|
25099
25072
|
}
|
|
25100
25073
|
const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
|
|
25101
25074
|
if (condition.length > 0) {
|
|
25102
|
-
|
|
25103
|
-
|
|
25075
|
+
chunkASKOHVGX_cjs.setArkPsbtField(arkTx, 0, chunkASKOHVGX_cjs.ConditionWitness, condition);
|
|
25076
|
+
chunkASKOHVGX_cjs.setArkPsbtField(checkpoints[0], 0, chunkASKOHVGX_cjs.ConditionWitness, condition);
|
|
25104
25077
|
}
|
|
25105
25078
|
const packets = [];
|
|
25106
25079
|
if (this.assetSpecs.length > 0) {
|
|
@@ -25208,19 +25181,19 @@ var ArkadeTransactionBuilder = class {
|
|
|
25208
25181
|
}
|
|
25209
25182
|
buildAssetPacket() {
|
|
25210
25183
|
const groups = this.assetSpecs.map((s) => {
|
|
25211
|
-
const id = typeof s.assetId === "string" ?
|
|
25212
|
-
return
|
|
25184
|
+
const id = typeof s.assetId === "string" ? chunkAICUNREA_cjs.AssetId.fromString(s.assetId) : chunkAICUNREA_cjs.AssetId.fromBytes(s.assetId);
|
|
25185
|
+
return chunkAICUNREA_cjs.AssetGroup.create(
|
|
25213
25186
|
id,
|
|
25214
25187
|
null,
|
|
25215
|
-
s.inputs.map((i) =>
|
|
25216
|
-
s.outputs.map((o) =>
|
|
25217
|
-
(s.metadata ?? []).map((m) =>
|
|
25188
|
+
s.inputs.map((i) => chunkAICUNREA_cjs.AssetInput.create(i.vin, i.amount)),
|
|
25189
|
+
s.outputs.map((o) => chunkAICUNREA_cjs.AssetOutput.create(o.vout, o.amount)),
|
|
25190
|
+
(s.metadata ?? []).map((m) => chunkAICUNREA_cjs.Metadata.create(m.key, m.value))
|
|
25218
25191
|
);
|
|
25219
25192
|
});
|
|
25220
|
-
return
|
|
25193
|
+
return chunkAICUNREA_cjs.Packet.create(groups);
|
|
25221
25194
|
}
|
|
25222
25195
|
witnessBytes(ref) {
|
|
25223
|
-
return
|
|
25196
|
+
return chunk4MCQZYH6_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
|
|
25224
25197
|
}
|
|
25225
25198
|
};
|
|
25226
25199
|
function bindInputs(fn, callArgs) {
|
|
@@ -25234,7 +25207,7 @@ function bindInputs(fn, callArgs) {
|
|
|
25234
25207
|
inputs.forEach((def, i) => {
|
|
25235
25208
|
if (Object.hasOwn(bound, def.name))
|
|
25236
25209
|
throw new Error(`${fn.name}: duplicate input '${def.name}'`);
|
|
25237
|
-
|
|
25210
|
+
chunk4MCQZYH6_cjs.validateParamValue(def, callArgs[i]);
|
|
25238
25211
|
bound[def.name] = callArgs[i];
|
|
25239
25212
|
});
|
|
25240
25213
|
return bound;
|
|
@@ -25645,17 +25618,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
|
|
|
25645
25618
|
function offchainInputFees(vtxos, fees) {
|
|
25646
25619
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25647
25620
|
return vtxos.reduce(
|
|
25648
|
-
(total, vtxo) => total + estimator.evalOffchainInput(
|
|
25621
|
+
(total, vtxo) => total + estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
|
|
25649
25622
|
0
|
|
25650
25623
|
);
|
|
25651
25624
|
}
|
|
25652
25625
|
async function changeOutputFee(wallet, inputs, needed, fees) {
|
|
25653
25626
|
const estimator = new Estimator(fees?.intentFee ?? {});
|
|
25654
25627
|
const net = inputs.reduce(
|
|
25655
|
-
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(
|
|
25628
|
+
(total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkASKOHVGX_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
|
|
25656
25629
|
0n
|
|
25657
25630
|
);
|
|
25658
|
-
const script = base.hex.encode(
|
|
25631
|
+
const script = base.hex.encode(chunkASKOHVGX_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
|
|
25659
25632
|
return changeAfterOutputFee(
|
|
25660
25633
|
net - needed,
|
|
25661
25634
|
(amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
|
|
@@ -25744,7 +25717,6 @@ exports.ContractManager = ContractManager;
|
|
|
25744
25717
|
exports.ContractWatcher = ContractWatcher;
|
|
25745
25718
|
exports.DEFAULT_MESSAGE_TIMEOUTS = DEFAULT_MESSAGE_TIMEOUTS;
|
|
25746
25719
|
exports.DEFAULT_MIN_BATCH_EXPIRY_SECONDS = DEFAULT_MIN_BATCH_EXPIRY_SECONDS;
|
|
25747
|
-
exports.DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
25748
25720
|
exports.DatabaseUpgradeBlockedError = DatabaseUpgradeBlockedError;
|
|
25749
25721
|
exports.DelegateManagerImpl = DelegateManagerImpl;
|
|
25750
25722
|
exports.DelegateNotConfiguredError = DelegateNotConfiguredError;
|
|
@@ -25776,7 +25748,6 @@ exports.MAX_PAGE_SIZE = MAX_PAGE_SIZE;
|
|
|
25776
25748
|
exports.MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD = MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD;
|
|
25777
25749
|
exports.MESSAGE_BUS_INITIALIZING = MESSAGE_BUS_INITIALIZING;
|
|
25778
25750
|
exports.MESSAGE_BUS_NOT_INITIALIZED = MESSAGE_BUS_NOT_INITIALIZED;
|
|
25779
|
-
exports.MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = MUTINYNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
25780
25751
|
exports.MessageBus = MessageBus;
|
|
25781
25752
|
exports.MessageBusInitializingError = MessageBusInitializingError;
|
|
25782
25753
|
exports.MessageBusNotInitializedError = MessageBusNotInitializedError;
|
|
@@ -25788,7 +25759,6 @@ exports.P2A = P2A;
|
|
|
25788
25759
|
exports.PaymentRouter = PaymentRouter;
|
|
25789
25760
|
exports.PrevTxUnavailableError = PrevTxUnavailableError;
|
|
25790
25761
|
exports.REGTEST_MIN_BATCH_EXPIRY_SECONDS = REGTEST_MIN_BATCH_EXPIRY_SECONDS;
|
|
25791
|
-
exports.REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = REGTEST_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
25792
25762
|
exports.Ramps = Ramps;
|
|
25793
25763
|
exports.ReadonlyAssetManager = ReadonlyAssetManager;
|
|
25794
25764
|
exports.ReadonlyDescriptorIdentity = ReadonlyDescriptorIdentity;
|
|
@@ -25797,7 +25767,6 @@ exports.ReadonlyWallet = ReadonlyWallet;
|
|
|
25797
25767
|
exports.ReadonlyWalletError = ReadonlyWalletError;
|
|
25798
25768
|
exports.RestDelegateProvider = RestDelegateProvider;
|
|
25799
25769
|
exports.RestEmulatorProvider = RestEmulatorProvider;
|
|
25800
|
-
exports.SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = SIGNET_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
|
|
25801
25770
|
exports.SeedIdentity = SeedIdentity;
|
|
25802
25771
|
exports.SendDeadlineExceededError = SendDeadlineExceededError;
|
|
25803
25772
|
exports.ServiceWorkerReadonlyWallet = ServiceWorkerReadonlyWallet;
|
|
@@ -25876,7 +25845,6 @@ exports.createManagedConnection = createManagedConnection;
|
|
|
25876
25845
|
exports.createdAtToIso = createdAtToIso;
|
|
25877
25846
|
exports.decodeArkContract = decodeArkContract;
|
|
25878
25847
|
exports.defaultBatchExpiryPolicy = defaultBatchExpiryPolicy;
|
|
25879
|
-
exports.defaultCheckpointExitDelayPolicy = defaultCheckpointExitDelayPolicy;
|
|
25880
25848
|
exports.deleteByIndex = deleteByIndex;
|
|
25881
25849
|
exports.deserializeAssets = deserializeAssets;
|
|
25882
25850
|
exports.deserializeExitPackage = deserializeExitPackage;
|
|
@@ -25934,7 +25902,6 @@ exports.provisionRefundKey = provisionRefundKey;
|
|
|
25934
25902
|
exports.registerWalletRestoreHook = registerWalletRestoreHook;
|
|
25935
25903
|
exports.resolveAssetAmount = resolveAssetAmount;
|
|
25936
25904
|
exports.resolveBatchExpiryPolicy = resolveBatchExpiryPolicy;
|
|
25937
|
-
exports.resolveCheckpointExitDelayPolicy = resolveCheckpointExitDelayPolicy;
|
|
25938
25905
|
exports.resolveDescriptorSigner = resolveDescriptorSigner;
|
|
25939
25906
|
exports.resolvePrevTxs = resolvePrevTxs;
|
|
25940
25907
|
exports.resolveSendAmount = resolveSendAmount;
|
|
@@ -25964,5 +25931,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
|
|
|
25964
25931
|
exports.walletFeeSource = walletFeeSource;
|
|
25965
25932
|
exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
|
|
25966
25933
|
exports.withPrevTxs = withPrevTxs;
|
|
25967
|
-
//# sourceMappingURL=chunk-
|
|
25968
|
-
//# sourceMappingURL=chunk-
|
|
25934
|
+
//# sourceMappingURL=chunk-3SM7BMIE.cjs.map
|
|
25935
|
+
//# sourceMappingURL=chunk-3SM7BMIE.cjs.map
|