@arkade-os/sdk 0.4.73 → 0.4.74

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 (77) 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 +5 -5
  6. package/dist/adapters/indexedDB.js +4 -4
  7. package/dist/{asyncStorageTaskQueue-DA2OdpJ0.d.cts → asyncStorageTaskQueue-D1AwLuqn.d.cts} +1 -1
  8. package/dist/{asyncStorageTaskQueue-C5IwA_Hs.d.ts → asyncStorageTaskQueue-aCaOBGTS.d.ts} +1 -1
  9. package/dist/{chunk-D5DLGVN4.cjs → chunk-AS3W34MG.cjs} +17 -17
  10. package/dist/{chunk-D5DLGVN4.cjs.map → chunk-AS3W34MG.cjs.map} +1 -1
  11. package/dist/{chunk-2D7F5IU3.cjs → chunk-DXLVCFVK.cjs} +49 -49
  12. package/dist/{chunk-2D7F5IU3.cjs.map → chunk-DXLVCFVK.cjs.map} +1 -1
  13. package/dist/{chunk-QX2M67YI.js → chunk-J3XVGWMP.js} +21 -22
  14. package/dist/chunk-J3XVGWMP.js.map +1 -0
  15. package/dist/{chunk-ZLDO4QDR.cjs → chunk-J4ZR4VEM.cjs} +31 -32
  16. package/dist/chunk-J4ZR4VEM.cjs.map +1 -0
  17. package/dist/{chunk-KJ5E646Y.cjs → chunk-KMPNH7NS.cjs} +8 -4
  18. package/dist/chunk-KMPNH7NS.cjs.map +1 -0
  19. package/dist/{chunk-5YCAC6XE.js → chunk-KPLQN4M4.js} +4 -4
  20. package/dist/{chunk-5YCAC6XE.js.map → chunk-KPLQN4M4.js.map} +1 -1
  21. package/dist/{chunk-G5RPUZJE.js → chunk-LGB65ZCO.js} +3 -3
  22. package/dist/{chunk-G5RPUZJE.js.map → chunk-LGB65ZCO.js.map} +1 -1
  23. package/dist/{chunk-L7IEXVXI.cjs → chunk-QS6AZE4F.cjs} +10 -10
  24. package/dist/{chunk-L7IEXVXI.cjs.map → chunk-QS6AZE4F.cjs.map} +1 -1
  25. package/dist/{chunk-C4RKZY7D.cjs → chunk-WIHSU3YS.cjs} +560 -476
  26. package/dist/chunk-WIHSU3YS.cjs.map +1 -0
  27. package/dist/{chunk-OV4GLPZI.js → chunk-WJVOFYTQ.js} +8 -4
  28. package/dist/chunk-WJVOFYTQ.js.map +1 -0
  29. package/dist/{chunk-M6HIWM5N.js → chunk-X5BPARRD.js} +3 -3
  30. package/dist/{chunk-M6HIWM5N.js.map → chunk-X5BPARRD.js.map} +1 -1
  31. package/dist/{chunk-YHJJSLE5.js → chunk-ZTGTQP2W.js} +115 -33
  32. package/dist/chunk-ZTGTQP2W.js.map +1 -0
  33. package/dist/contracts/handlers/index.cjs +9 -9
  34. package/dist/contracts/handlers/index.d.cts +3 -3
  35. package/dist/contracts/handlers/index.d.ts +3 -3
  36. package/dist/contracts/handlers/index.js +2 -2
  37. package/dist/{delegate-BJp8f6LT.d.cts → delegate-6N0DKdnG.d.cts} +1 -1
  38. package/dist/{delegate-Ckz_TWzM.d.ts → delegate-z6veQfLI.d.ts} +1 -1
  39. package/dist/{hdWalletCapable-DABgAD-T.d.ts → hdWalletCapable-Bncp-eF0.d.ts} +2 -2
  40. package/dist/{hdWalletCapable-DA9bJ5eB.d.cts → hdWalletCapable-DJT8E8sN.d.cts} +2 -2
  41. package/dist/{index-DSbDm0Io.d.cts → index-BVqlZJwW.d.cts} +2 -2
  42. package/dist/{index-Dg0-TvBQ.d.cts → index-Bxz3cKPA.d.cts} +13 -7
  43. package/dist/{index-Dg0-TvBQ.d.ts → index-Bxz3cKPA.d.ts} +13 -7
  44. package/dist/{index-B8xrELXY.d.ts → index-CKQQ1oOg.d.ts} +2 -2
  45. package/dist/index.cjs +308 -300
  46. package/dist/index.d.cts +47 -24
  47. package/dist/index.d.ts +47 -24
  48. package/dist/index.js +4 -4
  49. package/dist/repositories/realm/index.cjs +19 -19
  50. package/dist/repositories/realm/index.d.cts +2 -2
  51. package/dist/repositories/realm/index.d.ts +2 -2
  52. package/dist/repositories/realm/index.js +5 -5
  53. package/dist/repositories/sqlite/index.cjs +18 -18
  54. package/dist/repositories/sqlite/index.d.cts +2 -2
  55. package/dist/repositories/sqlite/index.d.ts +2 -2
  56. package/dist/repositories/sqlite/index.js +5 -5
  57. package/dist/{taskRunner-C_uAJDsn.d.cts → taskRunner-C26IIg1F.d.cts} +1 -1
  58. package/dist/{taskRunner-DARTFnZN.d.ts → taskRunner-KxtIKYLv.d.ts} +1 -1
  59. package/dist/wallet/expo/background.cjs +14 -14
  60. package/dist/wallet/expo/background.d.cts +3 -3
  61. package/dist/wallet/expo/background.d.ts +3 -3
  62. package/dist/wallet/expo/background.js +6 -6
  63. package/dist/wallet/expo/index.cjs +14 -14
  64. package/dist/wallet/expo/index.d.cts +4 -4
  65. package/dist/wallet/expo/index.d.ts +4 -4
  66. package/dist/wallet/expo/index.js +5 -5
  67. package/dist/worker/expo/index.cjs +9 -9
  68. package/dist/worker/expo/index.d.cts +4 -4
  69. package/dist/worker/expo/index.d.ts +4 -4
  70. package/dist/worker/expo/index.js +5 -5
  71. package/package.json +1 -1
  72. package/dist/chunk-C4RKZY7D.cjs.map +0 -1
  73. package/dist/chunk-KJ5E646Y.cjs.map +0 -1
  74. package/dist/chunk-OV4GLPZI.js.map +0 -1
  75. package/dist/chunk-QX2M67YI.js.map +0 -1
  76. package/dist/chunk-YHJJSLE5.js.map +0 -1
  77. package/dist/chunk-ZLDO4QDR.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkD5DLGVN4_cjs = require('./chunk-D5DLGVN4.cjs');
