@arkade-os/sdk 0.4.76 → 0.4.78

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.
Files changed (87) hide show
  1. package/dist/adapters/expo.cjs +5 -5
  2. package/dist/adapters/expo.d.cts +2 -2
  3. package/dist/adapters/expo.d.ts +2 -2
  4. package/dist/adapters/expo.js +3 -3
  5. package/dist/adapters/indexedDB.cjs +3 -5
  6. package/dist/adapters/indexedDB.cjs.map +1 -1
  7. package/dist/adapters/indexedDB.d.cts +1 -1
  8. package/dist/adapters/indexedDB.d.ts +1 -1
  9. package/dist/adapters/indexedDB.js +3 -5
  10. package/dist/adapters/indexedDB.js.map +1 -1
  11. package/dist/{asyncStorageTaskQueue-D7BU-BdP.d.cts → asyncStorageTaskQueue-DiXxP-nQ.d.cts} +2 -2
  12. package/dist/{asyncStorageTaskQueue-DrKbfleJ.d.ts → asyncStorageTaskQueue-YW2t31_o.d.ts} +2 -2
  13. package/dist/{chunk-F6YOCYWU.js → chunk-7KIGEOYT.js} +29 -12
  14. package/dist/chunk-7KIGEOYT.js.map +1 -0
  15. package/dist/{chunk-54W6QBXL.js → chunk-CTFYT24G.js} +3 -3
  16. package/dist/{chunk-54W6QBXL.js.map → chunk-CTFYT24G.js.map} +1 -1
  17. package/dist/{chunk-2KFXM3N5.cjs → chunk-DFWLP3MD.cjs} +17 -17
  18. package/dist/{chunk-2KFXM3N5.cjs.map → chunk-DFWLP3MD.cjs.map} +1 -1
  19. package/dist/{chunk-T327OEMV.cjs → chunk-IAM5IEVT.cjs} +17 -17
  20. package/dist/{chunk-T327OEMV.cjs.map → chunk-IAM5IEVT.cjs.map} +1 -1
  21. package/dist/{chunk-LQM6RHNT.cjs → chunk-KEEZSFLI.cjs} +10 -10
  22. package/dist/{chunk-LQM6RHNT.cjs.map → chunk-KEEZSFLI.cjs.map} +1 -1
  23. package/dist/{chunk-WMHELOHH.js → chunk-LKAASQTL.js} +604 -138
  24. package/dist/chunk-LKAASQTL.js.map +1 -0
  25. package/dist/{chunk-MUBPGYUE.js → chunk-OUHUC26M.js} +4 -4
  26. package/dist/{chunk-MUBPGYUE.js.map → chunk-OUHUC26M.js.map} +1 -1
  27. package/dist/{chunk-O2BIWLZC.js → chunk-P766MOPU.js} +4 -4
  28. package/dist/{chunk-O2BIWLZC.js.map → chunk-P766MOPU.js.map} +1 -1
  29. package/dist/{chunk-P53OHGXY.cjs → chunk-PWIESIO6.cjs} +30 -11
  30. package/dist/chunk-PWIESIO6.cjs.map +1 -0
  31. package/dist/{chunk-LHSVPDFJ.cjs → chunk-VJ7M6WKB.cjs} +1031 -566
  32. package/dist/chunk-VJ7M6WKB.cjs.map +1 -0
  33. package/dist/{chunk-CQNX4BTA.cjs → chunk-Y7BVR6SQ.cjs} +89 -57
  34. package/dist/chunk-Y7BVR6SQ.cjs.map +1 -0
  35. package/dist/{chunk-7UJLIZQU.js → chunk-ZOCJ7E6M.js} +43 -11
  36. package/dist/chunk-ZOCJ7E6M.js.map +1 -0
  37. package/dist/contracts/handlers/index.cjs +9 -9
  38. package/dist/contracts/handlers/index.d.cts +3 -3
  39. package/dist/contracts/handlers/index.d.ts +3 -3
  40. package/dist/contracts/handlers/index.js +2 -2
  41. package/dist/{delegate-CR7msIXK.d.cts → delegate-DaNNUI_B.d.cts} +1 -1
  42. package/dist/{delegate-BAYpqkEx.d.ts → delegate-b2Wiymoj.d.ts} +1 -1
  43. package/dist/{hdWalletCapable-BSF29IjK.d.ts → hdWalletCapable-B2XVTOvu.d.ts} +6 -4
  44. package/dist/{hdWalletCapable-BbZxCUeZ.d.cts → hdWalletCapable-D6PqWpuW.d.cts} +6 -4
  45. package/dist/{index-4NF3srcg.d.cts → index-BlB97fYl.d.cts} +26 -8
  46. package/dist/{index-B_RYn9rg.d.cts → index-CAS4GyN-.d.cts} +36 -9
  47. package/dist/{index-B_RYn9rg.d.ts → index-CAS4GyN-.d.ts} +36 -9
  48. package/dist/{index-Dj2yOhQ2.d.ts → index-CYsKAXog.d.ts} +26 -8
  49. package/dist/index.cjs +307 -303
  50. package/dist/index.d.cts +75 -13
  51. package/dist/index.d.ts +75 -13
  52. package/dist/index.js +4 -4
  53. package/dist/repositories/realm/index.cjs +36 -19
  54. package/dist/repositories/realm/index.cjs.map +1 -1
  55. package/dist/repositories/realm/index.d.cts +6 -3
  56. package/dist/repositories/realm/index.d.ts +6 -3
  57. package/dist/repositories/realm/index.js +22 -5
  58. package/dist/repositories/realm/index.js.map +1 -1
  59. package/dist/repositories/sqlite/index.cjs +42 -18
  60. package/dist/repositories/sqlite/index.cjs.map +1 -1
  61. package/dist/repositories/sqlite/index.d.cts +5 -2
  62. package/dist/repositories/sqlite/index.d.ts +5 -2
  63. package/dist/repositories/sqlite/index.js +29 -5
  64. package/dist/repositories/sqlite/index.js.map +1 -1
  65. package/dist/{taskRunner-TzGUhxP-.d.ts → taskRunner-BJj7xe35.d.ts} +2 -2
  66. package/dist/{taskRunner-DGxde-YU.d.cts → taskRunner-HS2d2oda.d.cts} +2 -2
  67. package/dist/wallet/expo/background.cjs +14 -14
  68. package/dist/wallet/expo/background.d.cts +3 -3
  69. package/dist/wallet/expo/background.d.ts +3 -3
  70. package/dist/wallet/expo/background.js +6 -6
  71. package/dist/wallet/expo/index.cjs +14 -14
  72. package/dist/wallet/expo/index.cjs.map +1 -1
  73. package/dist/wallet/expo/index.d.cts +5 -5
  74. package/dist/wallet/expo/index.d.ts +5 -5
  75. package/dist/wallet/expo/index.js +5 -5
  76. package/dist/wallet/expo/index.js.map +1 -1
  77. package/dist/worker/expo/index.cjs +9 -9
  78. package/dist/worker/expo/index.d.cts +4 -4
  79. package/dist/worker/expo/index.d.ts +4 -4
  80. package/dist/worker/expo/index.js +5 -5
  81. package/package.json +1 -1
  82. package/dist/chunk-7UJLIZQU.js.map +0 -1
  83. package/dist/chunk-CQNX4BTA.cjs.map +0 -1
  84. package/dist/chunk-F6YOCYWU.js.map +0 -1
  85. package/dist/chunk-LHSVPDFJ.cjs.map +0 -1
  86. package/dist/chunk-P53OHGXY.cjs.map +0 -1
  87. package/dist/chunk-WMHELOHH.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkT327OEMV_cjs = require('./chunk-T327OEMV.cjs');
4
- var chunkCQNX4BTA_cjs = require('./chunk-CQNX4BTA.cjs');
5
- var chunkP53OHGXY_cjs = require('./chunk-P53OHGXY.cjs');
3
+ var chunkIAM5IEVT_cjs = require('./chunk-IAM5IEVT.cjs');
4
+ var chunkY7BVR6SQ_cjs = require('./chunk-Y7BVR6SQ.cjs');
5
+ var chunkPWIESIO6_cjs = require('./chunk-PWIESIO6.cjs');
6
6
  var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
7
7
  var utils_js = require('@scure/btc-signer/utils.js');
8
8
  var btcSigner = require('@scure/btc-signer');