4
- var chunk2D7F5IU3_cjs = require('./chunk-2D7F5IU3.cjs');
5
- var chunkKJ5E646Y_cjs = require('./chunk-KJ5E646Y.cjs');
3
+ var chunkAS3W34MG_cjs = require('./chunk-AS3W34MG.cjs');
4
+ var chunkDXLVCFVK_cjs = require('./chunk-DXLVCFVK.cjs');
5
+ var chunkKMPNH7NS_cjs = require('./chunk-KMPNH7NS.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 = chunkKJ5E646Y_cjs.getArkPsbtFields(tx.root, 0, chunkKJ5E646Y_cjs.CosignerPublicKey).map(
191
+ const cosigners = chunkKMPNH7NS_cjs.getArkPsbtFields(tx.root, 0, chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.getArkPsbtFields(g.root, 0, chunkKJ5E646Y_cjs.CosignerPublicKey).map((c) => c.key);
243
+ const cosigners = chunkKMPNH7NS_cjs.getArkPsbtFields(g.root, 0, chunkKMPNH7NS_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
- chunkKJ5E646Y_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH);
326
+ chunkKMPNH7NS_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 = chunk2D7F5IU3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
435
+ network = chunkDXLVCFVK_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 chunk2D7F5IU3_cjs.descriptorIsOurs(descriptor, this.descriptor, utils_js.pubSchnorr(this.derivedKey));
533
+ return chunkDXLVCFVK_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 = chunk2D7F5IU3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
582
+ const network = chunkDXLVCFVK_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
- chunkKJ5E646Y_cjs.assertAllowedSighashTypes(txCpy, ALLOWED_SIGHASH2);
607
+ chunkKMPNH7NS_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 = chunk2D7F5IU3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
669
+ const network = chunkDXLVCFVK_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 chunk2D7F5IU3_cjs.descriptorIsOurs(descriptor, this.descriptor, this.indexZero.pubkey);
719
+ return chunkDXLVCFVK_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 chunk2D7F5IU3_cjs.deriveDescriptorLeafPubKey(this.descriptor);
881
+ return chunkDXLVCFVK_cjs.deriveDescriptorLeafPubKey(this.descriptor);
882
882
  }
883
883
  async compressedPublicKey() {
884
- return chunk2D7F5IU3_cjs.deriveDescriptorLeafCompressedPubKey(this.descriptor);
884
+ return chunkDXLVCFVK_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 && chunk2D7F5IU3_cjs.parseHDDescriptor(descriptor)) {
952
+ if (owner && chunkDXLVCFVK_cjs.parseHDDescriptor(descriptor)) {
953
953
  return new DescriptorIdentity({ descriptor, signer: owner, base: identity });
954
954
  }
955
955
  let key;
956
956
  try {
957
- key = chunk2D7F5IU3_cjs.deriveDescriptorLeafPubKey(descriptor);
957
+ key = chunkDXLVCFVK_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 chunk2D7F5IU3_cjs.parseHDDescriptor(descriptor) !== null;
1332
+ return chunkDXLVCFVK_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 chunk2D7F5IU3_cjs.identityDescriptor(wallet.identity);
1336
+ return allocated ?? await chunkDXLVCFVK_cjs.identityDescriptor(wallet.identity);
1337
1337
  }
1338
1338
  async function provisionRefundKey(wallet) {
1339
- const descriptor = await chunk2D7F5IU3_cjs.identityDescriptor(wallet.identity);
1339
+ const descriptor = await chunkDXLVCFVK_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 } = chunkKJ5E646Y_cjs.ArkAddress.decode(address);
1349
+ const { pkScript } = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
1350
1350
  return { descriptor, pubkey, pkScript, address };
1351
1351
  }
1352
1352
  async function provisionClaimSecret(wallet, opts = {}) {
@@ -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 = chunk2D7F5IU3_cjs.deriveDescriptorLeafPubKey(descriptor);
1395
+ expected = chunkDXLVCFVK_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 chunkKJ5E646Y_cjs.baseFetch(url, {
1614
+ const response = await chunkKMPNH7NS_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: chunkKJ5E646Y_cjs.Intent.encodeMessage(intent.message),
1621
+ message: chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.rateGate.runHttp(url, () => chunkKJ5E646Y_cjs.baseFetch(url));
1641
+ const response = await chunkKMPNH7NS_cjs.rateGate.runHttp(url, () => chunkKMPNH7NS_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[chunkKJ5E646Y_cjs.DEFAULT_NETWORK_NAME], opts) {
1666
+ constructor(baseUrl = ESPLORA_URL[chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1685
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1692
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1713
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1721
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/address/${address}`);
1734
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/hex`);
1741
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1749
+ const txresponse = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1757
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/blocks`);
2041
+ let tipBlocks = await chunkKMPNH7NS_cjs.baseFetch(`${this.baseUrl}/blocks`);
2042
2042
  if (tipBlocks.status === 404) {
2043
- tipBlocks = await chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/v1/blocks`);
2043
+ tipBlocks = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
2065
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.baseFetch(`${this.baseUrl}/tx`, {
2081
+ const response = await chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
2264
+ const child = new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.Transaction({
2312
+ const tx = new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.getArkPsbtFields(child.root, 0, chunkKJ5E646Y_cjs.CosignerPublicKey);
2388
+ const cosigners = chunkKMPNH7NS_cjs.getArkPsbtFields(child.root, 0, chunkKMPNH7NS_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 chunkD5DLGVN4_cjs.BufferReader(data);
2446
+ const reader = new chunkAS3W34MG_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 chunkD5DLGVN4_cjs.BufferWriter();
2464
+ const writer = new chunkAS3W34MG_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 chunkD5DLGVN4_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
2551
+ const reader = new chunkAS3W34MG_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 chunkD5DLGVN4_cjs.Packet) {
2625
+ if (p instanceof chunkAS3W34MG_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 chunkD5DLGVN4_cjs.Packet.PACKET_TYPE:
2664
- return chunkD5DLGVN4_cjs.Packet.fromBytes(data);
2663
+ case chunkAS3W34MG_cjs.Packet.PACKET_TYPE:
2664
+ return chunkAS3W34MG_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2712
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
2711
+ var ErrOffchainOutputNotFound = (address) => new chunkKMPNH7NS_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2712
+ var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
2713
2713
  `invalid asset output amount for ${assetId}: got ${got}, want ${want}`
2714
2714
  );
2715
- var ErrAssetGroupNotFound = (assetId) => new chunkKJ5E646Y_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2716
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
2715
+ var ErrAssetGroupNotFound = (assetId) => new chunkKMPNH7NS_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2716
+ var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
2717
2717
  `asset output not found in asset group ${assetId} at index ${outputIndex}`
2718
2718
  );
2719
- var ErrOnchainOutputNotFound = (address) => new chunkKJ5E646Y_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2720
- var ErrUnvalidatedOffchainOutput = (address) => new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
2719
+ var ErrOnchainOutputNotFound = (address) => new chunkKMPNH7NS_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2720
+ var ErrUnvalidatedOffchainOutput = (address) => new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
2723
+ var ErrIntentOutputNotFound = (index, kind) => new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
2726
+ var ErrUnvalidatedIntentOutput = (index) => new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
2735
+ throw new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.ArkAddress.decode(recipient.address);
2745
+ arkAddress = chunkKMPNH7NS_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
- chunkKJ5E646Y_cjs.ArkAddress.decode(recipient.address);
2757
+ chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
2766
+ const proof = chunkKMPNH7NS_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(chunkD5DLGVN4_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3058
+ return base.hex.encode(chunkAS3W34MG_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
- chunkD5DLGVN4_cjs.AssetInput.create(inputIndex, asset.amount)
3134
+ chunkAS3W34MG_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
- chunkD5DLGVN4_cjs.AssetOutput.create(outputIndex, asset.amount)
3146
+ chunkAS3W34MG_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
- chunkD5DLGVN4_cjs.AssetOutput.create(outputIndex, asset.amount)
3157
+ chunkAS3W34MG_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 = chunkD5DLGVN4_cjs.AssetId.fromString(assetIdStr);
3167
- const group = chunkD5DLGVN4_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3166
+ const assetId = chunkAS3W34MG_cjs.AssetId.fromString(assetIdStr);
3167
+ const group = chunkAS3W34MG_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
3168
3168
  groups.push(group);
3169
3169
  }
3170
- return chunkD5DLGVN4_cjs.Packet.create(groups);
3170
+ return chunkAS3W34MG_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(chunk2D7F5IU3_cjs.toXOnly(bytes, "signer key"));
3207
+ if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkDXLVCFVK_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3254
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3260
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3281
+ throw new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3311
+ script = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3312
3312
  } catch (e) {
3313
- throw new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3313
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3320
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3325
+ throw new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.decodeTapscript(chunkKJ5E646Y_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3370
- if (chunkKJ5E646Y_cjs.CLTVMultisigTapscript.is(tapscript)) {
3369
+ const tapscript = chunkKMPNH7NS_cjs.decodeTapscript(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3370
+ if (chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.Transaction({
3381
+ const tx = new chunkKMPNH7NS_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: chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).pkScript,
3391
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript,
3392
3392
  amount: BigInt(input.value)
3393
3393
  },
3394
3394
  tapLeafScript: [input.tapLeafScript]
3395
3395
  });
3396
- chunkKJ5E646Y_cjs.setArkPsbtField(tx, i, chunkKJ5E646Y_cjs.VtxoTaprootTree, input.tapTree);
3396
+ chunkKMPNH7NS_cjs.setArkPsbtField(tx, i, chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.decodeTapscript(chunkKJ5E646Y_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3406
- const checkpointVtxoScript = new chunkKJ5E646Y_cjs.VtxoScript([
3405
+ const collaborativeClosure = chunkKMPNH7NS_cjs.decodeTapscript(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3406
+ const checkpointVtxoScript = new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.formatSighash(sighashType);
3482
+ const sighashName = chunkKMPNH7NS_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
- chunkKJ5E646Y_cjs.ArkAddress.decode(address);
3556
+ chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3564
+ throw new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3570
+ const server = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3571
3571
  const local = byTxid.get(server.id);
3572
3572
  if (!local) {
3573
- throw new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3573
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3583
+ throw new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3588
+ const finalTxid = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3589
3589
  if (finalTxid !== signedArkTx.id) {
3590
- throw new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3590
+ throw new chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.scriptFromTapLeafScript(leaf);
3602
+ const script = chunkKMPNH7NS_cjs.scriptFromTapLeafScript(leaf);
3603
3603
  let leafPubkeys;
3604
3604
  try {
3605
- leafPubkeys = chunkKJ5E646Y_cjs.decodeTapscript(script).params.pubkeys.map(
3606
- (key) => base.hex.encode(chunk2D7F5IU3_cjs.toXOnly(key, "leaf key"))
3605
+ leafPubkeys = chunkKMPNH7NS_cjs.decodeTapscript(script).params.pubkeys.map(
3606
+ (key) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(key, "leaf key"))
3607
3607
  );
3608
3608
  } catch (error) {
3609
- throw new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3609
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3615
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3629
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3638
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3644
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3651
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3659
+ throw new chunkKMPNH7NS_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
- chunkKJ5E646Y_cjs.assertAllowedSighashTypes(server);
3685
+ chunkKMPNH7NS_cjs.assertAllowedSighashTypes(server);
3686
3686
  } catch (error) {
3687
- throw new chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3687
+ throw new chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.ServerResponseMismatchError(
3695
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3696
3696
  "submitTx: server returned no final ark tx to verify its signatures against"
3697
3697
  );
3698
3698
  }
3699
- const finalArkTx = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3699
+ const finalArkTx = chunkKMPNH7NS_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(chunk2D7F5IU3_cjs.toXOnly(key, "server key"))
3702
+ (key) => base.hex.encode(chunkDXLVCFVK_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 = chunkKJ5E646Y_cjs.Transaction.fromPSBT(
3754
+ const signed = chunkKMPNH7NS_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
- chunkKJ5E646Y_cjs.setArkPsbtField(signed, index, chunkKJ5E646Y_cjs.ConditionWitness, [preimage]);
3759
+ chunkKMPNH7NS_cjs.setArkPsbtField(signed, index, chunkKMPNH7NS_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 = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
3954
+ const handler = chunkDXLVCFVK_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
- chunkKJ5E646Y_cjs.ArkAddress.decode(address);
4025
+ chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.VtxoScript.decode(tapTree).pkScript;
4053
+ derived = chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.ArkAddress.decode(recipient.address);
4070
+ address = chunkKMPNH7NS_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 chunk2D7F5IU3_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4095
+ return chunkDXLVCFVK_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 (!chunk2D7F5IU3_cjs.contractHandlers.has(type)) {
4117
+ if (!chunkDXLVCFVK_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 (!chunkKJ5E646Y_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
4153
+ if (!chunkKMPNH7NS_cjs.hasTerminalSpend(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 chunkKJ5E646Y_cjs.resolveTimeHeight(wallet.onchainProvider);
4188
+ return chunkKMPNH7NS_cjs.resolveTimeHeight(wallet.onchainProvider);
4189
4189
  }
4190
4190
  function canMigrateBySend(vtxo, now) {
4191
- if (!chunkKJ5E646Y_cjs.canSpendOffchain(vtxo, now)) return false;
4191
+ if (!chunkKMPNH7NS_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 chunkKJ5E646Y_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4199
+ return chunkKMPNH7NS_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(chunkKJ5E646Y_cjs.toOffchainInputFeeParams(vtxo));
4226
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_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(chunkKJ5E646Y_cjs.ArkAddress.decode(arkAddress).pkScript)
4252
+ script: base.hex.encode(chunkKMPNH7NS_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 (chunkKJ5E646Y_cjs.canRecoverOnchain(vtxo, now)) {
4270
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
4271
4271
  return true;
4272
4272
  }
4273
- if (chunkKJ5E646Y_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4273
+ if (chunkKMPNH7NS_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 = chunkKJ5E646Y_cjs.normalizeVtxo(vtxo).expiresAt;
4305
+ const expiresAt = chunkKMPNH7NS_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) || chunkKJ5E646Y_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4316
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4317
4317
  );
4318
4318
  }
4319
4319
  function isMigrationCapable(wallet) {
@@ -4912,11 +4912,11 @@ var VtxoManager = class _VtxoManager {
4912
4912
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
4913
4913
  );
4914
4914
  }
4915
- const tx = new chunkKJ5E646Y_cjs.Transaction();
4915
+ const tx = new chunkKMPNH7NS_cjs.Transaction();
4916
4916
  for (const utxo of expiredUtxos) {
4917
- const utxoScript = chunkKJ5E646Y_cjs.VtxoScript.decode(utxo.tapTree);
4917
+ const utxoScript = chunkKMPNH7NS_cjs.VtxoScript.decode(utxo.tapTree);
4918
4918
  const utxoExitLeaf = utxoScript.leaves.find(
4919
- (leaf) => chunkKJ5E646Y_cjs.CSVMultisigTapscript.isScriptValid(chunkKJ5E646Y_cjs.scriptFromTapLeafScript(leaf)) === true
4919
+ (leaf) => chunkKMPNH7NS_cjs.CSVMultisigTapscript.isScriptValid(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(leaf)) === true
4920
4920
  );
4921
4921
  if (!utxoExitLeaf) {
4922
4922
  throw new Error(
@@ -4931,7 +4931,7 @@ var VtxoManager = class _VtxoManager {
4931
4931
  amount: BigInt(utxo.value)
4932
4932
  },
4933
4933
  tapLeafScript: [utxoExitLeaf],
4934
- sequence: chunkKJ5E646Y_cjs.getSequence(utxoExitLeaf)
4934
+ sequence: chunkKMPNH7NS_cjs.getSequence(utxoExitLeaf)
4935
4935
  });
4936
4936
  }
4937
4937
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -5174,8 +5174,8 @@ var VtxoManager = class _VtxoManager {
5174
5174
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
5175
5175
  if (cls.status === "CURRENT") continue;
5176
5176
  const live = vtxos.filter((v) => !v.isUnrolled);
5177
- const recoverable = live.filter((v) => v.isSwept && !chunkKJ5E646Y_cjs.hasTerminalSpend(v));
5178
- const spendable = live.filter((v) => !chunkKJ5E646Y_cjs.hasTerminalSpend(v) && !v.isSwept);
5177
+ const recoverable = live.filter((v) => v.isSwept && !chunkKMPNH7NS_cjs.hasTerminalSpend(v));
5178
+ const spendable = live.filter((v) => !chunkKMPNH7NS_cjs.hasTerminalSpend(v) && !v.isSwept);
5179
5179
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
5180
5180
  let recoverableCount = 0;
5181
5181
  let recoverableValue = 0;
@@ -5188,7 +5188,7 @@ var VtxoManager = class _VtxoManager {
5188
5188
  awaitingSweepCount = spendable.length;
5189
5189
  awaitingSweepValue = value;
5190
5190
  for (const v of spendable) {
5191
- const exp = chunkKJ5E646Y_cjs.toBatchExpiry(v);
5191
+ const exp = chunkKMPNH7NS_cjs.toBatchExpiry(v);
5192
5192
  if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
5193
5193
  nextSweepEta = exp;
5194
5194
  }
@@ -5449,7 +5449,7 @@ var VtxoManager = class _VtxoManager {
5449
5449
  /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
5450
5450
  getBoardingTimelock() {
5451
5451
  const wallet = this.getSweepWallet();
5452
- const exitScript = chunkKJ5E646Y_cjs.CSVMultisigTapscript.decode(
5452
+ const exitScript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(
5453
5453
  base.hex.decode(wallet.boardingTapscript.exitScript)
5454
5454
  );
5455
5455
  return exitScript.params.timelock;
@@ -5580,8 +5580,8 @@ var VtxoManager = class _VtxoManager {
5580
5580
  * or doesn't carry the metadata.
5581
5581
  */
5582
5582
  extractSpentOutpoint(error) {
5583
- const ark = chunkKJ5E646Y_cjs.maybeArkError(error);
5584
- if (!chunkKJ5E646Y_cjs.isArkError(ark, chunkKJ5E646Y_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5583
+ const ark = chunkKMPNH7NS_cjs.maybeArkError(error);
5584
+ if (!chunkKMPNH7NS_cjs.isArkError(ark, chunkKMPNH7NS_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
5585
5585
  const raw = ark.metadata?.vtxo_outpoint;
5586
5586
  if (typeof raw !== "string") return void 0;
5587
5587
  const [txid, voutStr] = raw.split(":");
@@ -5771,7 +5771,7 @@ var VtxoManager = class _VtxoManager {
5771
5771
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
5772
5772
  break;
5773
5773
  }
5774
- const inputFee = estimator.evalOffchainInput(chunkKJ5E646Y_cjs.toOffchainInputFeeParams(v));
5774
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(v));
5775
5775
  if (inputFee.satoshis >= v.value) {
5776
5776
  continue;
5777
5777
  }
@@ -5791,7 +5791,7 @@ var VtxoManager = class _VtxoManager {
5791
5791
  const arkAddress = await this.wallet.getAddress();
5792
5792
  const outputFee = estimator.evalOffchainOutput({
5793
5793
  amount: totalAmount,
5794
- script: base.hex.encode(chunkKJ5E646Y_cjs.ArkAddress.decode(arkAddress).pkScript)
5794
+ script: base.hex.encode(chunkKMPNH7NS_cjs.ArkAddress.decode(arkAddress).pkScript)
5795
5795
  });
5796
5796
  totalAmount -= BigInt(outputFee.satoshis);
5797
5797
  if (totalAmount < dustAmount) return;
@@ -5871,7 +5871,7 @@ var ArkNote = class _ArkNote {
5871
5871
  this.value = value;
5872
5872
  this.HRP = HRP;
5873
5873
  const preimageHash = utils_js.sha256(this.preimage);
5874
- this.vtxoScript = new chunkKJ5E646Y_cjs.VtxoScript([noteTapscript(preimageHash)]);
5874
+ this.vtxoScript = new chunkKMPNH7NS_cjs.VtxoScript([noteTapscript(preimageHash)]);
5875
5875
  const leaf = this.vtxoScript.leaves[0];
5876
5876
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
5877
5877
  this.tapTree = this.vtxoScript.encode();
@@ -6038,7 +6038,7 @@ var ArkadeCash = class _ArkadeCash {
6038
6038
  const privateKey = data.slice(1, 33);
6039
6039
  const serverPubKey = data.slice(33, 65);
6040
6040
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
6041
- const csvTimelock = chunkKJ5E646Y_cjs.sequenceToTimelock(sequence);
6041
+ const csvTimelock = chunkKMPNH7NS_cjs.sequenceToTimelock(sequence);
6042
6042
  return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
6043
6043
  }
6044
6044
  toString() {
@@ -6046,7 +6046,7 @@ var ArkadeCash = class _ArkadeCash {
6046
6046
  data[0] = _ArkadeCash.Version;
6047
6047
  data.set(this._privateKey, 1);
6048
6048
  data.set(this._serverPubKey, 33);
6049
- const sequence = chunkKJ5E646Y_cjs.timelockToSequence(this.csvTimelock);
6049
+ const sequence = chunkKMPNH7NS_cjs.timelockToSequence(this.csvTimelock);
6050
6050
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
6051
6051
  const words = base.bech32m.toWords(data);
6052
6052
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -6055,7 +6055,7 @@ var ArkadeCash = class _ArkadeCash {
6055
6055
  return SingleKey.fromPrivateKey(this._privateKey);
6056
6056
  }
6057
6057
  get vtxoScript() {
6058
- return new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
6058
+ return new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
6059
6059
  pubKey: this._publicKey,
6060
6060
  serverPubKey: this._serverPubKey,
6061
6061
  csvTimelock: this.csvTimelock
@@ -6316,7 +6316,7 @@ async function captureExitBranch(params) {
6316
6316
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
6317
6317
  if (nonCommitment.length > 0) {
6318
6318
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
6319
- psbtByTxid.set(chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6319
+ psbtByTxid.set(chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6320
6320
  }
6321
6321
  }
6322
6322
  }
@@ -6359,10 +6359,10 @@ var IndexerExitDataSource = class {
6359
6359
  while (hasMore) {
6360
6360
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
6361
6361
  { txid: vtxo.txid, vout: vtxo.vout },
6362
- { pageIndex, pageSize: chunkKJ5E646Y_cjs.DEFAULT_PAGE_SIZE }
6362
+ { pageIndex, pageSize: chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE }
6363
6363
  );
6364
6364
  chain.push(...page);
6365
- hasMore = meta ? page.length === chunkKJ5E646Y_cjs.DEFAULT_PAGE_SIZE : false;
6365
+ hasMore = meta ? page.length === chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE : false;
6366
6366
  pageIndex++;
6367
6367
  }
6368
6368
  return chain;
@@ -6374,12 +6374,12 @@ var IndexerExitDataSource = class {
6374
6374
  while (hasMore) {
6375
6375
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
6376
6376
  pageIndex,
6377
- pageSize: chunkKJ5E646Y_cjs.DEFAULT_PAGE_SIZE
6377
+ pageSize: chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE
6378
6378
  });
6379
6379
  for (const psbt of txs) {
6380
- out.set(chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6380
+ out.set(chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6381
6381
  }
6382
- hasMore = page ? txs.length === chunkKJ5E646Y_cjs.DEFAULT_PAGE_SIZE : false;
6382
+ hasMore = page ? txs.length === chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE : false;
6383
6383
  pageIndex++;
6384
6384
  }
6385
6385
  return out;
@@ -6400,7 +6400,7 @@ function chainedTxTypeToChainTxType(t) {
6400
6400
  }
6401
6401
  }
6402
6402
  function psbtInputTxids(psbtBase64) {
6403
- const tx = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6403
+ const tx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6404
6404
  const ids = [];
6405
6405
  for (let i = 0; i < tx.inputsLength; i++) {
6406
6406
  const txid = tx.getInput(i).txid;
@@ -6759,10 +6759,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
6759
6759
  try {
6760
6760
  info = await arkProvider.getInfo();
6761
6761
  } catch (err) {
6762
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
6762
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
6763
6763
  const snapshot = await loadArkInfoSnapshot(walletRepository);
6764
6764
  if (!snapshot) {
6765
- throw new chunkKJ5E646Y_cjs.ProviderUnavailableError(
6765
+ throw new chunkKMPNH7NS_cjs.ProviderUnavailableError(
6766
6766
  "Arkade server info is unavailable and no cached snapshot exists",
6767
6767
  { cause: err }
6768
6768
  );
@@ -7169,7 +7169,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
7169
7169
  return [...txids];
7170
7170
  }
7171
7171
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
7172
- const normalized = vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7172
+ const normalized = vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo).sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
7173
7173
  const localCreatedAt = localCreatedAtByTxid(normalized);
7174
7174
  const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
7175
7175
  const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
@@ -7343,7 +7343,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7343
7343
  const virtualCoins = await this.wallet.getSpendableVtxos({
7344
7344
  withRecoverable: false
7345
7345
  });
7346
- const controlAssetRef = params.controlAssetId ? chunkD5DLGVN4_cjs.AssetRef.fromId(chunkD5DLGVN4_cjs.AssetId.fromString(params.controlAssetId)) : null;
7346
+ const controlAssetRef = params.controlAssetId ? chunkAS3W34MG_cjs.AssetRef.fromId(chunkAS3W34MG_cjs.AssetId.fromString(params.controlAssetId)) : null;
7347
7347
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
7348
7348
  let totalBtcSelected = 0n;
7349
7349
  const assetChanges = /* @__PURE__ */ new Map();
@@ -7356,8 +7356,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7356
7356
  }
7357
7357
  }
7358
7358
  const groups = [];
7359
- const issuedAssetOutput = chunkD5DLGVN4_cjs.AssetOutput.create(0, params.amount);
7360
- const issuedAssetGroup = chunkD5DLGVN4_cjs.AssetGroup.create(
7359
+ const issuedAssetOutput = chunkAS3W34MG_cjs.AssetOutput.create(0, params.amount);
7360
+ const issuedAssetGroup = chunkAS3W34MG_cjs.AssetGroup.create(
7361
7361
  null,
7362
7362
  controlAssetRef,
7363
7363
  [],
@@ -7372,28 +7372,28 @@ var AssetManager = class extends ReadonlyAssetManager {
7372
7372
  for (const [inputIndex, assets] of assetInputs) {
7373
7373
  for (const asset of assets) {
7374
7374
  if (asset.assetId !== assetId) continue;
7375
- changeInputs.push(chunkD5DLGVN4_cjs.AssetInput.create(inputIndex, asset.amount));
7375
+ changeInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7376
7376
  }
7377
7377
  }
7378
7378
  groups.push(
7379
- chunkD5DLGVN4_cjs.AssetGroup.create(
7380
- chunkD5DLGVN4_cjs.AssetId.fromString(assetId),
7379
+ chunkAS3W34MG_cjs.AssetGroup.create(
7380
+ chunkAS3W34MG_cjs.AssetId.fromString(assetId),
7381
7381
  null,
7382
7382
  changeInputs,
7383
- [chunkD5DLGVN4_cjs.AssetOutput.create(0, amount)],
7383
+ [chunkAS3W34MG_cjs.AssetOutput.create(0, amount)],
7384
7384
  []
7385
7385
  )
7386
7386
  );
7387
7387
  }
7388
7388
  }
7389
7389
  const address = await this.wallet.getAddress();
7390
- const outputAddress = chunkKJ5E646Y_cjs.ArkAddress.decode(address);
7390
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
7391
7391
  const outputs = [
7392
7392
  {
7393
7393
  script: outputAddress.pkScript,
7394
7394
  amount: BigInt(totalBtcSelected)
7395
7395
  },
7396
- Extension.create([chunkD5DLGVN4_cjs.Packet.create(groups)]).txOut()
7396
+ Extension.create([chunkAS3W34MG_cjs.Packet.create(groups)]).txOut()
7397
7397
  ];
7398
7398
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
7399
7399
  coinSelection.inputs,
@@ -7401,7 +7401,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7401
7401
  );
7402
7402
  return {
7403
7403
  arkTxId: arkTxid,
7404
- assetId: chunkD5DLGVN4_cjs.AssetId.create(arkTxid, 0).toString()
7404
+ assetId: chunkAS3W34MG_cjs.AssetId.create(arkTxid, 0).toString()
7405
7405
  };
7406
7406
  }
7407
7407
  /**
@@ -7473,16 +7473,16 @@ var AssetManager = class extends ReadonlyAssetManager {
7473
7473
  for (const [inputIndex, assets] of assetInputs) {
7474
7474
  for (const asset of assets) {
7475
7475
  if (asset.assetId !== params.assetId) continue;
7476
- reissueInputs.push(chunkD5DLGVN4_cjs.AssetInput.create(inputIndex, asset.amount));
7476
+ reissueInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7477
7477
  }
7478
7478
  }
7479
7479
  const totalAssetAmount = assetToReissueAmount + params.amount;
7480
- const reissueAssetIdObj = chunkD5DLGVN4_cjs.AssetId.fromString(params.assetId);
7481
- const reissueAssetGroup = chunkD5DLGVN4_cjs.AssetGroup.create(
7480
+ const reissueAssetIdObj = chunkAS3W34MG_cjs.AssetId.fromString(params.assetId);
7481
+ const reissueAssetGroup = chunkAS3W34MG_cjs.AssetGroup.create(
7482
7482
  reissueAssetIdObj,
7483
7483
  null,
7484
7484
  reissueInputs,
7485
- [chunkD5DLGVN4_cjs.AssetOutput.create(0, totalAssetAmount)],
7485
+ [chunkAS3W34MG_cjs.AssetOutput.create(0, totalAssetAmount)],
7486
7486
  []
7487
7487
  );
7488
7488
  const groups = [reissueAssetGroup];
@@ -7491,27 +7491,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7491
7491
  for (const [inputIndex, assets] of assetInputs) {
7492
7492
  for (const asset of assets) {
7493
7493
  if (asset.assetId !== assetId) continue;
7494
- changeInputs.push(chunkD5DLGVN4_cjs.AssetInput.create(inputIndex, asset.amount));
7494
+ changeInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7495
7495
  }
7496
7496
  }
7497
7497
  groups.push(
7498
- chunkD5DLGVN4_cjs.AssetGroup.create(
7499
- chunkD5DLGVN4_cjs.AssetId.fromString(assetId),
7498
+ chunkAS3W34MG_cjs.AssetGroup.create(
7499
+ chunkAS3W34MG_cjs.AssetId.fromString(assetId),
7500
7500
  null,
7501
7501
  changeInputs,
7502
- [chunkD5DLGVN4_cjs.AssetOutput.create(0, amount)],
7502
+ [chunkAS3W34MG_cjs.AssetOutput.create(0, amount)],
7503
7503
  []
7504
7504
  )
7505
7505
  );
7506
7506
  }
7507
7507
  const address = await this.wallet.getAddress();
7508
- const outputAddress = chunkKJ5E646Y_cjs.ArkAddress.decode(address);
7508
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
7509
7509
  const outputs = [
7510
7510
  {
7511
7511
  script: outputAddress.pkScript,
7512
7512
  amount: BigInt(totalBtcSelected)
7513
7513
  },
7514
- Extension.create([chunkD5DLGVN4_cjs.Packet.create(groups)]).txOut()
7514
+ Extension.create([chunkAS3W34MG_cjs.Packet.create(groups)]).txOut()
7515
7515
  ];
7516
7516
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7517
7517
  return arkTxid;
@@ -7578,27 +7578,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7578
7578
  for (const [inputIndex, assets] of assetInputs) {
7579
7579
  for (const asset of assets) {
7580
7580
  if (asset.assetId !== assetId) continue;
7581
- changeInputs.push(chunkD5DLGVN4_cjs.AssetInput.create(inputIndex, asset.amount));
7581
+ changeInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7582
7582
  }
7583
7583
  }
7584
7584
  groups.push(
7585
- chunkD5DLGVN4_cjs.AssetGroup.create(
7586
- chunkD5DLGVN4_cjs.AssetId.fromString(assetId),
7585
+ chunkAS3W34MG_cjs.AssetGroup.create(
7586
+ chunkAS3W34MG_cjs.AssetId.fromString(assetId),
7587
7587
  null,
7588
7588
  changeInputs,
7589
- amount > 0n ? [chunkD5DLGVN4_cjs.AssetOutput.create(0, amount)] : [],
7589
+ amount > 0n ? [chunkAS3W34MG_cjs.AssetOutput.create(0, amount)] : [],
7590
7590
  []
7591
7591
  )
7592
7592
  );
7593
7593
  }
7594
7594
  const address = await this.wallet.getAddress();
7595
- const outputAddress = chunkKJ5E646Y_cjs.ArkAddress.decode(address);
7595
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
7596
7596
  const outputs = [
7597
7597
  {
7598
7598
  script: outputAddress.pkScript,
7599
7599
  amount: BigInt(totalBtcSelected)
7600
7600
  },
7601
- Extension.create([chunkD5DLGVN4_cjs.Packet.create(groups)]).txOut()
7601
+ Extension.create([chunkAS3W34MG_cjs.Packet.create(groups)]).txOut()
7602
7602
  ];
7603
7603
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7604
7604
  return arkTxid;
@@ -7623,7 +7623,7 @@ function castMetadata(metadata) {
7623
7623
  } else {
7624
7624
  throw new Error("Invalid metadata value type");
7625
7625
  }
7626
- md.push(chunkD5DLGVN4_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7626
+ md.push(chunkAS3W34MG_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7627
7627
  }
7628
7628
  return md;
7629
7629
  }
@@ -7644,10 +7644,10 @@ var DelegateManagerImpl = class {
7644
7644
  if (vtxos.length === 0) {
7645
7645
  return { delegated: [], failed: [] };
7646
7646
  }
7647
- const destinationScript = chunkKJ5E646Y_cjs.ArkAddress.decode(destination).pkScript;
7647
+ const destinationScript = chunkKMPNH7NS_cjs.ArkAddress.decode(destination).pkScript;
7648
7648
  const arkInfo = await this.arkInfoProvider.getInfo();
7649
7649
  const delegateInfo = await this.delegateProvider.getDelegateInfo();
7650
- const eligible = vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo).filter(
7650
+ const eligible = vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo).filter(
7651
7651
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
7652
7652
  );
7653
7653
  if (eligible.length === 0) {
@@ -7676,11 +7676,11 @@ var DelegateManagerImpl = class {
7676
7676
  const groupByExpiry = /* @__PURE__ */ new Map();
7677
7677
  let recoverableVtxos = [];
7678
7678
  for (const vtxo of eligible) {
7679
- if (chunkKJ5E646Y_cjs.canRecoverOnchain(vtxo, now)) {
7679
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
7680
7680
  recoverableVtxos.push(vtxo);
7681
7681
  continue;
7682
7682
  }
7683
- const expiry = chunkKJ5E646Y_cjs.toBatchExpiry(vtxo);
7683
+ const expiry = chunkKMPNH7NS_cjs.toBatchExpiry(vtxo);
7684
7684
  if (!expiry) continue;
7685
7685
  const dayKey = getDayTimestamp(expiry);
7686
7686
  groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
@@ -7745,7 +7745,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7745
7745
  }
7746
7746
  if (!delegateAt) {
7747
7747
  const now = { timestamp: /* @__PURE__ */ new Date() };
7748
- const expiryTimestamp = vtxos.filter((coin) => !chunkKJ5E646Y_cjs.canRecoverOnchain(coin, now) && chunkKJ5E646Y_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkKJ5E646Y_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
7748
+ const expiryTimestamp = vtxos.filter((coin) => !chunkKMPNH7NS_cjs.canRecoverOnchain(coin, now) && chunkKMPNH7NS_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunkKMPNH7NS_cjs.toBatchExpiry(coin)), Number.MAX_SAFE_INTEGER);
7749
7749
  if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
7750
7750
  delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7751
7751
  } else {
@@ -7769,7 +7769,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7769
7769
  let amount = 0n;
7770
7770
  for (const coin of vtxos) {
7771
7771
  const inputFee = estimator.evalOffchainInput({
7772
- ...chunkKJ5E646Y_cjs.toOffchainInputFeeParams(coin),
7772
+ ...chunkKMPNH7NS_cjs.toOffchainInputFeeParams(coin),
7773
7773
  type: "vtxo"
7774
7774
  });
7775
7775
  if (inputFee.value >= coin.value) {
@@ -7783,7 +7783,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7783
7783
  const delegateFee = BigInt(Number(fee));
7784
7784
  if (delegateFee > 0n) {
7785
7785
  outputs.push({
7786
- script: chunkKJ5E646Y_cjs.ArkAddress.decode(delegateAddress).pkScript,
7786
+ script: chunkKMPNH7NS_cjs.ArkAddress.decode(delegateAddress).pkScript,
7787
7787
  amount: delegateFee
7788
7788
  });
7789
7789
  }
@@ -7816,10 +7816,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7816
7816
  destinationScript
7817
7817
  );
7818
7818
  const forfeitOutputScript = btcSigner.OutScript.encode(
7819
- btcSigner.Address(chunkKJ5E646Y_cjs.getNetwork(network)).decode(forfeitAddress)
7819
+ btcSigner.Address(chunkKMPNH7NS_cjs.getNetwork(network)).decode(forfeitAddress)
7820
7820
  );
7821
7821
  const forfeits = await Promise.all(
7822
- vtxos.filter((v) => !chunkKJ5E646Y_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7822
+ vtxos.filter((v) => !chunkKMPNH7NS_cjs.canRecoverOnchain(v, { timestamp: /* @__PURE__ */ new Date() })).map(async (coin) => {
7823
7823
  const forfeit = await makeDelegateForfeitTx(
7824
7824
  coin,
7825
7825
  dust,
@@ -7844,7 +7844,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
7844
7844
  index: input.vout,
7845
7845
  witnessUtxo: {
7846
7846
  amount: BigInt(input.value),
7847
- script: chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).pkScript
7847
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
7848
7848
  },
7849
7849
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
7850
7850
  tapLeafScript: [delegateTapLeaf]
@@ -7902,7 +7902,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
7902
7902
  expire_at: 0,
7903
7903
  cosigners_public_keys: cosignerPubKeys
7904
7904
  };
7905
- const proof = chunkKJ5E646Y_cjs.Intent.create(message, coins, outputs);
7905
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, outputs);
7906
7906
  const signedProof = await identity.sign(proof);
7907
7907
  return {
7908
7908
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -7928,10 +7928,10 @@ function getDayTimestamp(timestamp) {
7928
7928
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
7929
7929
  if (!vtxo.tapTree) return void 0;
7930
7930
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
7931
- const vtxoScript = chunkKJ5E646Y_cjs.VtxoScript.decode(vtxo.tapTree);
7931
+ const vtxoScript = chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree);
7932
7932
  return vtxoScript.leaves.find((tapLeaf) => {
7933
- const arkTapscript = chunkKJ5E646Y_cjs.decodeTapscript(chunkKJ5E646Y_cjs.scriptFromTapLeafScript(tapLeaf));
7934
- if (!chunkKJ5E646Y_cjs.MultisigTapscript.is(arkTapscript)) return false;
7933
+ const arkTapscript = chunkKMPNH7NS_cjs.decodeTapscript(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(tapLeaf));
7934
+ if (!chunkKMPNH7NS_cjs.MultisigTapscript.is(arkTapscript)) return false;
7935
7935
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
7936
7936
  });
7937
7937
  }
@@ -8212,7 +8212,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
8212
8212
  };
8213
8213
  }
8214
8214
  function scriptFromArkAddress(address) {
8215
- return base.hex.encode(chunkKJ5E646Y_cjs.ArkAddress.decode(address).pkScript);
8215
+ return base.hex.encode(chunkKMPNH7NS_cjs.ArkAddress.decode(address).pkScript);
8216
8216
  }
8217
8217
 
8218
8218
  // src/repositories/indexedDB/schema.ts
@@ -8707,7 +8707,7 @@ function validateVtxosForScript(vtxos, script, context) {
8707
8707
  }
8708
8708
  async function getVtxosForContract(repo, contract) {
8709
8709
  const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8710
- return vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo);
8710
+ return vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
8711
8711
  }
8712
8712
  async function saveVtxosForContract(repo, contract, vtxos) {
8713
8713
  if (repo.saveVtxosForScript) {
@@ -8849,7 +8849,7 @@ function decodeArkContract(encoded) {
8849
8849
  }
8850
8850
  function contractFromArkContract(encoded, options = {}) {
8851
8851
  const parsed = decodeArkContract(encoded);
8852
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(parsed.type);
8852
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(parsed.type);
8853
8853
  if (!handler) {
8854
8854
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
8855
8855
  }
@@ -8863,9 +8863,9 @@ function contractFromArkContract(encoded, options = {}) {
8863
8863
  metadata: options.metadata
8864
8864
  };
8865
8865
  }
8866
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkKJ5E646Y_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8866
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkKMPNH7NS_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8867
8867
  const parsed = decodeArkContract(encoded);
8868
- const handler = chunk2D7F5IU3_cjs.contractHandlers.getOrThrow(parsed.type);
8868
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.getOrThrow(parsed.type);
8869
8869
  const params = parsed.data;
8870
8870
  const vtxoScript = handler.createScript(params);
8871
8871
  return {
@@ -9032,23 +9032,32 @@ var ContractWatcher = class {
9032
9032
  }
9033
9033
  /** @see IContractManager.watchScript for the delivery and filter contract. */
9034
9034
  async addWatchedScript(script, options) {
9035
- const existing = this.watchedScripts.get(script);
9036
- if (existing) {
9037
- if (options?.label !== void 0) existing.label = options.label;
9038
- return;
9035
+ const added = [];
9036
+ for (const one of Array.isArray(script) ? script : [script]) {
9037
+ const existing = this.watchedScripts.get(one);
9038
+ if (existing) {
9039
+ if (options?.label !== void 0) existing.label = options.label;
9040
+ continue;
9041
+ }
9042
+ this.watchedScripts.set(one, {
9043
+ label: options?.label,
9044
+ lastKnownVtxos: /* @__PURE__ */ new Map()
9045
+ });
9046
+ added.push(one);
9039
9047
  }
9040
- this.watchedScripts.set(script, {
9041
- label: options?.label,
9042
- lastKnownVtxos: /* @__PURE__ */ new Map()
9043
- });
9044
- if (this.isWatching) {
9045
- await this.pollWatchedScripts([script]);
9048
+ if (added.length === 0 || !this.isWatching) return;
9049
+ await this.withCoalescedSubscription(async () => {
9050
+ await this.pollWatchedScripts(added);
9046
9051
  await this.tryUpdateSubscription();
9047
- }
9052
+ });
9048
9053
  }
9049
9054
  /** Stop watching a script added by {@link addWatchedScript}. */
9050
9055
  async removeWatchedScript(script) {
9051
- if (!this.watchedScripts.delete(script)) return;
9056
+ let removed = false;
9057
+ for (const one of Array.isArray(script) ? script : [script]) {
9058
+ if (this.watchedScripts.delete(one)) removed = true;
9059
+ }
9060
+ if (!removed) return;
9052
9061
  if (this.isWatching) {
9053
9062
  await this.tryUpdateSubscription();
9054
9063
  }
@@ -9162,9 +9171,9 @@ var ContractWatcher = class {
9162
9171
  this.connectionState = "connected";
9163
9172
  this.reconnectAttempts = 0;
9164
9173
  this.listenLoop().catch((e) => {
9165
- if (chunkKJ5E646Y_cjs.isEventSourceError(e)) {
9174
+ if (chunkKMPNH7NS_cjs.isEventSourceError(e)) {
9166
9175
  console.debug("ContractWatcher subscription disconnected; reconnecting");
9167
- } else if (!chunkKJ5E646Y_cjs.isEventSourceUnavailableError(e)) {
9176
+ } else if (!chunkKMPNH7NS_cjs.isEventSourceUnavailableError(e)) {
9168
9177
  console.error(e);
9169
9178
  }
9170
9179
  this.connectionState = "disconnected";
@@ -9176,7 +9185,7 @@ var ContractWatcher = class {
9176
9185
  this.scheduleReconnect();
9177
9186
  });
9178
9187
  } catch (error) {
9179
- if (!chunkKJ5E646Y_cjs.isEventSourceUnavailableError(error)) {
9188
+ if (!chunkKMPNH7NS_cjs.isEventSourceUnavailableError(error)) {
9180
9189
  console.error("ContractWatcher connection failed:", error);
9181
9190
  }
9182
9191
  this.connectionState = "disconnected";
@@ -9202,7 +9211,7 @@ var ContractWatcher = class {
9202
9211
  * slower; what it loses is push latency.
9203
9212
  */
9204
9213
  reportEventSourceUnavailable(error) {
9205
- if (!chunkKJ5E646Y_cjs.isEventSourceUnavailableError(error)) return false;
9214
+ if (!chunkKMPNH7NS_cjs.isEventSourceUnavailableError(error)) return false;
9206
9215
  if (!this.eventSourceReported) {
9207
9216
  this.eventSourceReported = true;
9208
9217
  console.warn(
@@ -9274,7 +9283,7 @@ var ContractWatcher = class {
9274
9283
  const now = Date.now();
9275
9284
  let current;
9276
9285
  try {
9277
- current = await chunkKJ5E646Y_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9286
+ current = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9278
9287
  spendableOnly: true
9279
9288
  });
9280
9289
  } catch (error) {
@@ -9483,14 +9492,14 @@ var ContractWatcher = class {
9483
9492
  const timestamp = Date.now();
9484
9493
  if (update.newVtxos?.length) {
9485
9494
  this.processSubscriptionVtxos(
9486
- update.newVtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo),
9495
+ update.newVtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo),
9487
9496
  "vtxo_received",
9488
9497
  timestamp
9489
9498
  );
9490
9499
  }
9491
9500
  if (update.spentVtxos?.length) {
9492
9501
  this.processSubscriptionVtxos(
9493
- update.spentVtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo),
9502
+ update.spentVtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo),
9494
9503
  "vtxo_spent",
9495
9504
  timestamp
9496
9505
  );
@@ -9518,8 +9527,8 @@ var ContractWatcher = class {
9518
9527
  continue;
9519
9528
  }
9520
9529
  if (target === byWatchedScript && eventType === "vtxo_received") {
9521
- const n = chunkKJ5E646Y_cjs.normalizeVtxo(vtxo);
9522
- if (chunkKJ5E646Y_cjs.hasTerminalSpend(n) || n.isSwept || chunkKJ5E646Y_cjs.isPastExpiry(n, now)) continue;
9530
+ const n = chunkKMPNH7NS_cjs.normalizeVtxo(vtxo);
9531
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(n) || n.isSwept || chunkKMPNH7NS_cjs.isPastExpiry(n, now)) continue;
9523
9532
  }
9524
9533
  let bucket = target.get(vtxo.script);
9525
9534
  if (!bucket) {
@@ -9618,7 +9627,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
9618
9627
  (s) => !isTerminalIntentState(s)
9619
9628
  );
9620
9629
  function isConsumed(vtxo) {
9621
- return vtxo !== void 0 && chunkKJ5E646Y_cjs.hasTerminalSpend(vtxo);
9630
+ return vtxo !== void 0 && chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo);
9622
9631
  }
9623
9632
  async function classifyIntent(intent, vtxosByOutpoint, now) {
9624
9633
  if (isTerminalIntentState(intent.state)) return void 0;
@@ -9661,7 +9670,7 @@ async function reconcileIntents(deps) {
9661
9670
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
9662
9671
  if (outpoints.length > 0) {
9663
9672
  try {
9664
- const { vtxos } = await chunkKJ5E646Y_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9673
+ const { vtxos } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9665
9674
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
9666
9675
  } catch (e) {
9667
9676
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -9840,7 +9849,7 @@ var ContractManager = class _ContractManager {
9840
9849
  await this.reconcileWatched();
9841
9850
  this.markSyncOnline();
9842
9851
  } catch (err) {
9843
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
9852
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
9844
9853
  this.markSyncDegraded(err);
9845
9854
  }
9846
9855
  this.initialized = true;
@@ -9972,7 +9981,7 @@ var ContractManager = class _ContractManager {
9972
9981
  const from = Math.max(0, watermark - lookAhead.size);
9973
9982
  const to = watermark + lookAhead.size;
9974
9983
  const deps = lookAhead.candidateDeps();
9975
- const handlers = chunk2D7F5IU3_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk2D7F5IU3_cjs.contractHandlers.get(t)).filter(hasCandidates);
9984
+ const handlers = chunkDXLVCFVK_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkDXLVCFVK_cjs.contractHandlers.get(t)).filter(hasCandidates);
9976
9985
  const band = /* @__PURE__ */ new Map();
9977
9986
  for (let index = from; index <= to; index++) {
9978
9987
  const descriptor = lookAhead.materialize(index);
@@ -9983,7 +9992,7 @@ var ContractManager = class _ContractManager {
9983
9992
  index,
9984
9993
  params: {
9985
9994
  ...candidate,
9986
- ...chunk2D7F5IU3_cjs.speculativeReceiveMetadata(descriptor)
9995
+ ...chunkDXLVCFVK_cjs.speculativeReceiveMetadata(descriptor)
9987
9996
  }
9988
9997
  });
9989
9998
  }
@@ -10045,7 +10054,7 @@ var ContractManager = class _ContractManager {
10045
10054
  });
10046
10055
  for (const entry of pending) entry.catchUpPending = false;
10047
10056
  } catch (err) {
10048
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
10057
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10049
10058
  this.markSyncDegraded(err);
10050
10059
  }
10051
10060
  }
@@ -10095,7 +10104,7 @@ var ContractManager = class _ContractManager {
10095
10104
  await this.fetchContractVxosFromIndexer([contract]);
10096
10105
  this.markSyncOnline();
10097
10106
  } catch (err) {
10098
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
10107
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10099
10108
  this.markSyncDegraded(err);
10100
10109
  }
10101
10110
  await this.watcher.addContract(contract);
@@ -10129,7 +10138,7 @@ var ContractManager = class _ContractManager {
10129
10138
  await this.fetchContractVxosFromIndexer(fresh);
10130
10139
  this.markSyncOnline();
10131
10140
  } catch (err) {
10132
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
10141
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10133
10142
  this.markSyncDegraded(err);
10134
10143
  }
10135
10144
  for (const contract of fresh) await this.watcher.addContract(contract);
@@ -10167,7 +10176,7 @@ var ContractManager = class _ContractManager {
10167
10176
  return result;
10168
10177
  }
10169
10178
  async upsertContractRow(params) {
10170
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(params.type);
10179
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(params.type);
10171
10180
  if (!handler) {
10172
10181
  throw new Error(`No handler registered for contract type '${params.type}'`);
10173
10182
  }
@@ -10267,7 +10276,7 @@ var ContractManager = class _ContractManager {
10267
10276
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
10268
10277
  );
10269
10278
  }
10270
- const registered = chunk2D7F5IU3_cjs.contractHandlers.getRegisteredTypes().map((t) => chunk2D7F5IU3_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10279
+ const registered = chunkDXLVCFVK_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkDXLVCFVK_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10271
10280
  const discoverables = [
10272
10281
  ...registered.filter((h) => h.type === "boarding"),
10273
10282
  ...registered.filter((h) => h.type !== "boarding")
@@ -10405,7 +10414,7 @@ var ContractManager = class _ContractManager {
10405
10414
  await this.syncContracts({ contracts, pageSize });
10406
10415
  this.markSyncOnline();
10407
10416
  } catch (err) {
10408
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
10417
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10409
10418
  this.markSyncDegraded(err);
10410
10419
  }
10411
10420
  }
@@ -10427,7 +10436,7 @@ var ContractManager = class _ContractManager {
10427
10436
  }
10428
10437
  const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
10429
10438
  return vtxos.map(
10430
- (vtxo) => extendVirtualCoinForContract(chunkKJ5E646Y_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10439
+ (vtxo) => extendVirtualCoinForContract(chunkKMPNH7NS_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10431
10440
  );
10432
10441
  }
10433
10442
  /** @inheritdoc */
@@ -10471,14 +10480,14 @@ var ContractManager = class _ContractManager {
10471
10480
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
10472
10481
  const asking = vtxos.filter((vtxo) => {
10473
10482
  const contract = byScript.get(vtxo.script);
10474
- return contract !== void 0 && chunk2D7F5IU3_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10483
+ return contract !== void 0 && chunkDXLVCFVK_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10475
10484
  });
10476
10485
  if (asking.length === 0) return refused;
10477
10486
  const tip = await this.currentChainTip();
10478
10487
  const walletKey = await walletPubKey?.();
10479
10488
  for (const vtxo of asking) {
10480
10489
  const contract = byScript.get(vtxo.script);
10481
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
10490
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
10482
10491
  if (!handler?.assertSpendableNow) continue;
10483
10492
  const context = {
10484
10493
  collaborative: true,
@@ -10493,7 +10502,7 @@ var ContractManager = class _ContractManager {
10493
10502
  // the next handler to answer a CSV question would meet a
10494
10503
  // TypeError instead of a `false`. Carry the coin only when it
10495
10504
  // really is one.
10496
- vtxo: chunkKJ5E646Y_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10505
+ vtxo: chunkKMPNH7NS_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10497
10506
  };
10498
10507
  try {
10499
10508
  await handler.assertSpendableNow(
@@ -10649,7 +10658,7 @@ var ContractManager = class _ContractManager {
10649
10658
  const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
10650
10659
  const [contract] = await this.getContracts({ script: contractScript });
10651
10660
  if (!contract) return [];
10652
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
10661
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
10653
10662
  if (!handler) return [];
10654
10663
  const script = handler.createScript(contract.params);
10655
10664
  const tip = await this.currentChainTip();
@@ -10677,7 +10686,7 @@ var ContractManager = class _ContractManager {
10677
10686
  const { contractScript, collaborative = true, walletPubKey } = options;
10678
10687
  const [contract] = await this.getContracts({ script: contractScript });
10679
10688
  if (!contract) return [];
10680
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
10689
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
10681
10690
  if (!handler) return [];
10682
10691
  const script = handler.createScript(contract.params);
10683
10692
  const context = {
@@ -10733,7 +10742,7 @@ var ContractManager = class _ContractManager {
10733
10742
  }
10734
10743
  async refreshOutpoints(outpoints) {
10735
10744
  if (outpoints.length === 0) return;
10736
- const { vtxos } = await chunkKJ5E646Y_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10745
+ const { vtxos } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10737
10746
  outpoints
10738
10747
  });
10739
10748
  if (vtxos.length === 0) return;
@@ -10829,7 +10838,7 @@ var ContractManager = class _ContractManager {
10829
10838
  break;
10830
10839
  }
10831
10840
  } catch (err) {
10832
- if (!chunkKJ5E646Y_cjs.isRetryableProviderError(err)) throw err;
10841
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10833
10842
  this.markSyncDegraded(err);
10834
10843
  }
10835
10844
  this.emitEvent(event);
@@ -10920,7 +10929,7 @@ var ContractManager = class _ContractManager {
10920
10929
  */
10921
10930
  async reconcilePendingFrontier(contracts) {
10922
10931
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
10923
- const vtxos = await chunkKJ5E646Y_cjs.getAllNormalizedVtxos(
10932
+ const vtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(
10924
10933
  this.config.indexerProvider,
10925
10934
  contracts.map((c) => c.script),
10926
10935
  { pendingOnly: true }
@@ -11003,7 +11012,7 @@ var ContractManager = class _ContractManager {
11003
11012
  }
11004
11013
  return result;
11005
11014
  }
11006
- async fetchContractVtxosBulk(contracts, pageSize = chunkKJ5E646Y_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11015
+ async fetchContractVtxosBulk(contracts, pageSize = chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11007
11016
  if (contracts.length === 0) {
11008
11017
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
11009
11018
  }
@@ -11019,7 +11028,7 @@ var ContractManager = class _ContractManager {
11019
11028
  before: syncWindow.before
11020
11029
  }
11021
11030
  } : {};
11022
- const vtxos = await chunkKJ5E646Y_cjs.getAllNormalizedVtxos(
11031
+ const vtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(
11023
11032
  this.config.indexerProvider,
11024
11033
  contracts.map((c) => c.script),
11025
11034
  { ...windowOpts, pageSize }
@@ -11164,7 +11173,7 @@ var deserializeTapLeaf = (t) => {
11164
11173
  const s = base.hex.decode(t.s);
11165
11174
  return [cb, s];
11166
11175
  };
11167
- var deserializeVtxo = (o) => chunkKJ5E646Y_cjs.normalizeVtxo({
11176
+ var deserializeVtxo = (o) => chunkKMPNH7NS_cjs.normalizeVtxo({
11168
11177
  ...o,
11169
11178
  createdAt: new Date(o.createdAt),
11170
11179
  tapTree: base.hex.decode(o.tapTree),
@@ -11987,7 +11996,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
11987
11996
  */
11988
11997
  materializeDescriptorAt(index) {
11989
11998
  const descriptor = this.identity.descriptor;
11990
- const network = chunk2D7F5IU3_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11999
+ const network = chunkDXLVCFVK_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11991
12000
  const expansion = descriptorsScure.expand({ descriptor, network, index });
11992
12001
  const keyInfo = expansion.expansionMap?.["@0"];
11993
12002
  if (!keyInfo?.keyExpression) {
@@ -12135,7 +12144,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12135
12144
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
12136
12145
  if (!provider) return void 0;
12137
12146
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
12138
- const expectedContractType = setup.offchainTapscript instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script ? "delegate" : "default";
12147
+ const expectedContractType = setup.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? "delegate" : "default";
12139
12148
  const factoryOpts = {
12140
12149
  walletRepository: setup.walletRepository,
12141
12150
  contractRepository: setup.contractRepository,
@@ -12336,7 +12345,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12336
12345
  };
12337
12346
  function deriveLeafPubkey(descriptor) {
12338
12347
  try {
12339
- return chunk2D7F5IU3_cjs.deriveDescriptorLeafPubKey(descriptor);
12348
+ return chunkDXLVCFVK_cjs.deriveDescriptorLeafPubKey(descriptor);
12340
12349
  } catch (e) {
12341
12350
  throw new NonRangeableDescriptorError(
12342
12351
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -12348,7 +12357,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12348
12357
  const pubKey = deriveLeafPubkey(descriptor);
12349
12358
  const tapscript = rebuildTapscript(current, pubKey);
12350
12359
  const serverPubKey = tapscript.options.serverPubKey;
12351
- const csvTimelock = chunkKJ5E646Y_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12360
+ const csvTimelock = chunkKMPNH7NS_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12352
12361
  const base$1 = {
12353
12362
  script: base.hex.encode(tapscript.pkScript),
12354
12363
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -12359,11 +12368,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12359
12368
  // index-0 key. Without it, spends produce unsigned PSBTs that the
12360
12369
  // server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
12361
12370
  metadata: {
12362
- ...tagSource && { source: chunk2D7F5IU3_cjs.WALLET_RECEIVE_SOURCE },
12371
+ ...tagSource && { source: chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE },
12363
12372
  signingDescriptor: descriptor
12364
12373
  }
12365
12374
  };
12366
- const params = tapscript instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script ? {
12375
+ const params = tapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? {
12367
12376
  ...base$1,
12368
12377
  type: "delegate",
12369
12378
  params: {
@@ -12384,10 +12393,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12384
12393
  return { tapscript, params };
12385
12394
  }
12386
12395
  function rebuildTapscript(current, pubKey) {
12387
- if (current instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script) {
12388
- return new chunk2D7F5IU3_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12396
+ if (current instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script) {
12397
+ return new chunkDXLVCFVK_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12389
12398
  }
12390
- return new chunk2D7F5IU3_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12399
+ return new chunkDXLVCFVK_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12391
12400
  }
12392
12401
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
12393
12402
  const candidates = await contractRepository.getContracts({
@@ -12396,7 +12405,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
12396
12405
  });
12397
12406
  const serverPubKeyHex = base.hex.encode(serverPubKey);
12398
12407
  const matching = candidates.filter(
12399
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk2D7F5IU3_cjs.WALLET_RECEIVE_SOURCE
12408
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE
12400
12409
  ).sort((a, b) => {
12401
12410
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12402
12411
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12452,7 +12461,7 @@ function computeOffchainBalance(vtxos, caps) {
12452
12461
  }
12453
12462
  };
12454
12463
  for (const vtxo of vtxos) {
12455
- if (chunkKJ5E646Y_cjs.hasTerminalSpend(vtxo)) continue;
12464
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)) continue;
12456
12465
  addAssets(owned, vtxo);
12457
12466
  if (vtxo.isUnrolled) {
12458
12467
  unrolled += vtxo.value;
@@ -12462,11 +12471,11 @@ function computeOffchainBalance(vtxos, caps) {
12462
12471
  pendingRecovery += vtxo.value;
12463
12472
  continue;
12464
12473
  }
12465
- if (chunkKJ5E646Y_cjs.canRecoverOnchain(vtxo, now)) {
12474
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
12466
12475
  recoverable += vtxo.value;
12467
12476
  continue;
12468
12477
  }
12469
- if (!chunkKJ5E646Y_cjs.canSpendOffchain(vtxo, now)) continue;
12478
+ if (!chunkKMPNH7NS_cjs.canSpendOffchain(vtxo, now)) continue;
12470
12479
  if (vtxo.isPreconfirmed) {
12471
12480
  preconfirmed += vtxo.value;
12472
12481
  } else {
@@ -12636,12 +12645,12 @@ var InputSignerRouter = class {
12636
12645
  };
12637
12646
 
12638
12647
  // src/wallet/wallet.ts
12639
- var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkKJ5E646Y_cjs.DEFAULT_ARKADE_SERVER_URL;
12648
+ var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkKMPNH7NS_cjs.DEFAULT_ARKADE_SERVER_URL;
12640
12649
  function intentProofJobs(coins) {
12641
12650
  if (coins.length === 0) return [];
12642
12651
  const coinJobs = coins.map((coin, i) => ({
12643
12652
  index: i + 1,
12644
- lookupScript: chunkKJ5E646Y_cjs.VtxoScript.decode(coin.tapTree).pkScript
12653
+ lookupScript: chunkKMPNH7NS_cjs.VtxoScript.decode(coin.tapTree).pkScript
12645
12654
  }));
12646
12655
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
12647
12656
  }
@@ -12673,7 +12682,7 @@ function dedupeTimelocks(timelocks) {
12673
12682
  const seen = /* @__PURE__ */ new Set();
12674
12683
  const deduped = [];
12675
12684
  for (const timelock of timelocks) {
12676
- const sequence = chunkKJ5E646Y_cjs.timelockToSequence(timelock).toString();
12685
+ const sequence = chunkKMPNH7NS_cjs.timelockToSequence(timelock).toString();
12677
12686
  if (seen.has(sequence)) continue;
12678
12687
  seen.add(sequence);
12679
12688
  deduped.push(timelock);
@@ -12690,7 +12699,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12690
12699
  state: "active"
12691
12700
  });
12692
12701
  const newest = candidates.filter(
12693
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunk2D7F5IU3_cjs.WALLET_RECEIVE_SOURCE
12702
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE
12694
12703
  ).sort((a, b) => {
12695
12704
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12696
12705
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12698,7 +12707,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12698
12707
  if (!newest?.params.pubKey) return baseline;
12699
12708
  try {
12700
12709
  const pubKey = base.hex.decode(newest.params.pubKey);
12701
- return new chunk2D7F5IU3_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12710
+ return new chunkDXLVCFVK_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12702
12711
  } catch (e) {
12703
12712
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
12704
12713
  return baseline;
@@ -12717,10 +12726,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
12717
12726
  if (vtxo.isUnrolled) {
12718
12727
  return !!f.withUnrolled;
12719
12728
  }
12720
- if (chunkKJ5E646Y_cjs.hasTerminalSpend(vtxo)) {
12729
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)) {
12721
12730
  return false;
12722
12731
  }
12723
- if (!f.withRecoverable && chunkKJ5E646Y_cjs.canRecoverOnchain(vtxo, now)) {
12732
+ if (!f.withRecoverable && chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
12724
12733
  return false;
12725
12734
  }
12726
12735
  return true;
@@ -13060,7 +13069,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13060
13069
  */
13061
13070
  static async setupWalletConfig(config, pubKey) {
13062
13071
  const arkadeServerUrl = getArkadeServerUrl(config);
13063
- const arkProvider = config.arkProvider || new chunkKJ5E646Y_cjs.RestArkProvider(arkadeServerUrl);
13072
+ const arkProvider = config.arkProvider || new chunkKMPNH7NS_cjs.RestArkProvider(arkadeServerUrl);
13064
13073
  let indexerProvider = config.indexerProvider;
13065
13074
  if (!indexerProvider) {
13066
13075
  let indexerUrl = config.indexerUrl;
@@ -13077,7 +13086,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13077
13086
  indexerUrl = arkadeServerUrl;
13078
13087
  }
13079
13088
  }
13080
- indexerProvider = new chunkD5DLGVN4_cjs.RestIndexerProvider(indexerUrl);
13089
+ indexerProvider = new chunkAS3W34MG_cjs.RestIndexerProvider(indexerUrl);
13081
13090
  }
13082
13091
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
13083
13092
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -13086,7 +13095,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13086
13095
  source: serverInfoSource,
13087
13096
  lastOnlineAt: serverInfoLastOnlineAt
13088
13097
  } = await resolveArkInfo(arkProvider, walletRepository);
13089
- const network = chunkKJ5E646Y_cjs.getNetwork(info.network);
13098
+ const network = chunkKMPNH7NS_cjs.getNetwork(info.network);
13090
13099
  if ("descriptor" in config.identity) {
13091
13100
  const descriptor = config.identity.descriptor;
13092
13101
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -13126,18 +13135,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
13126
13135
  value: info.boardingExitDelay,
13127
13136
  type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
13128
13137
  };
13129
- const serverPubKey = chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13130
- const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
13138
+ const serverPubKey = chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13139
+ const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : void 0;
13131
13140
  const offchainOptions = {
13132
13141
  pubKey,
13133
13142
  serverPubKey,
13134
13143
  csvTimelock: exitTimelock
13135
13144
  };
13136
- const offchainTapscript = !delegatePubKey ? new chunk2D7F5IU3_cjs.DefaultVtxo.Script(offchainOptions) : new chunk2D7F5IU3_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13137
- const boardingTapscript = chunk2D7F5IU3_cjs.BoardingContractHandler.createScript({
13145
+ const offchainTapscript = !delegatePubKey ? new chunkDXLVCFVK_cjs.DefaultVtxo.Script(offchainOptions) : new chunkDXLVCFVK_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13146
+ const boardingTapscript = chunkDXLVCFVK_cjs.BoardingContractHandler.createScript({
13138
13147
  pubKey: base.hex.encode(pubKey),
13139
13148
  serverPubKey: base.hex.encode(serverPubKey),
13140
- csvTimelock: chunkKJ5E646Y_cjs.timelockToSequence(boardingTimelock).toString()
13149
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(boardingTimelock).toString()
13141
13150
  });
13142
13151
  return {
13143
13152
  arkProvider,
@@ -13303,7 +13312,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13303
13312
  if (!filter?.withUnrolled) {
13304
13313
  logExcludedVtxos(
13305
13314
  "getSpendableVtxos",
13306
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkKJ5E646Y_cjs.hasTerminalSpend(vtxo)),
13315
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)),
13307
13316
  [() => UNROLLED_REASON]
13308
13317
  );
13309
13318
  }
@@ -13447,7 +13456,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13447
13456
  this.getBoardingTxs()
13448
13457
  ]);
13449
13458
  const allVtxos = snapshot.flatMap((_) => _.vtxos);
13450
- const resolveTxCreatedAt = (txids) => chunkKJ5E646Y_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13459
+ const resolveTxCreatedAt = (txids) => chunkKMPNH7NS_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13451
13460
  return buildTransactionHistory(
13452
13461
  allVtxos,
13453
13462
  boardingTxs,
@@ -13542,7 +13551,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13542
13551
  },
13543
13552
  isUnrolled: true,
13544
13553
  ...boardingFacts,
13545
- virtualStatus: chunkKJ5E646Y_cjs.toVirtualStatus(boardingFacts),
13554
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(boardingFacts),
13546
13555
  spentBy: "",
13547
13556
  createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
13548
13557
  script: scriptHex
@@ -13598,9 +13607,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13598
13607
  async getBoardingTapscripts(allowedSigners) {
13599
13608
  const byScript = /* @__PURE__ */ new Map();
13600
13609
  const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
13601
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunk2D7F5IU3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13610
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13602
13611
  add(
13603
- new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
13612
+ new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
13604
13613
  pubKey: await this.identity.xOnlyPublicKey(),
13605
13614
  serverPubKey: this.boardingTapscript.options.serverPubKey,
13606
13615
  csvTimelock: boardingCsv
@@ -13615,7 +13624,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13615
13624
  for (const c of boardingContracts) {
13616
13625
  if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
13617
13626
  try {
13618
- add(chunk2D7F5IU3_cjs.BoardingContractHandler.createScript(c.params));
13627
+ add(chunkDXLVCFVK_cjs.BoardingContractHandler.createScript(c.params));
13619
13628
  } catch (e) {
13620
13629
  console.warn("Skipping malformed boarding contract", c.script, e);
13621
13630
  }
@@ -13653,7 +13662,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13653
13662
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
13654
13663
  // not the wallet's current boarding timelock, which a signer
13655
13664
  // rotation may have changed.
13656
- csvTimelock: chunkKJ5E646Y_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13665
+ csvTimelock: chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13657
13666
  coins: utxos
13658
13667
  });
13659
13668
  }
@@ -13786,7 +13795,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13786
13795
  /** Fetch Arkade transaction ids that are still pending final settlement. */
13787
13796
  async fetchPendingTxs() {
13788
13797
  const scripts = await this.getWalletScripts();
13789
- const vtxos = await chunkKJ5E646Y_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13798
+ const vtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13790
13799
  return vtxos.filter(
13791
13800
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
13792
13801
  ).map((_) => _.arkTxId);
@@ -13817,7 +13826,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13817
13826
  });
13818
13827
  for (const contract of contracts) {
13819
13828
  if (map.has(contract.script)) continue;
13820
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
13829
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
13821
13830
  if (handler) {
13822
13831
  const script = handler.createScript(contract.params);
13823
13832
  map.set(contract.script, script);
@@ -13929,7 +13938,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13929
13938
  }
13930
13939
  });
13931
13940
  const baselinePubkey = await this.identity.xOnlyPublicKey();
13932
- const delegatePubKey = this.offchainTapscript instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13941
+ const delegatePubKey = this.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
13933
13942
  const baselineSigners = [
13934
13943
  this.offchainTapscript.options.serverPubKey,
13935
13944
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -13937,8 +13946,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13937
13946
  const seenBaselineScripts = /* @__PURE__ */ new Set();
13938
13947
  for (const serverPubKey of baselineSigners) {
13939
13948
  for (const csvTimelock of this.walletContractTimelocks) {
13940
- const csvTimelockStr = chunkKJ5E646Y_cjs.timelockToSequence(csvTimelock).toString();
13941
- const defaultScript = new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
13949
+ const csvTimelockStr = chunkKMPNH7NS_cjs.timelockToSequence(csvTimelock).toString();
13950
+ const defaultScript = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
13942
13951
  pubKey: baselinePubkey,
13943
13952
  serverPubKey,
13944
13953
  csvTimelock
@@ -13959,7 +13968,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13959
13968
  });
13960
13969
  }
13961
13970
  if (delegatePubKey) {
13962
- const delegateScript = new chunk2D7F5IU3_cjs.DelegateVtxo.Script({
13971
+ const delegateScript = new chunkDXLVCFVK_cjs.DelegateVtxo.Script({
13963
13972
  pubKey: baselinePubkey,
13964
13973
  serverPubKey,
13965
13974
  delegatePubKey,
@@ -13983,9 +13992,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13983
13992
  }
13984
13993
  }
13985
13994
  }
13986
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunk2D7F5IU3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13995
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13987
13996
  for (const serverPubKey of baselineSigners) {
13988
- const baselineBoarding = new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
13997
+ const baselineBoarding = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
13989
13998
  pubKey: baselinePubkey,
13990
13999
  serverPubKey,
13991
14000
  csvTimelock: boardingCsvTimelock
@@ -13998,7 +14007,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13998
14007
  params: {
13999
14008
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
14000
14009
  serverPubKey: base.hex.encode(serverPubKey),
14001
- csvTimelock: chunkKJ5E646Y_cjs.timelockToSequence(boardingCsvTimelock).toString()
14010
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(boardingCsvTimelock).toString()
14002
14011
  },
14003
14012
  script: boardingScriptHex,
14004
14013
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -14198,7 +14207,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14198
14207
  serverPubKey: this.offchainTapscript.options.serverPubKey,
14199
14208
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
14200
14209
  csvTimelocks: this.walletContractTimelocks,
14201
- delegatePubKey: this.offchainTapscript instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14210
+ delegatePubKey: this.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14202
14211
  };
14203
14212
  }
14204
14213
  _signerRouter;
@@ -14443,7 +14452,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14443
14452
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
14444
14453
  const persisted = row?.metadata?.signingDescriptor;
14445
14454
  if (typeof persisted === "string") return persisted;
14446
- return chunk2D7F5IU3_cjs.identityDescriptor(this.identity);
14455
+ return chunkDXLVCFVK_cjs.identityDescriptor(this.identity);
14447
14456
  }
14448
14457
  /**
14449
14458
  * Build, persist and shape one address of `type` owned by `descriptor` —
@@ -14459,7 +14468,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14459
14468
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
14460
14469
  if (type === "boarding") {
14461
14470
  const built2 = this.buildBoardingContract(
14462
- chunk2D7F5IU3_cjs.deriveDescriptorLeafPubKey(descriptor),
14471
+ chunkDXLVCFVK_cjs.deriveDescriptorLeafPubKey(descriptor),
14463
14472
  descriptor,
14464
14473
  tagSource
14465
14474
  );
@@ -14504,11 +14513,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14504
14513
  * {@link buildReceiveContract}.
14505
14514
  */
14506
14515
  buildBoardingContract(pubKey, descriptor, tagSource) {
14507
- const tapscript = new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
14516
+ const tapscript = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
14508
14517
  ...this._boardingTapscript.options,
14509
14518
  pubKey
14510
14519
  });
14511
- const csvTimelock = tapscript.options.csvTimelock ?? chunk2D7F5IU3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14520
+ const csvTimelock = tapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14512
14521
  return {
14513
14522
  tapscript,
14514
14523
  params: {
@@ -14516,13 +14525,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14516
14525
  params: {
14517
14526
  pubKey: base.hex.encode(pubKey),
14518
14527
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
14519
- csvTimelock: chunkKJ5E646Y_cjs.timelockToSequence(csvTimelock).toString()
14528
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(csvTimelock).toString()
14520
14529
  },
14521
14530
  script: base.hex.encode(tapscript.pkScript),
14522
14531
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
14523
14532
  state: "active",
14524
14533
  metadata: {
14525
- ...tagSource && { source: chunk2D7F5IU3_cjs.WALLET_RECEIVE_SOURCE },
14534
+ ...tagSource && { source: chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE },
14526
14535
  signingDescriptor: descriptor
14527
14536
  }
14528
14537
  }
@@ -14551,7 +14560,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14551
14560
  if (this._descriptorProvider instanceof HDDescriptorProvider) {
14552
14561
  return (await this.getContractManager()).getNextSigningDescriptor();
14553
14562
  }
14554
- return chunk2D7F5IU3_cjs.identityDescriptor(this.identity);
14563
+ return chunkDXLVCFVK_cjs.identityDescriptor(this.identity);
14555
14564
  }
14556
14565
  /**
14557
14566
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -14647,7 +14656,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14647
14656
  * the stable public API.
14648
14657
  */
14649
14658
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
14650
- const xonly = chunk2D7F5IU3_cjs.toXOnly(newServerPubKey, "ark signer key");
14659
+ const xonly = chunkDXLVCFVK_cjs.toXOnly(newServerPubKey, "ark signer key");
14651
14660
  const newServerUnrollScript = assertValidServerUnrollScript(
14652
14661
  checkpointTapscript,
14653
14662
  resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
@@ -14676,21 +14685,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14676
14685
  const [currentBoardingRow] = await manager.getContracts({
14677
14686
  script: currentBoardingScript
14678
14687
  });
14679
- const newOffchain = this.offchainTapscript instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script ? new chunk2D7F5IU3_cjs.DelegateVtxo.Script({
14688
+ const newOffchain = this.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? new chunkDXLVCFVK_cjs.DelegateVtxo.Script({
14680
14689
  ...this.offchainTapscript.options,
14681
14690
  serverPubKey: xonly
14682
- }) : new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
14691
+ }) : new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
14683
14692
  ...this.offchainTapscript.options,
14684
14693
  serverPubKey: xonly
14685
14694
  });
14686
- const newBoarding = new chunk2D7F5IU3_cjs.DefaultVtxo.Script({
14695
+ const newBoarding = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
14687
14696
  ...this._boardingTapscript.options,
14688
14697
  serverPubKey: xonly
14689
14698
  });
14690
- const offchainCsv = chunkKJ5E646Y_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14699
+ const offchainCsv = chunkKMPNH7NS_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14691
14700
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
14692
14701
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
14693
- if (newOffchain instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script) {
14702
+ if (newOffchain instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script) {
14694
14703
  await manager.createContract({
14695
14704
  type: "delegate",
14696
14705
  params: {
@@ -14718,13 +14727,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14718
14727
  metadata: currentOffchainRow?.metadata
14719
14728
  });
14720
14729
  }
14721
- const boardingCsv = newBoarding.options.csvTimelock ?? chunk2D7F5IU3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14730
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14722
14731
  await manager.createContract({
14723
14732
  type: "boarding",
14724
14733
  params: {
14725
14734
  pubKey: base.hex.encode(newBoarding.options.pubKey),
14726
14735
  serverPubKey: base.hex.encode(xonly),
14727
- csvTimelock: chunkKJ5E646Y_cjs.timelockToSequence(boardingCsv).toString()
14736
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(boardingCsv).toString()
14728
14737
  },
14729
14738
  script: base.hex.encode(newBoarding.pkScript),
14730
14739
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -14757,14 +14766,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14757
14766
  _restoreInFlight;
14758
14767
  _addPendingSpends(inputs) {
14759
14768
  for (const input of inputs) {
14760
- if (chunkKJ5E646Y_cjs.isVirtualCoin(input)) {
14769
+ if (chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
14761
14770
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
14762
14771
  }
14763
14772
  }
14764
14773
  }
14765
14774
  _removePendingSpends(inputs) {
14766
14775
  for (const input of inputs) {
14767
- if (chunkKJ5E646Y_cjs.isVirtualCoin(input)) {
14776
+ if (chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
14768
14777
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
14769
14778
  }
14770
14779
  }
@@ -14825,13 +14834,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14825
14834
  const manager = await this.getContractManager();
14826
14835
  const provider = this._descriptorProvider;
14827
14836
  const hd = provider instanceof HDDescriptorProvider;
14828
- const staticDescriptor = hd ? void 0 : await chunk2D7F5IU3_cjs.identityDescriptor(this.identity);
14837
+ const staticDescriptor = hd ? void 0 : await chunkDXLVCFVK_cjs.identityDescriptor(this.identity);
14829
14838
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
14830
- const delegatePubKey = this.offchainTapscript instanceof chunk2D7F5IU3_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14839
+ const delegatePubKey = this.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
14831
14840
  const arkInfo = await this.arkProvider.getInfo();
14832
- const currentSignerPubKey = chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14841
+ const currentSignerPubKey = chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14833
14842
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
14834
- (s) => chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14843
+ (s) => chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14835
14844
  );
14836
14845
  const deps = {
14837
14846
  indexerProvider: this.indexerProvider,
@@ -14846,7 +14855,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14846
14855
  csvTimelocks: this.walletContractTimelocks,
14847
14856
  // Boarding-exit CSV so the boarding handler can build its
14848
14857
  // candidate script (distinct from the unilateral-exit matrix).
14849
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunk2D7F5IU3_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14858
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14850
14859
  delegatePubKey
14851
14860
  };
14852
14861
  const result = await manager.scanContracts({
@@ -14960,7 +14969,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14960
14969
  throw new Error("Invalid configured public key");
14961
14970
  }
14962
14971
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
14963
- const forfeitPubkey = chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14972
+ const forfeitPubkey = chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14964
14973
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
14965
14974
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
14966
14975
  const checkpointExitDelayOverrides = {
@@ -15109,7 +15118,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15109
15118
  inputs: params.selectedVtxos,
15110
15119
  changeAmount: BigInt(changeAmount)
15111
15120
  };
15112
- const outputAddress = chunkKJ5E646Y_cjs.ArkAddress.decode(params.address);
15121
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(params.address);
15113
15122
  assertRecipientArkAddress(
15114
15123
  params.address,
15115
15124
  outputAddress,
@@ -15175,13 +15184,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15175
15184
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
15176
15185
  }
15177
15186
  const offchainAddress = await this.getAddress();
15178
- const offchainPkScript = chunkKJ5E646Y_cjs.ArkAddress.decode(offchainAddress).pkScript;
15187
+ const offchainPkScript = chunkKMPNH7NS_cjs.ArkAddress.decode(offchainAddress).pkScript;
15179
15188
  const offchainOutputScript = base.hex.encode(offchainPkScript);
15180
15189
  if (!params) {
15181
15190
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
15182
15191
  const estimator = new Estimator(fees.intentFee);
15183
15192
  let amount = 0;
15184
- const exitScript = chunkKJ5E646Y_cjs.CSVMultisigTapscript.decode(
15193
+ const exitScript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(
15185
15194
  base.hex.decode(this.boardingTapscript.exitScript)
15186
15195
  );
15187
15196
  const boardingTimelock = exitScript.params.timelock;
@@ -15210,7 +15219,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15210
15219
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
15211
15220
  break;
15212
15221
  }
15213
- const inputFee = estimator.evalOffchainInput(chunkKJ5E646Y_cjs.toOffchainInputFeeParams(vtxo));
15222
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(vtxo));
15214
15223
  if (inputFee.satoshis >= vtxo.value) {
15215
15224
  continue;
15216
15225
  }
@@ -15257,7 +15266,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15257
15266
  let script;
15258
15267
  let arkAddress;
15259
15268
  try {
15260
- arkAddress = chunkKJ5E646Y_cjs.ArkAddress.decode(output.address);
15269
+ arkAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(output.address);
15261
15270
  } catch {
15262
15271
  arkAddress = void 0;
15263
15272
  }
@@ -15347,7 +15356,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15347
15356
  const abortController = new AbortController();
15348
15357
  let stream;
15349
15358
  let committedTxid;
15350
- const settleInputVtxos = params.inputs.filter(chunkKJ5E646Y_cjs.isVirtualCoin);
15359
+ const settleInputVtxos = params.inputs.filter(chunkKMPNH7NS_cjs.isVirtualCoin);
15351
15360
  const contractManager = await this.getContractManager();
15352
15361
  await contractManager.assertAnnotatable(settleInputVtxos);
15353
15362
  await contractManager.assertSpendableNow?.(
@@ -15459,7 +15468,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15459
15468
  async maybeRotateBoardingAfterBoard(inputs) {
15460
15469
  if (!this._descriptorProvider) return;
15461
15470
  const consumedBoarding = inputs.some(
15462
- (input) => typeof input !== "string" && !chunkKJ5E646Y_cjs.isVirtualCoin(input)
15471
+ (input) => typeof input !== "string" && !chunkKMPNH7NS_cjs.isVirtualCoin(input)
15463
15472
  );
15464
15473
  if (!consumedBoarding) return;
15465
15474
  try {
@@ -15483,7 +15492,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15483
15492
  let connectorIndex = 0;
15484
15493
  const connectorsLeaves = connectorsGraph?.leaves() || [];
15485
15494
  for (const input of inputs) {
15486
- if (!chunkKJ5E646Y_cjs.isVirtualCoin(input)) {
15495
+ if (!chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
15487
15496
  let matched = false;
15488
15497
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
15489
15498
  const settlementInput = settlementPsbt.getInput(i);
@@ -15521,7 +15530,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15521
15530
  }
15522
15531
  continue;
15523
15532
  }
15524
- if (chunkKJ5E646Y_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
15533
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(input, { timestamp: /* @__PURE__ */ new Date() }) || isSubdust({ value: input.value }, this.dustAmount)) {
15525
15534
  continue;
15526
15535
  }
15527
15536
  if (connectorsLeaves.length === 0) {
@@ -15549,7 +15558,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15549
15558
  index: input.vout,
15550
15559
  witnessUtxo: {
15551
15560
  amount: BigInt(input.value),
15552
- script: chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).pkScript
15561
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
15553
15562
  },
15554
15563
  sighashType: btcSigner.SigHash.DEFAULT,
15555
15564
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -15568,7 +15577,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15568
15577
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
15569
15578
  {
15570
15579
  index: 0,
15571
- lookupScript: chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).pkScript
15580
+ lookupScript: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
15572
15581
  }
15573
15582
  ]);
15574
15583
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -15626,7 +15635,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15626
15635
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
15627
15636
  );
15628
15637
  await this.arkProvider.confirmRegistration(intentId);
15629
- const sweepTapscript = chunkKJ5E646Y_cjs.CSVMultisigTapscript.encode({
15638
+ const sweepTapscript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.encode({
15630
15639
  timelock,
15631
15640
  pubkeys: [this.forfeitPubkey]
15632
15641
  }).script;
@@ -15641,10 +15650,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15641
15650
  throw new Error("Sweep tap tree root not set");
15642
15651
  }
15643
15652
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
15644
- (k) => base.hex.encode(chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15653
+ (k) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15645
15654
  );
15646
15655
  const signerPublicKey = await session.getPublicKey();
15647
- const xonlySignerPublicKey = chunk2D7F5IU3_cjs.toXOnly(signerPublicKey, "signer key");
15656
+ const xonlySignerPublicKey = chunkDXLVCFVK_cjs.toXOnly(signerPublicKey, "signer key");
15648
15657
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
15649
15658
  return { skip: true };
15650
15659
  }
@@ -15734,9 +15743,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15734
15743
  ...existing ?? {},
15735
15744
  intentTxId,
15736
15745
  registerProof: intent.proof,
15737
- registerProofMessage: chunkKJ5E646Y_cjs.Intent.encodeMessage(intent.message),
15746
+ registerProofMessage: chunkKMPNH7NS_cjs.Intent.encodeMessage(intent.message),
15738
15747
  deleteProof: deleteIntent.proof,
15739
- deleteProofMessage: chunkKJ5E646Y_cjs.Intent.encodeMessage(deleteIntent.message),
15748
+ deleteProofMessage: chunkKMPNH7NS_cjs.Intent.encodeMessage(deleteIntent.message),
15740
15749
  intentVtxos: inputs.map((i) => ({
15741
15750
  txid: i.txid,
15742
15751
  vout: i.vout
@@ -15768,7 +15777,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15768
15777
  try {
15769
15778
  return await this.arkProvider.registerIntent(intent);
15770
15779
  } catch (error) {
15771
- if (error instanceof chunkKJ5E646Y_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15780
+ if (error instanceof chunkKMPNH7NS_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
15772
15781
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
15773
15782
  await this.arkProvider.deleteIntent(deleteIntent);
15774
15783
  return this.arkProvider.registerIntent(intent);
@@ -15784,7 +15793,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15784
15793
  expire_at: 0,
15785
15794
  cosigners_public_keys: cosignerPubKeys
15786
15795
  };
15787
- const proof = chunkKJ5E646Y_cjs.Intent.create(message, coins, outputs);
15796
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, outputs);
15788
15797
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15789
15798
  return {
15790
15799
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15796,7 +15805,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15796
15805
  type: "delete",
15797
15806
  expire_at: 0
15798
15807
  };
15799
- const proof = chunkKJ5E646Y_cjs.Intent.create(message, coins, []);
15808
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, []);
15800
15809
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15801
15810
  return {
15802
15811
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15808,7 +15817,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15808
15817
  type: "get-pending-tx",
15809
15818
  expire_at: 0
15810
15819
  };
15811
- const proof = chunkKJ5E646Y_cjs.Intent.create(message, coins, []);
15820
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, []);
15812
15821
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15813
15822
  return {
15814
15823
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15829,7 +15838,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15829
15838
  if (!vtxos || vtxos.length === 0) {
15830
15839
  const scriptMap = await this.getScriptMap();
15831
15840
  const allExtended = [];
15832
- const fetchedVtxos = await chunkKJ5E646Y_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15841
+ const fetchedVtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15833
15842
  ...scriptMap.keys()
15834
15843
  ]);
15835
15844
  for (const vtxo of fetchedVtxos) {
@@ -15873,7 +15882,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15873
15882
  try {
15874
15883
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
15875
15884
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
15876
- chunkKJ5E646Y_cjs.assertAllowedSighashTypes(tx);
15885
+ chunkKMPNH7NS_cjs.assertAllowedSighashTypes(tx);
15877
15886
  return tx;
15878
15887
  });
15879
15888
  assertCheckpointsMatchInputs(
@@ -15945,11 +15954,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15945
15954
  * against the current key alone would leave it pending forever.
15946
15955
  */
15947
15956
  checkpointUnrollCandidates(info) {
15948
- const current = chunkKJ5E646Y_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15957
+ const current = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15949
15958
  const candidates = [this._serverUnrollScript, current];
15950
15959
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
15951
15960
  candidates.push(
15952
- chunkKJ5E646Y_cjs.CSVMultisigTapscript.encode({
15961
+ chunkKMPNH7NS_cjs.CSVMultisigTapscript.encode({
15953
15962
  ...current.params,
15954
15963
  pubkeys: [base.hex.decode(deprecated)]
15955
15964
  })
@@ -16040,7 +16049,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16040
16049
  if (vtxos.length === 0) {
16041
16050
  throw new Error("No VTXOs found for this arkadeCash");
16042
16051
  }
16043
- const myPkScript = chunkKJ5E646Y_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
16052
+ const myPkScript = chunkKMPNH7NS_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
16044
16053
  let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
16045
16054
  let swept = 0;
16046
16055
  const drainable = vtxos.filter(
@@ -16116,7 +16125,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16116
16125
  const spendable = [];
16117
16126
  const unclaimed = [];
16118
16127
  for (const vtxo of vtxos) {
16119
- if (chunkKJ5E646Y_cjs.hasTerminalSpend(vtxo)) {
16128
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)) {
16120
16129
  unclaimed.push(cashReport(vtxo, "already-spent"));
16121
16130
  } else if (vtxo.isUnrolled) {
16122
16131
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -16138,7 +16147,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16138
16147
  const all = [];
16139
16148
  const seen = /* @__PURE__ */ new Set();
16140
16149
  for (let pageIndex = 0; ; pageIndex++) {
16141
- const { vtxos, page } = await chunkKJ5E646Y_cjs.getNormalizedVtxos(this.indexerProvider, {
16150
+ const { vtxos, page } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(this.indexerProvider, {
16142
16151
  scripts,
16143
16152
  pageIndex,
16144
16153
  pageSize
@@ -16185,7 +16194,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16185
16194
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
16186
16195
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
16187
16196
  const message = { type: "get-pending-tx", expire_at: 0 };
16188
- const proof = chunkKJ5E646Y_cjs.Intent.create(message, batch, []);
16197
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, batch, []);
16189
16198
  const signedProof = await identity.sign(
16190
16199
  proof,
16191
16200
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -16207,7 +16216,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16207
16216
  try {
16208
16217
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
16209
16218
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
16210
- chunkKJ5E646Y_cjs.assertAllowedSighashTypes(tx);
16219
+ chunkKMPNH7NS_cjs.assertAllowedSighashTypes(tx);
16211
16220
  return tx;
16212
16221
  });
16213
16222
  assertCheckpointsMatchInputs(
@@ -16406,7 +16415,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16406
16415
  script: recipient.script,
16407
16416
  amount: BigInt(recipient.amount),
16408
16417
  // Already checked against the recipient address in `validateRecipients`.
16409
- ...recipient.tapTree ? { tapTree: chunkKJ5E646Y_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16418
+ ...recipient.tapTree ? { tapTree: chunkKMPNH7NS_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16410
16419
  }));
16411
16420
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
16412
16421
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -16550,10 +16559,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16550
16559
  const serverPubKey = this.arkServerPublicKey;
16551
16560
  const serverUnrollScript = this.serverUnrollScript;
16552
16561
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
16553
- const normalizedInputs = inputs.map(chunkKJ5E646Y_cjs.normalizeVtxo);
16554
- const at = now ?? await chunkKJ5E646Y_cjs.resolveTimeHeight(this.onchainProvider);
16562
+ const normalizedInputs = inputs.map(chunkKMPNH7NS_cjs.normalizeVtxo);
16563
+ const at = now ?? await chunkKMPNH7NS_cjs.resolveTimeHeight(this.onchainProvider);
16555
16564
  for (const input of normalizedInputs) {
16556
- if (!chunkKJ5E646Y_cjs.canSpendOffchain(input, at)) {
16565
+ if (!chunkKMPNH7NS_cjs.canSpendOffchain(input, at)) {
16557
16566
  throw new Error(
16558
16567
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
16559
16568
  );
@@ -16623,7 +16632,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16623
16632
  );
16624
16633
  const arkTxJobs = inputs.map((input, index) => ({
16625
16634
  index,
16626
- lookupScript: chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).pkScript
16635
+ lookupScript: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
16627
16636
  }));
16628
16637
  const identity = this.identity;
16629
16638
  const signer = {
@@ -16724,14 +16733,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16724
16733
  const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
16725
16734
  spentVtxos.push({
16726
16735
  ...spentFacts,
16727
- virtualStatus: chunkKJ5E646Y_cjs.toVirtualStatus(spentFacts),
16736
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(spentFacts),
16728
16737
  ...spentBy ? { spentBy } : {},
16729
16738
  arkTxId: arkTxid
16730
16739
  });
16731
16740
  for (const id of vtxo.commitmentTxIds) {
16732
16741
  commitmentTxIds.add(id);
16733
16742
  }
16734
- const vtxoExpiry = chunkKJ5E646Y_cjs.toBatchExpiry(vtxo);
16743
+ const vtxoExpiry = chunkKMPNH7NS_cjs.toBatchExpiry(vtxo);
16735
16744
  if (vtxoExpiry) {
16736
16745
  batchExpiry = Math.min(batchExpiry, vtxoExpiry);
16737
16746
  }
@@ -16744,7 +16753,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16744
16753
  isSwept: false,
16745
16754
  isPreconfirmed: true,
16746
16755
  commitmentTxIds: Array.from(commitmentTxIds),
16747
- ...chunkKJ5E646Y_cjs.parseLegacyExpiry(batchExpiry)
16756
+ ...chunkKMPNH7NS_cjs.parseLegacyExpiry(batchExpiry)
16748
16757
  };
16749
16758
  changeVtxo = {
16750
16759
  txid: arkTxid,
@@ -16756,7 +16765,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16756
16765
  tapTree: offchainTapscript.encode(),
16757
16766
  value: Number(changeAmount),
16758
16767
  ...changeFacts,
16759
- virtualStatus: chunkKJ5E646Y_cjs.toVirtualStatus(changeFacts),
16768
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(changeFacts),
16760
16769
  spentBy: "",
16761
16770
  status: {
16762
16771
  confirmed: false
@@ -16825,12 +16834,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16825
16834
  const spentVtxos = [];
16826
16835
  const inputArkTxIds = /* @__PURE__ */ new Set();
16827
16836
  const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
16828
- const vtxoInputs = inputs.filter(chunkKJ5E646Y_cjs.isVirtualCoin);
16837
+ const vtxoInputs = inputs.filter(chunkKMPNH7NS_cjs.isVirtualCoin);
16829
16838
  const cm = await this.getContractManager();
16830
16839
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
16831
16840
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
16832
16841
  for (const input of inputs) {
16833
- if (chunkKJ5E646Y_cjs.isVirtualCoin(input)) {
16842
+ if (chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
16834
16843
  const outpoint = `${input.txid}:${input.vout}`;
16835
16844
  const vtxo = annotatedByKey.get(outpoint);
16836
16845
  if (!vtxo) {
@@ -16842,13 +16851,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16842
16851
  const settledFacts = { ...vtxo, isSpent: true };
16843
16852
  spentVtxos.push({
16844
16853
  ...settledFacts,
16845
- virtualStatus: chunkKJ5E646Y_cjs.toVirtualStatus(settledFacts),
16854
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(settledFacts),
16846
16855
  settledBy: commitmentTxid
16847
16856
  });
16848
16857
  } else {
16849
16858
  let sourceAddress;
16850
16859
  try {
16851
- sourceAddress = chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16860
+ sourceAddress = chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16852
16861
  this.network
16853
16862
  );
16854
16863
  } catch {
@@ -16906,9 +16915,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16906
16915
  }
16907
16916
  };
16908
16917
  function selectVirtualCoins(coins, targetAmount) {
16909
- const sortedCoins = coins.map(chunkKJ5E646Y_cjs.normalizeVtxo).sort((a, b) => {
16910
- const expiryA = chunkKJ5E646Y_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
16911
- const expiryB = chunkKJ5E646Y_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
16918
+ const sortedCoins = coins.map(chunkKMPNH7NS_cjs.normalizeVtxo).sort((a, b) => {
16919
+ const expiryA = chunkKMPNH7NS_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
16920
+ const expiryB = chunkKMPNH7NS_cjs.toBatchExpiry(b) || Number.MAX_SAFE_INTEGER;
16912
16921
  if (expiryA !== expiryB) {
16913
16922
  return expiryA - expiryB;
16914
16923
  }
@@ -17277,7 +17286,7 @@ var MessageBus = class {
17277
17286
  this.initialized = true;
17278
17287
  }
17279
17288
  async buildServices(config) {
17280
- const arkProvider = new chunkKJ5E646Y_cjs.RestArkProvider(config.arkServer.url);
17289
+ const arkProvider = new chunkKMPNH7NS_cjs.RestArkProvider(config.arkServer.url);
17281
17290
  const storage = {
17282
17291
  walletRepository: this.walletRepository,
17283
17292
  contractRepository: this.contractRepository,
@@ -17619,7 +17628,7 @@ var offboardNetworkNames = [
17619
17628
  function offboardDestinationScript(destinationAddress) {
17620
17629
  for (const networkName of offboardNetworkNames) {
17621
17630
  try {
17622
- const network = chunkKJ5E646Y_cjs.networks[networkName];
17631
+ const network = chunkKMPNH7NS_cjs.networks[networkName];
17623
17632
  const addr = btcSigner.Address(network).decode(destinationAddress);
17624
17633
  return btcSigner.OutScript.encode(addr);
17625
17634
  } catch {
@@ -17628,6 +17637,23 @@ function offboardDestinationScript(destinationAddress) {
17628
17637
  }
17629
17638
  throw new Error(`Failed to decode destination address: ${destinationAddress}`);
17630
17639
  }
17640
+ var CHANGE_FEE_MAX_ROUNDS = 8;
17641
+ function settleChangeAgainstFee(change, feeOn) {
17642
+ let net = change;
17643
+ for (let i = 0; i < CHANGE_FEE_MAX_ROUNDS; i++) {
17644
+ const next = change - feeOn(net > 0n ? net : 0n);
17645
+ if (next === net) return net > 0n ? net : 0n;
17646
+ net = next;
17647
+ }
17648
+ throw new Error(
17649
+ `change fee does not settle after ${CHANGE_FEE_MAX_ROUNDS} rounds (${change} sats of change); settle the full balance instead`
17650
+ );
17651
+ }
17652
+ function reportUngatedInputs(wallet, inputs) {
17653
+ if (!("logUngatedInputs" in wallet)) return;
17654
+ const logger = wallet;
17655
+ void logger.logUngatedInputs("Ramps.offboard({ vtxos })", inputs);
17656
+ }
17631
17657
  var Ramps = class {
17632
17658
  /**
17633
17659
  * Create convenience wrappers for onboarding and offboarding flows.
@@ -17681,9 +17707,22 @@ var Ramps = class {
17681
17707
  }
17682
17708
  change = totalAmount - amount;
17683
17709
  }
17710
+ let boardingAddress;
17711
+ if (change > 0n) {
17712
+ boardingAddress = await this.wallet.getBoardingAddress();
17713
+ const changeScript = base.hex.encode(offboardDestinationScript(boardingAddress));
17714
+ change = settleChangeAgainstFee(
17715
+ change,
17716
+ (amt) => BigInt(estimator.evalOnchainOutput({ amount: amt, script: changeScript }).satoshis)
17717
+ );
17718
+ const dustAmount = getDustAmount(this.wallet);
17719
+ if (change > 0n && change < dustAmount) {
17720
+ throw new DustChangeError(change, dustAmount);
17721
+ }
17722
+ }
17684
17723
  amount = amount ?? totalAmount;
17685
17724
  const offchainAddress = await this.wallet.getAddress();
17686
- const offchainAddr = chunkKJ5E646Y_cjs.ArkAddress.decode(offchainAddress);
17725
+ const offchainAddr = chunkKMPNH7NS_cjs.ArkAddress.decode(offchainAddress);
17687
17726
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
17688
17727
  const outputFee = estimator.evalOffchainOutput({
17689
17728
  amount,
@@ -17702,7 +17741,6 @@ var Ramps = class {
17702
17741
  }
17703
17742
  ];
17704
17743
  if (change > 0n) {
17705
- const boardingAddress = await this.wallet.getBoardingAddress();
17706
17744
  outputs.push({
17707
17745
  address: boardingAddress,
17708
17746
  amount: change
@@ -17723,6 +17761,10 @@ var Ramps = class {
17723
17761
  * @param feeInfo - The fee info to deduct from the offboard amount.
17724
17762
  * @param amount - The amount to offboard. If not provided, the total amount of virtual outputs will be offboarded.
17725
17763
  * @param eventCallback - Optional callback that receives settlement events
17764
+ * @param vtxos - Specific virtual outputs to spend, mirroring {@link onboard}'s
17765
+ * `boardingUtxos`. Omitted, every spendable one is spent — merging the whole
17766
+ * off-chain balance into a single change output. Taken as given like
17767
+ * `settle({ inputs })`: an `amount` these cannot cover is an error, not a top-up.
17726
17768
  * @returns The Arkade transaction id created by settlement
17727
17769
  * @throws Error if no virtual outputs remain after fee deduction or the destination address cannot be decoded
17728
17770
  * @see IWallet.getSpendableVtxos
@@ -17734,8 +17776,10 @@ var Ramps = class {
17734
17776
  * await ramps.offboard('bc1q...', feeInfo);
17735
17777
  * ```
17736
17778
  */
17737
- async offboard(destinationAddress, feeInfo, amount, eventCallback) {
17738
- const vtxos = await this.wallet.getSpendableVtxos({
17779
+ async offboard(destinationAddress, feeInfo, amount, eventCallback, vtxos) {
17780
+ const named = vtxos !== void 0;
17781
+ if (vtxos) reportUngatedInputs(this.wallet, vtxos);
17782
+ vtxos ??= await this.wallet.getSpendableVtxos({
17739
17783
  withRecoverable: true,
17740
17784
  withUnrolled: false
17741
17785
  });
@@ -17743,8 +17787,13 @@ var Ramps = class {
17743
17787
  const filteredVtxos = [];
17744
17788
  let totalAmount = 0n;
17745
17789
  for (const vtxo of vtxos) {
17746
- const inputFee = estimator.evalOffchainInput(chunkKJ5E646Y_cjs.toOffchainInputFeeParams(vtxo));
17790
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(vtxo));
17747
17791
  if (inputFee.satoshis >= vtxo.value) {
17792
+ if (named) {
17793
+ throw new Error(
17794
+ `selected vtxo ${vtxo.txid}:${vtxo.vout} costs ${inputFee.satoshis} sats to spend and is worth ${vtxo.value} \u2014 drop it from the selection`
17795
+ );
17796
+ }
17748
17797
  continue;
17749
17798
  }
17750
17799
  filteredVtxos.push(vtxo);
@@ -17760,6 +17809,15 @@ var Ramps = class {
17760
17809
  }
17761
17810
  change = totalAmount - amount;
17762
17811
  }
17812
+ let changeAddress;
17813
+ if (change > 0n) {
17814
+ changeAddress = await this.wallet.getAddress();
17815
+ const changeScript = base.hex.encode(chunkKMPNH7NS_cjs.ArkAddress.decode(changeAddress).pkScript);
17816
+ change = settleChangeAgainstFee(
17817
+ change,
17818
+ (amount2) => BigInt(estimator.evalOffchainOutput({ amount: amount2, script: changeScript }).satoshis)
17819
+ );
17820
+ }
17763
17821
  const dustAmount = getDustAmount(this.wallet);
17764
17822
  if (change > 0n && change < dustAmount) {
17765
17823
  throw new DustChangeError(change, dustAmount);
@@ -17783,7 +17841,7 @@ var Ramps = class {
17783
17841
  }
17784
17842
  ];
17785
17843
  if (change > 0n) {
17786
- const offchainAddress = await this.wallet.getAddress();
17844
+ const offchainAddress = changeAddress;
17787
17845
  outputs.push({
17788
17846
  address: offchainAddress,
17789
17847
  amount: change
@@ -18614,7 +18672,7 @@ var WalletMessageHandler = class {
18614
18672
  // Wallet methods
18615
18673
  async handleInitWallet({ payload }) {
18616
18674
  const { arkServerUrl } = payload;
18617
- this.indexerProvider = new chunkD5DLGVN4_cjs.RestIndexerProvider(arkServerUrl);
18675
+ this.indexerProvider = new chunkAS3W34MG_cjs.RestIndexerProvider(arkServerUrl);
18618
18676
  await this.onWalletInitialized();
18619
18677
  }
18620
18678
  /**
@@ -18902,7 +18960,7 @@ var WalletMessageHandler = class {
18902
18960
  if (v.isUnrolled) {
18903
18961
  return withUnrolled;
18904
18962
  }
18905
- if (chunkKJ5E646Y_cjs.hasTerminalSpend(v)) {
18963
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(v)) {
18906
18964
  return false;
18907
18965
  }
18908
18966
  if (includeRecoverable) {
@@ -18911,10 +18969,10 @@ var WalletMessageHandler = class {
18911
18969
  if (dustAmount != null && isSubdust(v, dustAmount)) {
18912
18970
  return false;
18913
18971
  }
18914
- if (chunkKJ5E646Y_cjs.isRecoverable(v)) {
18972
+ if (chunkKMPNH7NS_cjs.isRecoverable(v)) {
18915
18973
  return false;
18916
18974
  }
18917
- if (chunkKJ5E646Y_cjs.isExpired(v)) {
18975
+ if (chunkKMPNH7NS_cjs.isExpired(v)) {
18918
18976
  return false;
18919
18977
  }
18920
18978
  return true;
@@ -19022,7 +19080,7 @@ var WalletMessageHandler = class {
19022
19080
  this.readonlyWallet.getBoardingTxs()
19023
19081
  ]);
19024
19082
  const indexerProvider = this.indexerProvider;
19025
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunkKJ5E646Y_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19083
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunkKMPNH7NS_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19026
19084
  return buildTransactionHistory(
19027
19085
  vtxos,
19028
19086
  boardingTxs,
@@ -19730,7 +19788,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19730
19788
  };
19731
19789
  try {
19732
19790
  const response = await this.sendMessage(message);
19733
- return response.payload.vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo);
19791
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
19734
19792
  } catch (error) {
19735
19793
  throw new Error(`Failed to get vtxos: ${error}`);
19736
19794
  }
@@ -19755,7 +19813,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19755
19813
  };
19756
19814
  try {
19757
19815
  const response = await this.sendMessage(message);
19758
- return response.payload.vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo);
19816
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
19759
19817
  } catch (error) {
19760
19818
  throw new Error(`Failed to get spendable vtxos: ${error}`);
19761
19819
  }
@@ -19926,7 +19984,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19926
19984
  };
19927
19985
  try {
19928
19986
  const response = await sendContractMessage(message);
19929
- return response.payload.vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo);
19987
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
19930
19988
  } catch (e) {
19931
19989
  throw new Error("Failed to annotate vtxos");
19932
19990
  }
@@ -20538,7 +20596,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
20538
20596
  };
20539
20597
  try {
20540
20598
  const response = await wallet.sendMessage(message);
20541
- return response.payload.vtxos.map(chunkKJ5E646Y_cjs.normalizeVtxo);
20599
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
20542
20600
  } catch (e) {
20543
20601
  throw new Error(`Failed to get expiring vtxos: ${e}`);
20544
20602
  }
@@ -20650,12 +20708,12 @@ var OnchainWallet = class _OnchainWallet {
20650
20708
  * @returns Configured onchain wallet
20651
20709
  * @throws Error if the configured identity cannot produce a valid x-only public key
20652
20710
  */
20653
- static async create(identity, networkName = chunkKJ5E646Y_cjs.DEFAULT_NETWORK_NAME, provider) {
20711
+ static async create(identity, networkName = chunkKMPNH7NS_cjs.DEFAULT_NETWORK_NAME, provider) {
20654
20712
  const pubkey = await identity.xOnlyPublicKey();
20655
20713
  if (!pubkey) {
20656
20714
  throw new Error("Invalid configured public key");
20657
20715
  }
20658
- const network = chunkKJ5E646Y_cjs.getNetwork(networkName);
20716
+ const network = chunkKMPNH7NS_cjs.getNetwork(networkName);
20659
20717
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
20660
20718
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
20661
20719
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -20761,7 +20819,7 @@ var OnchainWallet = class _OnchainWallet {
20761
20819
  if (!inputs) {
20762
20820
  throw new Error("Fee estimation failed");
20763
20821
  }
20764
- let tx = new chunkKJ5E646Y_cjs.Transaction();
20822
+ let tx = new chunkKMPNH7NS_cjs.Transaction();
20765
20823
  for (const input of inputs) {
20766
20824
  tx.addInput({
20767
20825
  txid: input.txid,
@@ -20819,7 +20877,7 @@ var OnchainWallet = class _OnchainWallet {
20819
20877
  * @throws If the parent has no anchor, or funding cannot be selected/signed
20820
20878
  */
20821
20879
  async bumpAnchor(parentHex, feeRate) {
20822
- const parent = chunkKJ5E646Y_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20880
+ const parent = chunkKMPNH7NS_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20823
20881
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
20824
20882
  const child = await this.buildBumpPackage(parent, feeRate, coins);
20825
20883
  return [parent.hex, child.hex];
@@ -21726,7 +21784,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21726
21784
  try {
21727
21785
  const { txs } = await source.getVirtualTxs(wanted);
21728
21786
  for (const psbt of txs) {
21729
- const tx = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21787
+ const tx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21730
21788
  resolved.set(tx.id, tx.toBytes());
21731
21789
  }
21732
21790
  } catch (err) {
@@ -21759,7 +21817,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21759
21817
  async function attachPrevArkTxs(tx, txids, source, onchain) {
21760
21818
  const pending = [];
21761
21819
  for (let i = 0; i < tx.inputsLength; i++) {
21762
- if (chunkKJ5E646Y_cjs.getArkPsbtFields(tx, i, chunkKJ5E646Y_cjs.PrevArkTxField).length === 0) pending.push(i);
21820
+ if (chunkKMPNH7NS_cjs.getArkPsbtFields(tx, i, chunkKMPNH7NS_cjs.PrevArkTxField).length === 0) pending.push(i);
21763
21821
  }
21764
21822
  if (pending.length === 0) return;
21765
21823
  const resolved = await resolvePrevTxs(
@@ -21768,13 +21826,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
21768
21826
  onchain
21769
21827
  );
21770
21828
  for (const i of pending) {
21771
- chunkKJ5E646Y_cjs.setArkPsbtField(tx, i, chunkKJ5E646Y_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21829
+ chunkKMPNH7NS_cjs.setArkPsbtField(tx, i, chunkKMPNH7NS_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21772
21830
  }
21773
21831
  }
21774
21832
  async function attachPrevoutTxs(tx, source) {
21775
21833
  const pending = [];
21776
21834
  for (let i = 0; i < tx.inputsLength; i++) {
21777
- if (chunkKJ5E646Y_cjs.getArkPsbtFields(tx, i, chunkKJ5E646Y_cjs.PrevoutTxField).length > 0) continue;
21835
+ if (chunkKMPNH7NS_cjs.getArkPsbtFields(tx, i, chunkKMPNH7NS_cjs.PrevoutTxField).length > 0) continue;
21778
21836
  const input = tx.getInput(i);
21779
21837
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
21780
21838
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -21785,7 +21843,7 @@ async function attachPrevoutTxs(tx, source) {
21785
21843
  resolved.set(txid, await source.getRawTransaction(txid));
21786
21844
  }
21787
21845
  for (const { index, txid } of pending) {
21788
- chunkKJ5E646Y_cjs.setArkPsbtField(tx, index, chunkKJ5E646Y_cjs.PrevoutTxField, resolved.get(txid));
21846
+ chunkKMPNH7NS_cjs.setArkPsbtField(tx, index, chunkKMPNH7NS_cjs.PrevoutTxField, resolved.get(txid));
21789
21847
  }
21790
21848
  }
21791
21849
  async function withPrevTxs(coins, source, onchain) {
@@ -21811,7 +21869,7 @@ exports.BIP322 = void 0;
21811
21869
  async function sign2(message, identity, network) {
21812
21870
  const xOnlyPubKey = await identity.xOnlyPublicKey();
21813
21871
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
21814
- const toSpend = chunkKJ5E646Y_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21872
+ const toSpend = chunkKMPNH7NS_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21815
21873
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
21816
21874
  const signed = await identity.sign(toSign, [0]);
21817
21875
  signed.finalizeIdx(0);
@@ -21869,7 +21927,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
21869
21927
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
21870
21928
  return false;
21871
21929
  }
21872
- const toSpend = chunkKJ5E646Y_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21930
+ const toSpend = chunkKMPNH7NS_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21873
21931
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
21874
21932
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
21875
21933
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -21890,7 +21948,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
21890
21948
  }
21891
21949
  const sighashType = sigWithHash[sigWithHash.length - 1];
21892
21950
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
21893
- const toSpend = chunkKJ5E646Y_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21951
+ const toSpend = chunkKMPNH7NS_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21894
21952
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
21895
21953
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
21896
21954
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -21943,7 +22001,7 @@ function encodeCompactSize(n) {
21943
22001
  return buf;
21944
22002
  }
21945
22003
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21946
- const tx = new chunkKJ5E646Y_cjs.Transaction({ version: 0 });
22004
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 0 });
21947
22005
  tx.addInput({
21948
22006
  txid: toSpend.id,
21949
22007
  index: 0,
@@ -21957,12 +22015,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21957
22015
  });
21958
22016
  tx.addOutput({
21959
22017
  amount: 0n,
21960
- script: chunkKJ5E646Y_cjs.OP_RETURN_EMPTY_PKSCRIPT
22018
+ script: chunkKMPNH7NS_cjs.OP_RETURN_EMPTY_PKSCRIPT
21961
22019
  });
21962
22020
  return tx;
21963
22021
  }
21964
22022
  function craftBIP322ToSignSimple(toSpend, pkScript) {
21965
- const tx = new chunkKJ5E646Y_cjs.Transaction({ version: 0 });
22023
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 0 });
21966
22024
  tx.addInput({
21967
22025
  txid: toSpend.id,
21968
22026
  index: 0,
@@ -21974,7 +22032,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
21974
22032
  });
21975
22033
  tx.addOutput({
21976
22034
  amount: 0n,
21977
- script: chunkKJ5E646Y_cjs.OP_RETURN_EMPTY_PKSCRIPT
22035
+ script: chunkKMPNH7NS_cjs.OP_RETURN_EMPTY_PKSCRIPT
21978
22036
  });
21979
22037
  return tx;
21980
22038
  }
@@ -21987,7 +22045,7 @@ var RestEmulatorProvider = class {
21987
22045
  serverUrl;
21988
22046
  async getInfo() {
21989
22047
  const url = `${this.serverUrl}/v1/info`;
21990
- const response = await chunkKJ5E646Y_cjs.baseFetch(url);
22048
+ const response = await chunkKMPNH7NS_cjs.baseFetch(url);
21991
22049
  if (!response.ok) {
21992
22050
  const errorText2 = await response.text();
21993
22051
  throw new Error(`Failed to get emulator info: ${errorText2}`);
@@ -22105,7 +22163,7 @@ var RestEmulatorProvider = class {
22105
22163
  }
22106
22164
  };
22107
22165
  function finalizeVirtualTx(type, psbtBase64) {
22108
- const tx = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22166
+ const tx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22109
22167
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
22110
22168
  const input = tx.getInput(0);
22111
22169
  if (!input) {
@@ -22132,14 +22190,14 @@ var ExitPathError = class extends Error {
22132
22190
  reason;
22133
22191
  };
22134
22192
  function delayWeight(sequence) {
22135
- const t = chunkKJ5E646Y_cjs.sequenceToTimelock(sequence);
22193
+ const t = chunkKMPNH7NS_cjs.sequenceToTimelock(sequence);
22136
22194
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
22137
22195
  }
22138
22196
  async function resolveUnilateralPath(params) {
22139
22197
  const { vtxo, scriptHex, contractRepository } = params;
22140
22198
  const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
22141
22199
  if (contract) {
22142
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
22200
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
22143
22201
  if (!handler) {
22144
22202
  throw new ExitPathError(
22145
22203
  "no-handler",
@@ -22162,12 +22220,12 @@ async function resolveUnilateralPath(params) {
22162
22220
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
22163
22221
  return { selection: paths[0], label: `${contract.type}:unilateral` };
22164
22222
  }
22165
- const decoded = chunkKJ5E646Y_cjs.VtxoScript.decode(vtxo.tapTree);
22223
+ const decoded = chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree);
22166
22224
  let best;
22167
22225
  for (const exit of decoded.exitPaths()) {
22168
22226
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
22169
22227
  if (!leaf) continue;
22170
- const sequence = chunkKJ5E646Y_cjs.timelockToSequence(exit.params.timelock);
22228
+ const sequence = chunkKMPNH7NS_cjs.timelockToSequence(exit.params.timelock);
22171
22229
  const weight = delayWeight(sequence);
22172
22230
  if (!best || weight < best.weight) {
22173
22231
  best = { selection: { leaf, sequence }, weight };
@@ -22387,7 +22445,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22387
22445
  let totalAmount = 0n;
22388
22446
  const txWeightEstimator = TxWeightEstimator.create();
22389
22447
  for (const vtxo of vtxos) {
22390
- if (!chunkKJ5E646Y_cjs.canSweepOnchain(vtxo)) {
22448
+ if (!chunkKMPNH7NS_cjs.canSweepOnchain(vtxo)) {
22391
22449
  throw new Error(
22392
22450
  `Vtxo ${vtxo.txid}:${vtxo.vout} cannot be swept onchain: it is not fully unrolled (use unroll first), or its exit output was already spent`
22393
22451
  );
@@ -22398,14 +22456,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22398
22456
  }
22399
22457
  const resolved = await resolveUnilateralPath({
22400
22458
  vtxo,
22401
- scriptHex: base.hex.encode(chunkKJ5E646Y_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22459
+ scriptHex: base.hex.encode(chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22402
22460
  contractRepository: wallet.contractRepository,
22403
22461
  walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
22404
22462
  currentTime: Date.now()
22405
22463
  });
22406
22464
  const spendingLeaf = resolved.selection.leaf;
22407
22465
  const sequence = resolved.selection.sequence;
22408
- const timelock = chunkKJ5E646Y_cjs.sequenceToTimelock(sequence);
22466
+ const timelock = chunkKMPNH7NS_cjs.sequenceToTimelock(sequence);
22409
22467
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
22410
22468
  if (!elapsed) {
22411
22469
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -22418,7 +22476,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22418
22476
  sequence,
22419
22477
  witnessUtxo: {
22420
22478
  amount: BigInt(vtxo.value),
22421
- script: chunkKJ5E646Y_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22479
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22422
22480
  },
22423
22481
  sighashType: btcSigner.SigHash.DEFAULT
22424
22482
  });
@@ -22428,7 +22486,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22428
22486
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
22429
22487
  );
22430
22488
  }
22431
- const tx = new chunkKJ5E646Y_cjs.Transaction({ version: 2 });
22489
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 2 });
22432
22490
  for (const input of inputs) {
22433
22491
  tx.addInput(input);
22434
22492
  }
@@ -22511,7 +22569,7 @@ async function buildSignedSweep(params) {
22511
22569
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
22512
22570
  );
22513
22571
  }
22514
- const tx = new chunkKJ5E646Y_cjs.Transaction({ version: 2 });
22572
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 2 });
22515
22573
  tx.addInput({
22516
22574
  txid: vtxo.txid,
22517
22575
  index: vtxo.vout,
@@ -22536,7 +22594,7 @@ async function buildSignedSweep(params) {
22536
22594
  finalScriptWitness: [
22537
22595
  tapScriptSig[0][1],
22538
22596
  ...path.extraWitness,
22539
- chunkKJ5E646Y_cjs.scriptFromTapLeafScript(path.leaf),
22597
+ chunkKMPNH7NS_cjs.scriptFromTapLeafScript(path.leaf),
22540
22598
  btcSigner.TaprootControlBlock.encode(controlBlock)
22541
22599
  ]
22542
22600
  });
@@ -22566,7 +22624,7 @@ async function resolveFeeRate(opts) {
22566
22624
  }
22567
22625
  async function selectExitVtxos(opts) {
22568
22626
  if (!opts.vtxos) return opts.wallet.getVtxos();
22569
- const res = await chunkKJ5E646Y_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22627
+ const res = await chunkKMPNH7NS_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22570
22628
  const tapTrees = /* @__PURE__ */ new Map();
22571
22629
  const out = [];
22572
22630
  for (const vtxo of res.vtxos) {
@@ -22581,7 +22639,7 @@ async function selectExitVtxos(opts) {
22581
22639
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
22582
22640
  );
22583
22641
  }
22584
- const handler = chunk2D7F5IU3_cjs.contractHandlers.get(contract.type);
22642
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
22585
22643
  if (!handler) {
22586
22644
  throw new Error(`no contract handler registered for type '${contract.type}'`);
22587
22645
  }
@@ -22611,7 +22669,7 @@ async function computeExitLayout(opts, feeRate) {
22611
22669
  if (pendingNodes.length > 0) {
22612
22670
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
22613
22671
  for (const psbt of txs) {
22614
- psbts.set(chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22672
+ psbts.set(chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22615
22673
  }
22616
22674
  }
22617
22675
  const childVsize = Number(
@@ -22647,7 +22705,7 @@ async function computeExitLayout(opts, feeRate) {
22647
22705
  try {
22648
22706
  const resolved = await resolveUnilateralPath({
22649
22707
  vtxo,
22650
- scriptHex: base.hex.encode(chunkKJ5E646Y_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22708
+ scriptHex: base.hex.encode(chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22651
22709
  contractRepository: wallet.contractRepository,
22652
22710
  walletPubKeyHex,
22653
22711
  currentTime: Date.now()
@@ -22666,7 +22724,7 @@ async function computeExitLayout(opts, feeRate) {
22666
22724
  });
22667
22725
  continue;
22668
22726
  }
22669
- const t = chunkKJ5E646Y_cjs.sequenceToTimelock(resolved.selection.sequence);
22727
+ const t = chunkKMPNH7NS_cjs.sequenceToTimelock(resolved.selection.sequence);
22670
22728
  const delay = { type: t.type, value: Number(t.value) };
22671
22729
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
22672
22730
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -23067,7 +23125,7 @@ async function prepare(opts) {
23067
23125
  txid: sweep.vtxo.txid,
23068
23126
  vout: sweep.vtxo.vout,
23069
23127
  value: sweep.vtxo.value,
23070
- pkScript: chunkKJ5E646Y_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23128
+ pkScript: chunkKMPNH7NS_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23071
23129
  },
23072
23130
  path: sweep.resolved.selection,
23073
23131
  outputAddress: opts.sweepAddress,
@@ -23155,7 +23213,7 @@ async function prepare(opts) {
23155
23213
  if (newFee <= splitterFee) break;
23156
23214
  splitterFee = newFee;
23157
23215
  }
23158
- const splitter = new chunkKJ5E646Y_cjs.Transaction({ version: 2 });
23216
+ const splitter = new chunkKMPNH7NS_cjs.Transaction({ version: 2 });
23159
23217
  for (const coin of selected.inputs) {
23160
23218
  splitter.addInput({
23161
23219
  txid: coin.txid,
@@ -23299,41 +23357,41 @@ var UnilateralExit = {
23299
23357
  // src/arkade/index.ts
23300
23358
  var arkade_exports = {};
23301
23359
  chunk5BLDMQED_cjs.__export(arkade_exports, {
23302
- ARKADE_OP: () => chunk2D7F5IU3_cjs.ARKADE_OP,
23303
- ARKADE_OPCODES: () => chunk2D7F5IU3_cjs.ARKADE_OPCODES,
23304
- ARKADE_OPCODE_NAMES: () => chunk2D7F5IU3_cjs.ARKADE_OPCODE_NAMES,
23305
- ARKADE_OPCODE_VALUES: () => chunk2D7F5IU3_cjs.ARKADE_OPCODE_VALUES,
23306
- ARKADE_OPS: () => chunk2D7F5IU3_cjs.ARKADE_OPS,
23360
+ ARKADE_OP: () => chunkDXLVCFVK_cjs.ARKADE_OP,
23361
+ ARKADE_OPCODES: () => chunkDXLVCFVK_cjs.ARKADE_OPCODES,
23362
+ ARKADE_OPCODE_NAMES: () => chunkDXLVCFVK_cjs.ARKADE_OPCODE_NAMES,
23363
+ ARKADE_OPCODE_VALUES: () => chunkDXLVCFVK_cjs.ARKADE_OPCODE_VALUES,
23364
+ ARKADE_OPS: () => chunkDXLVCFVK_cjs.ARKADE_OPS,
23307
23365
  Arkade: () => Arkade,
23308
23366
  ArkadeContract: () => ArkadeContract,
23309
- ArkadeProgramScript: () => chunk2D7F5IU3_cjs.ArkadeProgramScript,
23310
- ArkadeScript: () => chunk2D7F5IU3_cjs.ArkadeScript,
23367
+ ArkadeProgramScript: () => chunkDXLVCFVK_cjs.ArkadeProgramScript,
23368
+ ArkadeScript: () => chunkDXLVCFVK_cjs.ArkadeScript,
23311
23369
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
23312
- BigNum: () => chunk2D7F5IU3_cjs.bignum_exports,
23370
+ BigNum: () => chunkDXLVCFVK_cjs.bignum_exports,
23313
23371
  OP: () => btcSigner.OP,
23314
- OPCODE_NAMES: () => chunk2D7F5IU3_cjs.OPCODE_NAMES,
23315
- OPCODE_VALUES: () => chunk2D7F5IU3_cjs.OPCODE_VALUES,
23316
- SUPPORTED_PROGRAM_VERSION: () => chunk2D7F5IU3_cjs.SUPPORTED_PROGRAM_VERSION,
23372
+ OPCODE_NAMES: () => chunkDXLVCFVK_cjs.OPCODE_NAMES,
23373
+ OPCODE_VALUES: () => chunkDXLVCFVK_cjs.OPCODE_VALUES,
23374
+ SUPPORTED_PROGRAM_VERSION: () => chunkDXLVCFVK_cjs.SUPPORTED_PROGRAM_VERSION,
23317
23375
  Script: () => btcSigner.Script,
23318
- arkadeScriptHash: () => chunk2D7F5IU3_cjs.arkadeScriptHash,
23319
- arkadeWitnessHash: () => chunk2D7F5IU3_cjs.arkadeWitnessHash,
23320
- asmToBytes: () => chunk2D7F5IU3_cjs.asmToBytes,
23321
- bytesToASM: () => chunk2D7F5IU3_cjs.bytesToASM,
23322
- computeArkadeScriptPublicKey: () => chunk2D7F5IU3_cjs.computeArkadeScriptPublicKey,
23376
+ arkadeScriptHash: () => chunkDXLVCFVK_cjs.arkadeScriptHash,
23377
+ arkadeWitnessHash: () => chunkDXLVCFVK_cjs.arkadeWitnessHash,
23378
+ asmToBytes: () => chunkDXLVCFVK_cjs.asmToBytes,
23379
+ bytesToASM: () => chunkDXLVCFVK_cjs.bytesToASM,
23380
+ computeArkadeScriptPublicKey: () => chunkDXLVCFVK_cjs.computeArkadeScriptPublicKey,
23323
23381
  createArkadeBatchHandler: () => createArkadeBatchHandler,
23324
- deserializeArkadeContractParams: () => chunk2D7F5IU3_cjs.deserializeArkadeContractParams,
23325
- fromASM: () => chunk2D7F5IU3_cjs.fromASM,
23326
- getOpcodeName: () => chunk2D7F5IU3_cjs.getOpcodeName,
23327
- getOpcodeValue: () => chunk2D7F5IU3_cjs.getOpcodeValue,
23328
- parseArtifact: () => chunk2D7F5IU3_cjs.parseArtifact,
23329
- resolveAsm: () => chunk2D7F5IU3_cjs.resolveAsm,
23330
- serializeArkadeContractParams: () => chunk2D7F5IU3_cjs.serializeArkadeContractParams,
23331
- stringifyArtifact: () => chunk2D7F5IU3_cjs.stringifyArtifact,
23332
- toASM: () => chunk2D7F5IU3_cjs.toASM,
23333
- validateProgram: () => chunk2D7F5IU3_cjs.validateProgram,
23334
- witnessRefToBytes: () => chunk2D7F5IU3_cjs.witnessRefToBytes
23382
+ deserializeArkadeContractParams: () => chunkDXLVCFVK_cjs.deserializeArkadeContractParams,
23383
+ fromASM: () => chunkDXLVCFVK_cjs.fromASM,
23384
+ getOpcodeName: () => chunkDXLVCFVK_cjs.getOpcodeName,
23385
+ getOpcodeValue: () => chunkDXLVCFVK_cjs.getOpcodeValue,
23386
+ parseArtifact: () => chunkDXLVCFVK_cjs.parseArtifact,
23387
+ resolveAsm: () => chunkDXLVCFVK_cjs.resolveAsm,
23388
+ serializeArkadeContractParams: () => chunkDXLVCFVK_cjs.serializeArkadeContractParams,
23389
+ stringifyArtifact: () => chunkDXLVCFVK_cjs.stringifyArtifact,
23390
+ toASM: () => chunkDXLVCFVK_cjs.toASM,
23391
+ validateProgram: () => chunkDXLVCFVK_cjs.validateProgram,
23392
+ witnessRefToBytes: () => chunkDXLVCFVK_cjs.witnessRefToBytes
23335
23393
  });
23336
- var isVtxoCoin = (input) => chunkKJ5E646Y_cjs.isVirtualCoin(input);
23394
+ var isVtxoCoin = (input) => chunkKMPNH7NS_cjs.isVirtualCoin(input);
23337
23395
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
23338
23396
  let batchId;
23339
23397
  let sweepTapTreeRoot;
@@ -23354,23 +23412,23 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23354
23412
  );
23355
23413
  await arkProvider.confirmRegistration(intentId);
23356
23414
  batchId = event.id;
23357
- const sweepTapscript = chunkKJ5E646Y_cjs.CSVMultisigTapscript.encode({
23415
+ const sweepTapscript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.encode({
23358
23416
  timelock,
23359
- pubkeys: [chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23417
+ pubkeys: [chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23360
23418
  }).script;
23361
23419
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
23362
23420
  return { skip: false };
23363
23421
  },
23364
23422
  onTreeSigningStarted: async (event, vtxoTree) => {
23365
23423
  const signerPubKey = await session.getPublicKey();
23366
- const xonlySignerPubKey = chunk2D7F5IU3_cjs.toXOnly(signerPubKey, "signer key");
23424
+ const xonlySignerPubKey = chunkDXLVCFVK_cjs.toXOnly(signerPubKey, "signer key");
23367
23425
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
23368
- (k) => base.hex.encode(chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23426
+ (k) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23369
23427
  );
23370
23428
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
23371
23429
  return { skip: true };
23372
23430
  }
23373
- const commitmentTx = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23431
+ const commitmentTx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23374
23432
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
23375
23433
  if (recipients && recipients.length > 0) {
23376
23434
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -23408,7 +23466,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23408
23466
  if (connectorTree) {
23409
23467
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
23410
23468
  }
23411
- let commitmentPsbt = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23469
+ let commitmentPsbt = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23412
23470
  assertFinalCommitmentMatchesValidated(
23413
23471
  commitmentPsbt,
23414
23472
  validatedCommitmentTxid,
@@ -23450,7 +23508,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23450
23508
  boardingIndices.push(boardingIdx);
23451
23509
  continue;
23452
23510
  }
23453
- if (chunkKJ5E646Y_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
23511
+ if (chunkKMPNH7NS_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
23454
23512
  continue;
23455
23513
  }
23456
23514
  if (connectorIndex >= connectorLeaves.length) {
@@ -23471,7 +23529,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23471
23529
  index: input.vout,
23472
23530
  witnessUtxo: {
23473
23531
  amount: BigInt(input.value),
23474
- script: chunkKJ5E646Y_cjs.VtxoScript.decode(input.tapTree).pkScript
23532
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
23475
23533
  },
23476
23534
  sighashType: btcSigner.SigHash.DEFAULT,
23477
23535
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -23562,16 +23620,16 @@ var Arkade = class _Arkade {
23562
23620
  /** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
23563
23621
  static async connect(opts) {
23564
23622
  const info = await opts.arkade.getInfo();
23565
- const serverKey = chunk2D7F5IU3_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23566
- const checkpoint = chunkKJ5E646Y_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23567
- const network = opts.network ?? chunkKJ5E646Y_cjs.DEFAULT_NETWORK;
23623
+ const serverKey = chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23624
+ const checkpoint = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23625
+ const network = opts.network ?? chunkKMPNH7NS_cjs.DEFAULT_NETWORK;
23568
23626
  let emulatorKey;
23569
23627
  if (opts.emulator) {
23570
- emulatorKey = base.hex.decode(chunkKJ5E646Y_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23628
+ emulatorKey = base.hex.decode(chunkKMPNH7NS_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23571
23629
  }
23572
23630
  let userKey;
23573
23631
  if (opts.identity) {
23574
- userKey = chunk2D7F5IU3_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23632
+ userKey = chunkDXLVCFVK_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23575
23633
  }
23576
23634
  return new _Arkade({
23577
23635
  arkProvider: opts.arkade,
@@ -23597,7 +23655,7 @@ var Arkade = class _Arkade {
23597
23655
  * key respectively; explicit args always win.
23598
23656
  */
23599
23657
  contract(program, args = {}) {
23600
- const declared = (program.params ?? []).map(chunk2D7F5IU3_cjs.inputName);
23658
+ const declared = (program.params ?? []).map(chunkDXLVCFVK_cjs.inputName);
23601
23659
  if (declared.includes("server") && args.server === void 0) {
23602
23660
  args = { ...args, server: this.serverKey };
23603
23661
  }
@@ -23617,7 +23675,7 @@ var ArkadeContract = class _ArkadeContract {
23617
23675
  userKey: client.userKey,
23618
23676
  emulatorKey: client.emulatorKey
23619
23677
  };
23620
- this.vtxoScript = new chunk2D7F5IU3_cjs.ArkadeProgramScript(program, args, this.keys);
23678
+ this.vtxoScript = new chunkDXLVCFVK_cjs.ArkadeProgramScript(program, args, this.keys);
23621
23679
  this.tapTree = this.vtxoScript.encode();
23622
23680
  this.compiled = this.vtxoScript.compiled;
23623
23681
  }
@@ -23645,7 +23703,7 @@ var ArkadeContract = class _ArkadeContract {
23645
23703
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
23646
23704
  );
23647
23705
  }
23648
- const typed = chunk2D7F5IU3_cjs.deserializeArkadeContractParams(contract.params);
23706
+ const typed = chunkDXLVCFVK_cjs.deserializeArkadeContractParams(contract.params);
23649
23707
  return new _ArkadeContract(client, typed.program, typed.args, {
23650
23708
  serverKey: typed.serverKey,
23651
23709
  userKey: typed.userKey,
@@ -23686,7 +23744,7 @@ var ArkadeContract = class _ArkadeContract {
23686
23744
  toContractParams() {
23687
23745
  return {
23688
23746
  type: "arkade",
23689
- params: chunk2D7F5IU3_cjs.serializeArkadeContractParams({
23747
+ params: chunkDXLVCFVK_cjs.serializeArkadeContractParams({
23690
23748
  program: this.program,
23691
23749
  args: this.args,
23692
23750
  serverKey: this.keys.serverKey,
@@ -23736,18 +23794,18 @@ var ArkadeContract = class _ArkadeContract {
23736
23794
  if (registered) {
23737
23795
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
23738
23796
  return (withVtxos?.vtxos ?? []).filter(
23739
- (v) => !chunkKJ5E646Y_cjs.hasTerminalSpend(v) && !v.isUnrolled
23797
+ (v) => !chunkKMPNH7NS_cjs.hasTerminalSpend(v) && !v.isUnrolled
23740
23798
  );
23741
23799
  }
23742
23800
  }
23743
23801
  if (!this.client.indexer) {
23744
23802
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
23745
23803
  }
23746
- const { vtxos } = await chunkKJ5E646Y_cjs.getNormalizedVtxos(this.client.indexer, {
23804
+ const { vtxos } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(this.client.indexer, {
23747
23805
  scripts: [scriptHex],
23748
23806
  spendableOnly: true
23749
23807
  });
23750
- return vtxos.filter((v) => !chunkKJ5E646Y_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23808
+ return vtxos.filter((v) => !chunkKMPNH7NS_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23751
23809
  }
23752
23810
  /** Total spendable balance (requires an indexer). */
23753
23811
  async getBalance() {
@@ -23845,7 +23903,7 @@ var ArkadeTransactionBuilder = class {
23845
23903
  this.contract.client.checkpoint
23846
23904
  );
23847
23905
  if (coin.sourceTx) {
23848
- chunkKJ5E646Y_cjs.setArkPsbtField(arkTx, 0, chunkKJ5E646Y_cjs.PrevArkTxField, coin.sourceTx);
23906
+ chunkKMPNH7NS_cjs.setArkPsbtField(arkTx, 0, chunkKMPNH7NS_cjs.PrevArkTxField, coin.sourceTx);
23849
23907
  }
23850
23908
  if (this.fn.arkadeScript) {
23851
23909
  const indexer = this.contract.client.indexer;
@@ -23862,8 +23920,8 @@ var ArkadeTransactionBuilder = class {
23862
23920
  }
23863
23921
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
23864
23922
  if (condition.length > 0) {
23865
- chunkKJ5E646Y_cjs.setArkPsbtField(arkTx, 0, chunkKJ5E646Y_cjs.ConditionWitness, condition);
23866
- chunkKJ5E646Y_cjs.setArkPsbtField(checkpoints[0], 0, chunkKJ5E646Y_cjs.ConditionWitness, condition);
23923
+ chunkKMPNH7NS_cjs.setArkPsbtField(arkTx, 0, chunkKMPNH7NS_cjs.ConditionWitness, condition);
23924
+ chunkKMPNH7NS_cjs.setArkPsbtField(checkpoints[0], 0, chunkKMPNH7NS_cjs.ConditionWitness, condition);
23867
23925
  }
23868
23926
  const packets = [];
23869
23927
  if (this.assetSpecs.length > 0) {
@@ -23902,7 +23960,7 @@ var ArkadeTransactionBuilder = class {
23902
23960
  base.base64.encode(signedArk2.toPSBT()),
23903
23961
  signedCps.map((c) => base.base64.encode(c.toPSBT()))
23904
23962
  );
23905
- const txid = chunkKJ5E646Y_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23963
+ const txid = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23906
23964
  return {
23907
23965
  txid,
23908
23966
  signedArkTx: res2.signedArkTx,
@@ -23961,23 +24019,23 @@ var ArkadeTransactionBuilder = class {
23961
24019
  }
23962
24020
  buildAssetPacket() {
23963
24021
  const groups = this.assetSpecs.map((s) => {
23964
- const id = typeof s.assetId === "string" ? chunkD5DLGVN4_cjs.AssetId.fromString(s.assetId) : chunkD5DLGVN4_cjs.AssetId.fromBytes(s.assetId);
23965
- return chunkD5DLGVN4_cjs.AssetGroup.create(
24022
+ const id = typeof s.assetId === "string" ? chunkAS3W34MG_cjs.AssetId.fromString(s.assetId) : chunkAS3W34MG_cjs.AssetId.fromBytes(s.assetId);
24023
+ return chunkAS3W34MG_cjs.AssetGroup.create(
23966
24024
  id,
23967
24025
  null,
23968
- s.inputs.map((i) => chunkD5DLGVN4_cjs.AssetInput.create(i.vin, i.amount)),
23969
- s.outputs.map((o) => chunkD5DLGVN4_cjs.AssetOutput.create(o.vout, o.amount)),
23970
- (s.metadata ?? []).map((m) => chunkD5DLGVN4_cjs.Metadata.create(m.key, m.value))
24026
+ s.inputs.map((i) => chunkAS3W34MG_cjs.AssetInput.create(i.vin, i.amount)),
24027
+ s.outputs.map((o) => chunkAS3W34MG_cjs.AssetOutput.create(o.vout, o.amount)),
24028
+ (s.metadata ?? []).map((m) => chunkAS3W34MG_cjs.Metadata.create(m.key, m.value))
23971
24029
  );
23972
24030
  });
23973
- return chunkD5DLGVN4_cjs.Packet.create(groups);
24031
+ return chunkAS3W34MG_cjs.Packet.create(groups);
23974
24032
  }
23975
24033
  witnessBytes(ref) {
23976
- return chunk2D7F5IU3_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
24034
+ return chunkDXLVCFVK_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
23977
24035
  }
23978
24036
  };
23979
24037
  function bindInputs(fn, callArgs) {
23980
- const names = (fn.def.inputs ?? []).map(chunk2D7F5IU3_cjs.inputName);
24038
+ const names = (fn.def.inputs ?? []).map(chunkDXLVCFVK_cjs.inputName);
23981
24039
  if (callArgs.length !== names.length) {
23982
24040
  throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
23983
24041
  }
@@ -24181,6 +24239,16 @@ function assertNoAssets(railId, req) {
24181
24239
  );
24182
24240
  }
24183
24241
  }
24242
+ function selectionOf(req) {
24243
+ return req.selectedVtxos;
24244
+ }
24245
+ function assertNoSelection(railId, req) {
24246
+ if (selectionOf(req) !== void 0) {
24247
+ throw new Error(
24248
+ `${railId}: cannot spend a caller-chosen input set (selectedVtxos) \u2014 this rail does not choose the coins it spends`
24249
+ );
24250
+ }
24251
+ }
24184
24252
  function resolveAssetAmount(railId, req) {
24185
24253
  const assets = assetsOf(req);
24186
24254
  if (assets.length !== 1) {
@@ -24324,13 +24392,17 @@ function arkRail() {
24324
24392
  const address = arkTarget(req.raw);
24325
24393
  assertNoAssets("ark", req);
24326
24394
  const amt = resolveSendAmount("ark", req.raw, req.amount);
24395
+ const selectedVtxos = selectionOf(req);
24327
24396
  return {
24328
24397
  railId: "ark",
24329
24398
  amount: amt,
24330
24399
  fee: 0,
24331
24400
  total: amt,
24332
24401
  send: async () => makeHandle("ark", async (emit) => {
24333
- const txid = await ctx.wallet.send({ address, amount: amt });
24402
+ const txid = selectedVtxos ? await ctx.wallet.send({
24403
+ recipients: [{ address, amount: amt }],
24404
+ selectedVtxos
24405
+ }) : await ctx.wallet.send({ address, amount: amt });
24334
24406
  const result = { railId: "ark", txid };
24335
24407
  emit({ status: "settled", result });
24336
24408
  return result;
@@ -24353,6 +24425,7 @@ function arkAssetRail() {
24353
24425
  const asset = resolveAssetAmount("ark-asset", req);
24354
24426
  if (req.amount !== void 0) assertSendableAmount("ark-asset", req.amount);
24355
24427
  const carrier = tryResolveSendAmount(req.raw, req.amount) ?? ASSET_CARRIER_SATS;
24428
+ const selectedVtxos = selectionOf(req);
24356
24429
  return {
24357
24430
  railId: "ark-asset",
24358
24431
  amount: carrier,
@@ -24360,11 +24433,8 @@ function arkAssetRail() {
24360
24433
  total: carrier,
24361
24434
  assets: { delivered: asset, spent: asset },
24362
24435
  send: async () => makeHandle("ark-asset", async (emit) => {
24363
- const txid = await ctx.wallet.send({
24364
- address,
24365
- amount: carrier,
24366
- assets: [asset]
24367
- });
24436
+ const recipient = { address, amount: carrier, assets: [asset] };
24437
+ const txid = selectedVtxos ? await ctx.wallet.send({ recipients: [recipient], selectedVtxos }) : await ctx.wallet.send(recipient);
24368
24438
  const result = { railId: "ark-asset", txid };
24369
24439
  emit({ status: "settled", result });
24370
24440
  return result;
@@ -24386,6 +24456,13 @@ function grossUpOffboard(net, feeInfo, script) {
24386
24456
  }
24387
24457
  return { gross, fee: gross - net };
24388
24458
  }
24459
+ function offchainInputFees(vtxos, fees) {
24460
+ const estimator = new Estimator(fees?.intentFee ?? {});
24461
+ return vtxos.reduce(
24462
+ (total, vtxo) => total + estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(vtxo)).satoshis,
24463
+ 0
24464
+ );
24465
+ }
24389
24466
  function onchainRail(deps) {
24390
24467
  if (typeof deps?.feeInfo !== "function") {
24391
24468
  throw new Error("onchain rail: a feeInfo source is required");
@@ -24402,17 +24479,22 @@ function onchainRail(deps) {
24402
24479
  const fees = await deps.feeInfo();
24403
24480
  const script = base.hex.encode(offboardDestinationScript(address));
24404
24481
  const { gross, fee } = grossUpOffboard(amt, fees, script);
24482
+ const selectedVtxos = selectionOf(req);
24483
+ const inputFee = selectedVtxos ? offchainInputFees(selectedVtxos, fees) : 0;
24405
24484
  return {
24406
24485
  railId: "onchain",
24407
24486
  amount: amt,
24408
- fee,
24409
- total: gross,
24487
+ fee: fee + inputFee,
24488
+ total: gross + inputFee,
24410
24489
  send: async () => makeHandle("onchain", async (emit) => {
24411
- const txid = await new Ramps(ctx.wallet).offboard(
24490
+ const ramps = new Ramps(ctx.wallet);
24491
+ const txid = selectedVtxos ? await ramps.offboard(
24412
24492
  address,
24413
24493
  fees,
24414
- BigInt(gross)
24415
- );
24494
+ BigInt(gross),
24495
+ void 0,
24496
+ selectedVtxos
24497
+ ) : await ramps.offboard(address, fees, BigInt(gross));
24416
24498
  const result = { railId: "onchain", txid };
24417
24499
  emit({ status: "settled", result });
24418
24500
  return result;
@@ -24540,6 +24622,7 @@ exports.arkade_exports = arkade_exports;
24540
24622
  exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesValidated;
24541
24623
  exports.assertIntentIdUnique = assertIntentIdUnique;
24542
24624
  exports.assertNoAssets = assertNoAssets;
24625
+ exports.assertNoSelection = assertNoSelection;
24543
24626
  exports.assertSendableAmount = assertSendableAmount;
24544
24627
  exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
24545
24628
  exports.assertValidBatchExpiry = assertValidBatchExpiry;
@@ -24642,6 +24725,7 @@ exports.saveVtxosForContract = saveVtxosForContract;
24642
24725
  exports.scriptFromArkAddress = scriptFromArkAddress;
24643
24726
  exports.selectCoinsWithAsset = selectCoinsWithAsset;
24644
24727
  exports.selectVirtualCoins = selectVirtualCoins;
24728
+ exports.selectionOf = selectionOf;
24645
24729
  exports.serializeAssets = serializeAssets;
24646
24730
  exports.serializeExitPackage = serializeExitPackage;
24647
24731
  exports.serializeUtxo = serializeUtxo;
@@ -24661,5 +24745,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
24661
24745
  exports.walletFeeSource = walletFeeSource;
24662
24746
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
24663
24747
  exports.withPrevTxs = withPrevTxs;
24664
- //# sourceMappingURL=chunk-C4RKZY7D.cjs.map
24665
- //# sourceMappingURL=chunk-C4RKZY7D.cjs.map
24748
+ //# sourceMappingURL=chunk-WIHSU3YS.cjs.map
24749
+ //# sourceMappingURL=chunk-WIHSU3YS.cjs.map