@@ -188,7 +188,7 @@ var TreeSignerSession = class _TreeSignerSession {
188
188
  noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
189
189
  const tx = this.graph.find(txid);
190
190
  if (!tx) throw new Error(`missing tx for txid ${txid}`);
191
- const cosigners = chunkP53OHGXY_cjs.getArkPsbtFields(tx.root, 0, chunkP53OHGXY_cjs.CosignerPublicKey).map(
191
+ const cosigners = chunkPWIESIO6_cjs.getArkPsbtFields(tx.root, 0, chunkPWIESIO6_cjs.CosignerPublicKey).map(
192
192
  (c) => base.hex.encode(c.key.subarray(1))
193
193
  // xonly pubkey
194
194
  );
@@ -240,7 +240,7 @@ var TreeSignerSession = class _TreeSignerSession {
240
240
  if (!aggNonce) throw new Error("missing aggregate nonce");
241
241
  const prevoutAmounts = [];
242
242
  const prevoutScripts = [];
243
- const cosigners = chunkP53OHGXY_cjs.getArkPsbtFields(g.root, 0, chunkP53OHGXY_cjs.CosignerPublicKey).map((c) => c.key);
243
+ const cosigners = chunkPWIESIO6_cjs.getArkPsbtFields(g.root, 0, chunkPWIESIO6_cjs.CosignerPublicKey).map((c) => c.key);
244
244
  const { finalKey } = aggregateKeys(cosigners, true, {
245
245
  taprootTweak: this.scriptRoot
246
246
  });
@@ -323,7 +323,7 @@ var SingleKey = class _SingleKey {
323
323
  async sign(tx, inputIndexes) {
324
324
  const txCpy = tx.clone();
325
325
  if (!inputIndexes) {
326
- chunkP53OHGXY_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
326
+ chunkPWIESIO6_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
327
327
  try {
328
328
  if (!txCpy.sign(this.key, ALLOWED_SIGHASH)) {
329
329
  throw new Error("Failed to sign transaction");
@@ -432,7 +432,7 @@ var SeedIdentity = class _SeedIdentity {
432
432
  let network;
433
433
  if ("descriptor" in opts && typeof opts.descriptor === "string") {
434
434
  descriptor = opts.descriptor;
435
- network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
435
+ network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
436
436
  } else {
437
437
  network = opts.isMainnet ?? true ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
438
438
  descriptor = descriptorsScure.scriptExpressions.trBIP32({
@@ -530,7 +530,7 @@ var SeedIdentity = class _SeedIdentity {
530
530
  * `StaticDescriptorProvider` for legacy single-key wallets.
531
531
  */
532
532
  isOurs(descriptor) {
533
- return chunkCQNX4BTA_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
533
+ return chunkY7BVR6SQ_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
534
534
  }
535
535
  /**
536
536
  * Signs each request with the key derived from its descriptor.
@@ -579,7 +579,7 @@ var SeedIdentity = class _SeedIdentity {
579
579
  }
580
580
  // ── internal helpers ─────────────────────────────────────────────
581
581
  derivePrivateKeyForDescriptor(descriptor) {
582
- const network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
582
+ const network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
583
583
  const expansion = descriptorsScure.expand({ descriptor, network });
584
584
  if (expansion.isRanged) {
585
585
  throw new Error(
@@ -604,7 +604,7 @@ var SeedIdentity = class _SeedIdentity {
604
604
  signTxWithKey(tx, key, inputIndexes) {
605
605
  const txCpy = tx.clone();
606
606
  if (!inputIndexes) {
607
- chunkP53OHGXY_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
607
+ chunkPWIESIO6_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
608
608
  try {
609
609
  if (!txCpy.sign(key, ALLOWED_SIGHASH2)) {
610
610
  throw new Error("Failed to sign transaction");
@@ -666,7 +666,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
666
666
  */
667
667
  descriptor;
668
668
  constructor(descriptor) {
669
- const network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
669
+ const network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
670
670
  let expansion;
671
671
  try {
672
672
  expansion = descriptorsScure.expand({ descriptor, network, index: 0 });
@@ -716,7 +716,7 @@ var ReadonlyDescriptorIdentity = class _ReadonlyDescriptorIdentity {
716
716
  * `StaticDescriptorProvider` for legacy single-key wallets.
717
717
  */
718
718
  isOurs(descriptor) {
719
- return chunkCQNX4BTA_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
719
+ return chunkY7BVR6SQ_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
720
720
  }
721
721
  };
722
722
  function serializeSeedOwnedSigningIdentity(identity) {
@@ -878,10 +878,10 @@ var DescriptorIdentity = class {
878
878
  this.base = base;
879
879
  }
880
880
  async xOnlyPublicKey() {
881
- return chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(this.descriptor);
881
+ return chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(this.descriptor);
882
882
  }
883
883
  async compressedPublicKey() {
884
- return chunkCQNX4BTA_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
884
+ return chunkY7BVR6SQ_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
885
885
  }
886
886
  async sign(tx, inputIndexes) {
887
887
  const [signed] = await this.signer.signWithDescriptor([
@@ -949,12 +949,12 @@ var WalletCannotAllocateAddressError = class extends Error {
949
949
  };
950
950
  async function resolveDescriptorSigner(descriptor, identity, provider) {
951
951
  const owner = provider?.isOurs(descriptor) ? provider : isHDCapableIdentity(identity) && identity.isOurs(descriptor) ? identity : void 0;
952
- if (owner && chunkCQNX4BTA_cjs.parseHDDescriptor(descriptor)) {
952
+ if (owner && chunkY7BVR6SQ_cjs.parseHDDescriptor(descriptor)) {
953
953
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
954
954
  }
955
955
  let key;
956
956
  try {
957
- key = chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor);
957
+ key = chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor);
958
958
  } catch {
959
959
  throw new ForeignDescriptorError(descriptor);
960
960
  }
@@ -1329,14 +1329,14 @@ function buildSaltedPreimageMessage(xonly, salt) {
1329
1329
  }
1330
1330
  var PREIMAGE_INDEX = 0;
1331
1331
  function isPerArtifactDescriptor(descriptor) {
1332
- return chunkCQNX4BTA_cjs.parseHDDescriptor(descriptor) !== null;
1332
+ return chunkY7BVR6SQ_cjs.parseHDDescriptor(descriptor) !== null;
1333
1333
  }
1334
1334
  async function provisionDescriptor(wallet) {
1335
1335
  const allocated = isHDAllocationCapable(wallet) ? await wallet.getNextSigningDescriptor() : void 0;
1336
- return allocated ?? await chunkCQNX4BTA_cjs.identityDescriptor(wallet.identity);
1336
+ return allocated ?? await chunkY7BVR6SQ_cjs.identityDescriptor(wallet.identity);
1337
1337
  }
1338
1338
  async function provisionRefundKey(wallet) {
1339
- const descriptor = await chunkCQNX4BTA_cjs.identityDescriptor(wallet.identity);
1339
+ const descriptor = await chunkY7BVR6SQ_cjs.identityDescriptor(wallet.identity);
1340
1340
  const signer = await contractSigner(wallet, descriptor);
1341
1341
  const pubkey = await signer.xOnlyPublicKey();
1342
1342
  const identityPubkey = await wallet.identity.xOnlyPublicKey();
@@ -1346,7 +1346,7 @@ async function provisionRefundKey(wallet) {
1346
1346
  );
1347
1347
  }
1348
1348
  const address = await wallet.getAddress();
1349
- const { pkScript } = chunkP53OHGXY_cjs.ArkAddress.decode(address);
1349
+ const { pkScript } = chunkPWIESIO6_cjs.ArkAddress.decode(address);
1350
1350
  return { descriptor, pubkey, pkScript, address };
1351
1351
  }
1352
1352
  async function provisionClaimSecret(wallet, opts = {}) {
@@ -1356,7 +1356,7 @@ async function provisionClaimSecret(wallet, opts = {}) {
1356
1356
  const descriptor = await provisionDescriptor(wallet);
1357
1357
  const signer = await contractSigner(wallet, descriptor);
1358
1358
  const pubkey = await signer.xOnlyPublicKey();
1359
- const claim = async () => {
1359
+ const claim2 = async () => {
1360
1360
  if (opts.preimage) return { preimage: opts.preimage, mustPersistPreimage: true };
1361
1361
  if (isPerArtifactDescriptor(descriptor)) {
1362
1362
  return {
@@ -1378,7 +1378,7 @@ async function provisionClaimSecret(wallet, opts = {}) {
1378
1378
  return { preimage: randomBytes(32), mustPersistPreimage: true };
1379
1379
  }
1380
1380
  };
1381
- const { preimage, preimageSalt, mustPersistPreimage } = await claim();
1381
+ const { preimage, preimageSalt, mustPersistPreimage } = await claim2();
1382
1382
  return {
1383
1383
  descriptor,
1384
1384
  pubkey,
@@ -1392,7 +1392,7 @@ async function contractSigner(wallet, descriptor) {
1392
1392
  const signer = isHDWalletCapable(wallet) ? await wallet.signerForDescriptor(descriptor) : wallet.identity;
1393
1393
  let expected;
1394
1394
  try {
1395
- expected = chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor);
1395
+ expected = chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor);
1396
1396
  } catch (cause) {
1397
1397
  throw new ForeignDescriptorError(descriptor, { cause });
1398
1398
  }
@@ -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 chunkP53OHGXY_cjs.baseFetch(url, {
1614
+ const response = await chunkPWIESIO6_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: chunkP53OHGXY_cjs.Intent.encodeMessage(intent.message),
1621
+ message: chunkPWIESIO6_cjs.Intent.encodeMessage(intent.message),
1622
1622
  proof: intent.proof
1623
1623
  },
1624
1624
  forfeit_txs: forfeitTxs,
@@ -1638,7 +1638,7 @@ var RestDelegateProvider = class {
1638
1638
  */
1639
1639
  async getDelegateInfo() {
1640
1640
  const url = `${this.url}/v1/delegator/info`;
1641
- const response = await chunkP53OHGXY_cjs.rateGate.runHttp(url, () => chunkP53OHGXY_cjs.baseFetch(url));
1641
+ const response = await chunkPWIESIO6_cjs.rateGate.runHttp(url, () => chunkPWIESIO6_cjs.baseFetch(url));
1642
1642
  if (!response.ok) {
1643
1643
  const errorText2 = await response.text();
1644
1644
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1663,7 +1663,7 @@ var ESPLORA_URL = {
1663
1663
  regtest: "http://localhost:3000/api"
1664
1664
  };
1665
1665
  var EsploraProvider = class {
1666
- constructor(baseUrl = ESPLORA_URL[chunkP53OHGXY_cjs.DEFAULT_NETWORK_NAME], opts) {
1666
+ constructor(baseUrl = ESPLORA_URL[chunkPWIESIO6_cjs.DEFAULT_NETWORK_NAME], opts) {
1667
1667
  this.baseUrl = baseUrl;
1668
1668
  this.pollingInterval = opts?.pollingInterval ?? 15e3;
1669
1669
  this.forcePolling = opts?.forcePolling ?? false;
@@ -1682,14 +1682,14 @@ var EsploraProvider = class {
1682
1682
  */
1683
1683
  addressWatches = /* @__PURE__ */ new Map();
1684
1684
  async getCoins(address) {
1685
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1685
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1686
1686
  if (!response.ok) {
1687
1687
  throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
1688
1688
  }
1689
1689
  return response.json();
1690
1690
  }
1691
1691
  async getFeeRate() {
1692
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1692
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1693
1693
  if (response.status === 404) {
1694
1694
  return void 0;
1695
1695
  }
@@ -1710,7 +1710,7 @@ var EsploraProvider = class {
1710
1710
  }
1711
1711
  }
1712
1712
  async getTxOutspends(txid) {
1713
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1713
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1714
1714
  if (!response.ok) {
1715
1715
  const error = await response.text();
1716
1716
  throw new Error(`Failed to get transaction outspends: ${error}`);
@@ -1718,7 +1718,7 @@ var EsploraProvider = class {
1718
1718
  return response.json();
1719
1719
  }
1720
1720
  async getTransactions(address) {
1721
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1721
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1722
1722
  if (!response.ok) {
1723
1723
  const error = await response.text();
1724
1724
  throw new Error(`Failed to get transactions: ${error}`);
@@ -1731,14 +1731,14 @@ var EsploraProvider = class {
1731
1731
  * usable as a change probe for the polling fallback.
1732
1732
  */
1733
1733
  async getAddressStats(address) {
1734
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1734
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1735
1735
  if (!response.ok) {
1736
1736
  throw new Error(`Failed to get address stats: ${response.statusText}`);
1737
1737
  }
1738
1738
  return response.json();
1739
1739
  }
1740
1740
  async getRawTransaction(txid) {
1741
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1741
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1742
1742
  if (!response.ok) {
1743
1743
  const error = await response.text();
1744
1744
  throw new Error(`Failed to get raw transaction ${txid}: ${error}`);
@@ -1746,7 +1746,7 @@ var EsploraProvider = class {
1746
1746
  return base.hex.decode((await response.text()).trim());
1747
1747
  }
1748
1748
  async getTxStatus(txid) {
1749
- const txresponse = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1749
+ const txresponse = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1750
1750
  if (!txresponse.ok) {
1751
1751
  throw new Error(txresponse.statusText);
1752
1752
  }
@@ -1754,7 +1754,7 @@ var EsploraProvider = class {
1754
1754
  if (!tx.status.confirmed) {
1755
1755
  return { confirmed: false };
1756
1756
  }
1757
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1757
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1758
1758
  if (!response.ok) {
1759
1759
  throw new Error(`Failed to get transaction status: ${response.statusText}`);
1760
1760
  }
@@ -2038,9 +2038,9 @@ var EsploraProvider = class {
2038
2038
  return { subscribers, teardown, started };
2039
2039
  }
2040
2040
  async getChainTip() {
2041
- let tipBlocks = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/blocks`);
2041
+ let tipBlocks = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/blocks`);
2042
2042
  if (tipBlocks.status === 404) {
2043
- tipBlocks = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2043
+ tipBlocks = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2044
2044
  }
2045
2045
  if (!tipBlocks.ok) {
2046
2046
  throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
@@ -2062,7 +2062,7 @@ var EsploraProvider = class {
2062
2062
  };
2063
2063
  }
2064
2064
  async broadcastPackage(parent, child) {
2065
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2065
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2066
2066
  method: "POST",
2067
2067
  headers: {
2068
2068
  "Content-Type": "application/json"
@@ -2078,7 +2078,7 @@ var EsploraProvider = class {
2078
2078
  return result;
2079
2079
  }
2080
2080
  async broadcastTx(tx) {
2081
- const response = await chunkP53OHGXY_cjs.baseFetch(`${this.baseUrl}/tx`, {
2081
+ const response = await chunkPWIESIO6_cjs.baseFetch(`${this.baseUrl}/tx`, {
2082
2082
  method: "POST",
2083
2083
  headers: {
2084
2084
  "Content-Type": "text/plain"
@@ -2261,7 +2261,7 @@ function findP2AOutput(tx) {
2261
2261
  var CHILD_DUST_AMOUNT = 546;
2262
2262
  function buildAnchorChild(params) {
2263
2263
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
2264
- const child = new chunkP53OHGXY_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2264
+ const child = new chunkPWIESIO6_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2265
2265
  child.addInput(findP2AOutput(parent));
2266
2266
  const estimator = TxWeightEstimator.create().addP2AInput();
2267
2267
  for (const _ of fundingCoins) {
@@ -2309,7 +2309,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
2309
2309
  );
2310
2310
  }
2311
2311
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
2312
- const tx = new chunkP53OHGXY_cjs.Transaction({
2312
+ const tx = new chunkPWIESIO6_cjs.Transaction({
2313
2313
  version: 3,
2314
2314
  lockTime: txLocktime
2315
2315
  });
@@ -2385,7 +2385,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
2385
2385
  if (previousScriptKey.length !== 32) {
2386
2386
  throw new Error(`parent output ${childIndex} has invalid script`);
2387
2387
  }
2388
- const cosigners = chunkP53OHGXY_cjs.getArkPsbtFields(child.root, 0, chunkP53OHGXY_cjs.CosignerPublicKey);
2388
+ const cosigners = chunkPWIESIO6_cjs.getArkPsbtFields(child.root, 0, chunkPWIESIO6_cjs.CosignerPublicKey);
2389
2389
  if (cosigners.length === 0) {
2390
2390
  throw ErrMissingCosignersPublicKeys;
2391
2391
  }
@@ -2443,7 +2443,7 @@ var EmulatorPacket = class _EmulatorPacket {
2443
2443
  return new _EmulatorPacket(entries);
2444
2444
  }
2445
2445
  static fromBytes(data) {
2446
- const reader = new chunkT327OEMV_cjs.BufferReader(data);
2446
+ const reader = new chunkIAM5IEVT_cjs.BufferReader(data);
2447
2447
  const entryCount = reader.readCompactSize();
2448
2448
  const entries = [];
2449
2449
  for (let i = 0; i < entryCount; i++) {
@@ -2461,7 +2461,7 @@ var EmulatorPacket = class _EmulatorPacket {
2461
2461
  return _EmulatorPacket.PACKET_TYPE;
2462
2462
  }
2463
2463
  serialize() {
2464
- const writer = new chunkT327OEMV_cjs.BufferWriter();
2464
+ const writer = new chunkIAM5IEVT_cjs.BufferWriter();
2465
2465
  writer.writeCompactSize(this.entries.length);
2466
2466
  for (const entry of this.entries) {
2467
2467
  writer.writeUint16LE(entry.vin);
@@ -2548,7 +2548,7 @@ var Extension = class _Extension {
2548
2548
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
2549
2549
  );
2550
2550
  }
2551
- const reader = new chunkT327OEMV_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2551
+ const reader = new chunkIAM5IEVT_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2552
2552
  const packets = [];
2553
2553
  while (reader.remaining() > 0) {
2554
2554
  const packetType = reader.readByte();
@@ -2622,7 +2622,7 @@ var Extension = class _Extension {
2622
2622
  */
2623
2623
  getAssetPacket() {
2624
2624
  for (const p of this.packets) {
2625
- if (p instanceof chunkT327OEMV_cjs.Packet) {
2625
+ if (p instanceof chunkIAM5IEVT_cjs.Packet) {
2626
2626
  return p;
2627
2627
  }
2628
2628
  }
@@ -2660,8 +2660,8 @@ var Extension = class _Extension {
2660
2660
  };
2661
2661
  function parsePacket(packetType, data) {
2662
2662
  switch (packetType) {
2663
- case chunkT327OEMV_cjs.Packet.PACKET_TYPE:
2664
- return chunkT327OEMV_cjs.Packet.fromBytes(data);
2663
+ case chunkIAM5IEVT_cjs.Packet.PACKET_TYPE:
2664
+ return chunkIAM5IEVT_cjs.Packet.fromBytes(data);
2665
2665
  case EmulatorPacket.PACKET_TYPE:
2666
2666
  return EmulatorPacket.fromBytes(data);
2667
2667
  default:
@@ -2708,22 +2708,22 @@ function buildOpReturnScript(data) {
2708
2708
  }
2709
2709
  return script;
2710
2710
  }
2711
- var ErrOffchainOutputNotFound = (address) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2712
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
2711
+ var ErrOffchainOutputNotFound = (address) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2712
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
2713
2713
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
2714
2714
  );
2715
- var ErrAssetGroupNotFound = (assetId) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2716
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
2715
+ var ErrAssetGroupNotFound = (assetId) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2716
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
2717
2717
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
2718
2718
  );
2719
- var ErrOnchainOutputNotFound = (address) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2720
- var ErrUnvalidatedOffchainOutput = (address) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
2719
+ var ErrOnchainOutputNotFound = (address) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2720
+ var ErrUnvalidatedOffchainOutput = (address) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
2721
2721
  `offchain output ${address} cannot be validated: virtual output tree signing did not run`
2722
2722
  );
2723
- var ErrIntentOutputNotFound = (index, kind) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
2723
+ var ErrIntentOutputNotFound = (index, kind) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
2724
2724
  `${kind} output ${index} of the intent proof is not present in what the server built`
2725
2725
  );
2726
- var ErrUnvalidatedIntentOutput = (index) => new chunkP53OHGXY_cjs.ServerResponseMismatchError(
2726
+ var ErrUnvalidatedIntentOutput = (index) => new chunkPWIESIO6_cjs.ServerResponseMismatchError(
2727
2727
  `offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
2728
2728
  );
2729
2729
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
@@ -2732,7 +2732,7 @@ var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain ou
2732
2732
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
2733
2733
  if (!validatedCommitmentTxid) return;
2734
2734
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
2735
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
2735
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
2736
2736
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
2737
2737
  );
2738
2738
  }
@@ -2742,7 +2742,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
2742
2742
  for (const recipient of recipients) {
2743
2743
  let arkAddress;
2744
2744
  try {
2745
- arkAddress = chunkP53OHGXY_cjs.ArkAddress.decode(recipient.address);
2745
+ arkAddress = chunkPWIESIO6_cjs.ArkAddress.decode(recipient.address);
2746
2746
  } catch {
2747
2747
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2748
2748
  continue;
@@ -2754,7 +2754,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2754
2754
  const usedOnchainOutputs = /* @__PURE__ */ new Set();
2755
2755
  for (const recipient of recipients) {
2756
2756
  try {
2757
- chunkP53OHGXY_cjs.ArkAddress.decode(recipient.address);
2757
+ chunkPWIESIO6_cjs.ArkAddress.decode(recipient.address);
2758
2758
  } catch {
2759
2759
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2760
2760
  continue;
@@ -2763,7 +2763,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2763
2763
  }
2764
2764
  }
2765
2765
  function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
2766
- const proof = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
2766
+ const proof = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
2767
2767
  const onchain = new Set(onchainOutputIndexes);
2768
2768
  const declared = [];
2769
2769
  for (let i = 0; i < proof.outputsLength; i++) {
@@ -3055,7 +3055,7 @@ function assetMintResolver() {
3055
3055
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
3056
3056
  const minted = tx.assets.filter((a) => {
3057
3057
  try {
3058
- return base.hex.encode(chunkT327OEMV_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3058
+ return base.hex.encode(chunkIAM5IEVT_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3059
3059
  } catch {
3060
3060
  return false;
3061
3061
  }
@@ -3131,7 +3131,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3131
3131
  const existing = inputsByAssetId.get(asset.assetId);
3132
3132
  inputsByAssetId.set(asset.assetId, [
3133
3133
  ...existing ?? [],
3134
- chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount)
3134
+ chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount)
3135
3135
  ]);
3136
3136
  }
3137
3137
  }
@@ -3143,7 +3143,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3143
3143
  const existing = outputsByAssetId.get(asset.assetId);
3144
3144
  outputsByAssetId.set(asset.assetId, [
3145
3145
  ...existing ?? [],
3146
- chunkT327OEMV_cjs.AssetOutput.create(outputIndex, asset.amount)
3146
+ chunkIAM5IEVT_cjs.AssetOutput.create(outputIndex, asset.amount)
3147
3147
  ]);
3148
3148
  }
3149
3149
  }
@@ -3154,7 +3154,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3154
3154
  const existing = outputsByAssetId.get(asset.assetId);
3155
3155
  outputsByAssetId.set(asset.assetId, [
3156
3156
  ...existing ?? [],
3157
- chunkT327OEMV_cjs.AssetOutput.create(outputIndex, asset.amount)
3157
+ chunkIAM5IEVT_cjs.AssetOutput.create(outputIndex, asset.amount)
3158
3158
  ]);
3159
3159
  }
3160
3160
  }
@@ -3163,11 +3163,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3163
3163
  for (const assetIdStr of allAssetIds) {
3164
3164
  const inputs = inputsByAssetId.get(assetIdStr);
3165
3165
  const outputs = outputsByAssetId.get(assetIdStr);
3166
- const assetId = chunkT327OEMV_cjs.AssetId.fromString(assetIdStr);
3167
- const group = chunkT327OEMV_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3166
+ const assetId = chunkIAM5IEVT_cjs.AssetId.fromString(assetIdStr);
3167
+ const group = chunkIAM5IEVT_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3168
3168
  groups.push(group);
3169
3169
  }
3170
- return chunkT327OEMV_cjs.Packet.create(groups);
3170
+ return chunkIAM5IEVT_cjs.Packet.create(groups);
3171
3171
  }
3172
3172
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3173
3173
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3204,7 +3204,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
3204
3204
  }
3205
3205
  function toXOnlySignerHex(pubkeyHex) {
3206
3206
  const bytes = base.hex.decode(pubkeyHex);
3207
- if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(bytes, "signer key"));
3207
+ if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(bytes, "signer key"));
3208
3208
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
3209
3209
  }
3210
3210
  function signerSetFromInfo(info) {
@@ -3251,13 +3251,13 @@ var toTimelock = (value) => ({
3251
3251
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
3252
3252
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
3253
3253
  if (policy.requireSeconds && timelock.type === "blocks") {
3254
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3254
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3255
3255
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
3256
3256
  );
3257
3257
  }
3258
3258
  const seconds = toSeconds(timelock);
3259
3259
  if (seconds < policy.minSeconds) {
3260
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3260
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3261
3261
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
3262
3262
  );
3263
3263
  }
@@ -3278,7 +3278,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
3278
3278
  }
3279
3279
  function assertValidBatchExpiry(batchExpiry, policy) {
3280
3280
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
3281
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3281
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3282
3282
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
3283
3283
  );
3284
3284
  }
@@ -3308,21 +3308,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
3308
3308
  function assertValidServerUnrollScript(checkpointTapscript, policy) {
3309
3309
  let script;
3310
3310
  try {
3311
- script = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3311
+ script = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3312
3312
  } catch (e) {
3313
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3313
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3314
3314
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
3315
3315
  );
3316
3316
  }
3317
3317
  if (policy.advertisedForfeitPubkey !== void 0) {
3318
3318
  const { pubkeys } = script.params;
3319
3319
  if (pubkeys.length !== 1) {
3320
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3320
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3321
3321
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
3322
3322
  );
3323
3323
  }
3324
3324
  if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
3325
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3325
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3326
3326
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
3327
3327
  );
3328
3328
  }
@@ -3366,8 +3366,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
3366
3366
  function buildVirtualTx(inputs, outputs) {
3367
3367
  let lockTime = 0n;
3368
3368
  for (const input of inputs) {
3369
- const tapscript = chunkP53OHGXY_cjs.decodeTapscript(chunkP53OHGXY_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3370
- if (chunkP53OHGXY_cjs.CLTVMultisigTapscript.is(tapscript)) {
3369
+ const tapscript = chunkPWIESIO6_cjs.decodeTapscript(chunkPWIESIO6_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3370
+ if (chunkPWIESIO6_cjs.CLTVMultisigTapscript.is(tapscript)) {
3371
3371
  if (lockTime !== 0n) {
3372
3372
  if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
3373
3373
  throw new Error("cannot mix seconds and blocks locktime");
@@ -3378,7 +3378,7 @@ function buildVirtualTx(inputs, outputs) {
3378
3378
  }
3379
3379
  }
3380
3380
  }
3381
- const tx = new chunkP53OHGXY_cjs.Transaction({
3381
+ const tx = new chunkPWIESIO6_cjs.Transaction({
3382
3382
  version: 3,
3383
3383
  lockTime: Number(lockTime)
3384
3384
  });
@@ -3388,12 +3388,12 @@ function buildVirtualTx(inputs, outputs) {
3388
3388
  index: input.vout,
3389
3389
  sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
3390
3390
  witnessUtxo: {
3391
- script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript,
3391
+ script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript,
3392
3392
  amount: BigInt(input.value)
3393
3393
  },
3394
3394
  tapLeafScript: [input.tapLeafScript]
3395
3395
  });
3396
- chunkP53OHGXY_cjs.setArkPsbtField(tx, i, chunkP53OHGXY_cjs.VtxoTaprootTree, input.tapTree);
3396
+ chunkPWIESIO6_cjs.setArkPsbtField(tx, i, chunkPWIESIO6_cjs.VtxoTaprootTree, input.tapTree);
3397
3397
  }
3398
3398
  for (const output of outputs) {
3399
3399
  tx.addOutput(output);
@@ -3402,8 +3402,8 @@ function buildVirtualTx(inputs, outputs) {
3402
3402
  return tx;
3403
3403
  }
3404
3404
  function buildCheckpointTx(vtxo, serverUnrollScript) {
3405
- const collaborativeClosure = chunkP53OHGXY_cjs.decodeTapscript(chunkP53OHGXY_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3406
- const checkpointVtxoScript = new chunkP53OHGXY_cjs.VtxoScript([
3405
+ const collaborativeClosure = chunkPWIESIO6_cjs.decodeTapscript(chunkPWIESIO6_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3406
+ const checkpointVtxoScript = new chunkPWIESIO6_cjs.VtxoScript([
3407
3407
  serverUnrollScript.script,
3408
3408
  collaborativeClosure.script
3409
3409
  ]);
@@ -3479,7 +3479,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
3479
3479
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
3480
3480
  const sig = signature.subarray(0, 64);
3481
3481
  if (!allowedSighashTypes.includes(sighashType)) {
3482
- const sighashName = chunkP53OHGXY_cjs.formatSighash(sighashType);
3482
+ const sighashName = chunkPWIESIO6_cjs.formatSighash(sighashType);
3483
3483
  throw new Error(
3484
3484
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
3485
3485
  );
@@ -3553,7 +3553,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
3553
3553
  }
3554
3554
  function isValidArkAddress(address) {
3555
3555
  try {
3556
- chunkP53OHGXY_cjs.ArkAddress.decode(address);
3556
+ chunkPWIESIO6_cjs.ArkAddress.decode(address);
3557
3557
  return true;
3558
3558
  } catch (e) {
3559
3559
  return false;
@@ -3561,16 +3561,16 @@ function isValidArkAddress(address) {
3561
3561
  }
3562
3562
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
3563
3563
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
3564
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3564
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3565
3565
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
3566
3566
  );
3567
3567
  }
3568
3568
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
3569
3569
  return serverCheckpointTxs.map((encoded, index) => {
3570
- const server = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3570
+ const server = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3571
3571
  const local = byTxid.get(server.id);
3572
3572
  if (!local) {
3573
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3573
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3574
3574
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
3575
3575
  );
3576
3576
  }
@@ -3580,14 +3580,14 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
3580
3580
  }
3581
3581
  function assertSubmittedArkTxid(response, signedArkTx, context) {
3582
3582
  if (response.arkTxid !== signedArkTx.id) {
3583
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3583
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3584
3584
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
3585
3585
  );
3586
3586
  }
3587
3587
  if (response.finalArkTx === void 0) return;
3588
- const finalTxid = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3588
+ const finalTxid = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3589
3589
  if (finalTxid !== signedArkTx.id) {
3590
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3590
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3591
3591
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
3592
3592
  );
3593
3593
  }
@@ -3599,20 +3599,20 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
3599
3599
  `${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
3600
3600
  );
3601
3601
  }
3602
- const script = chunkP53OHGXY_cjs.scriptFromTapLeafScript(leaf);
3602
+ const script = chunkPWIESIO6_cjs.scriptFromTapLeafScript(leaf);
3603
3603
  let leafPubkeys;
3604
3604
  try {
3605
- leafPubkeys = chunkP53OHGXY_cjs.decodeTapscript(script).params.pubkeys.map(
3606
- (key) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(key, "leaf key"))
3605
+ leafPubkeys = chunkPWIESIO6_cjs.decodeTapscript(script).params.pubkeys.map(
3606
+ (key) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(key, "leaf key"))
3607
3607
  );
3608
3608
  } catch (error) {
3609
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3609
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3610
3610
  `${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
3611
3611
  );
3612
3612
  }
3613
3613
  const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
3614
3614
  if (!signer) {
3615
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3615
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3616
3616
  `${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
3617
3617
  );
3618
3618
  }
@@ -3626,7 +3626,7 @@ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, co
3626
3626
  payment_js.tapLeafHash(script)
3627
3627
  );
3628
3628
  } catch (error) {
3629
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3629
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3630
3630
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
3631
3631
  );
3632
3632
  }
@@ -3635,20 +3635,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3635
3635
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
3636
3636
  for (const [index, checkpoint] of checkpoints.entries()) {
3637
3637
  if (checkpoint.inputsLength !== 1) {
3638
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3638
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3639
3639
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
3640
3640
  );
3641
3641
  }
3642
3642
  const spent = checkpoint.getInput(0);
3643
3643
  if (!spent.txid || spent.index === void 0) {
3644
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3644
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3645
3645
  `${context}: checkpoint ${index} has no input outpoint`
3646
3646
  );
3647
3647
  }
3648
3648
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
3649
3649
  const input = byOutpoint.get(outpoint);
3650
3650
  if (!input) {
3651
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3651
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3652
3652
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
3653
3653
  );
3654
3654
  }
@@ -3656,7 +3656,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3656
3656
  (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
3657
3657
  );
3658
3658
  if (!rebuilt) {
3659
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3659
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3660
3660
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
3661
3661
  );
3662
3662
  }
@@ -3682,9 +3682,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3682
3682
  const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
3683
3683
  matched.forEach(({ server }, index) => {
3684
3684
  try {
3685
- chunkP53OHGXY_cjs.assertAllowedSighashTypes(server);
3685
+ chunkPWIESIO6_cjs.assertAllowedSighashTypes(server);
3686
3686
  } catch (error) {
3687
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3687
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3688
3688
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
3689
3689
  );
3690
3690
  }
@@ -3692,14 +3692,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3692
3692
  const verify = options?.verifyServerSignatures;
3693
3693
  if (verify) {
3694
3694
  if (response.finalArkTx === void 0) {
3695
- throw new chunkP53OHGXY_cjs.ServerResponseMismatchError(
3695
+ throw new chunkPWIESIO6_cjs.ServerResponseMismatchError(
3696
3696
  "submitTx: server returned no final ark tx to verify its signatures against"
3697
3697
  );
3698
3698
  }
3699
- const finalArkTx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3699
+ const finalArkTx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3700
3700
  const serverPubkeys = new Set(
3701
3701
  [verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
3702
- (key) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(key, "server key"))
3702
+ (key) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(key, "server key"))
3703
3703
  )
3704
3704
  );
3705
3705
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
@@ -3751,12 +3751,12 @@ function claimWithPreimageIdentity(identity, preimage) {
3751
3751
  return {
3752
3752
  ...identity,
3753
3753
  sign: async (tx, inputIndexes) => {
3754
- const signed = chunkP53OHGXY_cjs.Transaction.fromPSBT(
3754
+ const signed = chunkPWIESIO6_cjs.Transaction.fromPSBT(
3755
3755
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
3756
3756
  );
3757
3757
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
3758
3758
  for (const index of indexes) {
3759
- chunkP53OHGXY_cjs.setArkPsbtField(signed, index, chunkP53OHGXY_cjs.ConditionWitness, [preimage]);
3759
+ chunkPWIESIO6_cjs.setArkPsbtField(signed, index, chunkPWIESIO6_cjs.ConditionWitness, [preimage]);
3760
3760
  }
3761
3761
  return signed;
3762
3762
  }
@@ -3951,7 +3951,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
3951
3951
  };
3952
3952
  }
3953
3953
  function deriveContractTapscripts(contract) {
3954
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
3954
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
3955
3955
  if (!handler) {
3956
3956
  throw new Error(`No handler for contract type '${contract.type}'`);
3957
3957
  }
@@ -4022,7 +4022,7 @@ function getRandomId() {
4022
4022
  }
4023
4023
  function isValidArkAddress2(address) {
4024
4024
  try {
4025
- chunkP53OHGXY_cjs.ArkAddress.decode(address);
4025
+ chunkPWIESIO6_cjs.ArkAddress.decode(address);
4026
4026
  return true;
4027
4027
  } catch (e) {
4028
4028
  return false;
@@ -4050,7 +4050,7 @@ function assertRecipientArkAddress(encoded, address, context) {
4050
4050
  function assertTapTreeDerivesAddress(encoded, tapTree, address) {
4051
4051
  let derived;
4052
4052
  try {
4053
- derived = chunkP53OHGXY_cjs.VtxoScript.decode(tapTree).pkScript;
4053
+ derived = chunkPWIESIO6_cjs.VtxoScript.decode(tapTree).pkScript;
4054
4054
  } catch (e) {
4055
4055
  throw new Error(
4056
4056
  `Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
@@ -4067,7 +4067,7 @@ function validateRecipients(recipients, dustAmount, context) {
4067
4067
  for (const recipient of recipients) {
4068
4068
  let address;
4069
4069
  try {
4070
- address = chunkP53OHGXY_cjs.ArkAddress.decode(recipient.address);
4070
+ address = chunkPWIESIO6_cjs.ArkAddress.decode(recipient.address);
4071
4071
  } catch (e) {
4072
4072
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
4073
4073
  }
@@ -4092,7 +4092,7 @@ function validateRecipients(recipients, dustAmount, context) {
4092
4092
 
4093
4093
  // src/contracts/spendability.ts
4094
4094
  function isContractGenericallySpendable(contract) {
4095
- return chunkCQNX4BTA_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4095
+ return chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4096
4096
  }
4097
4097
  function gatedContracts(contracts) {
4098
4098
  const gated = /* @__PURE__ */ new Map();
@@ -4114,7 +4114,7 @@ function gateExclusion(gated) {
4114
4114
  return (vtxo) => {
4115
4115
  const type = gatedTypeOf(vtxo, gated);
4116
4116
  if (type === void 0) return void 0;
4117
- if (!chunkCQNX4BTA_cjs.contractHandlers.has(type)) {
4117
+ if (!chunkY7BVR6SQ_cjs.contractHandlers.has(type)) {
4118
4118
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
4119
4119
  }
4120
4120
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -4150,7 +4150,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
4150
4150
  continue;
4151
4151
  }
4152
4152
  for (const v of vtxos) {
4153
- if (!chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
4153
+ if (!chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isSwept && !v.isUnrolled) {
4154
4154
  out.add(`${v.txid}:${v.vout}`);
4155
4155
  }
4156
4156
  }
@@ -4185,10 +4185,10 @@ function byValueDescending(vtxos) {
4185
4185
  return [...vtxos].sort((a, b) => b.value - a.value);
4186
4186
  }
4187
4187
  async function fetchTimeHeight(wallet) {
4188
- return chunkP53OHGXY_cjs.resolveTimeHeight(wallet.onchainProvider);
4188
+ return chunkPWIESIO6_cjs.resolveTimeHeight(wallet.onchainProvider);
4189
4189
  }
4190
4190
  function canMigrateBySend(vtxo, now) {
4191
- if (!chunkP53OHGXY_cjs.canSpendOffchain(vtxo, now)) return false;
4191
+ if (!chunkPWIESIO6_cjs.canSpendOffchain(vtxo, now)) return false;
4192
4192
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
4193
4193
  }
4194
4194
  function byExpiryAscending(vtxos, now) {
@@ -4196,7 +4196,7 @@ function byExpiryAscending(vtxos, now) {
4196
4196
  if (vtxo.isSwept) return -Infinity;
4197
4197
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
4198
4198
  if (vtxo.expiresAtHeight !== void 0) {
4199
- return chunkP53OHGXY_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4199
+ return chunkPWIESIO6_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4200
4200
  }
4201
4201
  return Infinity;
4202
4202
  };
@@ -4223,7 +4223,7 @@ function priceSettlementInputs(vtxos, estimator) {
4223
4223
  const payable = [];
4224
4224
  const net = /* @__PURE__ */ new Map();
4225
4225
  for (const vtxo of vtxos) {
4226
- const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo));
4226
+ const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo));
4227
4227
  if (inputFee.satoshis >= vtxo.value) {
4228
4228
  continue;
4229
4229
  }
@@ -4249,7 +4249,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
4249
4249
  }
4250
4250
  const outputFee = estimator.evalOffchainOutput({
4251
4251
  amount: subtotal,
4252
- script: base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(arkAddress).pkScript)
4252
+ script: base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(arkAddress).pkScript)
4253
4253
  });
4254
4254
  return subtotal - BigInt(outputFee.satoshis);
4255
4255
  }
@@ -4267,10 +4267,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
4267
4267
  };
4268
4268
  function getRecoverableVtxos(vtxos, dustAmount, now) {
4269
4269
  return vtxos.filter((vtxo) => {
4270
- if (chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
4270
+ if (chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
4271
4271
  return true;
4272
4272
  }
4273
- if (chunkP53OHGXY_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4273
+ if (chunkPWIESIO6_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4274
4274
  return true;
4275
4275
  }
4276
4276
  return false;
@@ -4302,7 +4302,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
4302
4302
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
4303
4303
  if (vtxo.isUnrolled) return false;
4304
4304
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
4305
- const expiresAt = chunkP53OHGXY_cjs.normalizeVtxo(vtxo).expiresAt;
4305
+ const expiresAt = chunkPWIESIO6_cjs.normalizeVtxo(vtxo).expiresAt;
4306
4306
  if (expiresAt === void 0) return false;
4307
4307
  const now = Date.now();
4308
4308
  const batchExpiry = expiresAt.getTime();
@@ -4313,7 +4313,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
4313
4313
  return vtxos.filter(
4314
4314
  // The leading exclusion covers the `isSubdust` arm too, which is a value
4315
4315
  // property and would otherwise re-admit an exited coin on its own.
4316
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4316
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4317
4317
  );
4318
4318
  }
4319
4319
  function isMigrationCapable(wallet) {
@@ -4677,7 +4677,10 @@ var VtxoManager = class _VtxoManager {
4677
4677
  if (this.settlementConfig === false && thresholdMs === void 0) {
4678
4678
  return [];
4679
4679
  }
4680
- const vtxos = await this.wallet.getSpendableVtxos({ withRecoverable: true });
4680
+ const vtxos = await this.wallet.getSpendableVtxos({
4681
+ withRecoverable: true,
4682
+ genericallySpendableOnly: true
4683
+ });
4681
4684
  let threshold;
4682
4685
  if (thresholdMs !== void 0) {
4683
4686
  threshold = thresholdMs;
@@ -4912,11 +4915,11 @@ var VtxoManager = class _VtxoManager {
4912
4915
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
4913
4916
  );
4914
4917
  }
4915
- const tx = new chunkP53OHGXY_cjs.Transaction();
4918
+ const tx = new chunkPWIESIO6_cjs.Transaction();
4916
4919
  for (const utxo of expiredUtxos) {
4917
- const utxoScript = chunkP53OHGXY_cjs.VtxoScript.decode(utxo.tapTree);
4920
+ const utxoScript = chunkPWIESIO6_cjs.VtxoScript.decode(utxo.tapTree);
4918
4921
  const utxoExitLeaf = utxoScript.leaves.find(
4919
- (leaf) => chunkP53OHGXY_cjs.CSVMultisigTapscript.isScriptValid(chunkP53OHGXY_cjs.scriptFromTapLeafScript(leaf)) === true
4922
+ (leaf) => chunkPWIESIO6_cjs.CSVMultisigTapscript.isScriptValid(chunkPWIESIO6_cjs.scriptFromTapLeafScript(leaf)) === true
4920
4923
  );
4921
4924
  if (!utxoExitLeaf) {
4922
4925
  throw new Error(
@@ -4931,7 +4934,7 @@ var VtxoManager = class _VtxoManager {
4931
4934
  amount: BigInt(utxo.value)
4932
4935
  },
4933
4936
  tapLeafScript: [utxoExitLeaf],
4934
- sequence: chunkP53OHGXY_cjs.getSequence(utxoExitLeaf)
4937
+ sequence: chunkPWIESIO6_cjs.getSequence(utxoExitLeaf)
4935
4938
  });
4936
4939
  }
4937
4940
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -5174,8 +5177,8 @@ var VtxoManager = class _VtxoManager {
5174
5177
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
5175
5178
  if (cls.status === "CURRENT") continue;
5176
5179
  const live = vtxos.filter((v) => !v.isUnrolled);
5177
- const recoverable = live.filter((v) => v.isSwept && !chunkP53OHGXY_cjs.hasTerminalSpend(v));
5178
- const spendable = live.filter((v) => !chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isSwept);
5180
+ const recoverable = live.filter((v) => v.isSwept && !chunkPWIESIO6_cjs.isVtxoSpent(v));
5181
+ const spendable = live.filter((v) => !chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isSwept);
5179
5182
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
5180
5183
  let recoverableCount = 0;
5181
5184
  let recoverableValue = 0;
@@ -5188,7 +5191,7 @@ var VtxoManager = class _VtxoManager {
5188
5191
  awaitingSweepCount = spendable.length;
5189
5192
  awaitingSweepValue = value;
5190
5193
  for (const v of spendable) {
5191
- const exp = chunkP53OHGXY_cjs.toBatchExpiry(v);
5194
+ const exp = chunkPWIESIO6_cjs.toBatchExpiry(v);
5192
5195
  if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
5193
5196
  nextSweepEta = exp;
5194
5197
  }
@@ -5449,7 +5452,7 @@ var VtxoManager = class _VtxoManager {
5449
5452
  /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
5450
5453
  getBoardingTimelock() {
5451
5454
  const wallet = this.getSweepWallet();
5452
- const exitScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(
5455
+ const exitScript = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(
5453
5456
  base.hex.decode(wallet.boardingTapscript.exitScript)
5454
5457
  );
5455
5458
  return exitScript.params.timelock;
@@ -5580,8 +5583,8 @@ var VtxoManager = class _VtxoManager {
5580
5583
  * or doesn't carry the metadata.
5581
5584
  */
5582
5585
  extractSpentOutpoint(error) {
5583
- const ark = chunkP53OHGXY_cjs.maybeArkError(error);
5584
- if (!chunkP53OHGXY_cjs.isArkError(ark, chunkP53OHGXY_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5586
+ const ark = chunkPWIESIO6_cjs.maybeArkError(error);
5587
+ if (!chunkPWIESIO6_cjs.isArkError(ark, chunkPWIESIO6_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5585
5588
  const raw = ark.metadata?.vtxo_outpoint;
5586
5589
  if (typeof raw !== "string") return void 0;
5587
5590
  const [txid, voutStr] = raw.split(":");
@@ -5771,7 +5774,7 @@ var VtxoManager = class _VtxoManager {
5771
5774
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
5772
5775
  break;
5773
5776
  }
5774
- const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(v));
5777
+ const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(v));
5775
5778
  if (inputFee.satoshis >= v.value) {
5776
5779
  continue;
5777
5780
  }
@@ -5791,7 +5794,7 @@ var VtxoManager = class _VtxoManager {
5791
5794
  const arkAddress = await this.wallet.getAddress();
5792
5795
  const outputFee = estimator.evalOffchainOutput({
5793
5796
  amount: totalAmount,
5794
- script: base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(arkAddress).pkScript)
5797
+ script: base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(arkAddress).pkScript)
5795
5798
  });
5796
5799
  totalAmount -= BigInt(outputFee.satoshis);
5797
5800
  if (totalAmount < dustAmount) return;
@@ -5871,7 +5874,7 @@ var ArkNote = class _ArkNote {
5871
5874
  this.value = value;
5872
5875
  this.HRP = HRP;
5873
5876
  const preimageHash = utils_js.sha256(this.preimage);
5874
- this.vtxoScript = new chunkP53OHGXY_cjs.VtxoScript([noteTapscript(preimageHash)]);
5877
+ this.vtxoScript = new chunkPWIESIO6_cjs.VtxoScript([noteTapscript(preimageHash)]);
5875
5878
  const leaf = this.vtxoScript.leaves[0];
5876
5879
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
5877
5880
  this.tapTree = this.vtxoScript.encode();
@@ -5976,8 +5979,8 @@ function noteTapscript(preimageHash) {
5976
5979
  return btcSigner.Script.encode(["SHA256", preimageHash, "EQUAL"]);
5977
5980
  }
5978
5981
  var ArkadeCash = class _ArkadeCash {
5979
- constructor(privateKey, serverPubKey, csvTimelock, hrp = _ArkadeCash.DefaultHRP) {
5980
- this.csvTimelock = csvTimelock;
5982
+ constructor(privateKey, serverPubKey, csvTimelock2, hrp = _ArkadeCash.DefaultHRP) {
5983
+ this.csvTimelock = csvTimelock2;
5981
5984
  this.hrp = hrp;
5982
5985
  if (privateKey.length !== 32) {
5983
5986
  throw new Error(
@@ -6017,8 +6020,8 @@ var ArkadeCash = class _ArkadeCash {
6017
6020
  get publicKey() {
6018
6021
  return this._publicKey.slice();
6019
6022
  }
6020
- static generate(serverPubKey, csvTimelock, hrp) {
6021
- return new _ArkadeCash(utils_js.randomPrivateKeyBytes(), serverPubKey, csvTimelock, hrp);
6023
+ static generate(serverPubKey, csvTimelock2, hrp) {
6024
+ return new _ArkadeCash(utils_js.randomPrivateKeyBytes(), serverPubKey, csvTimelock2, hrp);
6022
6025
  }
6023
6026
  static fromString(encoded) {
6024
6027
  const decoded = base.bech32m.decodeUnsafe(encoded.trim().toLowerCase(), 1023);
@@ -6038,15 +6041,15 @@ var ArkadeCash = class _ArkadeCash {
6038
6041
  const privateKey = data.slice(1, 33);
6039
6042
  const serverPubKey = data.slice(33, 65);
6040
6043
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
6041
- const csvTimelock = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
6042
- return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
6044
+ const csvTimelock2 = chunkPWIESIO6_cjs.sequenceToTimelock(sequence);
6045
+ return new _ArkadeCash(privateKey, serverPubKey, csvTimelock2, decoded.prefix);
6043
6046
  }
6044
6047
  toString() {
6045
6048
  const data = new Uint8Array(_ArkadeCash.PayloadLength);
6046
6049
  data[0] = _ArkadeCash.Version;
6047
6050
  data.set(this._privateKey, 1);
6048
6051
  data.set(this._serverPubKey, 33);
6049
- const sequence = chunkP53OHGXY_cjs.timelockToSequence(this.csvTimelock);
6052
+ const sequence = chunkPWIESIO6_cjs.timelockToSequence(this.csvTimelock);
6050
6053
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
6051
6054
  const words = base.bech32m.toWords(data);
6052
6055
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -6055,7 +6058,7 @@ var ArkadeCash = class _ArkadeCash {
6055
6058
  return SingleKey.fromPrivateKey(this._privateKey);
6056
6059
  }
6057
6060
  get vtxoScript() {
6058
- return new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
6061
+ return new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
6059
6062
  pubKey: this._publicKey,
6060
6063
  serverPubKey: this._serverPubKey,
6061
6064
  csvTimelock: this.csvTimelock
@@ -6316,7 +6319,7 @@ async function captureExitBranch(params) {
6316
6319
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
6317
6320
  if (nonCommitment.length > 0) {
6318
6321
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
6319
- psbtByTxid.set(chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6322
+ psbtByTxid.set(chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6320
6323
  }
6321
6324
  }
6322
6325
  }
@@ -6359,10 +6362,10 @@ var IndexerExitDataSource = class {
6359
6362
  while (hasMore) {
6360
6363
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
6361
6364
  { txid: vtxo.txid, vout: vtxo.vout },
6362
- { pageIndex, pageSize: chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE }
6365
+ { pageIndex, pageSize: chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE }
6363
6366
  );
6364
6367
  chain.push(...page);
6365
- hasMore = meta ? page.length === chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE : false;
6368
+ hasMore = meta ? page.length === chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE : false;
6366
6369
  pageIndex++;
6367
6370
  }
6368
6371
  return chain;
@@ -6374,12 +6377,12 @@ var IndexerExitDataSource = class {
6374
6377
  while (hasMore) {
6375
6378
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
6376
6379
  pageIndex,
6377
- pageSize: chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE
6380
+ pageSize: chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE
6378
6381
  });
6379
6382
  for (const psbt of txs) {
6380
- out.set(chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6383
+ out.set(chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6381
6384
  }
6382
- hasMore = page ? txs.length === chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE : false;
6385
+ hasMore = page ? txs.length === chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE : false;
6383
6386
  pageIndex++;
6384
6387
  }
6385
6388
  return out;
@@ -6400,7 +6403,7 @@ function chainedTxTypeToChainTxType(t) {
6400
6403
  }
6401
6404
  }
6402
6405
  function psbtInputTxids(psbtBase64) {
6403
- const tx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6406
+ const tx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6404
6407
  const ids = [];
6405
6408
  for (let i = 0; i < tx.inputsLength; i++) {
6406
6409
  const txid = tx.getInput(i).txid;
@@ -6759,10 +6762,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
6759
6762
  try {
6760
6763
  info = await arkProvider.getInfo();
6761
6764
  } catch (err) {
6762
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
6765
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
6763
6766
  const snapshot = await loadArkInfoSnapshot(walletRepository);
6764
6767
  if (!snapshot) {
6765
- throw new chunkP53OHGXY_cjs.ProviderUnavailableError(
6768
+ throw new chunkPWIESIO6_cjs.ProviderUnavailableError(
6766
6769
  "Arkade server info is unavailable and no cached snapshot exists",
6767
6770
  { cause: err }
6768
6771
  );
@@ -7169,7 +7172,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
7169
7172
  return [...txids];
7170
7173
  }
7171
7174
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
7172
- const normalized = vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7175
+ const normalized = vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7173
7176
  const localCreatedAt = localCreatedAtByTxid(normalized);
7174
7177
  const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
7175
7178
  const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
@@ -7341,9 +7344,10 @@ var AssetManager = class extends ReadonlyAssetManager {
7341
7344
  }
7342
7345
  const metadata = castMetadata(params.metadata);
7343
7346
  const virtualCoins = await this.wallet.getSpendableVtxos({
7344
- withRecoverable: false
7347
+ withRecoverable: false,
7348
+ genericallySpendableOnly: true
7345
7349
  });
7346
- const controlAssetRef = params.controlAssetId ? chunkT327OEMV_cjs.AssetRef.fromId(chunkT327OEMV_cjs.AssetId.fromString(params.controlAssetId)) : null;
7350
+ const controlAssetRef = params.controlAssetId ? chunkIAM5IEVT_cjs.AssetRef.fromId(chunkIAM5IEVT_cjs.AssetId.fromString(params.controlAssetId)) : null;
7347
7351
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
7348
7352
  let totalBtcSelected = 0n;
7349
7353
  const assetChanges = /* @__PURE__ */ new Map();
@@ -7356,8 +7360,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7356
7360
  }
7357
7361
  }
7358
7362
  const groups = [];
7359
- const issuedAssetOutput = chunkT327OEMV_cjs.AssetOutput.create(0, params.amount);
7360
- const issuedAssetGroup = chunkT327OEMV_cjs.AssetGroup.create(
7363
+ const issuedAssetOutput = chunkIAM5IEVT_cjs.AssetOutput.create(0, params.amount);
7364
+ const issuedAssetGroup = chunkIAM5IEVT_cjs.AssetGroup.create(
7361
7365
  null,
7362
7366
  controlAssetRef,
7363
7367
  [],
@@ -7372,28 +7376,28 @@ var AssetManager = class extends ReadonlyAssetManager {
7372
7376
  for (const [inputIndex, assets] of assetInputs) {
7373
7377
  for (const asset of assets) {
7374
7378
  if (asset.assetId !== assetId) continue;
7375
- changeInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
7379
+ changeInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
7376
7380
  }
7377
7381
  }
7378
7382
  groups.push(
7379
- chunkT327OEMV_cjs.AssetGroup.create(
7380
- chunkT327OEMV_cjs.AssetId.fromString(assetId),
7383
+ chunkIAM5IEVT_cjs.AssetGroup.create(
7384
+ chunkIAM5IEVT_cjs.AssetId.fromString(assetId),
7381
7385
  null,
7382
7386
  changeInputs,
7383
- [chunkT327OEMV_cjs.AssetOutput.create(0, amount)],
7387
+ [chunkIAM5IEVT_cjs.AssetOutput.create(0, amount)],
7384
7388
  []
7385
7389
  )
7386
7390
  );
7387
7391
  }
7388
7392
  }
7389
7393
  const address = await this.wallet.getAddress();
7390
- const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(address);
7394
+ const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(address);
7391
7395
  const outputs = [
7392
7396
  {
7393
7397
  script: outputAddress.pkScript,
7394
7398
  amount: BigInt(totalBtcSelected)
7395
7399
  },
7396
- Extension.create([chunkT327OEMV_cjs.Packet.create(groups)]).txOut()
7400
+ Extension.create([chunkIAM5IEVT_cjs.Packet.create(groups)]).txOut()
7397
7401
  ];
7398
7402
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
7399
7403
  coinSelection.inputs,
@@ -7401,7 +7405,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7401
7405
  );
7402
7406
  return {
7403
7407
  arkTxId: arkTxid,
7404
- assetId: chunkT327OEMV_cjs.AssetId.create(arkTxid, 0).toString()
7408
+ assetId: chunkIAM5IEVT_cjs.AssetId.create(arkTxid, 0).toString()
7405
7409
  };
7406
7410
  }
7407
7411
  /**
@@ -7430,7 +7434,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7430
7434
  throw new Error(`Asset ${params.assetId} is not reissuable`);
7431
7435
  }
7432
7436
  const virtualCoins = await this.wallet.getSpendableVtxos({
7433
- withRecoverable: false
7437
+ withRecoverable: false,
7438
+ genericallySpendableOnly: true
7434
7439
  });
7435
7440
  const assetChanges = /* @__PURE__ */ new Map();
7436
7441
  const { selected: controlCoins } = selectCoinsWithAsset(virtualCoins, controlAssetId, 1n);
@@ -7473,16 +7478,16 @@ var AssetManager = class extends ReadonlyAssetManager {
7473
7478
  for (const [inputIndex, assets] of assetInputs) {
7474
7479
  for (const asset of assets) {
7475
7480
  if (asset.assetId !== params.assetId) continue;
7476
- reissueInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
7481
+ reissueInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
7477
7482
  }
7478
7483
  }
7479
7484
  const totalAssetAmount = assetToReissueAmount + params.amount;
7480
- const reissueAssetIdObj = chunkT327OEMV_cjs.AssetId.fromString(params.assetId);
7481
- const reissueAssetGroup = chunkT327OEMV_cjs.AssetGroup.create(
7485
+ const reissueAssetIdObj = chunkIAM5IEVT_cjs.AssetId.fromString(params.assetId);
7486
+ const reissueAssetGroup = chunkIAM5IEVT_cjs.AssetGroup.create(
7482
7487
  reissueAssetIdObj,
7483
7488
  null,
7484
7489
  reissueInputs,
7485
- [chunkT327OEMV_cjs.AssetOutput.create(0, totalAssetAmount)],
7490
+ [chunkIAM5IEVT_cjs.AssetOutput.create(0, totalAssetAmount)],
7486
7491
  []
7487
7492
  );
7488
7493
  const groups = [reissueAssetGroup];
@@ -7491,27 +7496,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7491
7496
  for (const [inputIndex, assets] of assetInputs) {
7492
7497
  for (const asset of assets) {
7493
7498
  if (asset.assetId !== assetId) continue;
7494
- changeInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
7499
+ changeInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
7495
7500
  }
7496
7501
  }
7497
7502
  groups.push(
7498
- chunkT327OEMV_cjs.AssetGroup.create(
7499
- chunkT327OEMV_cjs.AssetId.fromString(assetId),
7503
+ chunkIAM5IEVT_cjs.AssetGroup.create(
7504
+ chunkIAM5IEVT_cjs.AssetId.fromString(assetId),
7500
7505
  null,
7501
7506
  changeInputs,
7502
- [chunkT327OEMV_cjs.AssetOutput.create(0, amount)],
7507
+ [chunkIAM5IEVT_cjs.AssetOutput.create(0, amount)],
7503
7508
  []
7504
7509
  )
7505
7510
  );
7506
7511
  }
7507
7512
  const address = await this.wallet.getAddress();
7508
- const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(address);
7513
+ const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(address);
7509
7514
  const outputs = [
7510
7515
  {
7511
7516
  script: outputAddress.pkScript,
7512
7517
  amount: BigInt(totalBtcSelected)
7513
7518
  },
7514
- Extension.create([chunkT327OEMV_cjs.Packet.create(groups)]).txOut()
7519
+ Extension.create([chunkIAM5IEVT_cjs.Packet.create(groups)]).txOut()
7515
7520
  ];
7516
7521
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7517
7522
  return arkTxid;
@@ -7536,7 +7541,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7536
7541
  throw new Error(`Burn amount must be greater than 0, got ${params.amount}`);
7537
7542
  }
7538
7543
  const virtualCoins = await this.wallet.getSpendableVtxos({
7539
- withRecoverable: false
7544
+ withRecoverable: false,
7545
+ genericallySpendableOnly: true
7540
7546
  });
7541
7547
  const assetChanges = /* @__PURE__ */ new Map();
7542
7548
  const { selected: assetCoins } = selectCoinsWithAsset(
@@ -7578,27 +7584,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7578
7584
  for (const [inputIndex, assets] of assetInputs) {
7579
7585
  for (const asset of assets) {
7580
7586
  if (asset.assetId !== assetId) continue;
7581
- changeInputs.push(chunkT327OEMV_cjs.AssetInput.create(inputIndex, asset.amount));
7587
+ changeInputs.push(chunkIAM5IEVT_cjs.AssetInput.create(inputIndex, asset.amount));
7582
7588
  }
7583
7589
  }
7584
7590
  groups.push(
7585
- chunkT327OEMV_cjs.AssetGroup.create(
7586
- chunkT327OEMV_cjs.AssetId.fromString(assetId),
7591
+ chunkIAM5IEVT_cjs.AssetGroup.create(
7592
+ chunkIAM5IEVT_cjs.AssetId.fromString(assetId),
7587
7593
  null,
7588
7594
  changeInputs,
7589
- amount > 0n ? [chunkT327OEMV_cjs.AssetOutput.create(0, amount)] : [],
7595
+ amount > 0n ? [chunkIAM5IEVT_cjs.AssetOutput.create(0, amount)] : [],
7590
7596
  []
7591
7597
  )
7592
7598
  );
7593
7599
  }
7594
7600
  const address = await this.wallet.getAddress();
7595
- const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(address);
7601
+ const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(address);
7596
7602
  const outputs = [
7597
7603
  {
7598
7604
  script: outputAddress.pkScript,
7599
7605
  amount: BigInt(totalBtcSelected)
7600
7606
  },
7601
- Extension.create([chunkT327OEMV_cjs.Packet.create(groups)]).txOut()
7607
+ Extension.create([chunkIAM5IEVT_cjs.Packet.create(groups)]).txOut()
7602
7608
  ];
7603
7609
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7604
7610
  return arkTxid;
@@ -7623,7 +7629,7 @@ function castMetadata(metadata) {
7623
7629
  } else {
7624
7630
  throw new Error("Invalid metadata value type");
7625
7631
  }
7626
- md.push(chunkT327OEMV_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7632
+ md.push(chunkIAM5IEVT_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7627
7633
  }
7628
7634
  return md;
7629
7635
  }
@@ -7644,10 +7650,10 @@ var DelegateManagerImpl = class {
7644
7650
  if (vtxos.length === 0) {
7645
7651
  return { delegated: [], failed: [] };
7646
7652
  }
7647
- const destinationScript = chunkP53OHGXY_cjs.ArkAddress.decode(destination).pkScript;
7653
+ const destinationScript = chunkPWIESIO6_cjs.ArkAddress.decode(destination).pkScript;
7648
7654
  const arkInfo = await this.arkInfoProvider.getInfo();
7649
7655
  const delegateInfo = await this.delegateProvider.getDelegateInfo();
7650
- const eligible = vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo).filter(
7656
+ const eligible = vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo).filter(
7651
7657
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
7652
7658
  );
7653
7659
  if (eligible.length === 0) {
@@ -7676,11 +7682,11 @@ var DelegateManagerImpl = class {
7676
7682
  const groupByExpiry = /* @__PURE__ */ new Map();
7677
7683
  let recoverableVtxos = [];
7678
7684
  for (const vtxo of eligible) {
7679
- if (chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
7685
+ if (chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
7680
7686
  recoverableVtxos.push(vtxo);
7681
7687
  continue;
7682
7688
  }
7683
- const expiry = chunkP53OHGXY_cjs.toBatchExpiry(vtxo);
7689
+ const expiry = chunkPWIESIO6_cjs.toBatchExpiry(vtxo);
7684
7690
  if (!expiry) continue;
7685
7691
  const dayKey = getDayTimestamp(expiry);
7686
7692
  groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
@@ -7745,7 +7751,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7745
7751
  }
7746
7752
  if (!delegateAt) {
7747
7753
  const now = { timestamp: /* @__PURE__ */ new Date() };
7748
- const expiryTimestamp = vtxos.filter((coin) => !chunkP53OHGXY_cjs.canRecoverOnchain(coin, now) && chunkP53OHGXY_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkP53OHGXY_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
7754
+ const expiryTimestamp = vtxos.filter((coin) => !chunkPWIESIO6_cjs.canRecoverOnchain(coin, now) && chunkPWIESIO6_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkPWIESIO6_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
7749
7755
  if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
7750
7756
  delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7751
7757
  } else {
@@ -7769,7 +7775,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7769
7775
  let amount = 0n;
7770
7776
  for (const coin of vtxos) {
7771
7777
  const inputFee = estimator.evalOffchainInput({
7772
- ...chunkP53OHGXY_cjs.toOffchainInputFeeParams(coin),
7778
+ ...chunkPWIESIO6_cjs.toOffchainInputFeeParams(coin),
7773
7779
  type: "vtxo"
7774
7780
  });
7775
7781
  if (inputFee.value >= coin.value) {
@@ -7783,7 +7789,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7783
7789
  const delegateFee = BigInt(Number(fee));
7784
7790
  if (delegateFee > 0n) {
7785
7791
  outputs.push({
7786
- script: chunkP53OHGXY_cjs.ArkAddress.decode(delegateAddress).pkScript,
7792
+ script: chunkPWIESIO6_cjs.ArkAddress.decode(delegateAddress).pkScript,
7787
7793
  amount: delegateFee
7788
7794
  });
7789
7795
  }
@@ -7816,10 +7822,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7816
7822
  destinationScript
7817
7823
  );
7818
7824
  const forfeitOutputScript = btcSigner.OutScript.encode(
7819
- btcSigner.Address(chunkP53OHGXY_cjs.getNetwork(network)).decode(forfeitAddress)
7825
+ btcSigner.Address(chunkPWIESIO6_cjs.getNetwork(network)).decode(forfeitAddress)
7820
7826
  );
7821
7827
  const forfeits = await Promise.all(
7822
- vtxos.filter((v) => !chunkP53OHGXY_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7828
+ vtxos.filter((v) => chunkPWIESIO6_cjs.requiresForfeit(v)).map(async (coin) => {
7823
7829
  const forfeit = await makeDelegateForfeitTx(
7824
7830
  coin,
7825
7831
  dust,
@@ -7844,7 +7850,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
7844
7850
  index: input.vout,
7845
7851
  witnessUtxo: {
7846
7852
  amount: BigInt(input.value),
7847
- script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
7853
+ script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
7848
7854
  },
7849
7855
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
7850
7856
  tapLeafScript: [delegateTapLeaf]
@@ -7902,7 +7908,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
7902
7908
  expire_at: 0,
7903
7909
  cosigners_public_keys: cosignerPubKeys
7904
7910
  };
7905
- const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, outputs);
7911
+ const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, outputs);
7906
7912
  const signedProof = await identity.sign(proof);
7907
7913
  return {
7908
7914
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -7928,10 +7934,10 @@ function getDayTimestamp(timestamp) {
7928
7934
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
7929
7935
  if (!vtxo.tapTree) return void 0;
7930
7936
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
7931
- const vtxoScript = chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree);
7937
+ const vtxoScript = chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree);
7932
7938
  return vtxoScript.leaves.find((tapLeaf) => {
7933
- const arkTapscript = chunkP53OHGXY_cjs.decodeTapscript(chunkP53OHGXY_cjs.scriptFromTapLeafScript(tapLeaf));
7934
- if (!chunkP53OHGXY_cjs.MultisigTapscript.is(arkTapscript)) return false;
7939
+ const arkTapscript = chunkPWIESIO6_cjs.decodeTapscript(chunkPWIESIO6_cjs.scriptFromTapLeafScript(tapLeaf));
7940
+ if (!chunkPWIESIO6_cjs.MultisigTapscript.is(arkTapscript)) return false;
7935
7941
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
7936
7942
  });
7937
7943
  }
@@ -8212,7 +8218,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
8212
8218
  };
8213
8219
  }
8214
8220
  function scriptFromArkAddress(address) {
8215
- return base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(address).pkScript);
8221
+ return base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(address).pkScript);
8216
8222
  }
8217
8223
 
8218
8224
  // src/repositories/indexedDB/schema.ts
@@ -8225,7 +8231,7 @@ var STORE_INTENTS = "intents";
8225
8231
  var STORE_VIRTUAL_TXS = "virtualTxs";
8226
8232
  var STORE_VTXO_BRANCHES = "vtxoBranches";
8227
8233
  var LEGACY_STORE_CONTRACT_COLLECTIONS = "contractsCollections";
8228
- var DB_VERSION = 3;
8234
+ var DB_VERSION = 4;
8229
8235
  var INTENT_DB_VERSION = 5;
8230
8236
  function initDatabase(db, oldVersion, transaction) {
8231
8237
  if (!db.objectStoreNames.contains(STORE_VTXOS)) {
@@ -8288,6 +8294,7 @@ function initDatabase(db, oldVersion, transaction) {
8288
8294
  unique: false
8289
8295
  });
8290
8296
  }
8297
+ vtxosStore.createIndex("scriptUnspent", ["script", "unspent"], { unique: false });
8291
8298
  }
8292
8299
  if (!db.objectStoreNames.contains(STORE_UTXOS)) {
8293
8300
  const utxosStore = db.createObjectStore(STORE_UTXOS, {
@@ -8370,14 +8377,18 @@ function initDatabase(db, oldVersion, transaction) {
8370
8377
  keyPath: "key"
8371
8378
  });
8372
8379
  }
8373
- if (oldVersion >= 1 && oldVersion < 3 && transaction) {
8380
+ if (oldVersion >= 1 && oldVersion < 4 && transaction) {
8374
8381
  const vtxosStore = transaction.objectStore(STORE_VTXOS);
8375
8382
  if (!vtxosStore.indexNames.contains("script")) {
8376
8383
  vtxosStore.createIndex("script", "script", { unique: false });
8377
8384
  }
8378
- backfillVtxoScripts(transaction);
8385
+ if (!vtxosStore.indexNames.contains("scriptUnspent")) {
8386
+ vtxosStore.createIndex("scriptUnspent", ["script", "unspent"], { unique: false });
8387
+ }
8388
+ backfillVtxoIndexFields(transaction);
8379
8389
  }
8380
8390
  }
8391
+ var unspentFlag = (vtxo) => chunkPWIESIO6_cjs.isVtxoSpent(vtxo) ? {} : { unspent: 1 };
8381
8392
  function initDatabaseWithIntents(db, oldVersion, transaction) {
8382
8393
  initDatabase(db, oldVersion, transaction);
8383
8394
  if (!db.objectStoreNames.contains(STORE_INTENTS)) {
@@ -8427,19 +8438,28 @@ function dedupeIntentIds(store, onComplete) {
8427
8438
  cursor.continue();
8428
8439
  };
8429
8440
  }
8430
- function backfillVtxoScripts(transaction) {
8441
+ function backfillVtxoIndexFields(transaction) {
8431
8442
  const store = transaction.objectStore(STORE_VTXOS);
8432
- const cursorRequest = store.openCursor();
8433
- cursorRequest.onsuccess = () => {
8434
- const cursor = cursorRequest.result;
8435
- if (!cursor) return;
8436
- const value = cursor.value;
8437
- if (!value.script) {
8438
- value.script = scriptFromArkAddress(value.address);
8439
- cursor.update(value);
8440
- }
8441
- cursor.continue();
8443
+ const pageSize = 1e3;
8444
+ const readPage = (after) => {
8445
+ const request = store.getAll(after && IDBKeyRange.lowerBound(after, true), pageSize);
8446
+ request.onsuccess = () => {
8447
+ const rows = request.result;
8448
+ for (const value of rows) {
8449
+ const next = {
8450
+ ...value,
8451
+ script: value.script || scriptFromArkAddress(value.address),
8452
+ ...unspentFlag(value)
8453
+ };
8454
+ if (next.script !== value.script || next.unspent !== value.unspent) {
8455
+ store.put(next);
8456
+ }
8457
+ }
8458
+ const last = rows.at(-1);
8459
+ if (rows.length === pageSize && last) readPage([last.address, last.txid, last.vout]);
8460
+ };
8442
8461
  };
8462
+ readPage();
8443
8463
  }
8444
8464
 
8445
8465
  // src/worker/browser/utils.ts
@@ -8705,9 +8725,10 @@ function validateVtxosForScript(vtxos, script, context) {
8705
8725
  `${context}: refusing to persist ${mismatches.length} VTXO(s) whose script does not match ${script}: ${detail}`
8706
8726
  );
8707
8727
  }
8708
- async function getVtxosForContract(repo, contract) {
8709
- const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8710
- return vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
8728
+ async function getVtxosForContract(repo, contract, options) {
8729
+ const vtxos = options?.unspentOnly && repo.getVtxosForScripts ? await repo.getVtxosForScripts([contract.script], options) : repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8730
+ const normalized = vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
8731
+ return options?.unspentOnly ? normalized.filter((vtxo) => !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) : normalized;
8711
8732
  }
8712
8733
  function hasRecordedSpend(vtxo) {
8713
8734
  return vtxo.isSpent === true && (!!vtxo.spentBy || !!vtxo.arkTxId || !!vtxo.settledBy);
@@ -8798,15 +8819,21 @@ var InMemoryWalletRepository = class {
8798
8819
  this.vtxosByAddress.delete(address);
8799
8820
  }
8800
8821
  async getVtxosForScript(script) {
8801
- const allMatches = [];
8822
+ return this.getVtxosForScripts([script]);
8823
+ }
8824
+ async getVtxosForScripts(scripts, options) {
8825
+ if (scripts.length === 0) return [];
8826
+ const selected = new Set(scripts);
8827
+ const byOutpoint = /* @__PURE__ */ new Map();
8802
8828
  for (const bucket of this.vtxosByAddress.values()) {
8803
8829
  for (const vtxo of bucket) {
8804
- if (isVtxoForScript(vtxo, script)) {
8805
- allMatches.push(vtxo);
8830
+ if (vtxo.script && selected.has(vtxo.script)) {
8831
+ byOutpoint.set(`${vtxo.script}:${vtxo.txid}:${vtxo.vout}`, vtxo);
8806
8832
  }
8807
8833
  }
8808
8834
  }
8809
- return mergeByKey([], allMatches, (item) => `${item.txid}:${item.vout}`);
8835
+ const rows = [...byOutpoint.values()];
8836
+ return options?.unspentOnly ? rows.filter((vtxo) => !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) : rows;
8810
8837
  }
8811
8838
  async saveVtxosForScript(key, vtxos) {
8812
8839
  if (!key.address) {
@@ -8908,7 +8935,7 @@ function decodeArkContract(encoded) {
8908
8935
  }
8909
8936
  function contractFromArkContract(encoded, options = {}) {
8910
8937
  const parsed = decodeArkContract(encoded);
8911
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(parsed.type);
8938
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(parsed.type);
8912
8939
  if (!handler) {
8913
8940
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
8914
8941
  }
@@ -8922,9 +8949,9 @@ function contractFromArkContract(encoded, options = {}) {
8922
8949
  metadata: options.metadata
8923
8950
  };
8924
8951
  }
8925
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkP53OHGXY_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8952
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkPWIESIO6_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8926
8953
  const parsed = decodeArkContract(encoded);
8927
- const handler = chunkCQNX4BTA_cjs.contractHandlers.getOrThrow(parsed.type);
8954
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.getOrThrow(parsed.type);
8928
8955
  const params = parsed.data;
8929
8956
  const vtxoScript = handler.createScript(params);
8930
8957
  return {
@@ -9230,9 +9257,9 @@ var ContractWatcher = class {
9230
9257
  this.connectionState = "connected";
9231
9258
  this.reconnectAttempts = 0;
9232
9259
  this.listenLoop().catch((e) => {
9233
- if (chunkP53OHGXY_cjs.isEventSourceError(e)) {
9260
+ if (chunkPWIESIO6_cjs.isEventSourceError(e)) {
9234
9261
  console.debug("ContractWatcher subscription disconnected; reconnecting");
9235
- } else if (!chunkP53OHGXY_cjs.isEventSourceUnavailableError(e)) {
9262
+ } else if (!chunkPWIESIO6_cjs.isEventSourceUnavailableError(e)) {
9236
9263
  console.error(e);
9237
9264
  }
9238
9265
  this.connectionState = "disconnected";
@@ -9244,7 +9271,7 @@ var ContractWatcher = class {
9244
9271
  this.scheduleReconnect();
9245
9272
  });
9246
9273
  } catch (error) {
9247
- if (!chunkP53OHGXY_cjs.isEventSourceUnavailableError(error)) {
9274
+ if (!chunkPWIESIO6_cjs.isEventSourceUnavailableError(error)) {
9248
9275
  console.error("ContractWatcher connection failed:", error);
9249
9276
  }
9250
9277
  this.connectionState = "disconnected";
@@ -9270,7 +9297,7 @@ var ContractWatcher = class {
9270
9297
  * slower; what it loses is push latency.
9271
9298
  */
9272
9299
  reportEventSourceUnavailable(error) {
9273
- if (!chunkP53OHGXY_cjs.isEventSourceUnavailableError(error)) return false;
9300
+ if (!chunkPWIESIO6_cjs.isEventSourceUnavailableError(error)) return false;
9274
9301
  if (!this.eventSourceReported) {
9275
9302
  this.eventSourceReported = true;
9276
9303
  console.warn(
@@ -9342,7 +9369,7 @@ var ContractWatcher = class {
9342
9369
  const now = Date.now();
9343
9370
  let current;
9344
9371
  try {
9345
- current = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9372
+ current = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9346
9373
  spendableOnly: true
9347
9374
  });
9348
9375
  } catch (error) {
@@ -9551,14 +9578,14 @@ var ContractWatcher = class {
9551
9578
  const timestamp = Date.now();
9552
9579
  if (update.newVtxos?.length) {
9553
9580
  this.processSubscriptionVtxos(
9554
- update.newVtxos.map(chunkP53OHGXY_cjs.normalizeVtxo),
9581
+ update.newVtxos.map(chunkPWIESIO6_cjs.normalizeVtxo),
9555
9582
  "vtxo_received",
9556
9583
  timestamp
9557
9584
  );
9558
9585
  }
9559
9586
  if (update.spentVtxos?.length) {
9560
9587
  this.processSubscriptionVtxos(
9561
- update.spentVtxos.map(chunkP53OHGXY_cjs.normalizeVtxo),
9588
+ update.spentVtxos.map(chunkPWIESIO6_cjs.normalizeVtxo),
9562
9589
  "vtxo_spent",
9563
9590
  timestamp
9564
9591
  );
@@ -9586,8 +9613,8 @@ var ContractWatcher = class {
9586
9613
  continue;
9587
9614
  }
9588
9615
  if (target === byWatchedScript && eventType === "vtxo_received") {
9589
- const n = chunkP53OHGXY_cjs.normalizeVtxo(vtxo);
9590
- if (chunkP53OHGXY_cjs.hasTerminalSpend(n) || n.isSwept || chunkP53OHGXY_cjs.isPastExpiry(n, now)) continue;
9616
+ const n = chunkPWIESIO6_cjs.normalizeVtxo(vtxo);
9617
+ if (chunkPWIESIO6_cjs.isVtxoSpent(n) || n.isSwept || chunkPWIESIO6_cjs.isPastExpiry(n, now)) continue;
9591
9618
  }
9592
9619
  let bucket = target.get(vtxo.script);
9593
9620
  if (!bucket) {
@@ -9686,7 +9713,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
9686
9713
  (s) => !isTerminalIntentState(s)
9687
9714
  );
9688
9715
  function isConsumed(vtxo) {
9689
- return vtxo !== void 0 && chunkP53OHGXY_cjs.hasTerminalSpend(vtxo);
9716
+ return vtxo !== void 0 && chunkPWIESIO6_cjs.isVtxoSpent(vtxo);
9690
9717
  }
9691
9718
  async function classifyIntent(intent, vtxosByOutpoint, now) {
9692
9719
  if (isTerminalIntentState(intent.state)) return void 0;
@@ -9729,7 +9756,7 @@ async function reconcileIntents(deps) {
9729
9756
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
9730
9757
  if (outpoints.length > 0) {
9731
9758
  try {
9732
- const { vtxos } = await chunkP53OHGXY_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9759
+ const { vtxos } = await chunkPWIESIO6_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9733
9760
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
9734
9761
  } catch (e) {
9735
9762
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -9786,7 +9813,7 @@ function annotatableIn(scriptToContract, vtxos, memo) {
9786
9813
  if (!contract) continue;
9787
9814
  try {
9788
9815
  const key = `${contract.type}\0${script}\0${JSON.stringify(contract.params)}`;
9789
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
9816
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
9790
9817
  const hit = memo?.get(script);
9791
9818
  let tapscripts;
9792
9819
  if (hit && hit.key === key && hit.handler === handler) {
@@ -9941,7 +9968,7 @@ var ContractManager = class _ContractManager {
9941
9968
  try {
9942
9969
  await this.scheduleLookAheadDrain();
9943
9970
  } catch (err) {
9944
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
9971
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
9945
9972
  this.lookAheadRefillOwed = true;
9946
9973
  this.markSyncDegraded(err);
9947
9974
  }
@@ -9949,7 +9976,7 @@ var ContractManager = class _ContractManager {
9949
9976
  await this.reconcileWatched();
9950
9977
  this.markSyncOnline();
9951
9978
  } catch (err) {
9952
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
9979
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
9953
9980
  this.markSyncDegraded(err);
9954
9981
  }
9955
9982
  this.initialized = true;
@@ -10081,7 +10108,7 @@ var ContractManager = class _ContractManager {
10081
10108
  const from = Math.max(0, watermark - lookAhead.size);
10082
10109
  const to = watermark + lookAhead.size;
10083
10110
  const deps = lookAhead.candidateDeps();
10084
- const handlers = chunkCQNX4BTA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCQNX4BTA_cjs.contractHandlers.get(t)).filter(hasCandidates);
10111
+ const handlers = chunkY7BVR6SQ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkY7BVR6SQ_cjs.contractHandlers.get(t)).filter(hasCandidates);
10085
10112
  const band = /* @__PURE__ */ new Map();
10086
10113
  for (let index = from; index <= to; index++) {
10087
10114
  const descriptor = lookAhead.materialize(index);
@@ -10092,7 +10119,7 @@ var ContractManager = class _ContractManager {
10092
10119
  index,
10093
10120
  params: {
10094
10121
  ...candidate,
10095
- ...chunkCQNX4BTA_cjs.speculativeReceiveMetadata(descriptor)
10122
+ ...chunkY7BVR6SQ_cjs.speculativeReceiveMetadata(descriptor)
10096
10123
  }
10097
10124
  });
10098
10125
  }
@@ -10154,7 +10181,7 @@ var ContractManager = class _ContractManager {
10154
10181
  });
10155
10182
  for (const entry of pending) entry.catchUpPending = false;
10156
10183
  } catch (err) {
10157
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
10184
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
10158
10185
  this.markSyncDegraded(err);
10159
10186
  }
10160
10187
  }
@@ -10204,7 +10231,7 @@ var ContractManager = class _ContractManager {
10204
10231
  await this.fetchContractVxosFromIndexer([contract]);
10205
10232
  this.markSyncOnline();
10206
10233
  } catch (err) {
10207
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
10234
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
10208
10235
  this.markSyncDegraded(err);
10209
10236
  }
10210
10237
  await this.watcher.addContract(contract);
@@ -10238,7 +10265,7 @@ var ContractManager = class _ContractManager {
10238
10265
  await this.fetchContractVxosFromIndexer(fresh);
10239
10266
  this.markSyncOnline();
10240
10267
  } catch (err) {
10241
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
10268
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
10242
10269
  this.markSyncDegraded(err);
10243
10270
  }
10244
10271
  for (const contract of fresh) await this.watcher.addContract(contract);
@@ -10276,7 +10303,7 @@ var ContractManager = class _ContractManager {
10276
10303
  return result;
10277
10304
  }
10278
10305
  async upsertContractRow(params) {
10279
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(params.type);
10306
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(params.type);
10280
10307
  if (!handler) {
10281
10308
  throw new Error(`No handler registered for contract type '${params.type}'`);
10282
10309
  }
@@ -10376,7 +10403,7 @@ var ContractManager = class _ContractManager {
10376
10403
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
10377
10404
  );
10378
10405
  }
10379
- const registered = chunkCQNX4BTA_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkCQNX4BTA_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10406
+ const registered = chunkY7BVR6SQ_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkY7BVR6SQ_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10380
10407
  const discoverables = [
10381
10408
  ...registered.filter((h) => h.type === "boarding"),
10382
10409
  ...registered.filter((h) => h.type !== "boarding")
@@ -10505,23 +10532,40 @@ var ContractManager = class _ContractManager {
10505
10532
  const dbFilter = this.buildContractsDbFilter(filter ?? {});
10506
10533
  return await this.config.contractRepository.getContracts(dbFilter);
10507
10534
  }
10508
- async getContractsWithVtxos(filter, pageSize) {
10535
+ async getContractsWithVtxos(filter, pageSize, options) {
10536
+ if (options?.maxSyncAgeMs !== void 0 && (!Number.isSafeInteger(options.maxSyncAgeMs) || options.maxSyncAgeMs < 0)) {
10537
+ throw new Error("maxSyncAgeMs must be a non-negative safe integer");
10538
+ }
10509
10539
  const contracts = await this.getContracts(filter);
10510
- if (this.syncedWithin(contracts, this.config.vtxoSyncMaxAgeMs ?? 0)) {
10540
+ if (this.syncedWithin(
10541
+ contracts,
10542
+ options?.maxSyncAgeMs ?? (options?.requireSynced ? 0 : this.config.vtxoSyncMaxAgeMs ?? 0)
10543
+ )) {
10511
10544
  await this.demoteFundedAwaitingContracts(contracts);
10512
10545
  } else {
10513
10546
  try {
10514
10547
  await this.syncContracts({ contracts, pageSize });
10515
10548
  this.markSyncOnline();
10516
10549
  } catch (err) {
10517
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
10550
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
10518
10551
  this.markSyncDegraded(err);
10552
+ if (options?.requireSynced) {
10553
+ throw new Error("Spendable VTXO read requires an online contract sync", {
10554
+ cause: err
10555
+ });
10556
+ }
10519
10557
  }
10520
10558
  }
10521
- const vtxos = await this.getVtxosForContracts(contracts);
10559
+ const vtxos = await this.getVtxosForContracts(contracts, options);
10560
+ const vtxosByScript = /* @__PURE__ */ new Map();
10561
+ for (const vtxo of vtxos) {
10562
+ const group = vtxosByScript.get(vtxo.contractScript) ?? [];
10563
+ group.push(vtxo);
10564
+ vtxosByScript.set(vtxo.contractScript, group);
10565
+ }
10522
10566
  return contracts.map((contract) => ({
10523
10567
  contract,
10524
- vtxos: vtxos.filter((vtxo) => vtxo.contractScript === contract.script)
10568
+ vtxos: vtxosByScript.get(contract.script)?.slice() ?? []
10525
10569
  }));
10526
10570
  }
10527
10571
  async annotateVtxos(vtxos, tapscripts) {
@@ -10536,7 +10580,7 @@ var ContractManager = class _ContractManager {
10536
10580
  }
10537
10581
  const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
10538
10582
  return vtxos.map(
10539
- (vtxo) => extendVirtualCoinForContract(chunkP53OHGXY_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10583
+ (vtxo) => extendVirtualCoinForContract(chunkPWIESIO6_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10540
10584
  );
10541
10585
  }
10542
10586
  /** @inheritdoc */
@@ -10581,14 +10625,14 @@ var ContractManager = class _ContractManager {
10581
10625
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
10582
10626
  const asking = vtxos.filter((vtxo) => {
10583
10627
  const contract = byScript.get(vtxo.script);
10584
- return contract !== void 0 && chunkCQNX4BTA_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10628
+ return contract !== void 0 && chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10585
10629
  });
10586
10630
  if (asking.length === 0) return refused;
10587
10631
  const tip = await this.currentChainTip();
10588
10632
  const walletKey = await walletPubKey?.();
10589
10633
  for (const vtxo of asking) {
10590
10634
  const contract = byScript.get(vtxo.script);
10591
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
10635
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
10592
10636
  if (!handler?.assertSpendableNow) continue;
10593
10637
  const context = {
10594
10638
  collaborative: true,
@@ -10603,7 +10647,7 @@ var ContractManager = class _ContractManager {
10603
10647
  // the next handler to answer a CSV question would meet a
10604
10648
  // TypeError instead of a `false`. Carry the coin only when it
10605
10649
  // really is one.
10606
- vtxo: chunkP53OHGXY_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10650
+ vtxo: chunkPWIESIO6_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10607
10651
  };
10608
10652
  try {
10609
10653
  await handler.assertSpendableNow(
@@ -10760,7 +10804,7 @@ var ContractManager = class _ContractManager {
10760
10804
  const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
10761
10805
  const [contract] = await this.getContracts({ script: contractScript });
10762
10806
  if (!contract) return [];
10763
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
10807
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
10764
10808
  if (!handler) return [];
10765
10809
  const script = handler.createScript(contract.params);
10766
10810
  const tip = await this.currentChainTip();
@@ -10788,7 +10832,7 @@ var ContractManager = class _ContractManager {
10788
10832
  const { contractScript, collaborative = true, walletPubKey } = options;
10789
10833
  const [contract] = await this.getContracts({ script: contractScript });
10790
10834
  if (!contract) return [];
10791
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
10835
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
10792
10836
  if (!handler) return [];
10793
10837
  const script = handler.createScript(contract.params);
10794
10838
  const context = {
@@ -10844,7 +10888,7 @@ var ContractManager = class _ContractManager {
10844
10888
  }
10845
10889
  async refreshOutpoints(outpoints) {
10846
10890
  if (outpoints.length === 0) return;
10847
- const { vtxos } = await chunkP53OHGXY_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10891
+ const { vtxos } = await chunkPWIESIO6_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10848
10892
  outpoints
10849
10893
  });
10850
10894
  if (vtxos.length === 0) return;
@@ -10946,25 +10990,33 @@ var ContractManager = class _ContractManager {
10946
10990
  break;
10947
10991
  }
10948
10992
  } catch (err) {
10949
- if (!chunkP53OHGXY_cjs.isRetryableProviderError(err)) throw err;
10993
+ if (!chunkPWIESIO6_cjs.isRetryableProviderError(err)) throw err;
10950
10994
  this.markSyncDegraded(err);
10951
10995
  }
10952
10996
  this.emitEvent(event);
10953
10997
  }
10954
- async getVtxosForContracts(contracts) {
10955
- const res = await Promise.all(
10956
- contracts.map(
10957
- (contract) => getVtxosForContract(this.config.walletRepository, contract).then(
10958
- (vtxos) => vtxos.map(
10959
- (vtxo) => ({
10960
- ...vtxo,
10961
- contractScript: contract.script
10962
- })
10998
+ async getVtxosForContracts(contracts, options) {
10999
+ if (contracts.length === 0) return [];
11000
+ let rows;
11001
+ if (this.config.walletRepository.getVtxosForScripts) {
11002
+ const byScript = new Set(contracts.map((contract) => contract.script));
11003
+ rows = (await this.config.walletRepository.getVtxosForScripts([...byScript], options)).filter((vtxo) => vtxo.script !== void 0 && byScript.has(vtxo.script)).map((vtxo) => ({ ...chunkPWIESIO6_cjs.normalizeVtxo(vtxo), contractScript: vtxo.script }));
11004
+ } else {
11005
+ const res = await Promise.all(
11006
+ contracts.map(
11007
+ (contract) => getVtxosForContract(this.config.walletRepository, contract).then(
11008
+ (vtxos) => vtxos.map(
11009
+ (vtxo) => ({
11010
+ ...vtxo,
11011
+ contractScript: contract.script
11012
+ })
11013
+ )
10963
11014
  )
10964
11015
  )
10965
- )
10966
- );
10967
- return res.flat();
11016
+ );
11017
+ rows = res.flat();
11018
+ }
11019
+ return options?.unspentOnly ? rows.filter((vtxo) => !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) : rows;
10968
11020
  }
10969
11021
  /**
10970
11022
  * Sync virtual outputs for the given contracts against the indexer.
@@ -11037,7 +11089,7 @@ var ContractManager = class _ContractManager {
11037
11089
  */
11038
11090
  async reconcilePendingFrontier(contracts) {
11039
11091
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
11040
- const vtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(
11092
+ const vtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(
11041
11093
  this.config.indexerProvider,
11042
11094
  contracts.map((c) => c.script),
11043
11095
  { pendingOnly: true }
@@ -11124,7 +11176,7 @@ var ContractManager = class _ContractManager {
11124
11176
  }
11125
11177
  return result;
11126
11178
  }
11127
- async fetchContractVtxosBulk(contracts, pageSize = chunkP53OHGXY_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11179
+ async fetchContractVtxosBulk(contracts, pageSize = chunkPWIESIO6_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11128
11180
  if (contracts.length === 0) {
11129
11181
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
11130
11182
  }
@@ -11140,7 +11192,7 @@ var ContractManager = class _ContractManager {
11140
11192
  before: syncWindow.before
11141
11193
  }
11142
11194
  } : {};
11143
- const vtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(
11195
+ const vtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(
11144
11196
  this.config.indexerProvider,
11145
11197
  contracts.map((c) => c.script),
11146
11198
  { ...windowOpts, pageSize }
@@ -11289,7 +11341,7 @@ var deserializeTapLeaf = (t) => {
11289
11341
  const s = base.hex.decode(t.s);
11290
11342
  return [cb, s];
11291
11343
  };
11292
- var deserializeVtxo = (o) => chunkP53OHGXY_cjs.normalizeVtxo({
11344
+ var deserializeVtxo = (o) => chunkPWIESIO6_cjs.normalizeVtxo({
11293
11345
  ...o,
11294
11346
  createdAt: new Date(o.createdAt),
11295
11347
  tapTree: base.hex.decode(o.tapTree),
@@ -11465,7 +11517,7 @@ var IndexedDBWalletRepository = class {
11465
11517
  const store = transaction.objectStore(STORE_VTXOS);
11466
11518
  for (const vtxo of vtxos) {
11467
11519
  const serialized = serializeVtxo(vtxo);
11468
- store.put({ address, ...serialized });
11520
+ store.put({ address, ...serialized, ...unspentFlag(vtxo) });
11469
11521
  }
11470
11522
  await awaitTransaction(transaction);
11471
11523
  } catch (error) {
@@ -11485,31 +11537,52 @@ var IndexedDBWalletRepository = class {
11485
11537
  }
11486
11538
  }
11487
11539
  async getVtxosForScript(script) {
11540
+ return this.getVtxosForScripts([script]);
11541
+ }
11542
+ async getVtxosForScripts(scripts, options) {
11543
+ const unique = [...new Set(scripts)];
11544
+ if (unique.length === 0) return [];
11488
11545
  try {
11489
11546
  const db = await this.getDB();
11490
- const store = db.transaction([STORE_VTXOS], "readonly").objectStore(STORE_VTXOS);
11491
- const results = await promisifyRequest(
11492
- store.index("script").getAll(script)
11493
- );
11494
- const matching = (results || []).filter((r) => r.script === script);
11547
+ const rows = options?.unspentOnly ? await getAllByIndexValues(
11548
+ this.vtxoStore(db),
11549
+ "scriptUnspent",
11550
+ unique.map((script) => [script, 1])
11551
+ ) : await getAllByIndexValues(this.vtxoStore(db), "script", unique);
11552
+ const selected = new Set(unique);
11495
11553
  const byOutpoint = /* @__PURE__ */ new Map();
11496
- for (const row of matching) {
11497
- const outpoint = `${row.txid}:${row.vout}`;
11498
- const existing = byOutpoint.get(outpoint);
11499
- if (!existing) {
11500
- byOutpoint.set(outpoint, row);
11554
+ for (const row of rows) {
11555
+ if (!selected.has(row.script)) continue;
11556
+ const key = `${row.script}:${row.txid}:${row.vout}`;
11557
+ const existing = byOutpoint.get(key);
11558
+ if (!existing || shouldReplaceVtxo(existing, row)) byOutpoint.set(key, row);
11559
+ }
11560
+ if (options?.unspentOnly && byOutpoint.size > 0) {
11561
+ const txids = [...new Set([...byOutpoint.values()].map((row) => row.txid))];
11562
+ const store = this.vtxoStore(db);
11563
+ for (const row of await getAllByIndexValues(store, "txid", txids)) {
11564
+ const key = `${row.script}:${row.txid}:${row.vout}`;
11565
+ const existing = byOutpoint.get(key);
11566
+ if (existing && shouldReplaceVtxo(existing, row)) byOutpoint.set(key, row);
11567
+ }
11568
+ }
11569
+ const result = [];
11570
+ for (const row of byOutpoint.values()) {
11571
+ if (options?.unspentOnly && (row.isSpent || row.spentBy || row.settledBy)) {
11501
11572
  continue;
11502
11573
  }
11503
- if (shouldReplaceVtxo(existing, row)) {
11504
- byOutpoint.set(outpoint, row);
11505
- }
11574
+ const vtxo = deserializeVtxoWithBackfill(row);
11575
+ if (!options?.unspentOnly || !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) result.push(vtxo);
11506
11576
  }
11507
- return Array.from(byOutpoint.values()).map(deserializeVtxoWithBackfill);
11577
+ return result;
11508
11578
  } catch (error) {
11509
- console.error(`Failed to get VTXOs for script ${script}:`, error);
11579
+ console.error("Failed to get VTXOs for scripts:", error);
11510
11580
  throw error;
11511
11581
  }
11512
11582
  }
11583
+ vtxoStore(db) {
11584
+ return db.transaction([STORE_VTXOS], "readonly").objectStore(STORE_VTXOS);
11585
+ }
11513
11586
  async saveVtxosForScript(key, vtxos) {
11514
11587
  if (!key.address) {
11515
11588
  throw new Error("IndexedDBWalletRepository requires an address");
@@ -11640,7 +11713,7 @@ var IndexedDBWalletRepository = class {
11640
11713
  return this.connection.get();
11641
11714
  }
11642
11715
  };
11643
- function deserializeVtxoWithBackfill(o) {
11716
+ function deserializeVtxoWithBackfill({ unspent: _unspent, ...o }) {
11644
11717
  if (!o.script) {
11645
11718
  o = { ...o, script: scriptFromArkAddress(o.address) };
11646
11719
  }
@@ -12112,7 +12185,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
12112
12185
  */
12113
12186
  materializeDescriptorAt(index) {
12114
12187
  const descriptor = this.identity.descriptor;
12115
- const network = chunkCQNX4BTA_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
12188
+ const network = chunkY7BVR6SQ_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
12116
12189
  const expansion = descriptorsScure.expand({ descriptor, network, index });
12117
12190
  const keyInfo = expansion.expansionMap?.["@0"];
12118
12191
  if (!keyInfo?.keyExpression) {
@@ -12260,7 +12333,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12260
12333
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
12261
12334
  if (!provider) return void 0;
12262
12335
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
12263
- const expectedContractType = setup.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? "delegate" : "default";
12336
+ const expectedContractType = setup.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? "delegate" : "default";
12264
12337
  const factoryOpts = {
12265
12338
  walletRepository: setup.walletRepository,
12266
12339
  contractRepository: setup.contractRepository,
@@ -12461,7 +12534,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12461
12534
  };
12462
12535
  function deriveLeafPubkey(descriptor) {
12463
12536
  try {
12464
- return chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor);
12537
+ return chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor);
12465
12538
  } catch (e) {
12466
12539
  throw new NonRangeableDescriptorError(
12467
12540
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -12473,7 +12546,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12473
12546
  const pubKey = deriveLeafPubkey(descriptor);
12474
12547
  const tapscript = rebuildTapscript(current, pubKey);
12475
12548
  const serverPubKey = tapscript.options.serverPubKey;
12476
- const csvTimelock = chunkP53OHGXY_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12549
+ const csvTimelock2 = chunkPWIESIO6_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12477
12550
  const base$1 = {
12478
12551
  script: base.hex.encode(tapscript.pkScript),
12479
12552
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -12484,18 +12557,18 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12484
12557
  // index-0 key. Without it, spends produce unsigned PSBTs that the
12485
12558
  // server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
12486
12559
  metadata: {
12487
- ...tagSource && { source: chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE },
12560
+ ...tagSource && { source: chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE },
12488
12561
  signingDescriptor: descriptor
12489
12562
  }
12490
12563
  };
12491
- const params = tapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? {
12564
+ const params = tapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? {
12492
12565
  ...base$1,
12493
12566
  type: "delegate",
12494
12567
  params: {
12495
12568
  pubKey: base.hex.encode(pubKey),
12496
12569
  serverPubKey: base.hex.encode(serverPubKey),
12497
12570
  delegatePubKey: base.hex.encode(tapscript.options.delegatePubKey),
12498
- csvTimelock
12571
+ csvTimelock: csvTimelock2
12499
12572
  }
12500
12573
  } : {
12501
12574
  ...base$1,
@@ -12503,16 +12576,16 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12503
12576
  params: {
12504
12577
  pubKey: base.hex.encode(pubKey),
12505
12578
  serverPubKey: base.hex.encode(serverPubKey),
12506
- csvTimelock
12579
+ csvTimelock: csvTimelock2
12507
12580
  }
12508
12581
  };
12509
12582
  return { tapscript, params };
12510
12583
  }
12511
12584
  function rebuildTapscript(current, pubKey) {
12512
- if (current instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script) {
12513
- return new chunkCQNX4BTA_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12585
+ if (current instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script) {
12586
+ return new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12514
12587
  }
12515
- return new chunkCQNX4BTA_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12588
+ return new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12516
12589
  }
12517
12590
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
12518
12591
  const candidates = await contractRepository.getContracts({
@@ -12521,7 +12594,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
12521
12594
  });
12522
12595
  const serverPubKeyHex = base.hex.encode(serverPubKey);
12523
12596
  const matching = candidates.filter(
12524
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE
12597
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE
12525
12598
  ).sort((a, b) => {
12526
12599
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12527
12600
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12577,7 +12650,7 @@ function computeOffchainBalance(vtxos, caps) {
12577
12650
  }
12578
12651
  };
12579
12652
  for (const vtxo of vtxos) {
12580
- if (chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)) continue;
12653
+ if (chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) continue;
12581
12654
  addAssets(owned, vtxo);
12582
12655
  if (vtxo.isUnrolled) {
12583
12656
  unrolled += vtxo.value;
@@ -12587,11 +12660,11 @@ function computeOffchainBalance(vtxos, caps) {
12587
12660
  pendingRecovery += vtxo.value;
12588
12661
  continue;
12589
12662
  }
12590
- if (chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
12663
+ if (chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
12591
12664
  recoverable += vtxo.value;
12592
12665
  continue;
12593
12666
  }
12594
- if (!chunkP53OHGXY_cjs.canSpendOffchain(vtxo, now)) continue;
12667
+ if (!chunkPWIESIO6_cjs.canSpendOffchain(vtxo, now)) continue;
12595
12668
  if (vtxo.isPreconfirmed) {
12596
12669
  preconfirmed += vtxo.value;
12597
12670
  } else {
@@ -12768,12 +12841,12 @@ var InputSignerRouter = class {
12768
12841
  };
12769
12842
 
12770
12843
  // src/wallet/wallet.ts
12771
- var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkP53OHGXY_cjs.DEFAULT_ARKADE_SERVER_URL;
12844
+ var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkPWIESIO6_cjs.DEFAULT_ARKADE_SERVER_URL;
12772
12845
  function intentProofJobs(coins) {
12773
12846
  if (coins.length === 0) return [];
12774
12847
  const coinJobs = coins.map((coin, i) => ({
12775
12848
  index: i + 1,
12776
- lookupScript: chunkP53OHGXY_cjs.VtxoScript.decode(coin.tapTree).pkScript
12849
+ lookupScript: chunkPWIESIO6_cjs.VtxoScript.decode(coin.tapTree).pkScript
12777
12850
  }));
12778
12851
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
12779
12852
  }
@@ -12805,7 +12878,7 @@ function dedupeTimelocks(timelocks) {
12805
12878
  const seen = /* @__PURE__ */ new Set();
12806
12879
  const deduped = [];
12807
12880
  for (const timelock of timelocks) {
12808
- const sequence = chunkP53OHGXY_cjs.timelockToSequence(timelock).toString();
12881
+ const sequence = chunkPWIESIO6_cjs.timelockToSequence(timelock).toString();
12809
12882
  if (seen.has(sequence)) continue;
12810
12883
  seen.add(sequence);
12811
12884
  deduped.push(timelock);
@@ -12822,7 +12895,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12822
12895
  state: "active"
12823
12896
  });
12824
12897
  const newest = candidates.filter(
12825
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE
12898
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE
12826
12899
  ).sort((a, b) => {
12827
12900
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12828
12901
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12830,7 +12903,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12830
12903
  if (!newest?.params.pubKey) return baseline;
12831
12904
  try {
12832
12905
  const pubKey = base.hex.decode(newest.params.pubKey);
12833
- return new chunkCQNX4BTA_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12906
+ return new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12834
12907
  } catch (e) {
12835
12908
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
12836
12909
  return baseline;
@@ -12849,15 +12922,43 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
12849
12922
  if (vtxo.isUnrolled) {
12850
12923
  return !!f.withUnrolled;
12851
12924
  }
12852
- if (chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)) {
12925
+ if (chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) {
12853
12926
  return false;
12854
12927
  }
12855
- if (!f.withRecoverable && chunkP53OHGXY_cjs.canRecoverOnchain(vtxo, now)) {
12928
+ if (!f.withRecoverable && chunkPWIESIO6_cjs.canRecoverOnchain(vtxo, now)) {
12856
12929
  return false;
12857
12930
  }
12858
12931
  return true;
12859
12932
  });
12860
12933
  }
12934
+ async function refreshSweptStateOfExpiredInputs(wallet, inputs) {
12935
+ const candidates = inputs.filter(chunkPWIESIO6_cjs.isVirtualCoin).map(chunkPWIESIO6_cjs.normalizeVtxo).filter((v) => !v.isSwept);
12936
+ if (candidates.length === 0) return inputs;
12937
+ const now = candidates.some((v) => v.expiresAtHeight !== void 0) ? await chunkPWIESIO6_cjs.resolveTimeHeight(wallet.onchainProvider) : { timestamp: /* @__PURE__ */ new Date() };
12938
+ const suspects = candidates.filter(
12939
+ (v) => chunkPWIESIO6_cjs.isPastExpiry(v, now) || v.expiresAtHeight !== void 0 && now.height === void 0
12940
+ );
12941
+ if (suspects.length === 0) return inputs;
12942
+ let sweptNow;
12943
+ try {
12944
+ const manager = await wallet.getContractManager();
12945
+ await manager.refreshOutpoints(suspects.map(({ txid, vout }) => ({ txid, vout })));
12946
+ const suspectKeys = new Set(suspects.map((v) => `${v.txid}:${v.vout}`));
12947
+ const fresh = await wallet.getVtxos({ withRecoverable: true });
12948
+ sweptNow = new Set(
12949
+ fresh.filter((v) => v.isSwept && suspectKeys.has(`${v.txid}:${v.vout}`)).map((v) => `${v.txid}:${v.vout}`)
12950
+ );
12951
+ } catch (e) {
12952
+ const message = "could not confirm the swept state of expired settlement inputs; retry the settlement";
12953
+ throw chunkPWIESIO6_cjs.isRetryableProviderError(e) ? new chunkPWIESIO6_cjs.ProviderUnavailableError(message, { cause: e }) : new Error(message, { cause: e });
12954
+ }
12955
+ if (sweptNow.size === 0) return inputs;
12956
+ return inputs.map((input) => {
12957
+ if (!chunkPWIESIO6_cjs.isVirtualCoin(input) || !sweptNow.has(`${input.txid}:${input.vout}`)) return input;
12958
+ const swept = { ...chunkPWIESIO6_cjs.normalizeVtxo(input), isSwept: true };
12959
+ return { ...swept, virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(swept) };
12960
+ });
12961
+ }
12861
12962
  var PENDING_RECOVERY_REASON = "is past its operator signer's rotation cutoff \u2014 the operator will not co-sign it until it recovers";
12862
12963
  var UNROLLED_REASON = "was unilaterally exited and lives onchain \u2014 `Unroll.completeUnroll` is the only spend that reaches it";
12863
12964
  function omittedOutpoints(before, after) {
@@ -13192,7 +13293,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13192
13293
  */
13193
13294
  static async setupWalletConfig(config, pubKey) {
13194
13295
  const arkadeServerUrl = getArkadeServerUrl(config);
13195
- const arkProvider = config.arkProvider || new chunkP53OHGXY_cjs.RestArkProvider(arkadeServerUrl);
13296
+ const arkProvider = config.arkProvider || new chunkPWIESIO6_cjs.RestArkProvider(arkadeServerUrl);
13196
13297
  let indexerProvider = config.indexerProvider;
13197
13298
  if (!indexerProvider) {
13198
13299
  let indexerUrl = config.indexerUrl;
@@ -13209,7 +13310,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13209
13310
  indexerUrl = arkadeServerUrl;
13210
13311
  }
13211
13312
  }
13212
- indexerProvider = new chunkT327OEMV_cjs.RestIndexerProvider(indexerUrl);
13313
+ indexerProvider = new chunkIAM5IEVT_cjs.RestIndexerProvider(indexerUrl);
13213
13314
  }
13214
13315
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
13215
13316
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -13218,7 +13319,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13218
13319
  source: serverInfoSource,
13219
13320
  lastOnlineAt: serverInfoLastOnlineAt
13220
13321
  } = await resolveArkInfo(arkProvider, walletRepository);
13221
- const network = chunkP53OHGXY_cjs.getNetwork(info.network);
13322
+ const network = chunkPWIESIO6_cjs.getNetwork(info.network);
13222
13323
  if ("descriptor" in config.identity) {
13223
13324
  const descriptor = config.identity.descriptor;
13224
13325
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -13258,18 +13359,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
13258
13359
  value: info.boardingExitDelay,
13259
13360
  type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
13260
13361
  };
13261
- const serverPubKey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13262
- const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
13362
+ const serverPubKey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13363
+ const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
13263
13364
  const offchainOptions = {
13264
13365
  pubKey,
13265
13366
  serverPubKey,
13266
13367
  csvTimelock: exitTimelock
13267
13368
  };
13268
- const offchainTapscript = !delegatePubKey ? new chunkCQNX4BTA_cjs.DefaultVtxo.Script(offchainOptions) : new chunkCQNX4BTA_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13269
- const boardingTapscript = chunkCQNX4BTA_cjs.BoardingContractHandler.createScript({
13369
+ const offchainTapscript = !delegatePubKey ? new chunkY7BVR6SQ_cjs.DefaultVtxo.Script(offchainOptions) : new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13370
+ const boardingTapscript = chunkY7BVR6SQ_cjs.BoardingContractHandler.createScript({
13270
13371
  pubKey: base.hex.encode(pubKey),
13271
13372
  serverPubKey: base.hex.encode(serverPubKey),
13272
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(boardingTimelock).toString()
13373
+ csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(boardingTimelock).toString()
13273
13374
  });
13274
13375
  return {
13275
13376
  arkProvider,
@@ -13357,7 +13458,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13357
13458
  async getBalance() {
13358
13459
  const [boardingUtxos, snapshot] = await Promise.all([
13359
13460
  this.getBoardingUtxos(),
13360
- this.contractSnapshot()
13461
+ // The bucketer drops every spent coin and the gate reads contracts only.
13462
+ this.contractSnapshot(void 0, { unspentOnly: true })
13361
13463
  ]);
13362
13464
  const vtxos = filterSnapshotVtxos(
13363
13465
  snapshot,
@@ -13410,14 +13512,17 @@ var ReadonlyWallet = class _ReadonlyWallet {
13410
13512
  */
13411
13513
  async getVtxos(filter) {
13412
13514
  return filterSnapshotVtxos(
13413
- await this.contractSnapshot(),
13515
+ // Only an unrolled coin is returned spent, so no other read needs spent rows.
13516
+ await this.contractSnapshot(void 0, { unspentOnly: !filter?.withUnrolled }),
13414
13517
  filter,
13415
13518
  this._pendingSpendOutpoints
13416
13519
  );
13417
13520
  }
13418
13521
  /** @inheritdoc */
13419
13522
  async getSpendableVtxos(filter) {
13420
- const snapshot = await this.contractSnapshot();
13523
+ const snapshot = await this.contractSnapshot(filter, {
13524
+ unspentOnly: !filter?.withUnrolled
13525
+ });
13421
13526
  const vtxos = filterSnapshotVtxos(snapshot, filter, this._pendingSpendOutpoints);
13422
13527
  const { gated, pendingRecovery } = this.spendabilityView(snapshot);
13423
13528
  const selectable = vtxos.filter(
@@ -13435,7 +13540,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13435
13540
  if (!filter?.withUnrolled) {
13436
13541
  logExcludedVtxos(
13437
13542
  "getSpendableVtxos",
13438
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)),
13543
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkPWIESIO6_cjs.isVtxoSpent(vtxo)),
13439
13544
  [() => UNROLLED_REASON]
13440
13545
  );
13441
13546
  }
@@ -13509,9 +13614,25 @@ var ReadonlyWallet = class _ReadonlyWallet {
13509
13614
  * otherwise the gate and the pending-recovery set answer about two different
13510
13615
  * points in time, and each read costs another sync.
13511
13616
  */
13512
- async contractSnapshot() {
13617
+ async contractSnapshot(filter, options) {
13513
13618
  const contractManager = await this.getContractManager();
13514
- return contractManager.getContractsWithVtxos();
13619
+ const scope = filter?.watchedOnly ? { watch: ["watched", "awaiting-funds"] } : void 0;
13620
+ let query = scope;
13621
+ if (filter?.genericallySpendableOnly) {
13622
+ const scripts = (await contractManager.getContracts(scope)).filter(isContractGenericallySpendable).map((contract) => contract.script);
13623
+ if (scripts.length === 0) {
13624
+ if (filter.requireSynced) {
13625
+ throw new Error("No generically spendable contracts to sync");
13626
+ }
13627
+ return [];
13628
+ }
13629
+ query = { ...scope, script: scripts };
13630
+ }
13631
+ return contractManager.getContractsWithVtxos(query, void 0, {
13632
+ maxSyncAgeMs: filter?.maxSyncAgeMs,
13633
+ unspentOnly: options?.unspentOnly,
13634
+ requireSynced: filter?.requireSynced
13635
+ });
13515
13636
  }
13516
13637
  /**
13517
13638
  * The two exclusion sets the gate is made of, derived from one snapshot so
@@ -13580,7 +13701,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13580
13701
  this.getBoardingTxs()
13581
13702
  ]);
13582
13703
  const allVtxos = snapshot.flatMap((_) => _.vtxos);
13583
- const resolveTxCreatedAt = (txids) => chunkP53OHGXY_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13704
+ const resolveTxCreatedAt = (txids) => chunkPWIESIO6_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13584
13705
  return buildTransactionHistory(
13585
13706
  allVtxos,
13586
13707
  boardingTxs,
@@ -13675,7 +13796,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13675
13796
  },
13676
13797
  isUnrolled: true,
13677
13798
  ...boardingFacts,
13678
- virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(boardingFacts),
13799
+ virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(boardingFacts),
13679
13800
  spentBy: "",
13680
13801
  createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
13681
13802
  script: scriptHex
@@ -13731,9 +13852,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13731
13852
  async getBoardingTapscripts(allowedSigners) {
13732
13853
  const byScript = /* @__PURE__ */ new Map();
13733
13854
  const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
13734
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13855
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13735
13856
  add(
13736
- new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
13857
+ new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
13737
13858
  pubKey: await this.identity.xOnlyPublicKey(),
13738
13859
  serverPubKey: this.boardingTapscript.options.serverPubKey,
13739
13860
  csvTimelock: boardingCsv
@@ -13748,7 +13869,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13748
13869
  for (const c of boardingContracts) {
13749
13870
  if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
13750
13871
  try {
13751
- add(chunkCQNX4BTA_cjs.BoardingContractHandler.createScript(c.params));
13872
+ add(chunkY7BVR6SQ_cjs.BoardingContractHandler.createScript(c.params));
13752
13873
  } catch (e) {
13753
13874
  console.warn("Skipping malformed boarding contract", c.script, e);
13754
13875
  }
@@ -13785,7 +13906,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13785
13906
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
13786
13907
  // not the wallet's current boarding timelock, which a signer
13787
13908
  // rotation may have changed.
13788
- csvTimelock: chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13909
+ csvTimelock: chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13789
13910
  coins: utxos
13790
13911
  };
13791
13912
  })
@@ -13922,7 +14043,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13922
14043
  /** Fetch Arkade transaction ids that are still pending final settlement. */
13923
14044
  async fetchPendingTxs() {
13924
14045
  const scripts = await this.getWalletScripts();
13925
- const vtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
14046
+ const vtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13926
14047
  return vtxos.filter(
13927
14048
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
13928
14049
  ).map((_) => _.arkTxId);
@@ -13953,7 +14074,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13953
14074
  });
13954
14075
  for (const contract of contracts) {
13955
14076
  if (map.has(contract.script)) continue;
13956
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
14077
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
13957
14078
  if (handler) {
13958
14079
  const script = handler.createScript(contract.params);
13959
14080
  map.set(contract.script, script);
@@ -14065,19 +14186,19 @@ var ReadonlyWallet = class _ReadonlyWallet {
14065
14186
  }
14066
14187
  });
14067
14188
  const baselinePubkey = await this.identity.xOnlyPublicKey();
14068
- const delegatePubKey = this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14189
+ const delegatePubKey = this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14069
14190
  const baselineSigners = [
14070
14191
  this.offchainTapscript.options.serverPubKey,
14071
14192
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
14072
14193
  ];
14073
14194
  const seenBaselineScripts = /* @__PURE__ */ new Set();
14074
14195
  for (const serverPubKey of baselineSigners) {
14075
- for (const csvTimelock of this.walletContractTimelocks) {
14076
- const csvTimelockStr = chunkP53OHGXY_cjs.timelockToSequence(csvTimelock).toString();
14077
- const defaultScript = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
14196
+ for (const csvTimelock2 of this.walletContractTimelocks) {
14197
+ const csvTimelockStr = chunkPWIESIO6_cjs.timelockToSequence(csvTimelock2).toString();
14198
+ const defaultScript = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
14078
14199
  pubKey: baselinePubkey,
14079
14200
  serverPubKey,
14080
- csvTimelock
14201
+ csvTimelock: csvTimelock2
14081
14202
  });
14082
14203
  const defaultScriptHex = base.hex.encode(defaultScript.pkScript);
14083
14204
  if (!seenBaselineScripts.has(defaultScriptHex)) {
@@ -14095,11 +14216,11 @@ var ReadonlyWallet = class _ReadonlyWallet {
14095
14216
  });
14096
14217
  }
14097
14218
  if (delegatePubKey) {
14098
- const delegateScript = new chunkCQNX4BTA_cjs.DelegateVtxo.Script({
14219
+ const delegateScript = new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({
14099
14220
  pubKey: baselinePubkey,
14100
14221
  serverPubKey,
14101
14222
  delegatePubKey,
14102
- csvTimelock
14223
+ csvTimelock: csvTimelock2
14103
14224
  });
14104
14225
  const delegateScriptHex = base.hex.encode(delegateScript.pkScript);
14105
14226
  if (seenBaselineScripts.has(delegateScriptHex)) continue;
@@ -14119,9 +14240,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
14119
14240
  }
14120
14241
  }
14121
14242
  }
14122
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14243
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14123
14244
  for (const serverPubKey of baselineSigners) {
14124
- const baselineBoarding = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
14245
+ const baselineBoarding = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
14125
14246
  pubKey: baselinePubkey,
14126
14247
  serverPubKey,
14127
14248
  csvTimelock: boardingCsvTimelock
@@ -14134,7 +14255,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
14134
14255
  params: {
14135
14256
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
14136
14257
  serverPubKey: base.hex.encode(serverPubKey),
14137
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(boardingCsvTimelock).toString()
14258
+ csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(boardingCsvTimelock).toString()
14138
14259
  },
14139
14260
  script: boardingScriptHex,
14140
14261
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -14334,7 +14455,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14334
14455
  serverPubKey: this.offchainTapscript.options.serverPubKey,
14335
14456
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
14336
14457
  csvTimelocks: this.walletContractTimelocks,
14337
- delegatePubKey: this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14458
+ delegatePubKey: this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14338
14459
  };
14339
14460
  }
14340
14461
  _signerRouter;
@@ -14579,7 +14700,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14579
14700
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
14580
14701
  const persisted = row?.metadata?.signingDescriptor;
14581
14702
  if (typeof persisted === "string") return persisted;
14582
- return chunkCQNX4BTA_cjs.identityDescriptor(this.identity);
14703
+ return chunkY7BVR6SQ_cjs.identityDescriptor(this.identity);
14583
14704
  }
14584
14705
  /**
14585
14706
  * Build, persist and shape one address of `type` owned by `descriptor` —
@@ -14595,7 +14716,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14595
14716
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
14596
14717
  if (type === "boarding") {
14597
14718
  const built2 = this.buildBoardingContract(
14598
- chunkCQNX4BTA_cjs.deriveDescriptorLeafPubKey(descriptor),
14719
+ chunkY7BVR6SQ_cjs.deriveDescriptorLeafPubKey(descriptor),
14599
14720
  descriptor,
14600
14721
  tagSource
14601
14722
  );
@@ -14640,11 +14761,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14640
14761
  * {@link buildReceiveContract}.
14641
14762
  */
14642
14763
  buildBoardingContract(pubKey, descriptor, tagSource) {
14643
- const tapscript = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
14764
+ const tapscript = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
14644
14765
  ...this._boardingTapscript.options,
14645
14766
  pubKey
14646
14767
  });
14647
- const csvTimelock = tapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14768
+ const csvTimelock2 = tapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14648
14769
  return {
14649
14770
  tapscript,
14650
14771
  params: {
@@ -14652,13 +14773,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14652
14773
  params: {
14653
14774
  pubKey: base.hex.encode(pubKey),
14654
14775
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
14655
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(csvTimelock).toString()
14776
+ csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(csvTimelock2).toString()
14656
14777
  },
14657
14778
  script: base.hex.encode(tapscript.pkScript),
14658
14779
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
14659
14780
  state: "active",
14660
14781
  metadata: {
14661
- ...tagSource && { source: chunkCQNX4BTA_cjs.WALLET_RECEIVE_SOURCE },
14782
+ ...tagSource && { source: chunkY7BVR6SQ_cjs.WALLET_RECEIVE_SOURCE },
14662
14783
  signingDescriptor: descriptor
14663
14784
  }
14664
14785
  }
@@ -14687,7 +14808,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14687
14808
  if (this._descriptorProvider instanceof HDDescriptorProvider) {
14688
14809
  return (await this.getContractManager()).getNextSigningDescriptor();
14689
14810
  }
14690
- return chunkCQNX4BTA_cjs.identityDescriptor(this.identity);
14811
+ return chunkY7BVR6SQ_cjs.identityDescriptor(this.identity);
14691
14812
  }
14692
14813
  /**
14693
14814
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -14783,7 +14904,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14783
14904
  * the stable public API.
14784
14905
  */
14785
14906
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
14786
- const xonly = chunkCQNX4BTA_cjs.toXOnly(newServerPubKey, "ark signer key");
14907
+ const xonly = chunkY7BVR6SQ_cjs.toXOnly(newServerPubKey, "ark signer key");
14787
14908
  const newServerUnrollScript = assertValidServerUnrollScript(
14788
14909
  checkpointTapscript,
14789
14910
  resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
@@ -14812,21 +14933,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14812
14933
  const [currentBoardingRow] = await manager.getContracts({
14813
14934
  script: currentBoardingScript
14814
14935
  });
14815
- const newOffchain = this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? new chunkCQNX4BTA_cjs.DelegateVtxo.Script({
14936
+ const newOffchain = this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? new chunkY7BVR6SQ_cjs.DelegateVtxo.Script({
14816
14937
  ...this.offchainTapscript.options,
14817
14938
  serverPubKey: xonly
14818
- }) : new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
14939
+ }) : new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
14819
14940
  ...this.offchainTapscript.options,
14820
14941
  serverPubKey: xonly
14821
14942
  });
14822
- const newBoarding = new chunkCQNX4BTA_cjs.DefaultVtxo.Script({
14943
+ const newBoarding = new chunkY7BVR6SQ_cjs.DefaultVtxo.Script({
14823
14944
  ...this._boardingTapscript.options,
14824
14945
  serverPubKey: xonly
14825
14946
  });
14826
- const offchainCsv = chunkP53OHGXY_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14947
+ const offchainCsv = chunkPWIESIO6_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14827
14948
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
14828
14949
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
14829
- if (newOffchain instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script) {
14950
+ if (newOffchain instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script) {
14830
14951
  await manager.createContract({
14831
14952
  type: "delegate",
14832
14953
  params: {
@@ -14854,13 +14975,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14854
14975
  metadata: currentOffchainRow?.metadata
14855
14976
  });
14856
14977
  }
14857
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14978
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14858
14979
  await manager.createContract({
14859
14980
  type: "boarding",
14860
14981
  params: {
14861
14982
  pubKey: base.hex.encode(newBoarding.options.pubKey),
14862
14983
  serverPubKey: base.hex.encode(xonly),
14863
- csvTimelock: chunkP53OHGXY_cjs.timelockToSequence(boardingCsv).toString()
14984
+ csvTimelock: chunkPWIESIO6_cjs.timelockToSequence(boardingCsv).toString()
14864
14985
  },
14865
14986
  script: base.hex.encode(newBoarding.pkScript),
14866
14987
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -14893,14 +15014,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14893
15014
  _restoreInFlight;
14894
15015
  _addPendingSpends(inputs) {
14895
15016
  for (const input of inputs) {
14896
- if (chunkP53OHGXY_cjs.isVirtualCoin(input)) {
15017
+ if (chunkPWIESIO6_cjs.isVirtualCoin(input)) {
14897
15018
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
14898
15019
  }
14899
15020
  }
14900
15021
  }
14901
15022
  _removePendingSpends(inputs) {
14902
15023
  for (const input of inputs) {
14903
- if (chunkP53OHGXY_cjs.isVirtualCoin(input)) {
15024
+ if (chunkPWIESIO6_cjs.isVirtualCoin(input)) {
14904
15025
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
14905
15026
  }
14906
15027
  }
@@ -14961,13 +15082,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14961
15082
  const manager = await this.getContractManager();
14962
15083
  const provider = this._descriptorProvider;
14963
15084
  const hd = provider instanceof HDDescriptorProvider;
14964
- const staticDescriptor = hd ? void 0 : await chunkCQNX4BTA_cjs.identityDescriptor(this.identity);
15085
+ const staticDescriptor = hd ? void 0 : await chunkY7BVR6SQ_cjs.identityDescriptor(this.identity);
14965
15086
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
14966
- const delegatePubKey = this.offchainTapscript instanceof chunkCQNX4BTA_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
15087
+ const delegatePubKey = this.offchainTapscript instanceof chunkY7BVR6SQ_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14967
15088
  const arkInfo = await this.arkProvider.getInfo();
14968
- const currentSignerPubKey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
15089
+ const currentSignerPubKey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14969
15090
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
14970
- (s) => chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
15091
+ (s) => chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14971
15092
  );
14972
15093
  const deps = {
14973
15094
  indexerProvider: this.indexerProvider,
@@ -14982,7 +15103,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14982
15103
  csvTimelocks: this.walletContractTimelocks,
14983
15104
  // Boarding-exit CSV so the boarding handler can build its
14984
15105
  // candidate script (distinct from the unilateral-exit matrix).
14985
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkCQNX4BTA_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
15106
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkY7BVR6SQ_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14986
15107
  delegatePubKey
14987
15108
  };
14988
15109
  const result = await manager.scanContracts({
@@ -15096,7 +15217,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15096
15217
  throw new Error("Invalid configured public key");
15097
15218
  }
15098
15219
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
15099
- const forfeitPubkey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
15220
+ const forfeitPubkey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
15100
15221
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
15101
15222
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
15102
15223
  const checkpointExitDelayOverrides = {
@@ -15245,7 +15366,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15245
15366
  inputs: params.selectedVtxos,
15246
15367
  changeAmount: BigInt(changeAmount)
15247
15368
  };
15248
- const outputAddress = chunkP53OHGXY_cjs.ArkAddress.decode(params.address);
15369
+ const outputAddress = chunkPWIESIO6_cjs.ArkAddress.decode(params.address);
15249
15370
  assertRecipientArkAddress(
15250
15371
  params.address,
15251
15372
  outputAddress,
@@ -15311,13 +15432,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15311
15432
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
15312
15433
  }
15313
15434
  const offchainAddress = await this.getAddress();
15314
- const offchainPkScript = chunkP53OHGXY_cjs.ArkAddress.decode(offchainAddress).pkScript;
15435
+ const offchainPkScript = chunkPWIESIO6_cjs.ArkAddress.decode(offchainAddress).pkScript;
15315
15436
  const offchainOutputScript = base.hex.encode(offchainPkScript);
15316
15437
  if (!params) {
15317
15438
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
15318
15439
  const estimator = new Estimator(fees.intentFee);
15319
15440
  let amount = 0;
15320
- const exitScript = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(
15441
+ const exitScript = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(
15321
15442
  base.hex.decode(this.boardingTapscript.exitScript)
15322
15443
  );
15323
15444
  const boardingTimelock = exitScript.params.timelock;
@@ -15340,13 +15461,16 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15340
15461
  filteredBoardingUtxos.push(utxo);
15341
15462
  amount += utxo.value - inputFee.satoshis;
15342
15463
  }
15343
- const vtxos = await this.getSpendableVtxos({ withRecoverable: true });
15464
+ const vtxos = await this.getSpendableVtxos({
15465
+ withRecoverable: true,
15466
+ genericallySpendableOnly: true
15467
+ });
15344
15468
  const filteredVtxos = [];
15345
15469
  for (const vtxo of byValueDescending(vtxos)) {
15346
15470
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
15347
15471
  break;
15348
15472
  }
15349
- const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo));
15473
+ const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo));
15350
15474
  if (inputFee.satoshis >= vtxo.value) {
15351
15475
  continue;
15352
15476
  }
@@ -15385,6 +15509,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15385
15509
  outputs: [output]
15386
15510
  };
15387
15511
  }
15512
+ params = {
15513
+ ...params,
15514
+ inputs: await refreshSweptStateOfExpiredInputs(this, params.inputs)
15515
+ };
15388
15516
  const onchainOutputIndexes = [];
15389
15517
  const outputs = [];
15390
15518
  let hasOffchainOutputs = false;
@@ -15393,7 +15521,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15393
15521
  let script;
15394
15522
  let arkAddress;
15395
15523
  try {
15396
- arkAddress = chunkP53OHGXY_cjs.ArkAddress.decode(output.address);
15524
+ arkAddress = chunkPWIESIO6_cjs.ArkAddress.decode(output.address);
15397
15525
  } catch {
15398
15526
  arkAddress = void 0;
15399
15527
  }
@@ -15483,7 +15611,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15483
15611
  const abortController = new AbortController();
15484
15612
  let stream;
15485
15613
  let committedTxid;
15486
- const settleInputVtxos = params.inputs.filter(chunkP53OHGXY_cjs.isVirtualCoin);
15614
+ const settleInputVtxos = params.inputs.filter(chunkPWIESIO6_cjs.isVirtualCoin);
15487
15615
  const contractManager = await this.getContractManager();
15488
15616
  await contractManager.assertAnnotatable(settleInputVtxos);
15489
15617
  await contractManager.assertSpendableNow?.(
@@ -15595,7 +15723,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15595
15723
  async maybeRotateBoardingAfterBoard(inputs) {
15596
15724
  if (!this._descriptorProvider) return;
15597
15725
  const consumedBoarding = inputs.some(
15598
- (input) => typeof input !== "string" && !chunkP53OHGXY_cjs.isVirtualCoin(input)
15726
+ (input) => typeof input !== "string" && !chunkPWIESIO6_cjs.isVirtualCoin(input)
15599
15727
  );
15600
15728
  if (!consumedBoarding) return;
15601
15729
  try {
@@ -15619,7 +15747,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15619
15747
  let connectorIndex = 0;
15620
15748
  const connectorsLeaves = connectorsGraph?.leaves() || [];
15621
15749
  for (const input of inputs) {
15622
- if (!chunkP53OHGXY_cjs.isVirtualCoin(input)) {
15750
+ if (!chunkPWIESIO6_cjs.isVirtualCoin(input)) {
15623
15751
  let matched = false;
15624
15752
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
15625
15753
  const settlementInput = settlementPsbt.getInput(i);
@@ -15657,7 +15785,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15657
15785
  }
15658
15786
  continue;
15659
15787
  }
15660
- if (chunkP53OHGXY_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
15788
+ if (!chunkPWIESIO6_cjs.requiresForfeit(input) || isSubdust({ value: input.value }, this.dustAmount)) {
15661
15789
  continue;
15662
15790
  }
15663
15791
  if (connectorsLeaves.length === 0) {
@@ -15685,7 +15813,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15685
15813
  index: input.vout,
15686
15814
  witnessUtxo: {
15687
15815
  amount: BigInt(input.value),
15688
- script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
15816
+ script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
15689
15817
  },
15690
15818
  sighashType: btcSigner.SigHash.DEFAULT,
15691
15819
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -15704,7 +15832,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15704
15832
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
15705
15833
  {
15706
15834
  index: 0,
15707
- lookupScript: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
15835
+ lookupScript: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
15708
15836
  }
15709
15837
  ]);
15710
15838
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -15762,7 +15890,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15762
15890
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
15763
15891
  );
15764
15892
  await this.arkProvider.confirmRegistration(intentId);
15765
- const sweepTapscript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
15893
+ const sweepTapscript = chunkPWIESIO6_cjs.CSVMultisigTapscript.encode({
15766
15894
  timelock,
15767
15895
  pubkeys: [this.forfeitPubkey]
15768
15896
  }).script;
@@ -15777,10 +15905,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15777
15905
  throw new Error("Sweep tap tree root not set");
15778
15906
  }
15779
15907
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
15780
- (k) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15908
+ (k) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15781
15909
  );
15782
15910
  const signerPublicKey = await session.getPublicKey();
15783
- const xonlySignerPublicKey = chunkCQNX4BTA_cjs.toXOnly(signerPublicKey, "signer key");
15911
+ const xonlySignerPublicKey = chunkY7BVR6SQ_cjs.toXOnly(signerPublicKey, "signer key");
15784
15912
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
15785
15913
  return { skip: true };
15786
15914
  }
@@ -15870,9 +15998,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15870
15998
  ...existing ?? {},
15871
15999
  intentTxId,
15872
16000
  registerProof: intent.proof,
15873
- registerProofMessage: chunkP53OHGXY_cjs.Intent.encodeMessage(intent.message),
16001
+ registerProofMessage: chunkPWIESIO6_cjs.Intent.encodeMessage(intent.message),
15874
16002
  deleteProof: deleteIntent.proof,
15875
- deleteProofMessage: chunkP53OHGXY_cjs.Intent.encodeMessage(deleteIntent.message),
16003
+ deleteProofMessage: chunkPWIESIO6_cjs.Intent.encodeMessage(deleteIntent.message),
15876
16004
  intentVtxos: inputs.map((i) => ({
15877
16005
  txid: i.txid,
15878
16006
  vout: i.vout
@@ -15905,7 +16033,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15905
16033
  try {
15906
16034
  return await this.arkProvider.registerIntent(intent);
15907
16035
  } catch (error) {
15908
- if (error instanceof chunkP53OHGXY_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
16036
+ if (error instanceof chunkPWIESIO6_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15909
16037
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
15910
16038
  await this.arkProvider.deleteIntent(deleteIntent);
15911
16039
  return this.arkProvider.registerIntent(intent);
@@ -15921,7 +16049,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15921
16049
  expire_at: 0,
15922
16050
  cosigners_public_keys: cosignerPubKeys
15923
16051
  };
15924
- const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, outputs);
16052
+ const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, outputs);
15925
16053
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15926
16054
  return {
15927
16055
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15933,7 +16061,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15933
16061
  type: "delete",
15934
16062
  expire_at: 0
15935
16063
  };
15936
- const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, []);
16064
+ const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, []);
15937
16065
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15938
16066
  return {
15939
16067
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15945,7 +16073,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15945
16073
  type: "get-pending-tx",
15946
16074
  expire_at: 0
15947
16075
  };
15948
- const proof = chunkP53OHGXY_cjs.Intent.create(message, coins, []);
16076
+ const proof = chunkPWIESIO6_cjs.Intent.create(message, coins, []);
15949
16077
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15950
16078
  return {
15951
16079
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15966,7 +16094,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15966
16094
  if (!vtxos || vtxos.length === 0) {
15967
16095
  const scriptMap = await this.getScriptMap();
15968
16096
  const allExtended = [];
15969
- const fetchedVtxos = await chunkP53OHGXY_cjs.getAllNormalizedVtxos(this.indexerProvider, [
16097
+ const fetchedVtxos = await chunkPWIESIO6_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15970
16098
  ...scriptMap.keys()
15971
16099
  ]);
15972
16100
  for (const vtxo of fetchedVtxos) {
@@ -16010,7 +16138,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16010
16138
  try {
16011
16139
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
16012
16140
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
16013
- chunkP53OHGXY_cjs.assertAllowedSighashTypes(tx);
16141
+ chunkPWIESIO6_cjs.assertAllowedSighashTypes(tx);
16014
16142
  return tx;
16015
16143
  });
16016
16144
  assertCheckpointsMatchInputs(
@@ -16082,11 +16210,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16082
16210
  * against the current key alone would leave it pending forever.
16083
16211
  */
16084
16212
  checkpointUnrollCandidates(info) {
16085
- const current = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
16213
+ const current = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
16086
16214
  const candidates = [this._serverUnrollScript, current];
16087
16215
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
16088
16216
  candidates.push(
16089
- chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
16217
+ chunkPWIESIO6_cjs.CSVMultisigTapscript.encode({
16090
16218
  ...current.params,
16091
16219
  pubkeys: [base.hex.decode(deprecated)]
16092
16220
  })
@@ -16177,7 +16305,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16177
16305
  if (vtxos.length === 0) {
16178
16306
  throw new Error("No VTXOs found for this arkadeCash");
16179
16307
  }
16180
- const myPkScript = chunkP53OHGXY_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
16308
+ const myPkScript = chunkPWIESIO6_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
16181
16309
  let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
16182
16310
  let swept = 0;
16183
16311
  const drainable = vtxos.filter(
@@ -16253,7 +16381,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16253
16381
  const spendable = [];
16254
16382
  const unclaimed = [];
16255
16383
  for (const vtxo of vtxos) {
16256
- if (chunkP53OHGXY_cjs.hasTerminalSpend(vtxo)) {
16384
+ if (chunkPWIESIO6_cjs.isVtxoSpent(vtxo)) {
16257
16385
  unclaimed.push(cashReport(vtxo, "already-spent"));
16258
16386
  } else if (vtxo.isUnrolled) {
16259
16387
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -16275,7 +16403,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16275
16403
  const all = [];
16276
16404
  const seen = /* @__PURE__ */ new Set();
16277
16405
  for (let pageIndex = 0; ; pageIndex++) {
16278
- const { vtxos, page } = await chunkP53OHGXY_cjs.getNormalizedVtxos(this.indexerProvider, {
16406
+ const { vtxos, page } = await chunkPWIESIO6_cjs.getNormalizedVtxos(this.indexerProvider, {
16279
16407
  scripts,
16280
16408
  pageIndex,
16281
16409
  pageSize
@@ -16322,7 +16450,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16322
16450
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
16323
16451
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
16324
16452
  const message = { type: "get-pending-tx", expire_at: 0 };
16325
- const proof = chunkP53OHGXY_cjs.Intent.create(message, batch, []);
16453
+ const proof = chunkPWIESIO6_cjs.Intent.create(message, batch, []);
16326
16454
  const signedProof = await identity.sign(
16327
16455
  proof,
16328
16456
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -16344,7 +16472,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16344
16472
  try {
16345
16473
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
16346
16474
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
16347
- chunkP53OHGXY_cjs.assertAllowedSighashTypes(tx);
16475
+ chunkPWIESIO6_cjs.assertAllowedSighashTypes(tx);
16348
16476
  return tx;
16349
16477
  });
16350
16478
  assertCheckpointsMatchInputs(
@@ -16444,7 +16572,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16444
16572
  let virtualCoins = [];
16445
16573
  if (!selectedVtxos) {
16446
16574
  virtualCoins = await this.getSpendableVtxos({
16447
- withRecoverable: false
16575
+ withRecoverable: false,
16576
+ genericallySpendableOnly: true
16448
16577
  });
16449
16578
  }
16450
16579
  const assetChanges = /* @__PURE__ */ new Map();
@@ -16476,6 +16605,15 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16476
16605
  }
16477
16606
  }
16478
16607
  } else {
16608
+ const coinsByAsset = /* @__PURE__ */ new Map();
16609
+ for (const coin of virtualCoins) {
16610
+ for (const assetId of new Set(coin.assets?.map((asset) => asset.assetId))) {
16611
+ const coins = coinsByAsset.get(assetId) ?? [];
16612
+ coins.push(coin);
16613
+ coinsByAsset.set(assetId, coins);
16614
+ }
16615
+ }
16616
+ const selectedOutpoints2 = /* @__PURE__ */ new Set();
16479
16617
  for (const recipient of recipients) {
16480
16618
  if (!recipient.assets) {
16481
16619
  continue;
@@ -16494,8 +16632,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16494
16632
  amountToSelect -= existingChange;
16495
16633
  assetChanges.delete(receiverAsset.assetId);
16496
16634
  }
16497
- const availableCoins = virtualCoins.filter(
16498
- (c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
16635
+ const availableCoins = (coinsByAsset.get(receiverAsset.assetId) ?? []).filter(
16636
+ (coin) => !selectedOutpoints2.has(vtxoOutpoint(coin))
16499
16637
  );
16500
16638
  const { selected, totalAssetAmount } = selectCoinsWithAsset(
16501
16639
  availableCoins,
@@ -16504,6 +16642,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16504
16642
  );
16505
16643
  for (const coin of selected) {
16506
16644
  selectedCoins.push(coin);
16645
+ selectedOutpoints2.add(vtxoOutpoint(coin));
16507
16646
  btcAmountToSelect -= coin.value;
16508
16647
  if (coin.assets) {
16509
16648
  for (const a of coin.assets) {
@@ -16524,7 +16663,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16524
16663
  }
16525
16664
  if (btcAmountToSelect > 0) {
16526
16665
  const availableCoins = virtualCoins.filter(
16527
- (c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
16666
+ (coin) => !selectedOutpoints2.has(vtxoOutpoint(coin))
16528
16667
  );
16529
16668
  const { inputs: btcCoins } = selectVirtualCoins(availableCoins, btcAmountToSelect);
16530
16669
  for (const coin of btcCoins) {
@@ -16536,6 +16675,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16536
16675
  }
16537
16676
  }
16538
16677
  selectedCoins = [...selectedCoins, ...btcCoins];
16678
+ for (const coin of btcCoins) selectedOutpoints2.add(vtxoOutpoint(coin));
16539
16679
  }
16540
16680
  }
16541
16681
  let totalBtcSelected = selectedCoins.reduce((sum, c) => sum + c.value, 0);
@@ -16543,7 +16683,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16543
16683
  script: recipient.script,
16544
16684
  amount: BigInt(recipient.amount),
16545
16685
  // Already checked against the recipient address in `validateRecipients`.
16546
- ...recipient.tapTree ? { tapTree: chunkP53OHGXY_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16686
+ ...recipient.tapTree ? { tapTree: chunkPWIESIO6_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16547
16687
  }));
16548
16688
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
16549
16689
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -16552,19 +16692,58 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16552
16692
  `send({ selectedVtxos }): inputs total ${totalBtcSelected} sats, outputs need ${totalBtcOutput}`
16553
16693
  );
16554
16694
  }
16555
- if (assetChanges.size > 0 && changeAmount < Number(this.dustAmount)) {
16556
- if (selectedVtxos) {
16557
- throw new Error(
16558
- `send({ selectedVtxos }): ${changeAmount} sats of change cannot carry ${assetChanges.size} asset change(s), needs ${this.dustAmount}`
16559
- );
16560
- }
16561
- const availableCoins = virtualCoins.filter(
16562
- (c) => !selectedCoins.find((sc) => sc.txid === c.txid && sc.vout === c.vout)
16695
+ if (selectedVtxos && assetChanges.size > 0 && changeAmount < Number(this.dustAmount)) {
16696
+ throw new Error(
16697
+ `send({ selectedVtxos }): ${changeAmount} sats of change cannot carry ${assetChanges.size} asset change(s), needs ${this.dustAmount}`
16563
16698
  );
16564
- const { inputs: extraCoins } = selectVirtualCoins(
16565
- availableCoins,
16566
- Number(this.dustAmount) - changeAmount
16699
+ }
16700
+ const vtxoMinAmount = changeAmount > 0 || assetChanges.size > 0 ? (await this.arkProvider.getInfo()).vtxoMinAmount ?? 0n : 0n;
16701
+ if (selectedVtxos && changeAmount > 0 && BigInt(changeAmount) < vtxoMinAmount) {
16702
+ throw new Error(
16703
+ `send({ selectedVtxos }): ${changeAmount} sats of change is below the operator minimum of ${vtxoMinAmount} sats`
16704
+ );
16705
+ }
16706
+ const selectedOutpoints = new Set(selectedCoins.map(vtxoOutpoint));
16707
+ while (!selectedVtxos && (changeAmount > 0 && BigInt(changeAmount) < vtxoMinAmount || assetChanges.size > 0 && BigInt(changeAmount) < this.dustAmount)) {
16708
+ const minimumChange = assetChanges.size > 0 && this.dustAmount > vtxoMinAmount ? this.dustAmount : vtxoMinAmount;
16709
+ const availableCoins = virtualCoins.filter(
16710
+ (coin) => !selectedOutpoints.has(vtxoOutpoint(coin))
16567
16711
  );
16712
+ let extraCoins;
16713
+ try {
16714
+ ({ inputs: extraCoins } = selectVirtualCoins(
16715
+ availableCoins,
16716
+ Number(minimumChange) - changeAmount
16717
+ ));
16718
+ } catch (error) {
16719
+ if (!(error instanceof Error) || error.message !== "Insufficient funds") {
16720
+ throw error;
16721
+ }
16722
+ if (recipients.every((r) => r.assets.length === 0)) {
16723
+ const plainCoins = virtualCoins.filter((coin) => !coin.assets?.length);
16724
+ const exact = plainCoins.find((coin) => coin.value === totalBtcOutput);
16725
+ let exactCoins = exact ? [exact] : void 0;
16726
+ if (!exactCoins) {
16727
+ const byAmount = /* @__PURE__ */ new Map();
16728
+ for (const coin of plainCoins) {
16729
+ const partner = byAmount.get(totalBtcOutput - coin.value);
16730
+ if (partner) {
16731
+ exactCoins = [partner, coin];
16732
+ break;
16733
+ }
16734
+ byAmount.set(coin.value, coin);
16735
+ }
16736
+ }
16737
+ if (exactCoins) {
16738
+ selectedCoins = exactCoins;
16739
+ assetChanges.clear();
16740
+ totalBtcSelected = totalBtcOutput;
16741
+ changeAmount = 0;
16742
+ break;
16743
+ }
16744
+ }
16745
+ throw new Error(`Cannot form minimum change amount of ${minimumChange} sats`);
16746
+ }
16568
16747
  for (const coin of extraCoins) {
16569
16748
  if (coin.assets) {
16570
16749
  for (const asset of coin.assets) {
@@ -16574,6 +16753,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16574
16753
  }
16575
16754
  }
16576
16755
  selectedCoins = [...selectedCoins, ...extraCoins];
16756
+ for (const coin of extraCoins) selectedOutpoints.add(vtxoOutpoint(coin));
16577
16757
  totalBtcSelected += extraCoins.reduce((sum, c) => sum + c.value, 0);
16578
16758
  changeAmount = totalBtcSelected - totalBtcOutput;
16579
16759
  }
@@ -16687,10 +16867,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16687
16867
  const serverPubKey = this.arkServerPublicKey;
16688
16868
  const serverUnrollScript = this.serverUnrollScript;
16689
16869
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
16690
- const normalizedInputs = inputs.map(chunkP53OHGXY_cjs.normalizeVtxo);
16691
- const at = now ?? await chunkP53OHGXY_cjs.resolveTimeHeight(this.onchainProvider);
16870
+ const normalizedInputs = inputs.map(chunkPWIESIO6_cjs.normalizeVtxo);
16871
+ const at = now ?? await chunkPWIESIO6_cjs.resolveTimeHeight(this.onchainProvider);
16692
16872
  for (const input of normalizedInputs) {
16693
- if (!chunkP53OHGXY_cjs.canSpendOffchain(input, at)) {
16873
+ if (!chunkPWIESIO6_cjs.canSpendOffchain(input, at)) {
16694
16874
  throw new Error(
16695
16875
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
16696
16876
  );
@@ -16760,7 +16940,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16760
16940
  );
16761
16941
  const arkTxJobs = inputs.map((input, index) => ({
16762
16942
  index,
16763
- lookupScript: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
16943
+ lookupScript: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
16764
16944
  }));
16765
16945
  const identity = this.identity;
16766
16946
  const signer = {
@@ -16861,14 +17041,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16861
17041
  const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
16862
17042
  spentVtxos.push({
16863
17043
  ...spentFacts,
16864
- virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(spentFacts),
17044
+ virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(spentFacts),
16865
17045
  ...spentBy ? { spentBy } : {},
16866
17046
  arkTxId: arkTxid
16867
17047
  });
16868
17048
  for (const id of vtxo.commitmentTxIds) {
16869
17049
  commitmentTxIds.add(id);
16870
17050
  }
16871
- const vtxoExpiry = chunkP53OHGXY_cjs.toBatchExpiry(vtxo);
17051
+ const vtxoExpiry = chunkPWIESIO6_cjs.toBatchExpiry(vtxo);
16872
17052
  if (vtxoExpiry) {
16873
17053
  batchExpiry = Math.min(batchExpiry, vtxoExpiry);
16874
17054
  }
@@ -16881,7 +17061,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16881
17061
  isSwept: false,
16882
17062
  isPreconfirmed: true,
16883
17063
  commitmentTxIds: Array.from(commitmentTxIds),
16884
- ...chunkP53OHGXY_cjs.parseLegacyExpiry(batchExpiry)
17064
+ ...chunkPWIESIO6_cjs.parseLegacyExpiry(batchExpiry)
16885
17065
  };
16886
17066
  changeVtxo = {
16887
17067
  txid: arkTxid,
@@ -16893,7 +17073,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16893
17073
  tapTree: offchainTapscript.encode(),
16894
17074
  value: Number(changeAmount),
16895
17075
  ...changeFacts,
16896
- virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(changeFacts),
17076
+ virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(changeFacts),
16897
17077
  spentBy: "",
16898
17078
  status: {
16899
17079
  confirmed: false
@@ -16962,12 +17142,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16962
17142
  const spentVtxos = [];
16963
17143
  const inputArkTxIds = /* @__PURE__ */ new Set();
16964
17144
  const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
16965
- const vtxoInputs = inputs.filter(chunkP53OHGXY_cjs.isVirtualCoin);
17145
+ const vtxoInputs = inputs.filter(chunkPWIESIO6_cjs.isVirtualCoin);
16966
17146
  const cm = await this.getContractManager();
16967
17147
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
16968
17148
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
16969
17149
  for (const input of inputs) {
16970
- if (chunkP53OHGXY_cjs.isVirtualCoin(input)) {
17150
+ if (chunkPWIESIO6_cjs.isVirtualCoin(input)) {
16971
17151
  const outpoint = `${input.txid}:${input.vout}`;
16972
17152
  const vtxo = annotatedByKey.get(outpoint);
16973
17153
  if (!vtxo) {
@@ -16979,13 +17159,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16979
17159
  const settledFacts = { ...vtxo, isSpent: true };
16980
17160
  spentVtxos.push({
16981
17161
  ...settledFacts,
16982
- virtualStatus: chunkP53OHGXY_cjs.toVirtualStatus(settledFacts),
17162
+ virtualStatus: chunkPWIESIO6_cjs.toVirtualStatus(settledFacts),
16983
17163
  settledBy: commitmentTxid
16984
17164
  });
16985
17165
  } else {
16986
17166
  let sourceAddress;
16987
17167
  try {
16988
- sourceAddress = chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
17168
+ sourceAddress = chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16989
17169
  this.network
16990
17170
  );
16991
17171
  } catch {
@@ -17043,9 +17223,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
17043
17223
  }
17044
17224
  };
17045
17225
  function selectVirtualCoins(coins, targetAmount) {
17046
- const sortedCoins = coins.map(chunkP53OHGXY_cjs.normalizeVtxo).sort((a, b) => {
17047
- const expiryA = chunkP53OHGXY_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
17048
- const expiryB = chunkP53OHGXY_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
17226
+ const sortedCoins = coins.map(chunkPWIESIO6_cjs.normalizeVtxo).sort((a, b) => {
17227
+ const expiryA = chunkPWIESIO6_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
17228
+ const expiryB = chunkPWIESIO6_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
17049
17229
  if (expiryA !== expiryB) {
17050
17230
  return expiryA - expiryB;
17051
17231
  }
@@ -17414,7 +17594,7 @@ var MessageBus = class {
17414
17594
  this.initialized = true;
17415
17595
  }
17416
17596
  async buildServices(config) {
17417
- const arkProvider = new chunkP53OHGXY_cjs.RestArkProvider(config.arkServer.url);
17597
+ const arkProvider = new chunkPWIESIO6_cjs.RestArkProvider(config.arkServer.url);
17418
17598
  const storage = {
17419
17599
  walletRepository: this.walletRepository,
17420
17600
  contractRepository: this.contractRepository,
@@ -17768,7 +17948,7 @@ var offboardNetworkNames = [
17768
17948
  function offboardDestinationScript(destinationAddress) {
17769
17949
  for (const networkName of offboardNetworkNames) {
17770
17950
  try {
17771
- const network = chunkP53OHGXY_cjs.networks[networkName];
17951
+ const network = chunkPWIESIO6_cjs.networks[networkName];
17772
17952
  const addr = btcSigner.Address(network).decode(destinationAddress);
17773
17953
  return btcSigner.OutScript.encode(addr);
17774
17954
  } catch {
@@ -17804,7 +17984,7 @@ function filterOffboardInputs(vtxos, feeInfo, named) {
17804
17984
  const inputs = [];
17805
17985
  let subtotal = 0n;
17806
17986
  for (const vtxo of vtxos) {
17807
- const inputFee = estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo));
17987
+ const inputFee = estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo));
17808
17988
  if (inputFee.satoshis >= vtxo.value) {
17809
17989
  if (named) {
17810
17990
  throw new Error(
@@ -17901,7 +18081,7 @@ var Ramps = class {
17901
18081
  }
17902
18082
  amount = amount ?? totalAmount;
17903
18083
  const offchainAddress = await this.wallet.getAddress();
17904
- const offchainAddr = chunkP53OHGXY_cjs.ArkAddress.decode(offchainAddress);
18084
+ const offchainAddr = chunkPWIESIO6_cjs.ArkAddress.decode(offchainAddress);
17905
18085
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
17906
18086
  const outputFee = estimator.evalOffchainOutput({
17907
18087
  amount,
@@ -17960,7 +18140,8 @@ var Ramps = class {
17960
18140
  if (vtxos) reportUngatedInputs(this.wallet, vtxos);
17961
18141
  const spendable = vtxos ?? await this.wallet.getSpendableVtxos({
17962
18142
  withRecoverable: true,
17963
- withUnrolled: false
18143
+ withUnrolled: false,
18144
+ genericallySpendableOnly: true
17964
18145
  });
17965
18146
  const estimator = new Estimator(feeInfo?.intentFee ?? {});
17966
18147
  const { inputs, subtotal } = filterOffboardInputs(spendable, feeInfo, named);
@@ -18002,7 +18183,8 @@ var Ramps = class {
18002
18183
  if (vtxos) reportUngatedInputs(this.wallet, vtxos);
18003
18184
  const spendable = vtxos ?? await this.wallet.getSpendableVtxos({
18004
18185
  withRecoverable: true,
18005
- withUnrolled: false
18186
+ withUnrolled: false,
18187
+ genericallySpendableOnly: true
18006
18188
  });
18007
18189
  const estimator = new Estimator(feeInfo?.intentFee ?? {});
18008
18190
  const { inputs, subtotal } = filterOffboardInputs(spendable, feeInfo, named);
@@ -18028,7 +18210,7 @@ var Ramps = class {
18028
18210
  async fundChange(left, estimator) {
18029
18211
  if (left <= 0n) return { change: 0n };
18030
18212
  const changeAddress = await this.wallet.getAddress();
18031
- const changeScript = base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(changeAddress).pkScript);
18213
+ const changeScript = base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(changeAddress).pkScript);
18032
18214
  const { change } = changeAfterOutputFee(
18033
18215
  left,
18034
18216
  (amount) => BigInt(estimator.evalOffchainOutput({ amount, script: changeScript }).satoshis)
@@ -18389,7 +18571,7 @@ var WalletMessageHandler = class {
18389
18571
  return this.tagged({
18390
18572
  id,
18391
18573
  type: "SPENDABLE_VTXOS",
18392
- payload: { vtxos }
18574
+ payload: { vtxos, filterApplied: true }
18393
18575
  });
18394
18576
  }
18395
18577
  case "GET_BOARDING_UTXOS": {
@@ -18470,11 +18652,15 @@ var WalletMessageHandler = class {
18470
18652
  }
18471
18653
  case "GET_CONTRACTS_WITH_VTXOS": {
18472
18654
  const manager = await this.readonlyWallet.getContractManager();
18473
- const contracts = await manager.getContractsWithVtxos(message.payload.filter);
18655
+ const contracts = await manager.getContractsWithVtxos(
18656
+ message.payload.filter,
18657
+ void 0,
18658
+ message.payload.options
18659
+ );
18474
18660
  return this.tagged({
18475
18661
  id,
18476
18662
  type: "CONTRACTS_WITH_VTXOS",
18477
- payload: { contracts }
18663
+ payload: { contracts, filterApplied: true }
18478
18664
  });
18479
18665
  }
18480
18666
  case "WATCH_SCRIPT": {
@@ -18857,7 +19043,7 @@ var WalletMessageHandler = class {
18857
19043
  // Wallet methods
18858
19044
  async handleInitWallet({ payload }) {
18859
19045
  const { arkServerUrl } = payload;
18860
- this.indexerProvider = new chunkT327OEMV_cjs.RestIndexerProvider(arkServerUrl);
19046
+ this.indexerProvider = new chunkIAM5IEVT_cjs.RestIndexerProvider(arkServerUrl);
18861
19047
  await this.onWalletInitialized();
18862
19048
  }
18863
19049
  /**
@@ -18871,7 +19057,8 @@ var WalletMessageHandler = class {
18871
19057
  async handleGetBalance() {
18872
19058
  const [boardingUtxos, { snapshot, vtxos: allVtxos }] = await Promise.all([
18873
19059
  this.getAllBoardingUtxos(),
18874
- this.repoSnapshot()
19060
+ // The bucketer drops every spent coin and the gate reads contracts only.
19061
+ this.repoSnapshot({ unspentOnly: true })
18875
19062
  ]);
18876
19063
  const pendingOutpoints = this.readonlyWallet?.pendingRecoveryOutpointsIn(snapshot) ?? /* @__PURE__ */ new Set();
18877
19064
  let confirmed = 0;
@@ -19138,15 +19325,15 @@ var WalletMessageHandler = class {
19138
19325
  if (!this.readonlyWallet) {
19139
19326
  throw new WalletNotInitializedError();
19140
19327
  }
19141
- const allVtxos = await this.getVtxosFromRepo();
19142
- const dustAmount = this.readonlyWallet.dustAmount;
19143
19328
  const withUnrolled = message.payload.filter?.withUnrolled ?? false;
19329
+ const allVtxos = await this.getVtxosFromRepo({ unspentOnly: !withUnrolled });
19330
+ const dustAmount = this.readonlyWallet.dustAmount;
19144
19331
  const includeRecoverable = message.payload.filter?.withRecoverable ?? false;
19145
19332
  return allVtxos.filter((v) => {
19146
19333
  if (v.isUnrolled) {
19147
19334
  return withUnrolled;
19148
19335
  }
19149
- if (chunkP53OHGXY_cjs.hasTerminalSpend(v)) {
19336
+ if (chunkPWIESIO6_cjs.isVtxoSpent(v)) {
19150
19337
  return false;
19151
19338
  }
19152
19339
  if (includeRecoverable) {
@@ -19155,10 +19342,10 @@ var WalletMessageHandler = class {
19155
19342
  if (dustAmount != null && isSubdust(v, dustAmount)) {
19156
19343
  return false;
19157
19344
  }
19158
- if (chunkP53OHGXY_cjs.isRecoverable(v)) {
19345
+ if (chunkPWIESIO6_cjs.isRecoverable(v)) {
19159
19346
  return false;
19160
19347
  }
19161
- if (chunkP53OHGXY_cjs.isExpired(v)) {
19348
+ if (chunkPWIESIO6_cjs.isExpired(v)) {
19162
19349
  return false;
19163
19350
  }
19164
19351
  return true;
@@ -19190,8 +19377,8 @@ var WalletMessageHandler = class {
19190
19377
  * Read all virtual outputs from the repository, aggregated across all contract
19191
19378
  * addresses and the wallet's primary address, with deduplication.
19192
19379
  */
19193
- async getVtxosFromRepo() {
19194
- return (await this.repoSnapshot()).vtxos;
19380
+ async getVtxosFromRepo(options) {
19381
+ return (await this.repoSnapshot(options)).vtxos;
19195
19382
  }
19196
19383
  /**
19197
19384
  * The worker's equivalent of `ReadonlyWallet.contractSnapshot`: contracts
@@ -19206,7 +19393,7 @@ var WalletMessageHandler = class {
19206
19393
  * what it knows is closed — so the coins of a just-registered escrowed
19207
19394
  * contract would count as available until the next poll.
19208
19395
  */
19209
- async repoSnapshot() {
19396
+ async repoSnapshot(options) {
19210
19397
  if (!this.walletRepository || !this.readonlyWallet) return { snapshot: [], vtxos: [] };
19211
19398
  const seen = /* @__PURE__ */ new Set();
19212
19399
  const allVtxos = [];
@@ -19228,7 +19415,9 @@ var WalletMessageHandler = class {
19228
19415
  for (const contract of contracts) {
19229
19416
  snapshot.push({
19230
19417
  contract,
19231
- vtxos: addVtxos(await getVtxosForContract(this.walletRepository, contract))
19418
+ vtxos: addVtxos(
19419
+ await getVtxosForContract(this.walletRepository, contract, options)
19420
+ )
19232
19421
  });
19233
19422
  }
19234
19423
  const walletAddress = await this.readonlyWallet.getAddress();
@@ -19241,10 +19430,11 @@ var WalletMessageHandler = class {
19241
19430
  );
19242
19431
  }
19243
19432
  addVtxos(
19244
- await getVtxosForContract(this.walletRepository, {
19245
- script: walletScript,
19246
- address: walletAddress
19247
- })
19433
+ await getVtxosForContract(
19434
+ this.walletRepository,
19435
+ { script: walletScript, address: walletAddress },
19436
+ options
19437
+ )
19248
19438
  );
19249
19439
  return { snapshot, vtxos: allVtxos };
19250
19440
  }
@@ -19266,7 +19456,7 @@ var WalletMessageHandler = class {
19266
19456
  this.readonlyWallet.getBoardingTxs()
19267
19457
  ]);
19268
19458
  const indexerProvider = this.indexerProvider;
19269
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunkP53OHGXY_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19459
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunkPWIESIO6_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19270
19460
  return buildTransactionHistory(
19271
19461
  vtxos,
19272
19462
  boardingTxs,
@@ -19974,7 +20164,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19974
20164
  };
19975
20165
  try {
19976
20166
  const response = await this.sendMessage(message);
19977
- return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
20167
+ return response.payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
19978
20168
  } catch (error) {
19979
20169
  throw new Error(`Failed to get vtxos: ${error}`);
19980
20170
  }
@@ -19999,7 +20189,13 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19999
20189
  };
20000
20190
  try {
20001
20191
  const response = await this.sendMessage(message);
20002
- return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
20192
+ const payload = response.payload;
20193
+ if ((filter?.watchedOnly || filter?.genericallySpendableOnly || filter?.requireSynced) && payload.filterApplied !== true) {
20194
+ throw new Error(
20195
+ "Service worker does not support the requested contract scope or freshness check"
20196
+ );
20197
+ }
20198
+ return payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
20003
20199
  } catch (error) {
20004
20200
  throw new Error(`Failed to get spendable vtxos: ${error}`);
20005
20201
  }
@@ -20084,15 +20280,20 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20084
20280
  throw new Error("Failed to get contracts");
20085
20281
  }
20086
20282
  },
20087
- async getContractsWithVtxos(filter) {
20283
+ async getContractsWithVtxos(filter, _pageSize, options) {
20088
20284
  const message = {
20089
20285
  type: "GET_CONTRACTS_WITH_VTXOS",
20090
20286
  id: getRandomId(),
20091
20287
  tag: messageTag,
20092
- payload: { filter }
20288
+ payload: { filter, options }
20093
20289
  };
20094
20290
  try {
20095
20291
  const response = await sendContractMessage(message);
20292
+ if (options?.requireSynced && response.payload.filterApplied !== true) {
20293
+ throw new Error(
20294
+ "Service worker does not support the requested freshness check"
20295
+ );
20296
+ }
20096
20297
  await refreshSyncState();
20097
20298
  return response.payload.contracts;
20098
20299
  } catch (e) {
@@ -20170,7 +20371,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
20170
20371
  };
20171
20372
  try {
20172
20373
  const response = await sendContractMessage(message);
20173
- return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
20374
+ return response.payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
20174
20375
  } catch (e) {
20175
20376
  throw new Error("Failed to annotate vtxos");
20176
20377
  }
@@ -20782,7 +20983,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
20782
20983
  };
20783
20984
  try {
20784
20985
  const response = await wallet.sendMessage(message);
20785
- return response.payload.vtxos.map(chunkP53OHGXY_cjs.normalizeVtxo);
20986
+ return response.payload.vtxos.map(chunkPWIESIO6_cjs.normalizeVtxo);
20786
20987
  } catch (e) {
20787
20988
  throw new Error(`Failed to get expiring vtxos: ${e}`);
20788
20989
  }
@@ -20894,12 +21095,12 @@ var OnchainWallet = class _OnchainWallet {
20894
21095
  * @returns Configured onchain wallet
20895
21096
  * @throws Error if the configured identity cannot produce a valid x-only public key
20896
21097
  */
20897
- static async create(identity, networkName = chunkP53OHGXY_cjs.DEFAULT_NETWORK_NAME, provider) {
21098
+ static async create(identity, networkName = chunkPWIESIO6_cjs.DEFAULT_NETWORK_NAME, provider) {
20898
21099
  const pubkey = await identity.xOnlyPublicKey();
20899
21100
  if (!pubkey) {
20900
21101
  throw new Error("Invalid configured public key");
20901
21102
  }
20902
- const network = chunkP53OHGXY_cjs.getNetwork(networkName);
21103
+ const network = chunkPWIESIO6_cjs.getNetwork(networkName);
20903
21104
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
20904
21105
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
20905
21106
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -21005,7 +21206,7 @@ var OnchainWallet = class _OnchainWallet {
21005
21206
  if (!inputs) {
21006
21207
  throw new Error("Fee estimation failed");
21007
21208
  }
21008
- let tx = new chunkP53OHGXY_cjs.Transaction();
21209
+ let tx = new chunkPWIESIO6_cjs.Transaction();
21009
21210
  for (const input of inputs) {
21010
21211
  tx.addInput({
21011
21212
  txid: input.txid,
@@ -21063,7 +21264,7 @@ var OnchainWallet = class _OnchainWallet {
21063
21264
  * @throws If the parent has no anchor, or funding cannot be selected/signed
21064
21265
  */
21065
21266
  async bumpAnchor(parentHex, feeRate) {
21066
- const parent = chunkP53OHGXY_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
21267
+ const parent = chunkPWIESIO6_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
21067
21268
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
21068
21269
  const child = await this.buildBumpPackage(parent, feeRate, coins);
21069
21270
  return [parent.hex, child.hex];
@@ -21970,7 +22171,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21970
22171
  try {
21971
22172
  const { txs } = await source.getVirtualTxs(wanted);
21972
22173
  for (const psbt of txs) {
21973
- const tx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
22174
+ const tx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21974
22175
  resolved.set(tx.id, tx.toBytes());
21975
22176
  }
21976
22177
  } catch (err) {
@@ -22003,7 +22204,7 @@ async function resolvePrevTxs(txids, source, onchain) {
22003
22204
  async function attachPrevArkTxs(tx, txids, source, onchain) {
22004
22205
  const pending = [];
22005
22206
  for (let i = 0; i < tx.inputsLength; i++) {
22006
- if (chunkP53OHGXY_cjs.getArkPsbtFields(tx, i, chunkP53OHGXY_cjs.PrevArkTxField).length === 0) pending.push(i);
22207
+ if (chunkPWIESIO6_cjs.getArkPsbtFields(tx, i, chunkPWIESIO6_cjs.PrevArkTxField).length === 0) pending.push(i);
22007
22208
  }
22008
22209
  if (pending.length === 0) return;
22009
22210
  const resolved = await resolvePrevTxs(
@@ -22012,13 +22213,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
22012
22213
  onchain
22013
22214
  );
22014
22215
  for (const i of pending) {
22015
- chunkP53OHGXY_cjs.setArkPsbtField(tx, i, chunkP53OHGXY_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
22216
+ chunkPWIESIO6_cjs.setArkPsbtField(tx, i, chunkPWIESIO6_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
22016
22217
  }
22017
22218
  }
22018
22219
  async function attachPrevoutTxs(tx, source) {
22019
22220
  const pending = [];
22020
22221
  for (let i = 0; i < tx.inputsLength; i++) {
22021
- if (chunkP53OHGXY_cjs.getArkPsbtFields(tx, i, chunkP53OHGXY_cjs.PrevoutTxField).length > 0) continue;
22222
+ if (chunkPWIESIO6_cjs.getArkPsbtFields(tx, i, chunkPWIESIO6_cjs.PrevoutTxField).length > 0) continue;
22022
22223
  const input = tx.getInput(i);
22023
22224
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
22024
22225
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -22029,7 +22230,7 @@ async function attachPrevoutTxs(tx, source) {
22029
22230
  resolved.set(txid, await source.getRawTransaction(txid));
22030
22231
  }
22031
22232
  for (const { index, txid } of pending) {
22032
- chunkP53OHGXY_cjs.setArkPsbtField(tx, index, chunkP53OHGXY_cjs.PrevoutTxField, resolved.get(txid));
22233
+ chunkPWIESIO6_cjs.setArkPsbtField(tx, index, chunkPWIESIO6_cjs.PrevoutTxField, resolved.get(txid));
22033
22234
  }
22034
22235
  }
22035
22236
  async function withPrevTxs(coins, source, onchain) {
@@ -22055,7 +22256,7 @@ exports.BIP322 = void 0;
22055
22256
  async function sign2(message, identity, network) {
22056
22257
  const xOnlyPubKey = await identity.xOnlyPublicKey();
22057
22258
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
22058
- const toSpend = chunkP53OHGXY_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
22259
+ const toSpend = chunkPWIESIO6_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
22059
22260
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
22060
22261
  const signed = await identity.sign(toSign, [0]);
22061
22262
  signed.finalizeIdx(0);
@@ -22113,7 +22314,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
22113
22314
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
22114
22315
  return false;
22115
22316
  }
22116
- const toSpend = chunkP53OHGXY_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22317
+ const toSpend = chunkPWIESIO6_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22117
22318
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
22118
22319
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
22119
22320
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -22134,7 +22335,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
22134
22335
  }
22135
22336
  const sighashType = sigWithHash[sigWithHash.length - 1];
22136
22337
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
22137
- const toSpend = chunkP53OHGXY_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22338
+ const toSpend = chunkPWIESIO6_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
22138
22339
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
22139
22340
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
22140
22341
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -22187,7 +22388,7 @@ function encodeCompactSize(n) {
22187
22388
  return buf;
22188
22389
  }
22189
22390
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
22190
- const tx = new chunkP53OHGXY_cjs.Transaction({ version: 0 });
22391
+ const tx = new chunkPWIESIO6_cjs.Transaction({ version: 0 });
22191
22392
  tx.addInput({
22192
22393
  txid: toSpend.id,
22193
22394
  index: 0,
@@ -22201,12 +22402,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
22201
22402
  });
22202
22403
  tx.addOutput({
22203
22404
  amount: 0n,
22204
- script: chunkP53OHGXY_cjs.OP_RETURN_EMPTY_PKSCRIPT
22405
+ script: chunkPWIESIO6_cjs.OP_RETURN_EMPTY_PKSCRIPT
22205
22406
  });
22206
22407
  return tx;
22207
22408
  }
22208
22409
  function craftBIP322ToSignSimple(toSpend, pkScript) {
22209
- const tx = new chunkP53OHGXY_cjs.Transaction({ version: 0 });
22410
+ const tx = new chunkPWIESIO6_cjs.Transaction({ version: 0 });
22210
22411
  tx.addInput({
22211
22412
  txid: toSpend.id,
22212
22413
  index: 0,
@@ -22218,7 +22419,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
22218
22419
  });
22219
22420
  tx.addOutput({
22220
22421
  amount: 0n,
22221
- script: chunkP53OHGXY_cjs.OP_RETURN_EMPTY_PKSCRIPT
22422
+ script: chunkPWIESIO6_cjs.OP_RETURN_EMPTY_PKSCRIPT
22222
22423
  });
22223
22424
  return tx;
22224
22425
  }
@@ -22231,7 +22432,7 @@ var RestEmulatorProvider = class {
22231
22432
  serverUrl;
22232
22433
  async getInfo() {
22233
22434
  const url = `${this.serverUrl}/v1/info`;
22234
- const response = await chunkP53OHGXY_cjs.baseFetch(url);
22435
+ const response = await chunkPWIESIO6_cjs.baseFetch(url);
22235
22436
  if (!response.ok) {
22236
22437
  const errorText2 = await response.text();
22237
22438
  throw new Error(`Failed to get emulator info: ${errorText2}`);
@@ -22349,7 +22550,7 @@ var RestEmulatorProvider = class {
22349
22550
  }
22350
22551
  };
22351
22552
  function finalizeVirtualTx(type, psbtBase64) {
22352
- const tx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22553
+ const tx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22353
22554
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
22354
22555
  const input = tx.getInput(0);
22355
22556
  if (!input) {
@@ -22376,14 +22577,14 @@ var ExitPathError = class extends Error {
22376
22577
  reason;
22377
22578
  };
22378
22579
  function delayWeight(sequence) {
22379
- const t = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
22580
+ const t = chunkPWIESIO6_cjs.sequenceToTimelock(sequence);
22380
22581
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
22381
22582
  }
22382
22583
  async function resolveUnilateralPath(params) {
22383
22584
  const { vtxo, scriptHex, contractRepository } = params;
22384
22585
  const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
22385
22586
  if (contract) {
22386
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
22587
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
22387
22588
  if (!handler) {
22388
22589
  throw new ExitPathError(
22389
22590
  "no-handler",
@@ -22406,12 +22607,12 @@ async function resolveUnilateralPath(params) {
22406
22607
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
22407
22608
  return { selection: paths[0], label: `${contract.type}:unilateral` };
22408
22609
  }
22409
- const decoded = chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree);
22610
+ const decoded = chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree);
22410
22611
  let best;
22411
22612
  for (const exit of decoded.exitPaths()) {
22412
22613
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
22413
22614
  if (!leaf) continue;
22414
- const sequence = chunkP53OHGXY_cjs.timelockToSequence(exit.params.timelock);
22615
+ const sequence = chunkPWIESIO6_cjs.timelockToSequence(exit.params.timelock);
22415
22616
  const weight = delayWeight(sequence);
22416
22617
  if (!best || weight < best.weight) {
22417
22618
  best = { selection: { leaf, sequence }, weight };
@@ -22631,7 +22832,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22631
22832
  let totalAmount = 0n;
22632
22833
  const txWeightEstimator = TxWeightEstimator.create();
22633
22834
  for (const vtxo of vtxos) {
22634
- if (!chunkP53OHGXY_cjs.canSweepOnchain(vtxo)) {
22835
+ if (!chunkPWIESIO6_cjs.canSweepOnchain(vtxo)) {
22635
22836
  throw new Error(
22636
22837
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
22637
22838
  );
@@ -22642,14 +22843,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22642
22843
  }
22643
22844
  const resolved = await resolveUnilateralPath({
22644
22845
  vtxo,
22645
- scriptHex: base.hex.encode(chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22846
+ scriptHex: base.hex.encode(chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22646
22847
  contractRepository: wallet.contractRepository,
22647
22848
  walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
22648
22849
  currentTime: Date.now()
22649
22850
  });
22650
22851
  const spendingLeaf = resolved.selection.leaf;
22651
22852
  const sequence = resolved.selection.sequence;
22652
- const timelock = chunkP53OHGXY_cjs.sequenceToTimelock(sequence);
22853
+ const timelock = chunkPWIESIO6_cjs.sequenceToTimelock(sequence);
22653
22854
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
22654
22855
  if (!elapsed) {
22655
22856
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -22662,7 +22863,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22662
22863
  sequence,
22663
22864
  witnessUtxo: {
22664
22865
  amount: BigInt(vtxo.value),
22665
- script: chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22866
+ script: chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22666
22867
  },
22667
22868
  sighashType: btcSigner.SigHash.DEFAULT
22668
22869
  });
@@ -22672,7 +22873,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22672
22873
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
22673
22874
  );
22674
22875
  }
22675
- const tx = new chunkP53OHGXY_cjs.Transaction({ version: 2 });
22876
+ const tx = new chunkPWIESIO6_cjs.Transaction({ version: 2 });
22676
22877
  for (const input of inputs) {
22677
22878
  tx.addInput(input);
22678
22879
  }
@@ -22755,7 +22956,7 @@ async function buildSignedSweep(params) {
22755
22956
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
22756
22957
  );
22757
22958
  }
22758
- const tx = new chunkP53OHGXY_cjs.Transaction({ version: 2 });
22959
+ const tx = new chunkPWIESIO6_cjs.Transaction({ version: 2 });
22759
22960
  tx.addInput({
22760
22961
  txid: vtxo.txid,
22761
22962
  index: vtxo.vout,
@@ -22780,7 +22981,7 @@ async function buildSignedSweep(params) {
22780
22981
  finalScriptWitness: [
22781
22982
  tapScriptSig[0][1],
22782
22983
  ...path.extraWitness,
22783
- chunkP53OHGXY_cjs.scriptFromTapLeafScript(path.leaf),
22984
+ chunkPWIESIO6_cjs.scriptFromTapLeafScript(path.leaf),
22784
22985
  btcSigner.TaprootControlBlock.encode(controlBlock)
22785
22986
  ]
22786
22987
  });
@@ -22810,7 +23011,7 @@ async function resolveFeeRate(opts) {
22810
23011
  }
22811
23012
  async function selectExitVtxos(opts) {
22812
23013
  if (!opts.vtxos) return opts.wallet.getVtxos();
22813
- const res = await chunkP53OHGXY_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
23014
+ const res = await chunkPWIESIO6_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22814
23015
  const tapTrees = /* @__PURE__ */ new Map();
22815
23016
  const out = [];
22816
23017
  for (const vtxo of res.vtxos) {
@@ -22825,7 +23026,7 @@ async function selectExitVtxos(opts) {
22825
23026
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
22826
23027
  );
22827
23028
  }
22828
- const handler = chunkCQNX4BTA_cjs.contractHandlers.get(contract.type);
23029
+ const handler = chunkY7BVR6SQ_cjs.contractHandlers.get(contract.type);
22829
23030
  if (!handler) {
22830
23031
  throw new Error(`no contract handler registered for type '${contract.type}'`);
22831
23032
  }
@@ -22855,7 +23056,7 @@ async function computeExitLayout(opts, feeRate) {
22855
23056
  if (pendingNodes.length > 0) {
22856
23057
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
22857
23058
  for (const psbt of txs) {
22858
- psbts.set(chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
23059
+ psbts.set(chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22859
23060
  }
22860
23061
  }
22861
23062
  const childVsize = Number(
@@ -22891,7 +23092,7 @@ async function computeExitLayout(opts, feeRate) {
22891
23092
  try {
22892
23093
  const resolved = await resolveUnilateralPath({
22893
23094
  vtxo,
22894
- scriptHex: base.hex.encode(chunkP53OHGXY_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
23095
+ scriptHex: base.hex.encode(chunkPWIESIO6_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22895
23096
  contractRepository: wallet.contractRepository,
22896
23097
  walletPubKeyHex,
22897
23098
  currentTime: Date.now()
@@ -22910,7 +23111,7 @@ async function computeExitLayout(opts, feeRate) {
22910
23111
  });
22911
23112
  continue;
22912
23113
  }
22913
- const t = chunkP53OHGXY_cjs.sequenceToTimelock(resolved.selection.sequence);
23114
+ const t = chunkPWIESIO6_cjs.sequenceToTimelock(resolved.selection.sequence);
22914
23115
  const delay = { type: t.type, value: Number(t.value) };
22915
23116
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
22916
23117
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -23311,7 +23512,7 @@ async function prepare(opts) {
23311
23512
  txid: sweep.vtxo.txid,
23312
23513
  vout: sweep.vtxo.vout,
23313
23514
  value: sweep.vtxo.value,
23314
- pkScript: chunkP53OHGXY_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23515
+ pkScript: chunkPWIESIO6_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23315
23516
  },
23316
23517
  path: sweep.resolved.selection,
23317
23518
  outputAddress: opts.sweepAddress,
@@ -23400,7 +23601,7 @@ async function prepare(opts) {
23400
23601
  if (newFee <= splitterFee) break;
23401
23602
  splitterFee = newFee;
23402
23603
  }
23403
- const splitter = new chunkP53OHGXY_cjs.Transaction({ version: 2 });
23604
+ const splitter = new chunkPWIESIO6_cjs.Transaction({ version: 2 });
23404
23605
  for (const coin of selected.inputs) {
23405
23606
  splitter.addInput({
23406
23607
  txid: coin.txid,
@@ -23544,41 +23745,43 @@ var UnilateralExit = {
23544
23745
  // src/arkade/index.ts
23545
23746
  var arkade_exports = {};
23546
23747
  chunk5BLDMQED_cjs.__export(arkade_exports, {
23547
- ARKADE_OP: () => chunkCQNX4BTA_cjs.ARKADE_OP,
23548
- ARKADE_OPCODES: () => chunkCQNX4BTA_cjs.ARKADE_OPCODES,
23549
- ARKADE_OPCODE_NAMES: () => chunkCQNX4BTA_cjs.ARKADE_OPCODE_NAMES,
23550
- ARKADE_OPCODE_VALUES: () => chunkCQNX4BTA_cjs.ARKADE_OPCODE_VALUES,
23551
- ARKADE_OPS: () => chunkCQNX4BTA_cjs.ARKADE_OPS,
23748
+ ARKADE_OP: () => chunkY7BVR6SQ_cjs.ARKADE_OP,
23749
+ ARKADE_OPCODES: () => chunkY7BVR6SQ_cjs.ARKADE_OPCODES,
23750
+ ARKADE_OPCODE_NAMES: () => chunkY7BVR6SQ_cjs.ARKADE_OPCODE_NAMES,
23751
+ ARKADE_OPCODE_VALUES: () => chunkY7BVR6SQ_cjs.ARKADE_OPCODE_VALUES,
23752
+ ARKADE_OPS: () => chunkY7BVR6SQ_cjs.ARKADE_OPS,
23552
23753
  Arkade: () => Arkade,
23553
23754
  ArkadeContract: () => ArkadeContract,
23554
- ArkadeProgramScript: () => chunkCQNX4BTA_cjs.ArkadeProgramScript,
23555
- ArkadeScript: () => chunkCQNX4BTA_cjs.ArkadeScript,
23755
+ ArkadeProgramScript: () => chunkY7BVR6SQ_cjs.ArkadeProgramScript,
23756
+ ArkadeScript: () => chunkY7BVR6SQ_cjs.ArkadeScript,
23556
23757
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
23557
- BigNum: () => chunkCQNX4BTA_cjs.bignum_exports,
23758
+ BigNum: () => chunkY7BVR6SQ_cjs.bignum_exports,
23558
23759
  OP: () => btcSigner.OP,
23559
- OPCODE_NAMES: () => chunkCQNX4BTA_cjs.OPCODE_NAMES,
23560
- OPCODE_VALUES: () => chunkCQNX4BTA_cjs.OPCODE_VALUES,
23561
- SUPPORTED_PROGRAM_VERSION: () => chunkCQNX4BTA_cjs.SUPPORTED_PROGRAM_VERSION,
23760
+ OPCODE_NAMES: () => chunkY7BVR6SQ_cjs.OPCODE_NAMES,
23761
+ OPCODE_VALUES: () => chunkY7BVR6SQ_cjs.OPCODE_VALUES,
23762
+ SUPPORTED_PROGRAM_VERSION: () => chunkY7BVR6SQ_cjs.SUPPORTED_PROGRAM_VERSION,
23562
23763
  Script: () => btcSigner.Script,
23563
- arkadeScriptHash: () => chunkCQNX4BTA_cjs.arkadeScriptHash,
23564
- arkadeWitnessHash: () => chunkCQNX4BTA_cjs.arkadeWitnessHash,
23565
- asmToBytes: () => chunkCQNX4BTA_cjs.asmToBytes,
23566
- bytesToASM: () => chunkCQNX4BTA_cjs.bytesToASM,
23567
- computeArkadeScriptPublicKey: () => chunkCQNX4BTA_cjs.computeArkadeScriptPublicKey,
23764
+ arkadeScriptHash: () => chunkY7BVR6SQ_cjs.arkadeScriptHash,
23765
+ arkadeWitnessHash: () => chunkY7BVR6SQ_cjs.arkadeWitnessHash,
23766
+ asmToBytes: () => chunkY7BVR6SQ_cjs.asmToBytes,
23767
+ bytesToASM: () => chunkY7BVR6SQ_cjs.bytesToASM,
23768
+ computeArkadeScriptPublicKey: () => chunkY7BVR6SQ_cjs.computeArkadeScriptPublicKey,
23568
23769
  createArkadeBatchHandler: () => createArkadeBatchHandler,
23569
- deserializeArkadeContractParams: () => chunkCQNX4BTA_cjs.deserializeArkadeContractParams,
23570
- fromASM: () => chunkCQNX4BTA_cjs.fromASM,
23571
- getOpcodeName: () => chunkCQNX4BTA_cjs.getOpcodeName,
23572
- getOpcodeValue: () => chunkCQNX4BTA_cjs.getOpcodeValue,
23573
- parseArtifact: () => chunkCQNX4BTA_cjs.parseArtifact,
23574
- resolveAsm: () => chunkCQNX4BTA_cjs.resolveAsm,
23575
- serializeArkadeContractParams: () => chunkCQNX4BTA_cjs.serializeArkadeContractParams,
23576
- stringifyArtifact: () => chunkCQNX4BTA_cjs.stringifyArtifact,
23577
- toASM: () => chunkCQNX4BTA_cjs.toASM,
23578
- validateProgram: () => chunkCQNX4BTA_cjs.validateProgram,
23579
- witnessRefToBytes: () => chunkCQNX4BTA_cjs.witnessRefToBytes
23770
+ deserializeArkadeContractParams: () => chunkY7BVR6SQ_cjs.deserializeArkadeContractParams,
23771
+ fromASM: () => chunkY7BVR6SQ_cjs.fromASM,
23772
+ getOpcodeName: () => chunkY7BVR6SQ_cjs.getOpcodeName,
23773
+ getOpcodeValue: () => chunkY7BVR6SQ_cjs.getOpcodeValue,
23774
+ isContractArtifact: () => isContractArtifact,
23775
+ parseArtifact: () => chunkY7BVR6SQ_cjs.parseArtifact,
23776
+ programFromArtifact: () => programFromArtifact,
23777
+ resolveAsm: () => chunkY7BVR6SQ_cjs.resolveAsm,
23778
+ serializeArkadeContractParams: () => chunkY7BVR6SQ_cjs.serializeArkadeContractParams,
23779
+ stringifyArtifact: () => chunkY7BVR6SQ_cjs.stringifyArtifact,
23780
+ toASM: () => chunkY7BVR6SQ_cjs.toASM,
23781
+ validateProgram: () => chunkY7BVR6SQ_cjs.validateProgram,
23782
+ witnessRefToBytes: () => chunkY7BVR6SQ_cjs.witnessRefToBytes
23580
23783
  });
23581
- var isVtxoCoin = (input) => chunkP53OHGXY_cjs.isVirtualCoin(input);
23784
+ var isVtxoCoin = (input) => chunkPWIESIO6_cjs.isVirtualCoin(input);
23582
23785
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
23583
23786
  let batchId;
23584
23787
  let sweepTapTreeRoot;
@@ -23599,23 +23802,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23599
23802
  );
23600
23803
  await arkProvider.confirmRegistration(intentId);
23601
23804
  batchId = event.id;
23602
- const sweepTapscript = chunkP53OHGXY_cjs.CSVMultisigTapscript.encode({
23805
+ const sweepTapscript = chunkPWIESIO6_cjs.CSVMultisigTapscript.encode({
23603
23806
  timelock,
23604
- pubkeys: [chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23807
+ pubkeys: [chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23605
23808
  }).script;
23606
23809
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
23607
23810
  return { skip: false };
23608
23811
  },
23609
23812
  onTreeSigningStarted: async (event, vtxoTree) => {
23610
23813
  const signerPubKey = await session.getPublicKey();
23611
- const xonlySignerPubKey = chunkCQNX4BTA_cjs.toXOnly(signerPubKey, "signer key");
23814
+ const xonlySignerPubKey = chunkY7BVR6SQ_cjs.toXOnly(signerPubKey, "signer key");
23612
23815
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
23613
- (k) => base.hex.encode(chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23816
+ (k) => base.hex.encode(chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23614
23817
  );
23615
23818
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
23616
23819
  return { skip: true };
23617
23820
  }
23618
- const commitmentTx = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23821
+ const commitmentTx = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23619
23822
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
23620
23823
  if (recipients && recipients.length > 0) {
23621
23824
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -23653,7 +23856,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23653
23856
  if (connectorTree) {
23654
23857
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
23655
23858
  }
23656
- let commitmentPsbt = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23859
+ let commitmentPsbt = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23657
23860
  assertFinalCommitmentMatchesValidated(
23658
23861
  commitmentPsbt,
23659
23862
  validatedCommitmentTxid,
@@ -23695,7 +23898,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23695
23898
  boardingIndices.push(boardingIdx);
23696
23899
  continue;
23697
23900
  }
23698
- if (chunkP53OHGXY_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
23901
+ if (!chunkPWIESIO6_cjs.requiresForfeit(input) || isSubdust(input, info.dust)) {
23699
23902
  continue;
23700
23903
  }
23701
23904
  if (connectorIndex >= connectorLeaves.length) {
@@ -23716,7 +23919,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23716
23919
  index: input.vout,
23717
23920
  witnessUtxo: {
23718
23921
  amount: BigInt(input.value),
23719
- script: chunkP53OHGXY_cjs.VtxoScript.decode(input.tapTree).pkScript
23922
+ script: chunkPWIESIO6_cjs.VtxoScript.decode(input.tapTree).pkScript
23720
23923
  },
23721
23924
  sighashType: btcSigner.SigHash.DEFAULT,
23722
23925
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -23768,6 +23971,271 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23768
23971
  }
23769
23972
  };
23770
23973
  }
23974
+ var NATIVE_STRUCTS = {
23975
+ AssetId: [
23976
+ ["txid", "bytes32"],
23977
+ ["gidx", "int"]
23978
+ ],
23979
+ Outpoint: [
23980
+ ["txid", "bytes32"],
23981
+ ["vout", "int"]
23982
+ ],
23983
+ ECPoint: [
23984
+ ["x", "int"],
23985
+ ["y", "int"]
23986
+ ]
23987
+ };
23988
+ var HASH_OPCODES = /* @__PURE__ */ new Set(["OP_SHA256", "OP_HASH160", "OP_HASH256", "OP_RIPEMD160"]);
23989
+ function isRecord(value) {
23990
+ return typeof value === "object" && value !== null && !Array.isArray(value);
23991
+ }
23992
+ function isNamed(value) {
23993
+ return isRecord(value) && typeof value.name === "string" && typeof value.type === "string" && value.type.length > 0;
23994
+ }
23995
+ function isContractArtifact(value) {
23996
+ if (!isRecord(value) || typeof value.contractName !== "string") return false;
23997
+ if (!Array.isArray(value.constructorInputs)) return false;
23998
+ if (value.structs !== void 0 && !Array.isArray(value.structs)) return false;
23999
+ if (!Array.isArray(value.functions) || value.functions.length === 0) return false;
24000
+ return value.functions.every(
24001
+ (group) => isRecord(group) && typeof group.name === "string" && Array.isArray(group.leaves) && group.leaves.length > 0
24002
+ );
24003
+ }
24004
+ function fail(detail) {
24005
+ throw new Error(`programFromArtifact: ${detail}`);
24006
+ }
24007
+ function claim(seen, name, kind) {
24008
+ if (seen.has(name)) fail(`duplicate ${kind} '${name}'`);
24009
+ seen.add(name);
24010
+ }
24011
+ var SCALAR_TYPES = {
24012
+ pubkey: "pubkey",
24013
+ signature: "sig",
24014
+ bytes: "bytes",
24015
+ bytes20: "hash",
24016
+ bytes32: "hash",
24017
+ asset: "hash",
24018
+ int: "int",
24019
+ bool: "int"
24020
+ };
24021
+ function argType(arkType) {
24022
+ if (!Object.hasOwn(SCALAR_TYPES, arkType)) fail(`unknown type '${arkType}'`);
24023
+ return SCALAR_TYPES[arkType];
24024
+ }
24025
+ function arrayParts(type) {
24026
+ const open = type.indexOf("[");
24027
+ if (open < 0 || !type.endsWith("]")) return [type, 0];
24028
+ const length = Number(type.slice(open + 1, -1));
24029
+ return Number.isInteger(length) && length > 0 ? [type.slice(0, open), length] : [type, 0];
24030
+ }
24031
+ function flatten(param, structs, stack = []) {
24032
+ if (!isNamed(param)) fail("parameter needs a name and a type");
24033
+ if (Object.hasOwn(NATIVE_STRUCTS, param.type)) {
24034
+ return NATIVE_STRUCTS[param.type].map(([field, type]) => ({
24035
+ name: `${param.name}.${field}`,
24036
+ type: argType(type)
24037
+ }));
24038
+ }
24039
+ const declared = structs.find((struct) => struct?.name === param.type);
24040
+ if (declared) {
24041
+ if (stack.includes(param.type)) fail(`recursive struct layout '${param.type}'`);
24042
+ return declared.fields.flatMap(
24043
+ (field) => flatten({ name: `${param.name}.${field.name}`, type: field.type }, structs, [
24044
+ ...stack,
24045
+ param.type
24046
+ ])
24047
+ );
24048
+ }
24049
+ const [element, length] = arrayParts(param.type);
24050
+ if (length === 0) {
24051
+ if (param.type.includes("[") || param.type.includes("]")) {
24052
+ fail(`invalid array type '${param.type}'`);
24053
+ }
24054
+ return [{ name: param.name, type: argType(param.type) }];
24055
+ }
24056
+ if (Object.hasOwn(NATIVE_STRUCTS, element) || structs.some((struct) => struct.name === element)) {
24057
+ fail(`arrays of structs are not supported: '${param.type}'`);
24058
+ }
24059
+ return Array.from({ length }, (_, index) => ({
24060
+ name: `${param.name}.${index}`,
24061
+ type: argType(element)
24062
+ }));
24063
+ }
24064
+ function opcodeToken(token) {
24065
+ const base = token.slice(3);
24066
+ const name = base === "0" || /^([1-9]|1[0-6])$/.test(base) ? token : base;
24067
+ if (!Object.hasOwn(chunkY7BVR6SQ_cjs.ARKADE_OPS, name)) {
24068
+ fail(`opcode '${token}' is not in this SDK's table`);
24069
+ }
24070
+ return name;
24071
+ }
24072
+ function instantiationParam(body) {
24073
+ return `contract_${body.replace(/[^A-Za-z0-9]+/g, "_")}`.replace(/_+$/, "");
24074
+ }
24075
+ function asmToken(token, instantiations) {
24076
+ if (token.startsWith("OP_")) return opcodeToken(token);
24077
+ if (token.startsWith("<") && token.endsWith(">")) {
24078
+ const inner = token.slice(1, -1);
24079
+ if (inner.startsWith("CONTRACT:")) {
24080
+ const body = inner.slice("CONTRACT:".length);
24081
+ const name = instantiationParam(body);
24082
+ const seen = instantiations.get(name);
24083
+ if (seen !== void 0 && seen !== body) {
24084
+ fail(`instantiations '${seen}' and '${body}' both map to parameter '${name}'`);
24085
+ }
24086
+ instantiations.set(name, body);
24087
+ return `$${name}`;
24088
+ }
24089
+ if (inner.startsWith("VTXO:")) {
24090
+ fail(`'${token}' is not a placeholder; the compiler emits <CONTRACT:\u2026>`);
24091
+ }
24092
+ if (inner === "SERVER_KEY" || inner.startsWith("EMULATOR_KEY:")) {
24093
+ fail(`${token} is a signer role and cannot appear in a covenant`);
24094
+ }
24095
+ return `$${inner}`;
24096
+ }
24097
+ if (token.startsWith("0x")) return base.hex.decode(token.slice(2));
24098
+ try {
24099
+ return BigInt(token);
24100
+ } catch {
24101
+ fail(`unrecognized assembly token '${token}'`);
24102
+ }
24103
+ }
24104
+ function providedWitness(witness) {
24105
+ if (witness === void 0) return [];
24106
+ if (!Array.isArray(witness)) fail("leaf witness must be an array");
24107
+ return witness.filter((item) => {
24108
+ if (!isNamed(item)) fail("witness item needs a name and a type");
24109
+ return !item.injected && item.type !== "signature";
24110
+ });
24111
+ }
24112
+ function csvTimelock(leafName, operand) {
24113
+ if (typeof operand === "string") return { type: "blocks", value: operand };
24114
+ const timelock = operand >= 0n && operand < 0x80000000n ? chunkPWIESIO6_cjs.sequenceToTimelock(Number(operand)) : void 0;
24115
+ if (!timelock || BigInt(chunkPWIESIO6_cjs.timelockToSequence(timelock)) !== operand) {
24116
+ fail(`leaf '${leafName}': CSV literal ${operand} is not a canonical BIP68 sequence`);
24117
+ }
24118
+ return timelock;
24119
+ }
24120
+ function parseLeaf(leaf, hasCovenant, instantiations, extras) {
24121
+ const asm = leaf.asm;
24122
+ let index = 0;
24123
+ let condition;
24124
+ if (asm.length >= 4 && HASH_OPCODES.has(asm[0]) && asm[2] === "OP_EQUAL") {
24125
+ if (asm[3] !== "OP_VERIFY")
24126
+ fail(`leaf '${leaf.name}': hash condition must end in OP_VERIFY`);
24127
+ condition = asm.slice(0, 3).map((token) => asmToken(token, instantiations));
24128
+ index = 4;
24129
+ }
24130
+ let csv;
24131
+ let cltv;
24132
+ if (asm.length >= index + 3 && asm[index + 2] === "OP_DROP") {
24133
+ const operand = asm[index].startsWith("<") && asm[index].endsWith(">") ? `$${asm[index].slice(1, -1)}` : BigInt(asm[index]);
24134
+ if (asm[index + 1] === "OP_CHECKSEQUENCEVERIFY") csv = csvTimelock(leaf.name, operand);
24135
+ else if (asm[index + 1] === "OP_CHECKLOCKTIMEVERIFY") cltv = operand;
24136
+ else fail(`leaf '${leaf.name}': unexpected timelock opcode ${asm[index + 1]}`);
24137
+ index += 3;
24138
+ }
24139
+ const signers = [];
24140
+ let emulator;
24141
+ while (index < asm.length) {
24142
+ const key = asm[index];
24143
+ const terminator = asm[index + 1];
24144
+ const last = terminator === "OP_CHECKSIG";
24145
+ if (!last && terminator !== "OP_CHECKSIGVERIFY") {
24146
+ fail(`leaf '${leaf.name}': expected CHECKSIG after '${key}', found '${terminator}'`);
24147
+ }
24148
+ if (!key.startsWith("<") || !key.endsWith(">")) {
24149
+ fail(`leaf '${leaf.name}': unsupported key operand '${key}'`);
24150
+ }
24151
+ const inner = key.slice(1, -1);
24152
+ if (inner === "SERVER_KEY") signers.push("$server");
24153
+ else if (inner.startsWith("TWEAK:")) {
24154
+ const [, base, fn] = inner.match(/^TWEAK:([^:]+):([^:]+)$/) ?? [];
24155
+ if (!base || !fn) fail(`leaf '${leaf.name}': malformed tweak '${key}'`);
24156
+ signers.push({ tweak: `$${base}`, fn });
24157
+ } else if (inner.startsWith("EMULATOR_KEY:")) {
24158
+ if (!hasCovenant) fail(`leaf '${leaf.name}': ${key} needs a covenant`);
24159
+ if (!last) fail(`leaf '${leaf.name}': ${key} must be the last signer`);
24160
+ emulator = inner.slice("EMULATOR_KEY:".length);
24161
+ } else signers.push(`$${inner}`);
24162
+ index += 2;
24163
+ }
24164
+ const constructorTweak = signers.some((signer) => typeof signer !== "string");
24165
+ if (hasCovenant && emulator === void 0 && !constructorTweak) {
24166
+ fail(
24167
+ `leaf '${leaf.name}': covenant leaf must sign with the emulator or a tweaked constructor key`
24168
+ );
24169
+ }
24170
+ if (signers.length === 0) fail(`leaf '${leaf.name}': at least one named signer is required`);
24171
+ return {
24172
+ signers,
24173
+ ...emulator !== void 0 ? { emulator } : hasCovenant ? { emulator: null } : {},
24174
+ ...condition ? { asm: condition } : {},
24175
+ ...csv ? { csv } : {},
24176
+ ...cltv !== void 0 ? { cltv } : {},
24177
+ ...extras.length > 0 ? { witness: extras.map((item) => item.name) } : {}
24178
+ };
24179
+ }
24180
+ function programFromArtifact(artifact) {
24181
+ if (!isContractArtifact(artifact)) {
24182
+ fail(
24183
+ "expected a complete arkadec artifact with contractName, constructorInputs, and non-empty functions"
24184
+ );
24185
+ }
24186
+ const structs = artifact.structs ?? [];
24187
+ const structNames = /* @__PURE__ */ new Set();
24188
+ for (const struct of structs) {
24189
+ if (!isRecord(struct) || typeof struct.name !== "string") continue;
24190
+ if (Object.hasOwn(SCALAR_TYPES, struct.name) || Object.hasOwn(NATIVE_STRUCTS, struct.name)) {
24191
+ fail(`struct name '${struct.name}' shadows a built-in type`);
24192
+ }
24193
+ claim(structNames, struct.name, "struct");
24194
+ }
24195
+ const instantiations = /* @__PURE__ */ new Map();
24196
+ const functions = {};
24197
+ const groups = /* @__PURE__ */ new Set();
24198
+ const leafNames = /* @__PURE__ */ new Set();
24199
+ for (const group of artifact.functions) {
24200
+ claim(groups, group.name, "spend group");
24201
+ const covenantInputs = (group.arkade?.inputs ?? []).flatMap(
24202
+ (input) => flatten(input, structs)
24203
+ );
24204
+ const arkadeScript = group.arkade ? {
24205
+ asm: group.arkade.asm.map((token) => asmToken(token, instantiations)),
24206
+ // Covenant witness is reverse declaration order.
24207
+ witness: covenantInputs.map((field) => field.name).reverse()
24208
+ } : void 0;
24209
+ for (const [index, leaf] of group.leaves.entries()) {
24210
+ const name = index === 0 ? group.name : `${group.name}/${index}:${leaf.name}`;
24211
+ claim(leafNames, name, "function name");
24212
+ const extras = providedWitness(leaf.witness);
24213
+ const tapscript = parseLeaf(leaf, group.arkade !== void 0, instantiations, extras);
24214
+ const inputs = [
24215
+ ...covenantInputs,
24216
+ ...extras.map((item) => ({ name: item.name, type: argType(item.type) }))
24217
+ ];
24218
+ functions[name] = {
24219
+ ...inputs.length > 0 ? { inputs } : {},
24220
+ tapscript,
24221
+ ...arkadeScript ? { arkadeScript } : {}
24222
+ };
24223
+ }
24224
+ }
24225
+ const params = [
24226
+ ...artifact.constructorInputs.flatMap((input) => flatten(input, structs)),
24227
+ { name: "server", type: "pubkey" },
24228
+ ...[...instantiations.keys()].map((name) => ({ name, type: "hash" }))
24229
+ ];
24230
+ const paramNames = /* @__PURE__ */ new Set();
24231
+ for (const param of params) claim(paramNames, param.name, "program parameter");
24232
+ return {
24233
+ version: chunkY7BVR6SQ_cjs.SUPPORTED_PROGRAM_VERSION,
24234
+ name: artifact.contractName,
24235
+ params,
24236
+ functions
24237
+ };
24238
+ }
23771
24239
  var Arkade = class _Arkade {
23772
24240
  arkProvider;
23773
24241
  /** The co-signing service, or undefined for emulator-less (pure tapscript) usage. */
@@ -23807,16 +24275,16 @@ var Arkade = class _Arkade {
23807
24275
  /** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
23808
24276
  static async connect(opts) {
23809
24277
  const info = await opts.arkade.getInfo();
23810
- const serverKey = chunkCQNX4BTA_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23811
- const checkpoint = chunkP53OHGXY_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23812
- const network = opts.network ?? (Object.hasOwn(chunkP53OHGXY_cjs.networks, info.network) ? chunkP53OHGXY_cjs.getNetwork(info.network) : chunkP53OHGXY_cjs.DEFAULT_NETWORK);
24278
+ const serverKey = chunkY7BVR6SQ_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
24279
+ const checkpoint = chunkPWIESIO6_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
24280
+ const network = opts.network ?? (Object.hasOwn(chunkPWIESIO6_cjs.networks, info.network) ? chunkPWIESIO6_cjs.getNetwork(info.network) : chunkPWIESIO6_cjs.DEFAULT_NETWORK);
23813
24281
  let emulatorKey;
23814
24282
  if (opts.emulator) {
23815
- emulatorKey = base.hex.decode(chunkP53OHGXY_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
24283
+ emulatorKey = base.hex.decode(chunkPWIESIO6_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23816
24284
  }
23817
24285
  let userKey;
23818
24286
  if (opts.identity) {
23819
- userKey = chunkCQNX4BTA_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
24287
+ userKey = chunkY7BVR6SQ_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23820
24288
  }
23821
24289
  return new _Arkade({
23822
24290
  arkProvider: opts.arkade,
@@ -23842,7 +24310,7 @@ var Arkade = class _Arkade {
23842
24310
  * key respectively; explicit args always win.
23843
24311
  */
23844
24312
  contract(program, args = {}) {
23845
- const declared = (program.params ?? []).map(chunkCQNX4BTA_cjs.inputName);
24313
+ const declared = (program.params ?? []).map(chunkY7BVR6SQ_cjs.inputName);
23846
24314
  if (declared.includes("server") && args.server === void 0) {
23847
24315
  args = { ...args, server: this.serverKey };
23848
24316
  }
@@ -23862,7 +24330,7 @@ var ArkadeContract = class _ArkadeContract {
23862
24330
  userKey: client.userKey,
23863
24331
  emulatorKey: client.emulatorKey
23864
24332
  };
23865
- this.vtxoScript = new chunkCQNX4BTA_cjs.ArkadeProgramScript(program, args, this.keys);
24333
+ this.vtxoScript = new chunkY7BVR6SQ_cjs.ArkadeProgramScript(program, args, this.keys);
23866
24334
  this.tapTree = this.vtxoScript.encode();
23867
24335
  this.compiled = this.vtxoScript.compiled;
23868
24336
  }
@@ -23890,7 +24358,7 @@ var ArkadeContract = class _ArkadeContract {
23890
24358
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
23891
24359
  );
23892
24360
  }
23893
- const typed = chunkCQNX4BTA_cjs.deserializeArkadeContractParams(contract.params);
24361
+ const typed = chunkY7BVR6SQ_cjs.deserializeArkadeContractParams(contract.params);
23894
24362
  return new _ArkadeContract(client, typed.program, typed.args, {
23895
24363
  serverKey: typed.serverKey,
23896
24364
  userKey: typed.userKey,
@@ -23931,7 +24399,7 @@ var ArkadeContract = class _ArkadeContract {
23931
24399
  toContractParams() {
23932
24400
  return {
23933
24401
  type: "arkade",
23934
- params: chunkCQNX4BTA_cjs.serializeArkadeContractParams({
24402
+ params: chunkY7BVR6SQ_cjs.serializeArkadeContractParams({
23935
24403
  program: this.program,
23936
24404
  args: this.args,
23937
24405
  serverKey: this.keys.serverKey,
@@ -23980,19 +24448,17 @@ var ArkadeContract = class _ArkadeContract {
23980
24448
  const [registered] = await manager.getContracts({ script: scriptHex });
23981
24449
  if (registered) {
23982
24450
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
23983
- return (withVtxos?.vtxos ?? []).filter(
23984
- (v) => !chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isUnrolled
23985
- );
24451
+ return (withVtxos?.vtxos ?? []).filter((v) => !chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isUnrolled);
23986
24452
  }
23987
24453
  }
23988
24454
  if (!this.client.indexer) {
23989
24455
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
23990
24456
  }
23991
- const { vtxos } = await chunkP53OHGXY_cjs.getNormalizedVtxos(this.client.indexer, {
24457
+ const { vtxos } = await chunkPWIESIO6_cjs.getNormalizedVtxos(this.client.indexer, {
23992
24458
  scripts: [scriptHex],
23993
24459
  spendableOnly: true
23994
24460
  });
23995
- return vtxos.filter((v) => !chunkP53OHGXY_cjs.hasTerminalSpend(v) && !v.isUnrolled);
24461
+ return vtxos.filter((v) => !chunkPWIESIO6_cjs.isVtxoSpent(v) && !v.isUnrolled);
23996
24462
  }
23997
24463
  /** Total spendable balance (requires an indexer). */
23998
24464
  async getBalance() {
@@ -24090,7 +24556,7 @@ var ArkadeTransactionBuilder = class {
24090
24556
  this.contract.client.checkpoint
24091
24557
  );
24092
24558
  if (coin.sourceTx) {
24093
- chunkP53OHGXY_cjs.setArkPsbtField(arkTx, 0, chunkP53OHGXY_cjs.PrevArkTxField, coin.sourceTx);
24559
+ chunkPWIESIO6_cjs.setArkPsbtField(arkTx, 0, chunkPWIESIO6_cjs.PrevArkTxField, coin.sourceTx);
24094
24560
  }
24095
24561
  if (this.fn.arkadeScript) {
24096
24562
  const indexer = this.contract.client.indexer;
@@ -24107,8 +24573,8 @@ var ArkadeTransactionBuilder = class {
24107
24573
  }
24108
24574
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
24109
24575
  if (condition.length > 0) {
24110
- chunkP53OHGXY_cjs.setArkPsbtField(arkTx, 0, chunkP53OHGXY_cjs.ConditionWitness, condition);
24111
- chunkP53OHGXY_cjs.setArkPsbtField(checkpoints[0], 0, chunkP53OHGXY_cjs.ConditionWitness, condition);
24576
+ chunkPWIESIO6_cjs.setArkPsbtField(arkTx, 0, chunkPWIESIO6_cjs.ConditionWitness, condition);
24577
+ chunkPWIESIO6_cjs.setArkPsbtField(checkpoints[0], 0, chunkPWIESIO6_cjs.ConditionWitness, condition);
24112
24578
  }
24113
24579
  const packets = [];
24114
24580
  if (this.assetSpecs.length > 0) {
@@ -24147,7 +24613,7 @@ var ArkadeTransactionBuilder = class {
24147
24613
  base.base64.encode(signedArk2.toPSBT()),
24148
24614
  signedCps.map((c) => base.base64.encode(c.toPSBT()))
24149
24615
  );
24150
- const txid = chunkP53OHGXY_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
24616
+ const txid = chunkPWIESIO6_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
24151
24617
  return {
24152
24618
  txid,
24153
24619
  signedArkTx: res2.signedArkTx,
@@ -24206,23 +24672,23 @@ var ArkadeTransactionBuilder = class {
24206
24672
  }
24207
24673
  buildAssetPacket() {
24208
24674
  const groups = this.assetSpecs.map((s) => {
24209
- const id = typeof s.assetId === "string" ? chunkT327OEMV_cjs.AssetId.fromString(s.assetId) : chunkT327OEMV_cjs.AssetId.fromBytes(s.assetId);
24210
- return chunkT327OEMV_cjs.AssetGroup.create(
24675
+ const id = typeof s.assetId === "string" ? chunkIAM5IEVT_cjs.AssetId.fromString(s.assetId) : chunkIAM5IEVT_cjs.AssetId.fromBytes(s.assetId);
24676
+ return chunkIAM5IEVT_cjs.AssetGroup.create(
24211
24677
  id,
24212
24678
  null,
24213
- s.inputs.map((i) => chunkT327OEMV_cjs.AssetInput.create(i.vin, i.amount)),
24214
- s.outputs.map((o) => chunkT327OEMV_cjs.AssetOutput.create(o.vout, o.amount)),
24215
- (s.metadata ?? []).map((m) => chunkT327OEMV_cjs.Metadata.create(m.key, m.value))
24679
+ s.inputs.map((i) => chunkIAM5IEVT_cjs.AssetInput.create(i.vin, i.amount)),
24680
+ s.outputs.map((o) => chunkIAM5IEVT_cjs.AssetOutput.create(o.vout, o.amount)),
24681
+ (s.metadata ?? []).map((m) => chunkIAM5IEVT_cjs.Metadata.create(m.key, m.value))
24216
24682
  );
24217
24683
  });
24218
- return chunkT327OEMV_cjs.Packet.create(groups);
24684
+ return chunkIAM5IEVT_cjs.Packet.create(groups);
24219
24685
  }
24220
24686
  witnessBytes(ref) {
24221
- return chunkCQNX4BTA_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
24687
+ return chunkY7BVR6SQ_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
24222
24688
  }
24223
24689
  };
24224
24690
  function bindInputs(fn, callArgs) {
24225
- const names = (fn.def.inputs ?? []).map(chunkCQNX4BTA_cjs.inputName);
24691
+ const names = (fn.def.inputs ?? []).map(chunkY7BVR6SQ_cjs.inputName);
24226
24692
  if (callArgs.length !== names.length) {
24227
24693
  throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
24228
24694
  }
@@ -24635,17 +25101,17 @@ var walletFeeSource = (wallet) => async () => (await wallet.arkProvider.getInfo(
24635
25101
  function offchainInputFees(vtxos, fees) {
24636
25102
  const estimator = new Estimator(fees?.intentFee ?? {});
24637
25103
  return vtxos.reduce(
24638
- (total, vtxo) => total + estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
25104
+ (total, vtxo) => total + estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
24639
25105
  0
24640
25106
  );
24641
25107
  }
24642
25108
  async function changeOutputFee(wallet, inputs, needed, fees) {
24643
25109
  const estimator = new Estimator(fees?.intentFee ?? {});
24644
25110
  const net = inputs.reduce(
24645
- (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkP53OHGXY_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
25111
+ (total, vtxo) => total + BigInt(vtxo.value) - BigInt(estimator.evalOffchainInput(chunkPWIESIO6_cjs.toOffchainInputFeeParams(vtxo)).satoshis),
24646
25112
  0n
24647
25113
  );
24648
- const script = base.hex.encode(chunkP53OHGXY_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
25114
+ const script = base.hex.encode(chunkPWIESIO6_cjs.ArkAddress.decode(await wallet.getAddress()).pkScript);
24649
25115
  return changeAfterOutputFee(
24650
25116
  net - needed,
24651
25117
  (amount) => BigInt(estimator.evalOffchainOutput({ amount, script }).satoshis)
@@ -24736,7 +25202,6 @@ exports.ConnectionDisposedError = ConnectionDisposedError;
24736
25202
  exports.ContractManager = ContractManager;
24737
25203
  exports.ContractRepositoryImpl = ContractRepositoryImpl;
24738
25204
  exports.ContractWatcher = ContractWatcher;
24739
- exports.DB_VERSION = DB_VERSION;
24740
25205
  exports.DEFAULT_MESSAGE_TIMEOUTS = DEFAULT_MESSAGE_TIMEOUTS;
24741
25206
  exports.DEFAULT_MIN_BATCH_EXPIRY_SECONDS = DEFAULT_MIN_BATCH_EXPIRY_SECONDS;
24742
25207
  exports.DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS = DEFAULT_MIN_CHECKPOINT_EXIT_DELAY_SECONDS;
@@ -24945,5 +25410,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
24945
25410
  exports.walletFeeSource = walletFeeSource;
24946
25411
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
24947
25412
  exports.withPrevTxs = withPrevTxs;
24948
- //# sourceMappingURL=chunk-LHSVPDFJ.cjs.map
24949
- //# sourceMappingURL=chunk-LHSVPDFJ.cjs.map
25413
+ //# sourceMappingURL=chunk-VJ7M6WKB.cjs.map
25414
+ //# sourceMappingURL=chunk-VJ7M6WKB.cjs.map