@arkade-os/sdk 0.4.72 → 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-s5lUGWxu.d.cts → asyncStorageTaskQueue-D1AwLuqn.d.cts} +2 -2
  8. package/dist/{asyncStorageTaskQueue-DhhNZc4v.d.ts → asyncStorageTaskQueue-aCaOBGTS.d.ts} +2 -2
  9. package/dist/{chunk-4C5PMGBB.cjs → chunk-AS3W34MG.cjs} +17 -17
  10. package/dist/{chunk-4C5PMGBB.cjs.map → chunk-AS3W34MG.cjs.map} +1 -1
  11. package/dist/{chunk-NPM5YZBC.cjs → chunk-DXLVCFVK.cjs} +49 -49
  12. package/dist/{chunk-NPM5YZBC.cjs.map → chunk-DXLVCFVK.cjs.map} +1 -1
  13. package/dist/{chunk-S5PUFSXC.js → chunk-J3XVGWMP.js} +21 -22
  14. package/dist/chunk-J3XVGWMP.js.map +1 -0
  15. package/dist/{chunk-4BWZ437E.cjs → chunk-J4ZR4VEM.cjs} +31 -32
  16. package/dist/chunk-J4ZR4VEM.cjs.map +1 -0
  17. package/dist/{chunk-6FTHFJAN.cjs → chunk-KMPNH7NS.cjs} +8 -4
  18. package/dist/chunk-KMPNH7NS.cjs.map +1 -0
  19. package/dist/{chunk-CZPBPMO2.js → chunk-KPLQN4M4.js} +4 -4
  20. package/dist/{chunk-CZPBPMO2.js.map → chunk-KPLQN4M4.js.map} +1 -1
  21. package/dist/{chunk-CB6QPAO5.js → chunk-LGB65ZCO.js} +3 -3
  22. package/dist/{chunk-CB6QPAO5.js.map → chunk-LGB65ZCO.js.map} +1 -1
  23. package/dist/{chunk-KDMHEWTD.cjs → chunk-QS6AZE4F.cjs} +10 -10
  24. package/dist/{chunk-KDMHEWTD.cjs.map → chunk-QS6AZE4F.cjs.map} +1 -1
  25. package/dist/{chunk-U5I3ITV7.cjs → chunk-WIHSU3YS.cjs} +708 -497
  26. package/dist/chunk-WIHSU3YS.cjs.map +1 -0
  27. package/dist/{chunk-5GQFYVWP.js → chunk-WJVOFYTQ.js} +8 -4
  28. package/dist/chunk-WJVOFYTQ.js.map +1 -0
  29. package/dist/{chunk-IGER5FPC.js → chunk-X5BPARRD.js} +3 -3
  30. package/dist/{chunk-IGER5FPC.js.map → chunk-X5BPARRD.js.map} +1 -1
  31. package/dist/{chunk-BHLYB44A.js → chunk-ZTGTQP2W.js} +272 -63
  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.ts → index-Bxz3cKPA.d.cts} +13 -7
  43. package/dist/{index-Dg0-TvBQ.d.cts → 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 +50 -24
  47. package/dist/index.d.ts +50 -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-BH_FxaNI.d.cts → taskRunner-C26IIg1F.d.cts} +2 -2
  58. package/dist/{taskRunner-DrVz2QZs.d.ts → taskRunner-KxtIKYLv.d.ts} +2 -2
  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-4BWZ437E.cjs.map +0 -1
  73. package/dist/chunk-5GQFYVWP.js.map +0 -1
  74. package/dist/chunk-6FTHFJAN.cjs.map +0 -1
  75. package/dist/chunk-BHLYB44A.js.map +0 -1
  76. package/dist/chunk-S5PUFSXC.js.map +0 -1
  77. package/dist/chunk-U5I3ITV7.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunk4C5PMGBB_cjs = require('./chunk-4C5PMGBB.cjs');
4
- var chunkNPM5YZBC_cjs = require('./chunk-NPM5YZBC.cjs');
5
- var chunk6FTHFJAN_cjs = require('./chunk-6FTHFJAN.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 = chunk6FTHFJAN_cjs.getArkPsbtFields(tx.root, 0, chunk6FTHFJAN_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 = chunk6FTHFJAN_cjs.getArkPsbtFields(g.root, 0, chunk6FTHFJAN_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
- chunk6FTHFJAN_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 = chunkNPM5YZBC_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 chunkNPM5YZBC_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 = chunkNPM5YZBC_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
- chunk6FTHFJAN_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 = chunkNPM5YZBC_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 chunkNPM5YZBC_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 chunkNPM5YZBC_cjs.deriveDescriptorLeafPubKey(this.descriptor);
881
+ return chunkDXLVCFVK_cjs.deriveDescriptorLeafPubKey(this.descriptor);
882
882
  }
883
883
  async compressedPublicKey() {
884
- return chunkNPM5YZBC_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 && chunkNPM5YZBC_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 = chunkNPM5YZBC_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 chunkNPM5YZBC_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 chunkNPM5YZBC_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 chunkNPM5YZBC_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 } = chunk6FTHFJAN_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 = chunkNPM5YZBC_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 chunk6FTHFJAN_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: chunk6FTHFJAN_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 chunk6FTHFJAN_cjs.rateGate.runHttp(url, () => chunk6FTHFJAN_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[chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_cjs.baseFetch(`${this.baseUrl}/blocks`);
2041
+ let tipBlocks = await chunkKMPNH7NS_cjs.baseFetch(`${this.baseUrl}/blocks`);
2042
2042
  if (tipBlocks.status === 404) {
2043
- tipBlocks = await chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 chunk6FTHFJAN_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 = chunk6FTHFJAN_cjs.getArkPsbtFields(child.root, 0, chunk6FTHFJAN_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 chunk4C5PMGBB_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 chunk4C5PMGBB_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 chunk4C5PMGBB_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 chunk4C5PMGBB_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 chunk4C5PMGBB_cjs.Packet.PACKET_TYPE:
2664
- return chunk4C5PMGBB_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,25 +2708,31 @@ function buildOpReturnScript(data) {
2708
2708
  }
2709
2709
  return script;
2710
2710
  }
2711
- var ErrOffchainOutputNotFound = (address) => new chunk6FTHFJAN_cjs.ServerResponseMismatchError(`offchain send output not found: ${address}`);
2712
- var ErrInvalidAssetOutputAmount = (got, want, assetId) => new chunk6FTHFJAN_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 chunk6FTHFJAN_cjs.ServerResponseMismatchError(`asset group not found in batch leaf: ${assetId}`);
2716
- var ErrAssetOutputNotFound = (assetId, outputIndex) => new chunk6FTHFJAN_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 chunk6FTHFJAN_cjs.ServerResponseMismatchError(`onchain output not found: ${address}`);
2720
- var ErrUnvalidatedOffchainOutput = (address) => new chunk6FTHFJAN_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 chunkKMPNH7NS_cjs.ServerResponseMismatchError(
2724
+ `${kind} output ${index} of the intent proof is not present in what the server built`
2725
+ );
2726
+ var ErrUnvalidatedIntentOutput = (index) => new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
2727
+ `offchain output ${index} of the intent proof cannot be validated: virtual output tree signing did not run`
2728
+ );
2723
2729
  var ErrInvalidOnchainOutputAmount = (address) => new Error(`invalid onchain output amount: ${address}`);
2724
2730
  var ErrInvalidOnchainOutputAssets = (address) => new Error(`onchain output ${address} cannot have assets`);
2725
2731
  var ErrInvalidOffchainOutputAmount = (address) => new Error(`invalid offchain output ${address}, missing amount`);
2726
2732
  function assertFinalCommitmentMatchesValidated(finalCommitmentTx, validatedCommitmentTxid, context) {
2727
2733
  if (!validatedCommitmentTxid) return;
2728
2734
  if (finalCommitmentTx.id === validatedCommitmentTxid) return;
2729
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
2735
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
2730
2736
  `${context}: finalization commitment tx ${finalCommitmentTx.id} differs from the validated commitment tx ${validatedCommitmentTxid}`
2731
2737
  );
2732
2738
  }
@@ -2736,7 +2742,7 @@ function validateBatchRecipients(commitmentTx, vtxoTreeLeaves, recipients, netwo
2736
2742
  for (const recipient of recipients) {
2737
2743
  let arkAddress;
2738
2744
  try {
2739
- arkAddress = chunk6FTHFJAN_cjs.ArkAddress.decode(recipient.address);
2745
+ arkAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(recipient.address);
2740
2746
  } catch {
2741
2747
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2742
2748
  continue;
@@ -2748,7 +2754,7 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2748
2754
  const usedOnchainOutputs = /* @__PURE__ */ new Set();
2749
2755
  for (const recipient of recipients) {
2750
2756
  try {
2751
- chunk6FTHFJAN_cjs.ArkAddress.decode(recipient.address);
2757
+ chunkKMPNH7NS_cjs.ArkAddress.decode(recipient.address);
2752
2758
  } catch {
2753
2759
  validateOnchainRecipient(commitmentTx, recipient, network, usedOnchainOutputs);
2754
2760
  continue;
@@ -2756,6 +2762,74 @@ function validateBatchRecipientsWithoutTree(commitmentTx, recipients, network) {
2756
2762
  throw ErrUnvalidatedOffchainOutput(recipient.address);
2757
2763
  }
2758
2764
  }
2765
+ function declaredIntentOutputs(signedProof, onchainOutputIndexes) {
2766
+ const proof = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(signedProof));
2767
+ const onchain = new Set(onchainOutputIndexes);
2768
+ const declared = [];
2769
+ for (let i = 0; i < proof.outputsLength; i++) {
2770
+ const output = proof.getOutput(i);
2771
+ if (!output?.script || output.script.length === 0 || !output.amount) continue;
2772
+ declared.push({
2773
+ index: i,
2774
+ script: output.script,
2775
+ amount: output.amount,
2776
+ onchain: onchain.has(i)
2777
+ });
2778
+ }
2779
+ return declared;
2780
+ }
2781
+ function validateBatchAgainstIntent(commitmentTx, vtxoTreeLeaves, declared) {
2782
+ const usedOnchain = /* @__PURE__ */ new Set();
2783
+ const usedLeaf = /* @__PURE__ */ new Set();
2784
+ for (const output of declared) {
2785
+ if (output.onchain) {
2786
+ if (!takeOnchainOutput(commitmentTx, output, usedOnchain)) {
2787
+ throw ErrIntentOutputNotFound(output.index, "onchain");
2788
+ }
2789
+ continue;
2790
+ }
2791
+ if (!takeLeafOutput(vtxoTreeLeaves, output, usedLeaf)) {
2792
+ throw ErrIntentOutputNotFound(output.index, "offchain");
2793
+ }
2794
+ }
2795
+ }
2796
+ function validateBatchAgainstIntentWithoutTree(commitmentTx, declared) {
2797
+ const usedOnchain = /* @__PURE__ */ new Set();
2798
+ for (const output of declared) {
2799
+ if (!output.onchain) {
2800
+ throw ErrUnvalidatedIntentOutput(output.index);
2801
+ }
2802
+ if (!takeOnchainOutput(commitmentTx, output, usedOnchain)) {
2803
+ throw ErrIntentOutputNotFound(output.index, "onchain");
2804
+ }
2805
+ }
2806
+ }
2807
+ function takeOnchainOutput(commitmentTx, declared, used) {
2808
+ for (let i = 0; i < commitmentTx.outputsLength; i++) {
2809
+ if (used.has(i)) continue;
2810
+ const output = commitmentTx.getOutput(i);
2811
+ if (!output?.script || output.amount !== declared.amount) continue;
2812
+ if (!utils_js.equalBytes(output.script, declared.script)) continue;
2813
+ used.add(i);
2814
+ return true;
2815
+ }
2816
+ return false;
2817
+ }
2818
+ function takeLeafOutput(leaves, declared, used) {
2819
+ for (let leafIdx = 0; leafIdx < leaves.length; leafIdx++) {
2820
+ const leaf = leaves[leafIdx];
2821
+ for (let i = 0; i < leaf.outputsLength; i++) {
2822
+ const key = `${leafIdx}:${i}`;
2823
+ if (used.has(key)) continue;
2824
+ const output = leaf.getOutput(i);
2825
+ if (!output?.script || output.amount !== declared.amount) continue;
2826
+ if (!utils_js.equalBytes(output.script, declared.script)) continue;
2827
+ used.add(key);
2828
+ return true;
2829
+ }
2830
+ }
2831
+ return false;
2832
+ }
2759
2833
  function validateOnchainRecipient(commitmentTx, recipient, network, usedOutputs) {
2760
2834
  const addr = btcSigner.Address(network).decode(recipient.address);
2761
2835
  const expectedPkScript = btcSigner.OutScript.encode(addr);
@@ -2981,7 +3055,7 @@ function assetMintResolver() {
2981
3055
  if (!tx.assets?.length || !tx.key.arkTxid) return void 0;
2982
3056
  const minted = tx.assets.filter((a) => {
2983
3057
  try {
2984
- return base.hex.encode(chunk4C5PMGBB_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
3058
+ return base.hex.encode(chunkAS3W34MG_cjs.AssetId.fromString(a.assetId).txid) === tx.key.arkTxid;
2985
3059
  } catch {
2986
3060
  return false;
2987
3061
  }
@@ -3057,7 +3131,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3057
3131
  const existing = inputsByAssetId.get(asset.assetId);
3058
3132
  inputsByAssetId.set(asset.assetId, [
3059
3133
  ...existing ?? [],
3060
- chunk4C5PMGBB_cjs.AssetInput.create(inputIndex, asset.amount)
3134
+ chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount)
3061
3135
  ]);
3062
3136
  }
3063
3137
  }
@@ -3069,7 +3143,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3069
3143
  const existing = outputsByAssetId.get(asset.assetId);
3070
3144
  outputsByAssetId.set(asset.assetId, [
3071
3145
  ...existing ?? [],
3072
- chunk4C5PMGBB_cjs.AssetOutput.create(outputIndex, asset.amount)
3146
+ chunkAS3W34MG_cjs.AssetOutput.create(outputIndex, asset.amount)
3073
3147
  ]);
3074
3148
  }
3075
3149
  }
@@ -3080,7 +3154,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3080
3154
  const existing = outputsByAssetId.get(asset.assetId);
3081
3155
  outputsByAssetId.set(asset.assetId, [
3082
3156
  ...existing ?? [],
3083
- chunk4C5PMGBB_cjs.AssetOutput.create(outputIndex, asset.amount)
3157
+ chunkAS3W34MG_cjs.AssetOutput.create(outputIndex, asset.amount)
3084
3158
  ]);
3085
3159
  }
3086
3160
  }
@@ -3089,11 +3163,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
3089
3163
  for (const assetIdStr of allAssetIds) {
3090
3164
  const inputs = inputsByAssetId.get(assetIdStr);
3091
3165
  const outputs = outputsByAssetId.get(assetIdStr);
3092
- const assetId = chunk4C5PMGBB_cjs.AssetId.fromString(assetIdStr);
3093
- const group = chunk4C5PMGBB_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 ?? [], []);
3094
3168
  groups.push(group);
3095
3169
  }
3096
- return chunk4C5PMGBB_cjs.Packet.create(groups);
3170
+ return chunkAS3W34MG_cjs.Packet.create(groups);
3097
3171
  }
3098
3172
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
3099
3173
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -3130,7 +3204,7 @@ function selectedCoinsToAssetInputs(selectedCoins) {
3130
3204
  }
3131
3205
  function toXOnlySignerHex(pubkeyHex) {
3132
3206
  const bytes = base.hex.decode(pubkeyHex);
3133
- if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkNPM5YZBC_cjs.toXOnly(bytes, "signer key"));
3207
+ if (bytes.length === 32 || bytes.length === 33) return base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(bytes, "signer key"));
3134
3208
  throw new Error(`invalid signer pubkey length: expected 32 or 33 bytes, got ${bytes.length}`);
3135
3209
  }
3136
3210
  function signerSetFromInfo(info) {
@@ -3177,13 +3251,13 @@ var toTimelock = (value) => ({
3177
3251
  var toSeconds = (t) => t.type === "seconds" ? t.value : t.value * NOMINAL_BLOCK_SECONDS;
3178
3252
  function assertTimelockInPolicy(timelock, policy, label, overrideOption) {
3179
3253
  if (policy.requireSeconds && timelock.type === "blocks") {
3180
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3254
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3181
3255
  `${label} rejected: block-typed timelocks are not accepted (got ${timelock.value})`
3182
3256
  );
3183
3257
  }
3184
3258
  const seconds = toSeconds(timelock);
3185
3259
  if (seconds < policy.minSeconds) {
3186
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3260
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3187
3261
  `${label} rejected: ${timelock.value} ${timelock.type} is below the ${policy.minSeconds}s floor; pass ${overrideOption}: ${seconds}n to Wallet.create to lower it`
3188
3262
  );
3189
3263
  }
@@ -3204,7 +3278,7 @@ function resolveBatchExpiryPolicy(network, overrides) {
3204
3278
  }
3205
3279
  function assertValidBatchExpiry(batchExpiry, policy) {
3206
3280
  if (policy.advertisedVtxoTreeExpiry !== void 0 && batchExpiry !== policy.advertisedVtxoTreeExpiry) {
3207
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3281
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3208
3282
  `batch expiry rejected: ${batchExpiry} does not match the advertised vtxoTreeExpiry ${policy.advertisedVtxoTreeExpiry}`
3209
3283
  );
3210
3284
  }
@@ -3234,21 +3308,21 @@ function resolveCheckpointExitDelayPolicy(network, overrides) {
3234
3308
  function assertValidServerUnrollScript(checkpointTapscript, policy) {
3235
3309
  let script;
3236
3310
  try {
3237
- script = chunk6FTHFJAN_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3311
+ script = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(checkpointTapscript));
3238
3312
  } catch (e) {
3239
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3313
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3240
3314
  `checkpoint exit delay rejected: invalid checkpointTapscript from server (${e instanceof Error ? e.message : String(e)})`
3241
3315
  );
3242
3316
  }
3243
3317
  if (policy.advertisedForfeitPubkey !== void 0) {
3244
3318
  const { pubkeys } = script.params;
3245
3319
  if (pubkeys.length !== 1) {
3246
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3320
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3247
3321
  `checkpoint exit delay rejected: checkpointTapscript must commit to exactly one pubkey, got ${pubkeys.length} [${pubkeys.map(base.hex.encode).join(", ")}]`
3248
3322
  );
3249
3323
  }
3250
3324
  if (!utils_js.equalBytes(pubkeys[0], policy.advertisedForfeitPubkey)) {
3251
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3325
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3252
3326
  `checkpoint exit delay rejected: checkpointTapscript pubkey ${base.hex.encode(pubkeys[0])} does not match the advertised forfeitPubkey ${base.hex.encode(policy.advertisedForfeitPubkey)}`
3253
3327
  );
3254
3328
  }
@@ -3292,8 +3366,8 @@ function buildOffchainTx(inputs, outputs, serverUnrollScript) {
3292
3366
  function buildVirtualTx(inputs, outputs) {
3293
3367
  let lockTime = 0n;
3294
3368
  for (const input of inputs) {
3295
- const tapscript = chunk6FTHFJAN_cjs.decodeTapscript(chunk6FTHFJAN_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3296
- if (chunk6FTHFJAN_cjs.CLTVMultisigTapscript.is(tapscript)) {
3369
+ const tapscript = chunkKMPNH7NS_cjs.decodeTapscript(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(input.tapLeafScript));
3370
+ if (chunkKMPNH7NS_cjs.CLTVMultisigTapscript.is(tapscript)) {
3297
3371
  if (lockTime !== 0n) {
3298
3372
  if (isSeconds(lockTime) !== isSeconds(tapscript.params.absoluteTimelock)) {
3299
3373
  throw new Error("cannot mix seconds and blocks locktime");
@@ -3304,7 +3378,7 @@ function buildVirtualTx(inputs, outputs) {
3304
3378
  }
3305
3379
  }
3306
3380
  }
3307
- const tx = new chunk6FTHFJAN_cjs.Transaction({
3381
+ const tx = new chunkKMPNH7NS_cjs.Transaction({
3308
3382
  version: 3,
3309
3383
  lockTime: Number(lockTime)
3310
3384
  });
@@ -3314,12 +3388,12 @@ function buildVirtualTx(inputs, outputs) {
3314
3388
  index: input.vout,
3315
3389
  sequence: lockTime ? btcSigner.DEFAULT_SEQUENCE - 1 : void 0,
3316
3390
  witnessUtxo: {
3317
- script: chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).pkScript,
3391
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript,
3318
3392
  amount: BigInt(input.value)
3319
3393
  },
3320
3394
  tapLeafScript: [input.tapLeafScript]
3321
3395
  });
3322
- chunk6FTHFJAN_cjs.setArkPsbtField(tx, i, chunk6FTHFJAN_cjs.VtxoTaprootTree, input.tapTree);
3396
+ chunkKMPNH7NS_cjs.setArkPsbtField(tx, i, chunkKMPNH7NS_cjs.VtxoTaprootTree, input.tapTree);
3323
3397
  }
3324
3398
  for (const output of outputs) {
3325
3399
  tx.addOutput(output);
@@ -3328,8 +3402,8 @@ function buildVirtualTx(inputs, outputs) {
3328
3402
  return tx;
3329
3403
  }
3330
3404
  function buildCheckpointTx(vtxo, serverUnrollScript) {
3331
- const collaborativeClosure = chunk6FTHFJAN_cjs.decodeTapscript(chunk6FTHFJAN_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3332
- const checkpointVtxoScript = new chunk6FTHFJAN_cjs.VtxoScript([
3405
+ const collaborativeClosure = chunkKMPNH7NS_cjs.decodeTapscript(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(vtxo.tapLeafScript));
3406
+ const checkpointVtxoScript = new chunkKMPNH7NS_cjs.VtxoScript([
3333
3407
  serverUnrollScript.script,
3334
3408
  collaborativeClosure.script
3335
3409
  ]);
@@ -3405,7 +3479,7 @@ function verifyTapscriptSignatures(tx, inputIndex, requiredSigners, excludePubke
3405
3479
  const sighashType = signature.length === 65 ? signature[64] : btcSigner.SigHash.DEFAULT;
3406
3480
  const sig = signature.subarray(0, 64);
3407
3481
  if (!allowedSighashTypes.includes(sighashType)) {
3408
- const sighashName = chunk6FTHFJAN_cjs.formatSighash(sighashType);
3482
+ const sighashName = chunkKMPNH7NS_cjs.formatSighash(sighashType);
3409
3483
  throw new Error(
3410
3484
  `Unallowed sighash type ${sighashName} for input ${inputIndex}, pubkey ${pubKeyHex}.`
3411
3485
  );
@@ -3479,7 +3553,7 @@ function combineTapscriptSigs(signedTx, originalTx) {
3479
3553
  }
3480
3554
  function isValidArkAddress(address) {
3481
3555
  try {
3482
- chunk6FTHFJAN_cjs.ArkAddress.decode(address);
3556
+ chunkKMPNH7NS_cjs.ArkAddress.decode(address);
3483
3557
  return true;
3484
3558
  } catch (e) {
3485
3559
  return false;
@@ -3487,16 +3561,16 @@ function isValidArkAddress(address) {
3487
3561
  }
3488
3562
  function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, context) {
3489
3563
  if (serverCheckpointTxs.length !== expectedCheckpoints.length) {
3490
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3564
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3491
3565
  `${context} returned ${serverCheckpointTxs.length} checkpoints, expected ${expectedCheckpoints.length}`
3492
3566
  );
3493
3567
  }
3494
3568
  const byTxid = new Map(expectedCheckpoints.map((c) => [c.id, c]));
3495
3569
  return serverCheckpointTxs.map((encoded, index) => {
3496
- const server = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3570
+ const server = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(encoded));
3497
3571
  const local = byTxid.get(server.id);
3498
3572
  if (!local) {
3499
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3573
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3500
3574
  `${context} checkpoint ${index} txid ${server.id} does not match any submitted checkpoint`
3501
3575
  );
3502
3576
  }
@@ -3506,36 +3580,53 @@ function matchServerCheckpoints(serverCheckpointTxs, expectedCheckpoints, contex
3506
3580
  }
3507
3581
  function assertSubmittedArkTxid(response, signedArkTx, context) {
3508
3582
  if (response.arkTxid !== signedArkTx.id) {
3509
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3583
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3510
3584
  `${context} returned ark txid ${response.arkTxid}, expected ${signedArkTx.id}`
3511
3585
  );
3512
3586
  }
3513
3587
  if (response.finalArkTx === void 0) return;
3514
- const finalTxid = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3588
+ const finalTxid = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx)).id;
3515
3589
  if (finalTxid !== signedArkTx.id) {
3516
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3590
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3517
3591
  `${context} returned final ark tx ${finalTxid}, expected ${signedArkTx.id}`
3518
3592
  );
3519
3593
  }
3520
3594
  }
3521
- function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeyHex, context) {
3595
+ function assertServerSignedLeaf(serverTx, localTx, inputIndex, serverPubkeys, context) {
3522
3596
  const leaf = localTx.getInput(inputIndex).tapLeafScript?.[0];
3523
3597
  if (!leaf) {
3524
3598
  throw new Error(
3525
3599
  `${context}: input ${inputIndex} carries no spend leaf to verify the server signature against`
3526
3600
  );
3527
3601
  }
3602
+ const script = chunkKMPNH7NS_cjs.scriptFromTapLeafScript(leaf);
3603
+ let leafPubkeys;
3604
+ try {
3605
+ leafPubkeys = chunkKMPNH7NS_cjs.decodeTapscript(script).params.pubkeys.map(
3606
+ (key) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(key, "leaf key"))
3607
+ );
3608
+ } catch (error) {
3609
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3610
+ `${context}: input ${inputIndex} spend leaf cannot be decoded (${error instanceof Error ? error.message : String(error)})`
3611
+ );
3612
+ }
3613
+ const signer = leafPubkeys.find((key) => serverPubkeys.has(key));
3614
+ if (!signer) {
3615
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3616
+ `${context}: input ${inputIndex} spend leaf names no signer key the server advertises`
3617
+ );
3618
+ }
3528
3619
  try {
3529
3620
  verifyTapscriptSignatures(
3530
3621
  serverTx,
3531
3622
  inputIndex,
3532
- [serverPubkeyHex],
3623
+ [signer],
3533
3624
  void 0,
3534
3625
  void 0,
3535
- payment_js.tapLeafHash(chunk6FTHFJAN_cjs.scriptFromTapLeafScript(leaf))
3626
+ payment_js.tapLeafHash(script)
3536
3627
  );
3537
3628
  } catch (error) {
3538
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3629
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3539
3630
  `${context}: input ${inputIndex} is not signed by the server on the leaf being spent (${error instanceof Error ? error.message : String(error)})`
3540
3631
  );
3541
3632
  }
@@ -3544,20 +3635,20 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3544
3635
  const byOutpoint = new Map(inputs.map((input) => [`${input.txid}:${input.vout}`, input]));
3545
3636
  for (const [index, checkpoint] of checkpoints.entries()) {
3546
3637
  if (checkpoint.inputsLength !== 1) {
3547
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3638
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3548
3639
  `${context}: checkpoint ${index} spends ${checkpoint.inputsLength} inputs, expected 1`
3549
3640
  );
3550
3641
  }
3551
3642
  const spent = checkpoint.getInput(0);
3552
3643
  if (!spent.txid || spent.index === void 0) {
3553
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3644
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3554
3645
  `${context}: checkpoint ${index} has no input outpoint`
3555
3646
  );
3556
3647
  }
3557
3648
  const outpoint = `${base.hex.encode(spent.txid)}:${spent.index}`;
3558
3649
  const input = byOutpoint.get(outpoint);
3559
3650
  if (!input) {
3560
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3651
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3561
3652
  `${context}: checkpoint ${index} spends ${outpoint}, which is not one of the requested virtual outputs`
3562
3653
  );
3563
3654
  }
@@ -3565,7 +3656,7 @@ function assertCheckpointsMatchInputs(checkpoints, inputs, unrollCandidates, con
3565
3656
  (unroll) => buildCheckpointTx(input, unroll).tx.id === checkpoint.id
3566
3657
  );
3567
3658
  if (!rebuilt) {
3568
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3659
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3569
3660
  `${context}: checkpoint ${index} txid ${checkpoint.id} differs from the checkpoint built locally for ${outpoint}`
3570
3661
  );
3571
3662
  }
@@ -3591,9 +3682,9 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3591
3682
  const matched = matchServerCheckpoints(signedCheckpointTxs, offchainTx.checkpoints, "submitTx");
3592
3683
  matched.forEach(({ server }, index) => {
3593
3684
  try {
3594
- chunk6FTHFJAN_cjs.assertAllowedSighashTypes(server);
3685
+ chunkKMPNH7NS_cjs.assertAllowedSighashTypes(server);
3595
3686
  } catch (error) {
3596
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3687
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3597
3688
  `submitTx checkpoint ${index}: ${error instanceof Error ? error.message : String(error)}`
3598
3689
  );
3599
3690
  }
@@ -3601,29 +3692,27 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks, options) {
3601
3692
  const verify = options?.verifyServerSignatures;
3602
3693
  if (verify) {
3603
3694
  if (response.finalArkTx === void 0) {
3604
- throw new chunk6FTHFJAN_cjs.ServerResponseMismatchError(
3695
+ throw new chunkKMPNH7NS_cjs.ServerResponseMismatchError(
3605
3696
  "submitTx: server returned no final ark tx to verify its signatures against"
3606
3697
  );
3607
3698
  }
3608
- const finalArkTx = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3609
- const serverPubkeyHex = base.hex.encode(chunkNPM5YZBC_cjs.toXOnly(verify.serverPubkey, "server key"));
3699
+ const finalArkTx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(response.finalArkTx));
3700
+ const serverPubkeys = new Set(
3701
+ [verify.serverPubkey, ...verify.deprecatedServerPubkeys ?? []].map(
3702
+ (key) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(key, "server key"))
3703
+ )
3704
+ );
3610
3705
  for (let i = 0; i < offchainTx.arkTx.inputsLength; i++) {
3611
3706
  assertServerSignedLeaf(
3612
3707
  finalArkTx,
3613
3708
  offchainTx.arkTx,
3614
3709
  i,
3615
- serverPubkeyHex,
3710
+ serverPubkeys,
3616
3711
  "submitTx ark tx"
3617
3712
  );
3618
3713
  }
3619
3714
  matched.forEach(
3620
- ({ server, local }, index) => assertServerSignedLeaf(
3621
- server,
3622
- local,
3623
- 0,
3624
- serverPubkeyHex,
3625
- `submitTx checkpoint ${index}`
3626
- )
3715
+ ({ server, local }, index) => assertServerSignedLeaf(server, local, 0, serverPubkeys, `submitTx checkpoint ${index}`)
3627
3716
  );
3628
3717
  }
3629
3718
  let finalCheckpoints;
@@ -3662,12 +3751,12 @@ function claimWithPreimageIdentity(identity, preimage) {
3662
3751
  return {
3663
3752
  ...identity,
3664
3753
  sign: async (tx, inputIndexes) => {
3665
- const signed = chunk6FTHFJAN_cjs.Transaction.fromPSBT(
3754
+ const signed = chunkKMPNH7NS_cjs.Transaction.fromPSBT(
3666
3755
  (await identity.sign(tx.clone(), inputIndexes)).toPSBT()
3667
3756
  );
3668
3757
  const indexes = inputIndexes ?? Array.from({ length: signed.inputsLength }, (_, i) => i);
3669
3758
  for (const index of indexes) {
3670
- chunk6FTHFJAN_cjs.setArkPsbtField(signed, index, chunk6FTHFJAN_cjs.ConditionWitness, [preimage]);
3759
+ chunkKMPNH7NS_cjs.setArkPsbtField(signed, index, chunkKMPNH7NS_cjs.ConditionWitness, [preimage]);
3671
3760
  }
3672
3761
  return signed;
3673
3762
  }
@@ -3862,7 +3951,7 @@ function extendCoinWithTapscript(boardingTapscript, utxo) {
3862
3951
  };
3863
3952
  }
3864
3953
  function deriveContractTapscripts(contract) {
3865
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
3954
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
3866
3955
  if (!handler) {
3867
3956
  throw new Error(`No handler for contract type '${contract.type}'`);
3868
3957
  }
@@ -3933,7 +4022,7 @@ function getRandomId() {
3933
4022
  }
3934
4023
  function isValidArkAddress2(address) {
3935
4024
  try {
3936
- chunk6FTHFJAN_cjs.ArkAddress.decode(address);
4025
+ chunkKMPNH7NS_cjs.ArkAddress.decode(address);
3937
4026
  return true;
3938
4027
  } catch (e) {
3939
4028
  return false;
@@ -3961,7 +4050,7 @@ function assertRecipientArkAddress(encoded, address, context) {
3961
4050
  function assertTapTreeDerivesAddress(encoded, tapTree, address) {
3962
4051
  let derived;
3963
4052
  try {
3964
- derived = chunk6FTHFJAN_cjs.VtxoScript.decode(tapTree).pkScript;
4053
+ derived = chunkKMPNH7NS_cjs.VtxoScript.decode(tapTree).pkScript;
3965
4054
  } catch (e) {
3966
4055
  throw new Error(
3967
4056
  `Invalid tapTree for ${encoded}: ${e instanceof Error ? e.message : String(e)}`
@@ -3978,7 +4067,7 @@ function validateRecipients(recipients, dustAmount, context) {
3978
4067
  for (const recipient of recipients) {
3979
4068
  let address;
3980
4069
  try {
3981
- address = chunk6FTHFJAN_cjs.ArkAddress.decode(recipient.address);
4070
+ address = chunkKMPNH7NS_cjs.ArkAddress.decode(recipient.address);
3982
4071
  } catch (e) {
3983
4072
  throw new Error(`Invalid Arkade address: ${recipient.address}`);
3984
4073
  }
@@ -4003,7 +4092,7 @@ function validateRecipients(recipients, dustAmount, context) {
4003
4092
 
4004
4093
  // src/contracts/spendability.ts
4005
4094
  function isContractGenericallySpendable(contract) {
4006
- return chunkNPM5YZBC_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4095
+ return chunkDXLVCFVK_cjs.contractHandlers.get(contract.type)?.isGenericallySpendable?.(contract) === true;
4007
4096
  }
4008
4097
  function gatedContracts(contracts) {
4009
4098
  const gated = /* @__PURE__ */ new Map();
@@ -4025,7 +4114,7 @@ function gateExclusion(gated) {
4025
4114
  return (vtxo) => {
4026
4115
  const type = gatedTypeOf(vtxo, gated);
4027
4116
  if (type === void 0) return void 0;
4028
- if (!chunkNPM5YZBC_cjs.contractHandlers.has(type)) {
4117
+ if (!chunkDXLVCFVK_cjs.contractHandlers.has(type)) {
4029
4118
  return `at ${vtxo.script} (contract type '${type}') has no handler registered in this build`;
4030
4119
  }
4031
4120
  return `at ${vtxo.script} (contract type '${type}') is not generically spendable`;
@@ -4061,7 +4150,7 @@ function selectPendingRecoveryOutpoints(contractsWithVtxos, signerSet, nowSecond
4061
4150
  continue;
4062
4151
  }
4063
4152
  for (const v of vtxos) {
4064
- if (!chunk6FTHFJAN_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
4153
+ if (!chunkKMPNH7NS_cjs.hasTerminalSpend(v) && !v.isSwept && !v.isUnrolled) {
4065
4154
  out.add(`${v.txid}:${v.vout}`);
4066
4155
  }
4067
4156
  }
@@ -4096,10 +4185,10 @@ function byValueDescending(vtxos) {
4096
4185
  return [...vtxos].sort((a, b) => b.value - a.value);
4097
4186
  }
4098
4187
  async function fetchTimeHeight(wallet) {
4099
- return chunk6FTHFJAN_cjs.resolveTimeHeight(wallet.onchainProvider);
4188
+ return chunkKMPNH7NS_cjs.resolveTimeHeight(wallet.onchainProvider);
4100
4189
  }
4101
4190
  function canMigrateBySend(vtxo, now) {
4102
- if (!chunk6FTHFJAN_cjs.canSpendOffchain(vtxo, now)) return false;
4191
+ if (!chunkKMPNH7NS_cjs.canSpendOffchain(vtxo, now)) return false;
4103
4192
  return vtxo.expiresAt !== void 0 || vtxo.expiresAtHeight !== void 0;
4104
4193
  }
4105
4194
  function byExpiryAscending(vtxos, now) {
@@ -4107,7 +4196,7 @@ function byExpiryAscending(vtxos, now) {
4107
4196
  if (vtxo.isSwept) return -Infinity;
4108
4197
  if (vtxo.expiresAt !== void 0) return vtxo.expiresAt.getTime();
4109
4198
  if (vtxo.expiresAtHeight !== void 0) {
4110
- return chunk6FTHFJAN_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4199
+ return chunkKMPNH7NS_cjs.isPastExpiry(vtxo, now) ? -Infinity : Infinity;
4111
4200
  }
4112
4201
  return Infinity;
4113
4202
  };
@@ -4134,7 +4223,7 @@ function priceSettlementInputs(vtxos, estimator) {
4134
4223
  const payable = [];
4135
4224
  const net = /* @__PURE__ */ new Map();
4136
4225
  for (const vtxo of vtxos) {
4137
- const inputFee = estimator.evalOffchainInput(chunk6FTHFJAN_cjs.toOffchainInputFeeParams(vtxo));
4226
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(vtxo));
4138
4227
  if (inputFee.satoshis >= vtxo.value) {
4139
4228
  continue;
4140
4229
  }
@@ -4160,7 +4249,7 @@ function deductOffchainOutputFee(subtotal, estimator, arkAddress) {
4160
4249
  }
4161
4250
  const outputFee = estimator.evalOffchainOutput({
4162
4251
  amount: subtotal,
4163
- script: base.hex.encode(chunk6FTHFJAN_cjs.ArkAddress.decode(arkAddress).pkScript)
4252
+ script: base.hex.encode(chunkKMPNH7NS_cjs.ArkAddress.decode(arkAddress).pkScript)
4164
4253
  });
4165
4254
  return subtotal - BigInt(outputFee.satoshis);
4166
4255
  }
@@ -4178,10 +4267,10 @@ var DEFAULT_SETTLEMENT_CONFIG = {
4178
4267
  };
4179
4268
  function getRecoverableVtxos(vtxos, dustAmount, now) {
4180
4269
  return vtxos.filter((vtxo) => {
4181
- if (chunk6FTHFJAN_cjs.canRecoverOnchain(vtxo, now)) {
4270
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
4182
4271
  return true;
4183
4272
  }
4184
- if (chunk6FTHFJAN_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4273
+ if (chunkKMPNH7NS_cjs.canSpendOffchain(vtxo, now) && vtxo.isPreconfirmed && isSubdust(vtxo, dustAmount)) {
4185
4274
  return true;
4186
4275
  }
4187
4276
  return false;
@@ -4213,7 +4302,7 @@ function getRecoverableWithSubdust(vtxos, dustAmount, now) {
4213
4302
  function isVtxoExpiringSoon(vtxo, thresholdMs) {
4214
4303
  if (vtxo.isUnrolled) return false;
4215
4304
  const realThresholdMs = thresholdMs <= 100 ? DEFAULT_THRESHOLD_MS : thresholdMs;
4216
- const expiresAt = chunk6FTHFJAN_cjs.normalizeVtxo(vtxo).expiresAt;
4305
+ const expiresAt = chunkKMPNH7NS_cjs.normalizeVtxo(vtxo).expiresAt;
4217
4306
  if (expiresAt === void 0) return false;
4218
4307
  const now = Date.now();
4219
4308
  const batchExpiry = expiresAt.getTime();
@@ -4224,7 +4313,7 @@ function getExpiringAndRecoverableVtxos(vtxos, thresholdMs, dustAmount, now) {
4224
4313
  return vtxos.filter(
4225
4314
  // The leading exclusion covers the `isSubdust` arm too, which is a value
4226
4315
  // property and would otherwise re-admit an exited coin on its own.
4227
- (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunk6FTHFJAN_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4316
+ (vtxo) => !vtxo.isUnrolled && (isVtxoExpiringSoon(vtxo, thresholdMs) || chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now) || isSubdust(vtxo, dustAmount))
4228
4317
  );
4229
4318
  }
4230
4319
  function isMigrationCapable(wallet) {
@@ -4823,11 +4912,11 @@ var VtxoManager = class _VtxoManager {
4823
4912
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
4824
4913
  );
4825
4914
  }
4826
- const tx = new chunk6FTHFJAN_cjs.Transaction();
4915
+ const tx = new chunkKMPNH7NS_cjs.Transaction();
4827
4916
  for (const utxo of expiredUtxos) {
4828
- const utxoScript = chunk6FTHFJAN_cjs.VtxoScript.decode(utxo.tapTree);
4917
+ const utxoScript = chunkKMPNH7NS_cjs.VtxoScript.decode(utxo.tapTree);
4829
4918
  const utxoExitLeaf = utxoScript.leaves.find(
4830
- (leaf) => chunk6FTHFJAN_cjs.CSVMultisigTapscript.isScriptValid(chunk6FTHFJAN_cjs.scriptFromTapLeafScript(leaf)) === true
4919
+ (leaf) => chunkKMPNH7NS_cjs.CSVMultisigTapscript.isScriptValid(chunkKMPNH7NS_cjs.scriptFromTapLeafScript(leaf)) === true
4831
4920
  );
4832
4921
  if (!utxoExitLeaf) {
4833
4922
  throw new Error(
@@ -4842,7 +4931,7 @@ var VtxoManager = class _VtxoManager {
4842
4931
  amount: BigInt(utxo.value)
4843
4932
  },
4844
4933
  tapLeafScript: [utxoExitLeaf],
4845
- sequence: chunk6FTHFJAN_cjs.getSequence(utxoExitLeaf)
4934
+ sequence: chunkKMPNH7NS_cjs.getSequence(utxoExitLeaf)
4846
4935
  });
4847
4936
  }
4848
4937
  tx.addOutputAddress(boardingAddress, outputAmount, this.getNetwork());
@@ -5085,8 +5174,8 @@ var VtxoManager = class _VtxoManager {
5085
5174
  const cls = classifyAgainstSignerSet(serverPubKey, signerSet, nowSeconds);
5086
5175
  if (cls.status === "CURRENT") continue;
5087
5176
  const live = vtxos.filter((v) => !v.isUnrolled);
5088
- const recoverable = live.filter((v) => v.isSwept && !chunk6FTHFJAN_cjs.hasTerminalSpend(v));
5089
- const spendable = live.filter((v) => !chunk6FTHFJAN_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);
5090
5179
  const value = spendable.reduce((sum, v) => sum + v.value, 0);
5091
5180
  let recoverableCount = 0;
5092
5181
  let recoverableValue = 0;
@@ -5099,7 +5188,7 @@ var VtxoManager = class _VtxoManager {
5099
5188
  awaitingSweepCount = spendable.length;
5100
5189
  awaitingSweepValue = value;
5101
5190
  for (const v of spendable) {
5102
- const exp = chunk6FTHFJAN_cjs.toBatchExpiry(v);
5191
+ const exp = chunkKMPNH7NS_cjs.toBatchExpiry(v);
5103
5192
  if (exp !== void 0 && (nextSweepEta === void 0 || exp < nextSweepEta)) {
5104
5193
  nextSweepEta = exp;
5105
5194
  }
@@ -5360,7 +5449,7 @@ var VtxoManager = class _VtxoManager {
5360
5449
  /** Decodes the boarding tapscript exit path to extract the CSV timelock. */
5361
5450
  getBoardingTimelock() {
5362
5451
  const wallet = this.getSweepWallet();
5363
- const exitScript = chunk6FTHFJAN_cjs.CSVMultisigTapscript.decode(
5452
+ const exitScript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(
5364
5453
  base.hex.decode(wallet.boardingTapscript.exitScript)
5365
5454
  );
5366
5455
  return exitScript.params.timelock;
@@ -5491,8 +5580,8 @@ var VtxoManager = class _VtxoManager {
5491
5580
  * or doesn't carry the metadata.
5492
5581
  */
5493
5582
  extractSpentOutpoint(error) {
5494
- const ark = chunk6FTHFJAN_cjs.maybeArkError(error);
5495
- if (!chunk6FTHFJAN_cjs.isArkError(ark, chunk6FTHFJAN_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;
5496
5585
  const raw = ark.metadata?.vtxo_outpoint;
5497
5586
  if (typeof raw !== "string") return void 0;
5498
5587
  const [txid, voutStr] = raw.split(":");
@@ -5682,7 +5771,7 @@ var VtxoManager = class _VtxoManager {
5682
5771
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
5683
5772
  break;
5684
5773
  }
5685
- const inputFee = estimator.evalOffchainInput(chunk6FTHFJAN_cjs.toOffchainInputFeeParams(v));
5774
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(v));
5686
5775
  if (inputFee.satoshis >= v.value) {
5687
5776
  continue;
5688
5777
  }
@@ -5702,7 +5791,7 @@ var VtxoManager = class _VtxoManager {
5702
5791
  const arkAddress = await this.wallet.getAddress();
5703
5792
  const outputFee = estimator.evalOffchainOutput({
5704
5793
  amount: totalAmount,
5705
- script: base.hex.encode(chunk6FTHFJAN_cjs.ArkAddress.decode(arkAddress).pkScript)
5794
+ script: base.hex.encode(chunkKMPNH7NS_cjs.ArkAddress.decode(arkAddress).pkScript)
5706
5795
  });
5707
5796
  totalAmount -= BigInt(outputFee.satoshis);
5708
5797
  if (totalAmount < dustAmount) return;
@@ -5782,7 +5871,7 @@ var ArkNote = class _ArkNote {
5782
5871
  this.value = value;
5783
5872
  this.HRP = HRP;
5784
5873
  const preimageHash = utils_js.sha256(this.preimage);
5785
- this.vtxoScript = new chunk6FTHFJAN_cjs.VtxoScript([noteTapscript(preimageHash)]);
5874
+ this.vtxoScript = new chunkKMPNH7NS_cjs.VtxoScript([noteTapscript(preimageHash)]);
5786
5875
  const leaf = this.vtxoScript.leaves[0];
5787
5876
  this.txid = base.hex.encode(new Uint8Array(preimageHash).reverse());
5788
5877
  this.tapTree = this.vtxoScript.encode();
@@ -5949,7 +6038,7 @@ var ArkadeCash = class _ArkadeCash {
5949
6038
  const privateKey = data.slice(1, 33);
5950
6039
  const serverPubKey = data.slice(33, 65);
5951
6040
  const sequence = new DataView(data.buffer, data.byteOffset + 65, 4).getUint32(0, false);
5952
- const csvTimelock = chunk6FTHFJAN_cjs.sequenceToTimelock(sequence);
6041
+ const csvTimelock = chunkKMPNH7NS_cjs.sequenceToTimelock(sequence);
5953
6042
  return new _ArkadeCash(privateKey, serverPubKey, csvTimelock, decoded.prefix);
5954
6043
  }
5955
6044
  toString() {
@@ -5957,7 +6046,7 @@ var ArkadeCash = class _ArkadeCash {
5957
6046
  data[0] = _ArkadeCash.Version;
5958
6047
  data.set(this._privateKey, 1);
5959
6048
  data.set(this._serverPubKey, 33);
5960
- const sequence = chunk6FTHFJAN_cjs.timelockToSequence(this.csvTimelock);
6049
+ const sequence = chunkKMPNH7NS_cjs.timelockToSequence(this.csvTimelock);
5961
6050
  new DataView(data.buffer, data.byteOffset + 65, 4).setUint32(0, sequence, false);
5962
6051
  const words = base.bech32m.toWords(data);
5963
6052
  return base.bech32m.encode(this.hrp, words, 1023);
@@ -5966,7 +6055,7 @@ var ArkadeCash = class _ArkadeCash {
5966
6055
  return SingleKey.fromPrivateKey(this._privateKey);
5967
6056
  }
5968
6057
  get vtxoScript() {
5969
- return new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
6058
+ return new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
5970
6059
  pubKey: this._publicKey,
5971
6060
  serverPubKey: this._serverPubKey,
5972
6061
  csvTimelock: this.csvTimelock
@@ -6227,7 +6316,7 @@ async function captureExitBranch(params) {
6227
6316
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
6228
6317
  if (nonCommitment.length > 0) {
6229
6318
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
6230
- psbtByTxid.set(chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6319
+ psbtByTxid.set(chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6231
6320
  }
6232
6321
  }
6233
6322
  }
@@ -6270,10 +6359,10 @@ var IndexerExitDataSource = class {
6270
6359
  while (hasMore) {
6271
6360
  const { chain: page, page: meta } = await this.indexer.getVtxoChain(
6272
6361
  { txid: vtxo.txid, vout: vtxo.vout },
6273
- { pageIndex, pageSize: chunk6FTHFJAN_cjs.DEFAULT_PAGE_SIZE }
6362
+ { pageIndex, pageSize: chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE }
6274
6363
  );
6275
6364
  chain.push(...page);
6276
- hasMore = meta ? page.length === chunk6FTHFJAN_cjs.DEFAULT_PAGE_SIZE : false;
6365
+ hasMore = meta ? page.length === chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE : false;
6277
6366
  pageIndex++;
6278
6367
  }
6279
6368
  return chain;
@@ -6285,12 +6374,12 @@ var IndexerExitDataSource = class {
6285
6374
  while (hasMore) {
6286
6375
  const { txs, page } = await this.indexer.getVirtualTxs(txids, {
6287
6376
  pageIndex,
6288
- pageSize: chunk6FTHFJAN_cjs.DEFAULT_PAGE_SIZE
6377
+ pageSize: chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE
6289
6378
  });
6290
6379
  for (const psbt of txs) {
6291
- out.set(chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6380
+ out.set(chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
6292
6381
  }
6293
- hasMore = page ? txs.length === chunk6FTHFJAN_cjs.DEFAULT_PAGE_SIZE : false;
6382
+ hasMore = page ? txs.length === chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE : false;
6294
6383
  pageIndex++;
6295
6384
  }
6296
6385
  return out;
@@ -6311,7 +6400,7 @@ function chainedTxTypeToChainTxType(t) {
6311
6400
  }
6312
6401
  }
6313
6402
  function psbtInputTxids(psbtBase64) {
6314
- const tx = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6403
+ const tx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
6315
6404
  const ids = [];
6316
6405
  for (let i = 0; i < tx.inputsLength; i++) {
6317
6406
  const txid = tx.getInput(i).txid;
@@ -6670,10 +6759,10 @@ async function resolveArkInfo(arkProvider, walletRepository) {
6670
6759
  try {
6671
6760
  info = await arkProvider.getInfo();
6672
6761
  } catch (err) {
6673
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
6762
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
6674
6763
  const snapshot = await loadArkInfoSnapshot(walletRepository);
6675
6764
  if (!snapshot) {
6676
- throw new chunk6FTHFJAN_cjs.ProviderUnavailableError(
6765
+ throw new chunkKMPNH7NS_cjs.ProviderUnavailableError(
6677
6766
  "Arkade server info is unavailable and no cached snapshot exists",
6678
6767
  { cause: err }
6679
6768
  );
@@ -7080,7 +7169,7 @@ function collectArkTxidsNeedingCreatedAt(vtxos, localCreatedAt) {
7080
7169
  return [...txids];
7081
7170
  }
7082
7171
  async function buildTransactionHistory(vtxos, allBoardingTxs, commitmentsToIgnore, resolveTxCreatedAt, gatedScripts = /* @__PURE__ */ new Map()) {
7083
- const normalized = vtxos.map(chunk6FTHFJAN_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());
7084
7173
  const localCreatedAt = localCreatedAtByTxid(normalized);
7085
7174
  const gatedVtxos = normalized.filter((vtxo) => isGatedVtxo(vtxo, gatedScripts));
7086
7175
  const ownVtxos = normalized.filter((vtxo) => !isGatedVtxo(vtxo, gatedScripts));
@@ -7254,7 +7343,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7254
7343
  const virtualCoins = await this.wallet.getSpendableVtxos({
7255
7344
  withRecoverable: false
7256
7345
  });
7257
- const controlAssetRef = params.controlAssetId ? chunk4C5PMGBB_cjs.AssetRef.fromId(chunk4C5PMGBB_cjs.AssetId.fromString(params.controlAssetId)) : null;
7346
+ const controlAssetRef = params.controlAssetId ? chunkAS3W34MG_cjs.AssetRef.fromId(chunkAS3W34MG_cjs.AssetId.fromString(params.controlAssetId)) : null;
7258
7347
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
7259
7348
  let totalBtcSelected = 0n;
7260
7349
  const assetChanges = /* @__PURE__ */ new Map();
@@ -7267,8 +7356,8 @@ var AssetManager = class extends ReadonlyAssetManager {
7267
7356
  }
7268
7357
  }
7269
7358
  const groups = [];
7270
- const issuedAssetOutput = chunk4C5PMGBB_cjs.AssetOutput.create(0, params.amount);
7271
- const issuedAssetGroup = chunk4C5PMGBB_cjs.AssetGroup.create(
7359
+ const issuedAssetOutput = chunkAS3W34MG_cjs.AssetOutput.create(0, params.amount);
7360
+ const issuedAssetGroup = chunkAS3W34MG_cjs.AssetGroup.create(
7272
7361
  null,
7273
7362
  controlAssetRef,
7274
7363
  [],
@@ -7283,28 +7372,28 @@ var AssetManager = class extends ReadonlyAssetManager {
7283
7372
  for (const [inputIndex, assets] of assetInputs) {
7284
7373
  for (const asset of assets) {
7285
7374
  if (asset.assetId !== assetId) continue;
7286
- changeInputs.push(chunk4C5PMGBB_cjs.AssetInput.create(inputIndex, asset.amount));
7375
+ changeInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7287
7376
  }
7288
7377
  }
7289
7378
  groups.push(
7290
- chunk4C5PMGBB_cjs.AssetGroup.create(
7291
- chunk4C5PMGBB_cjs.AssetId.fromString(assetId),
7379
+ chunkAS3W34MG_cjs.AssetGroup.create(
7380
+ chunkAS3W34MG_cjs.AssetId.fromString(assetId),
7292
7381
  null,
7293
7382
  changeInputs,
7294
- [chunk4C5PMGBB_cjs.AssetOutput.create(0, amount)],
7383
+ [chunkAS3W34MG_cjs.AssetOutput.create(0, amount)],
7295
7384
  []
7296
7385
  )
7297
7386
  );
7298
7387
  }
7299
7388
  }
7300
7389
  const address = await this.wallet.getAddress();
7301
- const outputAddress = chunk6FTHFJAN_cjs.ArkAddress.decode(address);
7390
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
7302
7391
  const outputs = [
7303
7392
  {
7304
7393
  script: outputAddress.pkScript,
7305
7394
  amount: BigInt(totalBtcSelected)
7306
7395
  },
7307
- Extension.create([chunk4C5PMGBB_cjs.Packet.create(groups)]).txOut()
7396
+ Extension.create([chunkAS3W34MG_cjs.Packet.create(groups)]).txOut()
7308
7397
  ];
7309
7398
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
7310
7399
  coinSelection.inputs,
@@ -7312,7 +7401,7 @@ var AssetManager = class extends ReadonlyAssetManager {
7312
7401
  );
7313
7402
  return {
7314
7403
  arkTxId: arkTxid,
7315
- assetId: chunk4C5PMGBB_cjs.AssetId.create(arkTxid, 0).toString()
7404
+ assetId: chunkAS3W34MG_cjs.AssetId.create(arkTxid, 0).toString()
7316
7405
  };
7317
7406
  }
7318
7407
  /**
@@ -7384,16 +7473,16 @@ var AssetManager = class extends ReadonlyAssetManager {
7384
7473
  for (const [inputIndex, assets] of assetInputs) {
7385
7474
  for (const asset of assets) {
7386
7475
  if (asset.assetId !== params.assetId) continue;
7387
- reissueInputs.push(chunk4C5PMGBB_cjs.AssetInput.create(inputIndex, asset.amount));
7476
+ reissueInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7388
7477
  }
7389
7478
  }
7390
7479
  const totalAssetAmount = assetToReissueAmount + params.amount;
7391
- const reissueAssetIdObj = chunk4C5PMGBB_cjs.AssetId.fromString(params.assetId);
7392
- const reissueAssetGroup = chunk4C5PMGBB_cjs.AssetGroup.create(
7480
+ const reissueAssetIdObj = chunkAS3W34MG_cjs.AssetId.fromString(params.assetId);
7481
+ const reissueAssetGroup = chunkAS3W34MG_cjs.AssetGroup.create(
7393
7482
  reissueAssetIdObj,
7394
7483
  null,
7395
7484
  reissueInputs,
7396
- [chunk4C5PMGBB_cjs.AssetOutput.create(0, totalAssetAmount)],
7485
+ [chunkAS3W34MG_cjs.AssetOutput.create(0, totalAssetAmount)],
7397
7486
  []
7398
7487
  );
7399
7488
  const groups = [reissueAssetGroup];
@@ -7402,27 +7491,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7402
7491
  for (const [inputIndex, assets] of assetInputs) {
7403
7492
  for (const asset of assets) {
7404
7493
  if (asset.assetId !== assetId) continue;
7405
- changeInputs.push(chunk4C5PMGBB_cjs.AssetInput.create(inputIndex, asset.amount));
7494
+ changeInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7406
7495
  }
7407
7496
  }
7408
7497
  groups.push(
7409
- chunk4C5PMGBB_cjs.AssetGroup.create(
7410
- chunk4C5PMGBB_cjs.AssetId.fromString(assetId),
7498
+ chunkAS3W34MG_cjs.AssetGroup.create(
7499
+ chunkAS3W34MG_cjs.AssetId.fromString(assetId),
7411
7500
  null,
7412
7501
  changeInputs,
7413
- [chunk4C5PMGBB_cjs.AssetOutput.create(0, amount)],
7502
+ [chunkAS3W34MG_cjs.AssetOutput.create(0, amount)],
7414
7503
  []
7415
7504
  )
7416
7505
  );
7417
7506
  }
7418
7507
  const address = await this.wallet.getAddress();
7419
- const outputAddress = chunk6FTHFJAN_cjs.ArkAddress.decode(address);
7508
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
7420
7509
  const outputs = [
7421
7510
  {
7422
7511
  script: outputAddress.pkScript,
7423
7512
  amount: BigInt(totalBtcSelected)
7424
7513
  },
7425
- Extension.create([chunk4C5PMGBB_cjs.Packet.create(groups)]).txOut()
7514
+ Extension.create([chunkAS3W34MG_cjs.Packet.create(groups)]).txOut()
7426
7515
  ];
7427
7516
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7428
7517
  return arkTxid;
@@ -7489,27 +7578,27 @@ var AssetManager = class extends ReadonlyAssetManager {
7489
7578
  for (const [inputIndex, assets] of assetInputs) {
7490
7579
  for (const asset of assets) {
7491
7580
  if (asset.assetId !== assetId) continue;
7492
- changeInputs.push(chunk4C5PMGBB_cjs.AssetInput.create(inputIndex, asset.amount));
7581
+ changeInputs.push(chunkAS3W34MG_cjs.AssetInput.create(inputIndex, asset.amount));
7493
7582
  }
7494
7583
  }
7495
7584
  groups.push(
7496
- chunk4C5PMGBB_cjs.AssetGroup.create(
7497
- chunk4C5PMGBB_cjs.AssetId.fromString(assetId),
7585
+ chunkAS3W34MG_cjs.AssetGroup.create(
7586
+ chunkAS3W34MG_cjs.AssetId.fromString(assetId),
7498
7587
  null,
7499
7588
  changeInputs,
7500
- amount > 0n ? [chunk4C5PMGBB_cjs.AssetOutput.create(0, amount)] : [],
7589
+ amount > 0n ? [chunkAS3W34MG_cjs.AssetOutput.create(0, amount)] : [],
7501
7590
  []
7502
7591
  )
7503
7592
  );
7504
7593
  }
7505
7594
  const address = await this.wallet.getAddress();
7506
- const outputAddress = chunk6FTHFJAN_cjs.ArkAddress.decode(address);
7595
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(address);
7507
7596
  const outputs = [
7508
7597
  {
7509
7598
  script: outputAddress.pkScript,
7510
7599
  amount: BigInt(totalBtcSelected)
7511
7600
  },
7512
- Extension.create([chunk4C5PMGBB_cjs.Packet.create(groups)]).txOut()
7601
+ Extension.create([chunkAS3W34MG_cjs.Packet.create(groups)]).txOut()
7513
7602
  ];
7514
7603
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
7515
7604
  return arkTxid;
@@ -7534,7 +7623,7 @@ function castMetadata(metadata) {
7534
7623
  } else {
7535
7624
  throw new Error("Invalid metadata value type");
7536
7625
  }
7537
- md.push(chunk4C5PMGBB_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7626
+ md.push(chunkAS3W34MG_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
7538
7627
  }
7539
7628
  return md;
7540
7629
  }
@@ -7555,10 +7644,10 @@ var DelegateManagerImpl = class {
7555
7644
  if (vtxos.length === 0) {
7556
7645
  return { delegated: [], failed: [] };
7557
7646
  }
7558
- const destinationScript = chunk6FTHFJAN_cjs.ArkAddress.decode(destination).pkScript;
7647
+ const destinationScript = chunkKMPNH7NS_cjs.ArkAddress.decode(destination).pkScript;
7559
7648
  const arkInfo = await this.arkInfoProvider.getInfo();
7560
7649
  const delegateInfo = await this.delegateProvider.getDelegateInfo();
7561
- const eligible = vtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo).filter(
7650
+ const eligible = vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo).filter(
7562
7651
  (v) => isAnnotated(v) && findDelegateTapLeaf(v, delegateInfo.pubkey) !== void 0
7563
7652
  );
7564
7653
  if (eligible.length === 0) {
@@ -7587,11 +7676,11 @@ var DelegateManagerImpl = class {
7587
7676
  const groupByExpiry = /* @__PURE__ */ new Map();
7588
7677
  let recoverableVtxos = [];
7589
7678
  for (const vtxo of eligible) {
7590
- if (chunk6FTHFJAN_cjs.canRecoverOnchain(vtxo, now)) {
7679
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
7591
7680
  recoverableVtxos.push(vtxo);
7592
7681
  continue;
7593
7682
  }
7594
- const expiry = chunk6FTHFJAN_cjs.toBatchExpiry(vtxo);
7683
+ const expiry = chunkKMPNH7NS_cjs.toBatchExpiry(vtxo);
7595
7684
  if (!expiry) continue;
7596
7685
  const dayKey = getDayTimestamp(expiry);
7597
7686
  groupByExpiry.set(dayKey, [...groupByExpiry.get(dayKey) ?? [], vtxo]);
@@ -7656,16 +7745,11 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7656
7745
  }
7657
7746
  if (!delegateAt) {
7658
7747
  const now = { timestamp: /* @__PURE__ */ new Date() };
7659
- const expiryTimestamp = vtxos.filter((coin) => !chunk6FTHFJAN_cjs.canRecoverOnchain(coin, now) && chunk6FTHFJAN_cjs.toBatchExpiry(coin)).reduce((min, coin) => Math.min(min, chunk6FTHFJAN_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);
7660
7749
  if (!expiryTimestamp || expiryTimestamp === Number.MAX_SAFE_INTEGER) {
7661
7750
  delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7662
7751
  } else {
7663
- const remainingTimeMs = expiryTimestamp - Date.now();
7664
- if (remainingTimeMs <= 0) {
7665
- delegateAt = new Date(Date.now() + 1 * 60 * 1e3);
7666
- } else {
7667
- delegateAt = new Date(expiryTimestamp - remainingTimeMs * 0.1);
7668
- }
7752
+ delegateAt = defaultDelegateAt(expiryTimestamp, arkInfo.sessionDuration);
7669
7753
  }
7670
7754
  }
7671
7755
  const { fees, dust, forfeitAddress, network } = arkInfo;
@@ -7685,7 +7769,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7685
7769
  let amount = 0n;
7686
7770
  for (const coin of vtxos) {
7687
7771
  const inputFee = estimator.evalOffchainInput({
7688
- ...chunk6FTHFJAN_cjs.toOffchainInputFeeParams(coin),
7772
+ ...chunkKMPNH7NS_cjs.toOffchainInputFeeParams(coin),
7689
7773
  type: "vtxo"
7690
7774
  });
7691
7775
  if (inputFee.value >= coin.value) {
@@ -7699,7 +7783,7 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7699
7783
  const delegateFee = BigInt(Number(fee));
7700
7784
  if (delegateFee > 0n) {
7701
7785
  outputs.push({
7702
- script: chunk6FTHFJAN_cjs.ArkAddress.decode(delegateAddress).pkScript,
7786
+ script: chunkKMPNH7NS_cjs.ArkAddress.decode(delegateAddress).pkScript,
7703
7787
  amount: delegateFee
7704
7788
  });
7705
7789
  }
@@ -7732,10 +7816,10 @@ async function delegate(identity, delegateProvider, arkInfo, delegateInfo, vtxos
7732
7816
  destinationScript
7733
7817
  );
7734
7818
  const forfeitOutputScript = btcSigner.OutScript.encode(
7735
- btcSigner.Address(chunk6FTHFJAN_cjs.getNetwork(network)).decode(forfeitAddress)
7819
+ btcSigner.Address(chunkKMPNH7NS_cjs.getNetwork(network)).decode(forfeitAddress)
7736
7820
  );
7737
7821
  const forfeits = await Promise.all(
7738
- vtxos.filter((v) => !chunk6FTHFJAN_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) => {
7739
7823
  const forfeit = await makeDelegateForfeitTx(
7740
7824
  coin,
7741
7825
  dust,
@@ -7760,7 +7844,7 @@ async function makeDelegateForfeitTx(input, connectorAmount, delegatePubkey, for
7760
7844
  index: input.vout,
7761
7845
  witnessUtxo: {
7762
7846
  amount: BigInt(input.value),
7763
- script: chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).pkScript
7847
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
7764
7848
  },
7765
7849
  sighashType: btcSigner.SigHash.ALL_ANYONECANPAY,
7766
7850
  tapLeafScript: [delegateTapLeaf]
@@ -7818,13 +7902,21 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
7818
7902
  expire_at: 0,
7819
7903
  cosigners_public_keys: cosignerPubKeys
7820
7904
  };
7821
- const proof = chunk6FTHFJAN_cjs.Intent.create(message, coins, outputs);
7905
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, outputs);
7822
7906
  const signedProof = await identity.sign(proof);
7823
7907
  return {
7824
7908
  proof: base.base64.encode(signedProof.toPSBT()),
7825
7909
  message
7826
7910
  };
7827
7911
  }
7912
+ function defaultDelegateAt(expiryTimestamp, sessionDurationSeconds, now = Date.now()) {
7913
+ const remainingTimeMs = expiryTimestamp - now;
7914
+ if (remainingTimeMs <= 0) return new Date(now + 6e4);
7915
+ const sessionLeadMs = Number(sessionDurationSeconds * 1000n);
7916
+ const leadTimeMs = Math.max(remainingTimeMs * 0.1, sessionLeadMs);
7917
+ const delegateAt = expiryTimestamp - leadTimeMs;
7918
+ return new Date(delegateAt > now ? delegateAt : now + 2e3);
7919
+ }
7828
7920
  function findDestinationOutputIndex(outputs, destinationScript) {
7829
7921
  return outputs.findIndex((o) => o.script && utils_js.equalBytes(o.script, destinationScript));
7830
7922
  }
@@ -7836,10 +7928,10 @@ function getDayTimestamp(timestamp) {
7836
7928
  function findDelegateTapLeaf(vtxo, delegatePubkey) {
7837
7929
  if (!vtxo.tapTree) return void 0;
7838
7930
  const pk = delegatePubkey.length === 66 ? delegatePubkey.slice(2) : delegatePubkey;
7839
- const vtxoScript = chunk6FTHFJAN_cjs.VtxoScript.decode(vtxo.tapTree);
7931
+ const vtxoScript = chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree);
7840
7932
  return vtxoScript.leaves.find((tapLeaf) => {
7841
- const arkTapscript = chunk6FTHFJAN_cjs.decodeTapscript(chunk6FTHFJAN_cjs.scriptFromTapLeafScript(tapLeaf));
7842
- if (!chunk6FTHFJAN_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;
7843
7935
  return arkTapscript.params.pubkeys.map(base.hex.encode).includes(pk);
7844
7936
  });
7845
7937
  }
@@ -8120,7 +8212,7 @@ function createManagedConnection(dbName, version, initDatabase2) {
8120
8212
  };
8121
8213
  }
8122
8214
  function scriptFromArkAddress(address) {
8123
- return base.hex.encode(chunk6FTHFJAN_cjs.ArkAddress.decode(address).pkScript);
8215
+ return base.hex.encode(chunkKMPNH7NS_cjs.ArkAddress.decode(address).pkScript);
8124
8216
  }
8125
8217
 
8126
8218
  // src/repositories/indexedDB/schema.ts
@@ -8615,7 +8707,7 @@ function validateVtxosForScript(vtxos, script, context) {
8615
8707
  }
8616
8708
  async function getVtxosForContract(repo, contract) {
8617
8709
  const vtxos = repo.getVtxosForScript ? await repo.getVtxosForScript(contract.script) : filterVtxosForScript(await repo.getVtxos(contract.address), contract.script);
8618
- return vtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo);
8710
+ return vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
8619
8711
  }
8620
8712
  async function saveVtxosForContract(repo, contract, vtxos) {
8621
8713
  if (repo.saveVtxosForScript) {
@@ -8757,7 +8849,7 @@ function decodeArkContract(encoded) {
8757
8849
  }
8758
8850
  function contractFromArkContract(encoded, options = {}) {
8759
8851
  const parsed = decodeArkContract(encoded);
8760
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(parsed.type);
8852
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(parsed.type);
8761
8853
  if (!handler) {
8762
8854
  throw new Error(`No handler registered for contract type '${parsed.type}'`);
8763
8855
  }
@@ -8771,9 +8863,9 @@ function contractFromArkContract(encoded, options = {}) {
8771
8863
  metadata: options.metadata
8772
8864
  };
8773
8865
  }
8774
- function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunk6FTHFJAN_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8866
+ function contractFromArkContractWithAddress(encoded, serverPubKey, addressPrefix = chunkKMPNH7NS_cjs.DEFAULT_NETWORK.hrp, options = {}) {
8775
8867
  const parsed = decodeArkContract(encoded);
8776
- const handler = chunkNPM5YZBC_cjs.contractHandlers.getOrThrow(parsed.type);
8868
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.getOrThrow(parsed.type);
8777
8869
  const params = parsed.data;
8778
8870
  const vtxoScript = handler.createScript(params);
8779
8871
  return {
@@ -8940,23 +9032,32 @@ var ContractWatcher = class {
8940
9032
  }
8941
9033
  /** @see IContractManager.watchScript for the delivery and filter contract. */
8942
9034
  async addWatchedScript(script, options) {
8943
- const existing = this.watchedScripts.get(script);
8944
- if (existing) {
8945
- if (options?.label !== void 0) existing.label = options.label;
8946
- 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);
8947
9047
  }
8948
- this.watchedScripts.set(script, {
8949
- label: options?.label,
8950
- lastKnownVtxos: /* @__PURE__ */ new Map()
8951
- });
8952
- if (this.isWatching) {
8953
- await this.pollWatchedScripts([script]);
9048
+ if (added.length === 0 || !this.isWatching) return;
9049
+ await this.withCoalescedSubscription(async () => {
9050
+ await this.pollWatchedScripts(added);
8954
9051
  await this.tryUpdateSubscription();
8955
- }
9052
+ });
8956
9053
  }
8957
9054
  /** Stop watching a script added by {@link addWatchedScript}. */
8958
9055
  async removeWatchedScript(script) {
8959
- 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;
8960
9061
  if (this.isWatching) {
8961
9062
  await this.tryUpdateSubscription();
8962
9063
  }
@@ -9070,9 +9171,9 @@ var ContractWatcher = class {
9070
9171
  this.connectionState = "connected";
9071
9172
  this.reconnectAttempts = 0;
9072
9173
  this.listenLoop().catch((e) => {
9073
- if (chunk6FTHFJAN_cjs.isEventSourceError(e)) {
9174
+ if (chunkKMPNH7NS_cjs.isEventSourceError(e)) {
9074
9175
  console.debug("ContractWatcher subscription disconnected; reconnecting");
9075
- } else if (!chunk6FTHFJAN_cjs.isEventSourceUnavailableError(e)) {
9176
+ } else if (!chunkKMPNH7NS_cjs.isEventSourceUnavailableError(e)) {
9076
9177
  console.error(e);
9077
9178
  }
9078
9179
  this.connectionState = "disconnected";
@@ -9084,7 +9185,7 @@ var ContractWatcher = class {
9084
9185
  this.scheduleReconnect();
9085
9186
  });
9086
9187
  } catch (error) {
9087
- if (!chunk6FTHFJAN_cjs.isEventSourceUnavailableError(error)) {
9188
+ if (!chunkKMPNH7NS_cjs.isEventSourceUnavailableError(error)) {
9088
9189
  console.error("ContractWatcher connection failed:", error);
9089
9190
  }
9090
9191
  this.connectionState = "disconnected";
@@ -9110,7 +9211,7 @@ var ContractWatcher = class {
9110
9211
  * slower; what it loses is push latency.
9111
9212
  */
9112
9213
  reportEventSourceUnavailable(error) {
9113
- if (!chunk6FTHFJAN_cjs.isEventSourceUnavailableError(error)) return false;
9214
+ if (!chunkKMPNH7NS_cjs.isEventSourceUnavailableError(error)) return false;
9114
9215
  if (!this.eventSourceReported) {
9115
9216
  this.eventSourceReported = true;
9116
9217
  console.warn(
@@ -9182,7 +9283,7 @@ var ContractWatcher = class {
9182
9283
  const now = Date.now();
9183
9284
  let current;
9184
9285
  try {
9185
- current = await chunk6FTHFJAN_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9286
+ current = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(this.config.indexerProvider, scripts, {
9186
9287
  spendableOnly: true
9187
9288
  });
9188
9289
  } catch (error) {
@@ -9391,14 +9492,14 @@ var ContractWatcher = class {
9391
9492
  const timestamp = Date.now();
9392
9493
  if (update.newVtxos?.length) {
9393
9494
  this.processSubscriptionVtxos(
9394
- update.newVtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo),
9495
+ update.newVtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo),
9395
9496
  "vtxo_received",
9396
9497
  timestamp
9397
9498
  );
9398
9499
  }
9399
9500
  if (update.spentVtxos?.length) {
9400
9501
  this.processSubscriptionVtxos(
9401
- update.spentVtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo),
9502
+ update.spentVtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo),
9402
9503
  "vtxo_spent",
9403
9504
  timestamp
9404
9505
  );
@@ -9426,8 +9527,8 @@ var ContractWatcher = class {
9426
9527
  continue;
9427
9528
  }
9428
9529
  if (target === byWatchedScript && eventType === "vtxo_received") {
9429
- const n = chunk6FTHFJAN_cjs.normalizeVtxo(vtxo);
9430
- if (chunk6FTHFJAN_cjs.hasTerminalSpend(n) || n.isSwept || chunk6FTHFJAN_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;
9431
9532
  }
9432
9533
  let bucket = target.get(vtxo.script);
9433
9534
  if (!bucket) {
@@ -9526,7 +9627,7 @@ var NON_TERMINAL_INTENT_STATES = ALL_INTENT_STATES.filter(
9526
9627
  (s) => !isTerminalIntentState(s)
9527
9628
  );
9528
9629
  function isConsumed(vtxo) {
9529
- return vtxo !== void 0 && chunk6FTHFJAN_cjs.hasTerminalSpend(vtxo);
9630
+ return vtxo !== void 0 && chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo);
9530
9631
  }
9531
9632
  async function classifyIntent(intent, vtxosByOutpoint, now) {
9532
9633
  if (isTerminalIntentState(intent.state)) return void 0;
@@ -9569,7 +9670,7 @@ async function reconcileIntents(deps) {
9569
9670
  let vtxosByOutpoint = /* @__PURE__ */ new Map();
9570
9671
  if (outpoints.length > 0) {
9571
9672
  try {
9572
- const { vtxos } = await chunk6FTHFJAN_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9673
+ const { vtxos } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(deps.indexerProvider, { outpoints });
9573
9674
  vtxosByOutpoint = new Map(vtxos.map((v) => [outpointKey(v), v]));
9574
9675
  } catch (e) {
9575
9676
  console.error("reconcileIntents: failed to fetch input VTXO state", e);
@@ -9748,7 +9849,7 @@ var ContractManager = class _ContractManager {
9748
9849
  await this.reconcileWatched();
9749
9850
  this.markSyncOnline();
9750
9851
  } catch (err) {
9751
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
9852
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
9752
9853
  this.markSyncDegraded(err);
9753
9854
  }
9754
9855
  this.initialized = true;
@@ -9880,7 +9981,7 @@ var ContractManager = class _ContractManager {
9880
9981
  const from = Math.max(0, watermark - lookAhead.size);
9881
9982
  const to = watermark + lookAhead.size;
9882
9983
  const deps = lookAhead.candidateDeps();
9883
- const handlers = chunkNPM5YZBC_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkNPM5YZBC_cjs.contractHandlers.get(t)).filter(hasCandidates);
9984
+ const handlers = chunkDXLVCFVK_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkDXLVCFVK_cjs.contractHandlers.get(t)).filter(hasCandidates);
9884
9985
  const band = /* @__PURE__ */ new Map();
9885
9986
  for (let index = from; index <= to; index++) {
9886
9987
  const descriptor = lookAhead.materialize(index);
@@ -9891,7 +9992,7 @@ var ContractManager = class _ContractManager {
9891
9992
  index,
9892
9993
  params: {
9893
9994
  ...candidate,
9894
- ...chunkNPM5YZBC_cjs.speculativeReceiveMetadata(descriptor)
9995
+ ...chunkDXLVCFVK_cjs.speculativeReceiveMetadata(descriptor)
9895
9996
  }
9896
9997
  });
9897
9998
  }
@@ -9953,7 +10054,7 @@ var ContractManager = class _ContractManager {
9953
10054
  });
9954
10055
  for (const entry of pending) entry.catchUpPending = false;
9955
10056
  } catch (err) {
9956
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
10057
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
9957
10058
  this.markSyncDegraded(err);
9958
10059
  }
9959
10060
  }
@@ -10003,7 +10104,7 @@ var ContractManager = class _ContractManager {
10003
10104
  await this.fetchContractVxosFromIndexer([contract]);
10004
10105
  this.markSyncOnline();
10005
10106
  } catch (err) {
10006
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
10107
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10007
10108
  this.markSyncDegraded(err);
10008
10109
  }
10009
10110
  await this.watcher.addContract(contract);
@@ -10037,7 +10138,7 @@ var ContractManager = class _ContractManager {
10037
10138
  await this.fetchContractVxosFromIndexer(fresh);
10038
10139
  this.markSyncOnline();
10039
10140
  } catch (err) {
10040
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
10141
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10041
10142
  this.markSyncDegraded(err);
10042
10143
  }
10043
10144
  for (const contract of fresh) await this.watcher.addContract(contract);
@@ -10075,7 +10176,7 @@ var ContractManager = class _ContractManager {
10075
10176
  return result;
10076
10177
  }
10077
10178
  async upsertContractRow(params) {
10078
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(params.type);
10179
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(params.type);
10079
10180
  if (!handler) {
10080
10181
  throw new Error(`No handler registered for contract type '${params.type}'`);
10081
10182
  }
@@ -10175,7 +10276,7 @@ var ContractManager = class _ContractManager {
10175
10276
  `scanContracts: batchSize must be a positive integer (got ${String(opts.batchSize)})`
10176
10277
  );
10177
10278
  }
10178
- const registered = chunkNPM5YZBC_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkNPM5YZBC_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10279
+ const registered = chunkDXLVCFVK_cjs.contractHandlers.getRegisteredTypes().map((t) => chunkDXLVCFVK_cjs.contractHandlers.get(t)).filter(isDiscoverable);
10179
10280
  const discoverables = [
10180
10281
  ...registered.filter((h) => h.type === "boarding"),
10181
10282
  ...registered.filter((h) => h.type !== "boarding")
@@ -10313,7 +10414,7 @@ var ContractManager = class _ContractManager {
10313
10414
  await this.syncContracts({ contracts, pageSize });
10314
10415
  this.markSyncOnline();
10315
10416
  } catch (err) {
10316
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
10417
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10317
10418
  this.markSyncDegraded(err);
10318
10419
  }
10319
10420
  }
@@ -10335,7 +10436,7 @@ var ContractManager = class _ContractManager {
10335
10436
  }
10336
10437
  const tapscriptCache = tapscripts ?? /* @__PURE__ */ new Map();
10337
10438
  return vtxos.map(
10338
- (vtxo) => extendVirtualCoinForContract(chunk6FTHFJAN_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10439
+ (vtxo) => extendVirtualCoinForContract(chunkKMPNH7NS_cjs.normalizeVtxo(vtxo), byScript, tapscriptCache)
10339
10440
  );
10340
10441
  }
10341
10442
  /** @inheritdoc */
@@ -10379,14 +10480,14 @@ var ContractManager = class _ContractManager {
10379
10480
  const byScript = new Map(contracts.map((contract) => [contract.script, contract]));
10380
10481
  const asking = vtxos.filter((vtxo) => {
10381
10482
  const contract = byScript.get(vtxo.script);
10382
- return contract !== void 0 && chunkNPM5YZBC_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10483
+ return contract !== void 0 && chunkDXLVCFVK_cjs.contractHandlers.get(contract.type)?.assertSpendableNow !== void 0;
10383
10484
  });
10384
10485
  if (asking.length === 0) return refused;
10385
10486
  const tip = await this.currentChainTip();
10386
10487
  const walletKey = await walletPubKey?.();
10387
10488
  for (const vtxo of asking) {
10388
10489
  const contract = byScript.get(vtxo.script);
10389
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
10490
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
10390
10491
  if (!handler?.assertSpendableNow) continue;
10391
10492
  const context = {
10392
10493
  collaborative: true,
@@ -10401,7 +10502,7 @@ var ContractManager = class _ContractManager {
10401
10502
  // the next handler to answer a CSV question would meet a
10402
10503
  // TypeError instead of a `false`. Carry the coin only when it
10403
10504
  // really is one.
10404
- vtxo: chunk6FTHFJAN_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10505
+ vtxo: chunkKMPNH7NS_cjs.isVirtualCoin(vtxo) && "status" in vtxo ? vtxo : void 0
10405
10506
  };
10406
10507
  try {
10407
10508
  await handler.assertSpendableNow(
@@ -10557,7 +10658,7 @@ var ContractManager = class _ContractManager {
10557
10658
  const { contractScript, collaborative = true, walletPubKey, vtxo } = options;
10558
10659
  const [contract] = await this.getContracts({ script: contractScript });
10559
10660
  if (!contract) return [];
10560
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
10661
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
10561
10662
  if (!handler) return [];
10562
10663
  const script = handler.createScript(contract.params);
10563
10664
  const tip = await this.currentChainTip();
@@ -10585,7 +10686,7 @@ var ContractManager = class _ContractManager {
10585
10686
  const { contractScript, collaborative = true, walletPubKey } = options;
10586
10687
  const [contract] = await this.getContracts({ script: contractScript });
10587
10688
  if (!contract) return [];
10588
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
10689
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
10589
10690
  if (!handler) return [];
10590
10691
  const script = handler.createScript(contract.params);
10591
10692
  const context = {
@@ -10641,7 +10742,7 @@ var ContractManager = class _ContractManager {
10641
10742
  }
10642
10743
  async refreshOutpoints(outpoints) {
10643
10744
  if (outpoints.length === 0) return;
10644
- const { vtxos } = await chunk6FTHFJAN_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10745
+ const { vtxos } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(this.config.indexerProvider, {
10645
10746
  outpoints
10646
10747
  });
10647
10748
  if (vtxos.length === 0) return;
@@ -10737,7 +10838,7 @@ var ContractManager = class _ContractManager {
10737
10838
  break;
10738
10839
  }
10739
10840
  } catch (err) {
10740
- if (!chunk6FTHFJAN_cjs.isRetryableProviderError(err)) throw err;
10841
+ if (!chunkKMPNH7NS_cjs.isRetryableProviderError(err)) throw err;
10741
10842
  this.markSyncDegraded(err);
10742
10843
  }
10743
10844
  this.emitEvent(event);
@@ -10828,7 +10929,7 @@ var ContractManager = class _ContractManager {
10828
10929
  */
10829
10930
  async reconcilePendingFrontier(contracts) {
10830
10931
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
10831
- const vtxos = await chunk6FTHFJAN_cjs.getAllNormalizedVtxos(
10932
+ const vtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(
10832
10933
  this.config.indexerProvider,
10833
10934
  contracts.map((c) => c.script),
10834
10935
  { pendingOnly: true }
@@ -10911,7 +11012,7 @@ var ContractManager = class _ContractManager {
10911
11012
  }
10912
11013
  return result;
10913
11014
  }
10914
- async fetchContractVtxosBulk(contracts, pageSize = chunk6FTHFJAN_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
11015
+ async fetchContractVtxosBulk(contracts, pageSize = chunkKMPNH7NS_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
10915
11016
  if (contracts.length === 0) {
10916
11017
  return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
10917
11018
  }
@@ -10927,7 +11028,7 @@ var ContractManager = class _ContractManager {
10927
11028
  before: syncWindow.before
10928
11029
  }
10929
11030
  } : {};
10930
- const vtxos = await chunk6FTHFJAN_cjs.getAllNormalizedVtxos(
11031
+ const vtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(
10931
11032
  this.config.indexerProvider,
10932
11033
  contracts.map((c) => c.script),
10933
11034
  { ...windowOpts, pageSize }
@@ -11072,7 +11173,7 @@ var deserializeTapLeaf = (t) => {
11072
11173
  const s = base.hex.decode(t.s);
11073
11174
  return [cb, s];
11074
11175
  };
11075
- var deserializeVtxo = (o) => chunk6FTHFJAN_cjs.normalizeVtxo({
11176
+ var deserializeVtxo = (o) => chunkKMPNH7NS_cjs.normalizeVtxo({
11076
11177
  ...o,
11077
11178
  createdAt: new Date(o.createdAt),
11078
11179
  tapTree: base.hex.decode(o.tapTree),
@@ -11895,7 +11996,7 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
11895
11996
  */
11896
11997
  materializeDescriptorAt(index) {
11897
11998
  const descriptor = this.identity.descriptor;
11898
- const network = chunkNPM5YZBC_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11999
+ const network = chunkDXLVCFVK_cjs.isMainnetDescriptor(descriptor) ? descriptorsScure.networks.bitcoin : descriptorsScure.networks.testnet;
11899
12000
  const expansion = descriptorsScure.expand({ descriptor, network, index });
11900
12001
  const keyInfo = expansion.expansionMap?.["@0"];
11901
12002
  if (!keyInfo?.keyExpression) {
@@ -12043,7 +12144,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12043
12144
  const provider = await resolveDescriptorProvider(config, setup.walletRepository);
12044
12145
  if (!provider) return void 0;
12045
12146
  const allowSilentFallback = (config.walletMode ?? "auto") === "auto";
12046
- const expectedContractType = setup.offchainTapscript instanceof chunkNPM5YZBC_cjs.DelegateVtxo.Script ? "delegate" : "default";
12147
+ const expectedContractType = setup.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? "delegate" : "default";
12047
12148
  const factoryOpts = {
12048
12149
  walletRepository: setup.walletRepository,
12049
12150
  contractRepository: setup.contractRepository,
@@ -12244,7 +12345,7 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
12244
12345
  };
12245
12346
  function deriveLeafPubkey(descriptor) {
12246
12347
  try {
12247
- return chunkNPM5YZBC_cjs.deriveDescriptorLeafPubKey(descriptor);
12348
+ return chunkDXLVCFVK_cjs.deriveDescriptorLeafPubKey(descriptor);
12248
12349
  } catch (e) {
12249
12350
  throw new NonRangeableDescriptorError(
12250
12351
  "Cannot derive leaf pubkey: descriptor is not a materialized, parsable tr(...) shape.",
@@ -12256,7 +12357,7 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12256
12357
  const pubKey = deriveLeafPubkey(descriptor);
12257
12358
  const tapscript = rebuildTapscript(current, pubKey);
12258
12359
  const serverPubKey = tapscript.options.serverPubKey;
12259
- const csvTimelock = chunk6FTHFJAN_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12360
+ const csvTimelock = chunkKMPNH7NS_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
12260
12361
  const base$1 = {
12261
12362
  script: base.hex.encode(tapscript.pkScript),
12262
12363
  address: tapscript.address(hrp, serverPubKey).encode(),
@@ -12267,11 +12368,11 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12267
12368
  // index-0 key. Without it, spends produce unsigned PSBTs that the
12268
12369
  // server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
12269
12370
  metadata: {
12270
- ...tagSource && { source: chunkNPM5YZBC_cjs.WALLET_RECEIVE_SOURCE },
12371
+ ...tagSource && { source: chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE },
12271
12372
  signingDescriptor: descriptor
12272
12373
  }
12273
12374
  };
12274
- const params = tapscript instanceof chunkNPM5YZBC_cjs.DelegateVtxo.Script ? {
12375
+ const params = tapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? {
12275
12376
  ...base$1,
12276
12377
  type: "delegate",
12277
12378
  params: {
@@ -12292,10 +12393,10 @@ function buildReceiveContract(current, descriptor, hrp, tagSource) {
12292
12393
  return { tapscript, params };
12293
12394
  }
12294
12395
  function rebuildTapscript(current, pubKey) {
12295
- if (current instanceof chunkNPM5YZBC_cjs.DelegateVtxo.Script) {
12296
- return new chunkNPM5YZBC_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12396
+ if (current instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script) {
12397
+ return new chunkDXLVCFVK_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
12297
12398
  }
12298
- return new chunkNPM5YZBC_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12399
+ return new chunkDXLVCFVK_cjs.DefaultVtxo.Script({ ...current.options, pubKey });
12299
12400
  }
12300
12401
  async function pickActiveReceive(contractRepository, serverPubKey, expectedType) {
12301
12402
  const candidates = await contractRepository.getContracts({
@@ -12304,7 +12405,7 @@ async function pickActiveReceive(contractRepository, serverPubKey, expectedType)
12304
12405
  });
12305
12406
  const serverPubKeyHex = base.hex.encode(serverPubKey);
12306
12407
  const matching = candidates.filter(
12307
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkNPM5YZBC_cjs.WALLET_RECEIVE_SOURCE
12408
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE
12308
12409
  ).sort((a, b) => {
12309
12410
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12310
12411
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12360,7 +12461,7 @@ function computeOffchainBalance(vtxos, caps) {
12360
12461
  }
12361
12462
  };
12362
12463
  for (const vtxo of vtxos) {
12363
- if (chunk6FTHFJAN_cjs.hasTerminalSpend(vtxo)) continue;
12464
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)) continue;
12364
12465
  addAssets(owned, vtxo);
12365
12466
  if (vtxo.isUnrolled) {
12366
12467
  unrolled += vtxo.value;
@@ -12370,11 +12471,11 @@ function computeOffchainBalance(vtxos, caps) {
12370
12471
  pendingRecovery += vtxo.value;
12371
12472
  continue;
12372
12473
  }
12373
- if (chunk6FTHFJAN_cjs.canRecoverOnchain(vtxo, now)) {
12474
+ if (chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
12374
12475
  recoverable += vtxo.value;
12375
12476
  continue;
12376
12477
  }
12377
- if (!chunk6FTHFJAN_cjs.canSpendOffchain(vtxo, now)) continue;
12478
+ if (!chunkKMPNH7NS_cjs.canSpendOffchain(vtxo, now)) continue;
12378
12479
  if (vtxo.isPreconfirmed) {
12379
12480
  preconfirmed += vtxo.value;
12380
12481
  } else {
@@ -12544,12 +12645,12 @@ var InputSignerRouter = class {
12544
12645
  };
12545
12646
 
12546
12647
  // src/wallet/wallet.ts
12547
- var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunk6FTHFJAN_cjs.DEFAULT_ARKADE_SERVER_URL;
12648
+ var getArkadeServerUrl = ({ arkServerUrl }) => arkServerUrl || chunkKMPNH7NS_cjs.DEFAULT_ARKADE_SERVER_URL;
12548
12649
  function intentProofJobs(coins) {
12549
12650
  if (coins.length === 0) return [];
12550
12651
  const coinJobs = coins.map((coin, i) => ({
12551
12652
  index: i + 1,
12552
- lookupScript: chunk6FTHFJAN_cjs.VtxoScript.decode(coin.tapTree).pkScript
12653
+ lookupScript: chunkKMPNH7NS_cjs.VtxoScript.decode(coin.tapTree).pkScript
12553
12654
  }));
12554
12655
  return [{ index: 0, lookupScript: coinJobs[0].lookupScript }, ...coinJobs];
12555
12656
  }
@@ -12581,7 +12682,7 @@ function dedupeTimelocks(timelocks) {
12581
12682
  const seen = /* @__PURE__ */ new Set();
12582
12683
  const deduped = [];
12583
12684
  for (const timelock of timelocks) {
12584
- const sequence = chunk6FTHFJAN_cjs.timelockToSequence(timelock).toString();
12685
+ const sequence = chunkKMPNH7NS_cjs.timelockToSequence(timelock).toString();
12585
12686
  if (seen.has(sequence)) continue;
12586
12687
  seen.add(sequence);
12587
12688
  deduped.push(timelock);
@@ -12598,7 +12699,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12598
12699
  state: "active"
12599
12700
  });
12600
12701
  const newest = candidates.filter(
12601
- (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkNPM5YZBC_cjs.WALLET_RECEIVE_SOURCE
12702
+ (c) => c.params.serverPubKey === serverPubKeyHex && c.metadata?.source === chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE
12602
12703
  ).sort((a, b) => {
12603
12704
  if (b.createdAt !== a.createdAt) return b.createdAt - a.createdAt;
12604
12705
  return signingDescriptorIndex(b.metadata?.signingDescriptor) - signingDescriptorIndex(a.metadata?.signingDescriptor);
@@ -12606,7 +12707,7 @@ async function resolveBoardingBootTapscript(contractRepository, serverPubKey, ba
12606
12707
  if (!newest?.params.pubKey) return baseline;
12607
12708
  try {
12608
12709
  const pubKey = base.hex.decode(newest.params.pubKey);
12609
- return new chunkNPM5YZBC_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12710
+ return new chunkDXLVCFVK_cjs.DefaultVtxo.Script({ ...baseline.options, pubKey });
12610
12711
  } catch (e) {
12611
12712
  console.warn("Skipping malformed boarding contract at boot", newest.script, e);
12612
12713
  return baseline;
@@ -12625,10 +12726,10 @@ function filterSnapshotVtxos(snapshot, filter, pendingSpendOutpoints) {
12625
12726
  if (vtxo.isUnrolled) {
12626
12727
  return !!f.withUnrolled;
12627
12728
  }
12628
- if (chunk6FTHFJAN_cjs.hasTerminalSpend(vtxo)) {
12729
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)) {
12629
12730
  return false;
12630
12731
  }
12631
- if (!f.withRecoverable && chunk6FTHFJAN_cjs.canRecoverOnchain(vtxo, now)) {
12732
+ if (!f.withRecoverable && chunkKMPNH7NS_cjs.canRecoverOnchain(vtxo, now)) {
12632
12733
  return false;
12633
12734
  }
12634
12735
  return true;
@@ -12968,7 +13069,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12968
13069
  */
12969
13070
  static async setupWalletConfig(config, pubKey) {
12970
13071
  const arkadeServerUrl = getArkadeServerUrl(config);
12971
- const arkProvider = config.arkProvider || new chunk6FTHFJAN_cjs.RestArkProvider(arkadeServerUrl);
13072
+ const arkProvider = config.arkProvider || new chunkKMPNH7NS_cjs.RestArkProvider(arkadeServerUrl);
12972
13073
  let indexerProvider = config.indexerProvider;
12973
13074
  if (!indexerProvider) {
12974
13075
  let indexerUrl = config.indexerUrl;
@@ -12985,7 +13086,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12985
13086
  indexerUrl = arkadeServerUrl;
12986
13087
  }
12987
13088
  }
12988
- indexerProvider = new chunk4C5PMGBB_cjs.RestIndexerProvider(indexerUrl);
13089
+ indexerProvider = new chunkAS3W34MG_cjs.RestIndexerProvider(indexerUrl);
12989
13090
  }
12990
13091
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
12991
13092
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -12994,7 +13095,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
12994
13095
  source: serverInfoSource,
12995
13096
  lastOnlineAt: serverInfoLastOnlineAt
12996
13097
  } = await resolveArkInfo(arkProvider, walletRepository);
12997
- const network = chunk6FTHFJAN_cjs.getNetwork(info.network);
13098
+ const network = chunkKMPNH7NS_cjs.getNetwork(info.network);
12998
13099
  if ("descriptor" in config.identity) {
12999
13100
  const descriptor = config.identity.descriptor;
13000
13101
  const identityIsMainnet = !descriptor.includes("tpub");
@@ -13034,18 +13135,18 @@ var ReadonlyWallet = class _ReadonlyWallet {
13034
13135
  value: info.boardingExitDelay,
13035
13136
  type: info.boardingExitDelay < 512n ? "blocks" : "seconds"
13036
13137
  };
13037
- const serverPubKey = chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
13038
- const delegatePubKey = config.delegateProvider ? await config.delegateProvider.getDelegateInfo().then((info2) => chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(info2.pubkey), "delegate key")).catch(() => void 0) : config.delegatorProvider ? await config.delegatorProvider.getDelegateInfo().then((info2) => chunkNPM5YZBC_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;
13039
13140
  const offchainOptions = {
13040
13141
  pubKey,
13041
13142
  serverPubKey,
13042
13143
  csvTimelock: exitTimelock
13043
13144
  };
13044
- const offchainTapscript = !delegatePubKey ? new chunkNPM5YZBC_cjs.DefaultVtxo.Script(offchainOptions) : new chunkNPM5YZBC_cjs.DelegateVtxo.Script({ ...offchainOptions, delegatePubKey });
13045
- const boardingTapscript = chunkNPM5YZBC_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({
13046
13147
  pubKey: base.hex.encode(pubKey),
13047
13148
  serverPubKey: base.hex.encode(serverPubKey),
13048
- csvTimelock: chunk6FTHFJAN_cjs.timelockToSequence(boardingTimelock).toString()
13149
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(boardingTimelock).toString()
13049
13150
  });
13050
13151
  return {
13051
13152
  arkProvider,
@@ -13211,7 +13312,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13211
13312
  if (!filter?.withUnrolled) {
13212
13313
  logExcludedVtxos(
13213
13314
  "getSpendableVtxos",
13214
- snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunk6FTHFJAN_cjs.hasTerminalSpend(vtxo)),
13315
+ snapshot.flatMap((contract) => contract.vtxos).filter((vtxo) => vtxo.isUnrolled && !chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)),
13215
13316
  [() => UNROLLED_REASON]
13216
13317
  );
13217
13318
  }
@@ -13355,7 +13456,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13355
13456
  this.getBoardingTxs()
13356
13457
  ]);
13357
13458
  const allVtxos = snapshot.flatMap((_) => _.vtxos);
13358
- const resolveTxCreatedAt = (txids) => chunk6FTHFJAN_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13459
+ const resolveTxCreatedAt = (txids) => chunkKMPNH7NS_cjs.fetchVtxoCreatedAtByTxid(this.indexerProvider, txids);
13359
13460
  return buildTransactionHistory(
13360
13461
  allVtxos,
13361
13462
  boardingTxs,
@@ -13450,7 +13551,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13450
13551
  },
13451
13552
  isUnrolled: true,
13452
13553
  ...boardingFacts,
13453
- virtualStatus: chunk6FTHFJAN_cjs.toVirtualStatus(boardingFacts),
13554
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(boardingFacts),
13454
13555
  spentBy: "",
13455
13556
  createdAt: tx.status.confirmed ? new Date(tx.status.block_time * 1e3) : /* @__PURE__ */ new Date(0),
13456
13557
  script: scriptHex
@@ -13506,9 +13607,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13506
13607
  async getBoardingTapscripts(allowedSigners) {
13507
13608
  const byScript = /* @__PURE__ */ new Map();
13508
13609
  const add = (s) => byScript.set(base.hex.encode(s.pkScript), s);
13509
- const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkNPM5YZBC_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13610
+ const boardingCsv = this.boardingTapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13510
13611
  add(
13511
- new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
13612
+ new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
13512
13613
  pubKey: await this.identity.xOnlyPublicKey(),
13513
13614
  serverPubKey: this.boardingTapscript.options.serverPubKey,
13514
13615
  csvTimelock: boardingCsv
@@ -13523,7 +13624,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13523
13624
  for (const c of boardingContracts) {
13524
13625
  if (!allowed.has(toXOnlySignerHex(c.params.serverPubKey))) continue;
13525
13626
  try {
13526
- add(chunkNPM5YZBC_cjs.BoardingContractHandler.createScript(c.params));
13627
+ add(chunkDXLVCFVK_cjs.BoardingContractHandler.createScript(c.params));
13527
13628
  } catch (e) {
13528
13629
  console.warn("Skipping malformed boarding contract", c.script, e);
13529
13630
  }
@@ -13561,7 +13662,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13561
13662
  // Per-row CSV delay decoded from THIS tapscript's exit leaf —
13562
13663
  // not the wallet's current boarding timelock, which a signer
13563
13664
  // rotation may have changed.
13564
- csvTimelock: chunk6FTHFJAN_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13665
+ csvTimelock: chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(tapscript.exitScript)).params.timelock,
13565
13666
  coins: utxos
13566
13667
  });
13567
13668
  }
@@ -13694,7 +13795,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13694
13795
  /** Fetch Arkade transaction ids that are still pending final settlement. */
13695
13796
  async fetchPendingTxs() {
13696
13797
  const scripts = await this.getWalletScripts();
13697
- const vtxos = await chunk6FTHFJAN_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13798
+ const vtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(this.indexerProvider, scripts);
13698
13799
  return vtxos.filter(
13699
13800
  (vtxo) => (vtxo.isSpent || vtxo.isPreconfirmed && !vtxo.isSwept) && vtxo.arkTxId !== void 0
13700
13801
  ).map((_) => _.arkTxId);
@@ -13725,7 +13826,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13725
13826
  });
13726
13827
  for (const contract of contracts) {
13727
13828
  if (map.has(contract.script)) continue;
13728
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
13829
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
13729
13830
  if (handler) {
13730
13831
  const script = handler.createScript(contract.params);
13731
13832
  map.set(contract.script, script);
@@ -13837,7 +13938,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13837
13938
  }
13838
13939
  });
13839
13940
  const baselinePubkey = await this.identity.xOnlyPublicKey();
13840
- const delegatePubKey = this.offchainTapscript instanceof chunkNPM5YZBC_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;
13841
13942
  const baselineSigners = [
13842
13943
  this.offchainTapscript.options.serverPubKey,
13843
13944
  ...[...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h))
@@ -13845,8 +13946,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
13845
13946
  const seenBaselineScripts = /* @__PURE__ */ new Set();
13846
13947
  for (const serverPubKey of baselineSigners) {
13847
13948
  for (const csvTimelock of this.walletContractTimelocks) {
13848
- const csvTimelockStr = chunk6FTHFJAN_cjs.timelockToSequence(csvTimelock).toString();
13849
- const defaultScript = new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
13949
+ const csvTimelockStr = chunkKMPNH7NS_cjs.timelockToSequence(csvTimelock).toString();
13950
+ const defaultScript = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
13850
13951
  pubKey: baselinePubkey,
13851
13952
  serverPubKey,
13852
13953
  csvTimelock
@@ -13867,7 +13968,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13867
13968
  });
13868
13969
  }
13869
13970
  if (delegatePubKey) {
13870
- const delegateScript = new chunkNPM5YZBC_cjs.DelegateVtxo.Script({
13971
+ const delegateScript = new chunkDXLVCFVK_cjs.DelegateVtxo.Script({
13871
13972
  pubKey: baselinePubkey,
13872
13973
  serverPubKey,
13873
13974
  delegatePubKey,
@@ -13891,9 +13992,9 @@ var ReadonlyWallet = class _ReadonlyWallet {
13891
13992
  }
13892
13993
  }
13893
13994
  }
13894
- const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkNPM5YZBC_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13995
+ const boardingCsvTimelock = this.boardingTapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
13895
13996
  for (const serverPubKey of baselineSigners) {
13896
- const baselineBoarding = new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
13997
+ const baselineBoarding = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
13897
13998
  pubKey: baselinePubkey,
13898
13999
  serverPubKey,
13899
14000
  csvTimelock: boardingCsvTimelock
@@ -13906,7 +14007,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
13906
14007
  params: {
13907
14008
  pubKey: base.hex.encode(baselineBoarding.options.pubKey),
13908
14009
  serverPubKey: base.hex.encode(serverPubKey),
13909
- csvTimelock: chunk6FTHFJAN_cjs.timelockToSequence(boardingCsvTimelock).toString()
14010
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(boardingCsvTimelock).toString()
13910
14011
  },
13911
14012
  script: boardingScriptHex,
13912
14013
  address: baselineBoarding.address(this.network.hrp, serverPubKey).encode(),
@@ -14106,7 +14207,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14106
14207
  serverPubKey: this.offchainTapscript.options.serverPubKey,
14107
14208
  deprecatedSignerPubKeys: [...this._deprecatedSigners.keys()].map((h) => base.hex.decode(h)),
14108
14209
  csvTimelocks: this.walletContractTimelocks,
14109
- delegatePubKey: this.offchainTapscript instanceof chunkNPM5YZBC_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14210
+ delegatePubKey: this.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0
14110
14211
  };
14111
14212
  }
14112
14213
  _signerRouter;
@@ -14351,7 +14452,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14351
14452
  const [row] = await manager.getContracts({ script: base.hex.encode(display.pkScript) });
14352
14453
  const persisted = row?.metadata?.signingDescriptor;
14353
14454
  if (typeof persisted === "string") return persisted;
14354
- return chunkNPM5YZBC_cjs.identityDescriptor(this.identity);
14455
+ return chunkDXLVCFVK_cjs.identityDescriptor(this.identity);
14355
14456
  }
14356
14457
  /**
14357
14458
  * Build, persist and shape one address of `type` owned by `descriptor` —
@@ -14367,7 +14468,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14367
14468
  async mintAddress(manager, type, descriptor, tagSource, allocated) {
14368
14469
  if (type === "boarding") {
14369
14470
  const built2 = this.buildBoardingContract(
14370
- chunkNPM5YZBC_cjs.deriveDescriptorLeafPubKey(descriptor),
14471
+ chunkDXLVCFVK_cjs.deriveDescriptorLeafPubKey(descriptor),
14371
14472
  descriptor,
14372
14473
  tagSource
14373
14474
  );
@@ -14412,11 +14513,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14412
14513
  * {@link buildReceiveContract}.
14413
14514
  */
14414
14515
  buildBoardingContract(pubKey, descriptor, tagSource) {
14415
- const tapscript = new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
14516
+ const tapscript = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
14416
14517
  ...this._boardingTapscript.options,
14417
14518
  pubKey
14418
14519
  });
14419
- const csvTimelock = tapscript.options.csvTimelock ?? chunkNPM5YZBC_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14520
+ const csvTimelock = tapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14420
14521
  return {
14421
14522
  tapscript,
14422
14523
  params: {
@@ -14424,13 +14525,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14424
14525
  params: {
14425
14526
  pubKey: base.hex.encode(pubKey),
14426
14527
  serverPubKey: base.hex.encode(tapscript.options.serverPubKey),
14427
- csvTimelock: chunk6FTHFJAN_cjs.timelockToSequence(csvTimelock).toString()
14528
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(csvTimelock).toString()
14428
14529
  },
14429
14530
  script: base.hex.encode(tapscript.pkScript),
14430
14531
  address: tapscript.address(this.network.hrp, this.arkServerPublicKey).encode(),
14431
14532
  state: "active",
14432
14533
  metadata: {
14433
- ...tagSource && { source: chunkNPM5YZBC_cjs.WALLET_RECEIVE_SOURCE },
14534
+ ...tagSource && { source: chunkDXLVCFVK_cjs.WALLET_RECEIVE_SOURCE },
14434
14535
  signingDescriptor: descriptor
14435
14536
  }
14436
14537
  }
@@ -14459,7 +14560,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14459
14560
  if (this._descriptorProvider instanceof HDDescriptorProvider) {
14460
14561
  return (await this.getContractManager()).getNextSigningDescriptor();
14461
14562
  }
14462
- return chunkNPM5YZBC_cjs.identityDescriptor(this.identity);
14563
+ return chunkDXLVCFVK_cjs.identityDescriptor(this.identity);
14463
14564
  }
14464
14565
  /**
14465
14566
  * @see HDAllocationCapable.advanceSigningDescriptorWatermark
@@ -14555,7 +14656,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14555
14656
  * the stable public API.
14556
14657
  */
14557
14658
  async rotateServerSigner(newServerPubKey, checkpointTapscript) {
14558
- const xonly = chunkNPM5YZBC_cjs.toXOnly(newServerPubKey, "ark signer key");
14659
+ const xonly = chunkDXLVCFVK_cjs.toXOnly(newServerPubKey, "ark signer key");
14559
14660
  const newServerUnrollScript = assertValidServerUnrollScript(
14560
14661
  checkpointTapscript,
14561
14662
  resolveCheckpointExitDelayPolicy(this.network, this.checkpointExitDelayPolicy)
@@ -14584,21 +14685,21 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14584
14685
  const [currentBoardingRow] = await manager.getContracts({
14585
14686
  script: currentBoardingScript
14586
14687
  });
14587
- const newOffchain = this.offchainTapscript instanceof chunkNPM5YZBC_cjs.DelegateVtxo.Script ? new chunkNPM5YZBC_cjs.DelegateVtxo.Script({
14688
+ const newOffchain = this.offchainTapscript instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script ? new chunkDXLVCFVK_cjs.DelegateVtxo.Script({
14588
14689
  ...this.offchainTapscript.options,
14589
14690
  serverPubKey: xonly
14590
- }) : new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
14691
+ }) : new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
14591
14692
  ...this.offchainTapscript.options,
14592
14693
  serverPubKey: xonly
14593
14694
  });
14594
- const newBoarding = new chunkNPM5YZBC_cjs.DefaultVtxo.Script({
14695
+ const newBoarding = new chunkDXLVCFVK_cjs.DefaultVtxo.Script({
14595
14696
  ...this._boardingTapscript.options,
14596
14697
  serverPubKey: xonly
14597
14698
  });
14598
- const offchainCsv = chunk6FTHFJAN_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14699
+ const offchainCsv = chunkKMPNH7NS_cjs.timelockToSequence(newOffchain.options.csvTimelock).toString();
14599
14700
  const newOffchainScript = base.hex.encode(newOffchain.pkScript);
14600
14701
  const newOffchainAddress = newOffchain.address(this.network.hrp, xonly).encode();
14601
- if (newOffchain instanceof chunkNPM5YZBC_cjs.DelegateVtxo.Script) {
14702
+ if (newOffchain instanceof chunkDXLVCFVK_cjs.DelegateVtxo.Script) {
14602
14703
  await manager.createContract({
14603
14704
  type: "delegate",
14604
14705
  params: {
@@ -14626,13 +14727,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14626
14727
  metadata: currentOffchainRow?.metadata
14627
14728
  });
14628
14729
  }
14629
- const boardingCsv = newBoarding.options.csvTimelock ?? chunkNPM5YZBC_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14730
+ const boardingCsv = newBoarding.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK;
14630
14731
  await manager.createContract({
14631
14732
  type: "boarding",
14632
14733
  params: {
14633
14734
  pubKey: base.hex.encode(newBoarding.options.pubKey),
14634
14735
  serverPubKey: base.hex.encode(xonly),
14635
- csvTimelock: chunk6FTHFJAN_cjs.timelockToSequence(boardingCsv).toString()
14736
+ csvTimelock: chunkKMPNH7NS_cjs.timelockToSequence(boardingCsv).toString()
14636
14737
  },
14637
14738
  script: base.hex.encode(newBoarding.pkScript),
14638
14739
  address: newBoarding.address(this.network.hrp, xonly).encode(),
@@ -14665,14 +14766,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14665
14766
  _restoreInFlight;
14666
14767
  _addPendingSpends(inputs) {
14667
14768
  for (const input of inputs) {
14668
- if (chunk6FTHFJAN_cjs.isVirtualCoin(input)) {
14769
+ if (chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
14669
14770
  this._pendingSpendOutpoints.add(`${input.txid}:${input.vout}`);
14670
14771
  }
14671
14772
  }
14672
14773
  }
14673
14774
  _removePendingSpends(inputs) {
14674
14775
  for (const input of inputs) {
14675
- if (chunk6FTHFJAN_cjs.isVirtualCoin(input)) {
14776
+ if (chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
14676
14777
  this._pendingSpendOutpoints.delete(`${input.txid}:${input.vout}`);
14677
14778
  }
14678
14779
  }
@@ -14733,13 +14834,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14733
14834
  const manager = await this.getContractManager();
14734
14835
  const provider = this._descriptorProvider;
14735
14836
  const hd = provider instanceof HDDescriptorProvider;
14736
- const staticDescriptor = hd ? void 0 : await chunkNPM5YZBC_cjs.identityDescriptor(this.identity);
14837
+ const staticDescriptor = hd ? void 0 : await chunkDXLVCFVK_cjs.identityDescriptor(this.identity);
14737
14838
  const materialize = (index) => hd ? provider.materializeDescriptorAt(index) : staticDescriptor;
14738
- const delegatePubKey = this.offchainTapscript instanceof chunkNPM5YZBC_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;
14739
14840
  const arkInfo = await this.arkProvider.getInfo();
14740
- const currentSignerPubKey = chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14841
+ const currentSignerPubKey = chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(arkInfo.signerPubkey), "ark signer key");
14741
14842
  const deprecatedSignerPubKeys = arkInfo.deprecatedSigners.map(
14742
- (s) => chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14843
+ (s) => chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(s.pubkey), "deprecated signer key")
14743
14844
  );
14744
14845
  const deps = {
14745
14846
  indexerProvider: this.indexerProvider,
@@ -14754,7 +14855,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14754
14855
  csvTimelocks: this.walletContractTimelocks,
14755
14856
  // Boarding-exit CSV so the boarding handler can build its
14756
14857
  // candidate script (distinct from the unilateral-exit matrix).
14757
- boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkNPM5YZBC_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14858
+ boardingTimelock: this.boardingTapscript.options.csvTimelock ?? chunkDXLVCFVK_cjs.DefaultVtxo.Script.DEFAULT_TIMELOCK,
14758
14859
  delegatePubKey
14759
14860
  };
14760
14861
  const result = await manager.scanContracts({
@@ -14868,7 +14969,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
14868
14969
  throw new Error("Invalid configured public key");
14869
14970
  }
14870
14971
  const setup = await ReadonlyWallet.setupWalletConfig(config, pubkey);
14871
- const forfeitPubkey = chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14972
+ const forfeitPubkey = chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(setup.info.forfeitPubkey), "forfeit key");
14872
14973
  const forfeitAddress = btcSigner.Address(setup.network).decode(setup.info.forfeitAddress);
14873
14974
  const forfeitOutputScript = btcSigner.OutScript.encode(forfeitAddress);
14874
14975
  const checkpointExitDelayOverrides = {
@@ -15017,7 +15118,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15017
15118
  inputs: params.selectedVtxos,
15018
15119
  changeAmount: BigInt(changeAmount)
15019
15120
  };
15020
- const outputAddress = chunk6FTHFJAN_cjs.ArkAddress.decode(params.address);
15121
+ const outputAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(params.address);
15021
15122
  assertRecipientArkAddress(
15022
15123
  params.address,
15023
15124
  outputAddress,
@@ -15083,13 +15184,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15083
15184
  void this.logUngatedInputs("settle({ inputs })", params.inputs);
15084
15185
  }
15085
15186
  const offchainAddress = await this.getAddress();
15086
- const offchainPkScript = chunk6FTHFJAN_cjs.ArkAddress.decode(offchainAddress).pkScript;
15187
+ const offchainPkScript = chunkKMPNH7NS_cjs.ArkAddress.decode(offchainAddress).pkScript;
15087
15188
  const offchainOutputScript = base.hex.encode(offchainPkScript);
15088
15189
  if (!params) {
15089
15190
  const { fees, vtxoMaxAmount } = await this.arkProvider.getInfo();
15090
15191
  const estimator = new Estimator(fees.intentFee);
15091
15192
  let amount = 0;
15092
- const exitScript = chunk6FTHFJAN_cjs.CSVMultisigTapscript.decode(
15193
+ const exitScript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(
15093
15194
  base.hex.decode(this.boardingTapscript.exitScript)
15094
15195
  );
15095
15196
  const boardingTimelock = exitScript.params.timelock;
@@ -15118,7 +15219,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15118
15219
  if (filteredVtxos.length >= MAX_VTXOS_PER_SETTLEMENT) {
15119
15220
  break;
15120
15221
  }
15121
- const inputFee = estimator.evalOffchainInput(chunk6FTHFJAN_cjs.toOffchainInputFeeParams(vtxo));
15222
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(vtxo));
15122
15223
  if (inputFee.satoshis >= vtxo.value) {
15123
15224
  continue;
15124
15225
  }
@@ -15165,7 +15266,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15165
15266
  let script;
15166
15267
  let arkAddress;
15167
15268
  try {
15168
- arkAddress = chunk6FTHFJAN_cjs.ArkAddress.decode(output.address);
15269
+ arkAddress = chunkKMPNH7NS_cjs.ArkAddress.decode(output.address);
15169
15270
  } catch {
15170
15271
  arkAddress = void 0;
15171
15272
  }
@@ -15255,7 +15356,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15255
15356
  const abortController = new AbortController();
15256
15357
  let stream;
15257
15358
  let committedTxid;
15258
- const settleInputVtxos = params.inputs.filter(chunk6FTHFJAN_cjs.isVirtualCoin);
15359
+ const settleInputVtxos = params.inputs.filter(chunkKMPNH7NS_cjs.isVirtualCoin);
15259
15360
  const contractManager = await this.getContractManager();
15260
15361
  await contractManager.assertAnnotatable(settleInputVtxos);
15261
15362
  await contractManager.assertSpendableNow?.(
@@ -15367,7 +15468,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15367
15468
  async maybeRotateBoardingAfterBoard(inputs) {
15368
15469
  if (!this._descriptorProvider) return;
15369
15470
  const consumedBoarding = inputs.some(
15370
- (input) => typeof input !== "string" && !chunk6FTHFJAN_cjs.isVirtualCoin(input)
15471
+ (input) => typeof input !== "string" && !chunkKMPNH7NS_cjs.isVirtualCoin(input)
15371
15472
  );
15372
15473
  if (!consumedBoarding) return;
15373
15474
  try {
@@ -15391,7 +15492,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15391
15492
  let connectorIndex = 0;
15392
15493
  const connectorsLeaves = connectorsGraph?.leaves() || [];
15393
15494
  for (const input of inputs) {
15394
- if (!chunk6FTHFJAN_cjs.isVirtualCoin(input)) {
15495
+ if (!chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
15496
+ let matched = false;
15395
15497
  for (let i = 0; i < settlementPsbt.inputsLength; i++) {
15396
15498
  const settlementInput = settlementPsbt.getInput(i);
15397
15499
  if (!settlementInput.txid || settlementInput.index === void 0) {
@@ -15418,11 +15520,17 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15418
15520
  throw new Error(await this.unsignableBoardingInputError(input, script));
15419
15521
  }
15420
15522
  hasBoardingUtxos = true;
15523
+ matched = true;
15421
15524
  break;
15422
15525
  }
15526
+ if (!matched && !(input instanceof ArkNote)) {
15527
+ throw new Error(
15528
+ `boarding input ${input.txid}:${input.vout} is not an input of the commitment tx`
15529
+ );
15530
+ }
15423
15531
  continue;
15424
15532
  }
15425
- if (chunk6FTHFJAN_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)) {
15426
15534
  continue;
15427
15535
  }
15428
15536
  if (connectorsLeaves.length === 0) {
@@ -15450,7 +15558,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15450
15558
  index: input.vout,
15451
15559
  witnessUtxo: {
15452
15560
  amount: BigInt(input.value),
15453
- script: chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).pkScript
15561
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
15454
15562
  },
15455
15563
  sighashType: btcSigner.SigHash.DEFAULT,
15456
15564
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -15469,7 +15577,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15469
15577
  forfeitTx = await this._signerRouter.sign(forfeitTx, [
15470
15578
  {
15471
15579
  index: 0,
15472
- lookupScript: chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).pkScript
15580
+ lookupScript: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
15473
15581
  }
15474
15582
  ]);
15475
15583
  signedForfeits.push(base.base64.encode(forfeitTx.toPSBT()));
@@ -15527,7 +15635,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15527
15635
  resolveBatchExpiryPolicy(this.network, this.batchExpiryPolicy)
15528
15636
  );
15529
15637
  await this.arkProvider.confirmRegistration(intentId);
15530
- const sweepTapscript = chunk6FTHFJAN_cjs.CSVMultisigTapscript.encode({
15638
+ const sweepTapscript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.encode({
15531
15639
  timelock,
15532
15640
  pubkeys: [this.forfeitPubkey]
15533
15641
  }).script;
@@ -15542,10 +15650,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15542
15650
  throw new Error("Sweep tap tree root not set");
15543
15651
  }
15544
15652
  const xOnlyPublicKeys = event.cosignersPublicKeys.map(
15545
- (k) => base.hex.encode(chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15653
+ (k) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
15546
15654
  );
15547
15655
  const signerPublicKey = await session.getPublicKey();
15548
- const xonlySignerPublicKey = chunkNPM5YZBC_cjs.toXOnly(signerPublicKey, "signer key");
15656
+ const xonlySignerPublicKey = chunkDXLVCFVK_cjs.toXOnly(signerPublicKey, "signer key");
15549
15657
  if (!xOnlyPublicKeys.includes(base.hex.encode(xonlySignerPublicKey))) {
15550
15658
  return { skip: true };
15551
15659
  }
@@ -15635,9 +15743,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15635
15743
  ...existing ?? {},
15636
15744
  intentTxId,
15637
15745
  registerProof: intent.proof,
15638
- registerProofMessage: chunk6FTHFJAN_cjs.Intent.encodeMessage(intent.message),
15746
+ registerProofMessage: chunkKMPNH7NS_cjs.Intent.encodeMessage(intent.message),
15639
15747
  deleteProof: deleteIntent.proof,
15640
- deleteProofMessage: chunk6FTHFJAN_cjs.Intent.encodeMessage(deleteIntent.message),
15748
+ deleteProofMessage: chunkKMPNH7NS_cjs.Intent.encodeMessage(deleteIntent.message),
15641
15749
  intentVtxos: inputs.map((i) => ({
15642
15750
  txid: i.txid,
15643
15751
  vout: i.vout
@@ -15669,7 +15777,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15669
15777
  try {
15670
15778
  return await this.arkProvider.registerIntent(intent);
15671
15779
  } catch (error) {
15672
- if (error instanceof chunk6FTHFJAN_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")) {
15673
15781
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
15674
15782
  await this.arkProvider.deleteIntent(deleteIntent);
15675
15783
  return this.arkProvider.registerIntent(intent);
@@ -15685,7 +15793,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15685
15793
  expire_at: 0,
15686
15794
  cosigners_public_keys: cosignerPubKeys
15687
15795
  };
15688
- const proof = chunk6FTHFJAN_cjs.Intent.create(message, coins, outputs);
15796
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, outputs);
15689
15797
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15690
15798
  return {
15691
15799
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15697,7 +15805,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15697
15805
  type: "delete",
15698
15806
  expire_at: 0
15699
15807
  };
15700
- const proof = chunk6FTHFJAN_cjs.Intent.create(message, coins, []);
15808
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, []);
15701
15809
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15702
15810
  return {
15703
15811
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15709,7 +15817,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15709
15817
  type: "get-pending-tx",
15710
15818
  expire_at: 0
15711
15819
  };
15712
- const proof = chunk6FTHFJAN_cjs.Intent.create(message, coins, []);
15820
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, coins, []);
15713
15821
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
15714
15822
  return {
15715
15823
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -15730,7 +15838,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15730
15838
  if (!vtxos || vtxos.length === 0) {
15731
15839
  const scriptMap = await this.getScriptMap();
15732
15840
  const allExtended = [];
15733
- const fetchedVtxos = await chunk6FTHFJAN_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15841
+ const fetchedVtxos = await chunkKMPNH7NS_cjs.getAllNormalizedVtxos(this.indexerProvider, [
15734
15842
  ...scriptMap.keys()
15735
15843
  ]);
15736
15844
  for (const vtxo of fetchedVtxos) {
@@ -15774,7 +15882,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15774
15882
  try {
15775
15883
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((c) => {
15776
15884
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(c));
15777
- chunk6FTHFJAN_cjs.assertAllowedSighashTypes(tx);
15885
+ chunkKMPNH7NS_cjs.assertAllowedSighashTypes(tx);
15778
15886
  return tx;
15779
15887
  });
15780
15888
  assertCheckpointsMatchInputs(
@@ -15846,11 +15954,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15846
15954
  * against the current key alone would leave it pending forever.
15847
15955
  */
15848
15956
  checkpointUnrollCandidates(info) {
15849
- const current = chunk6FTHFJAN_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15957
+ const current = chunkKMPNH7NS_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
15850
15958
  const candidates = [this._serverUnrollScript, current];
15851
15959
  for (const deprecated of signerSetFromInfo(info).deprecated.keys()) {
15852
15960
  candidates.push(
15853
- chunk6FTHFJAN_cjs.CSVMultisigTapscript.encode({
15961
+ chunkKMPNH7NS_cjs.CSVMultisigTapscript.encode({
15854
15962
  ...current.params,
15855
15963
  pubkeys: [base.hex.decode(deprecated)]
15856
15964
  })
@@ -15941,7 +16049,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
15941
16049
  if (vtxos.length === 0) {
15942
16050
  throw new Error("No VTXOs found for this arkadeCash");
15943
16051
  }
15944
- const myPkScript = chunk6FTHFJAN_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
16052
+ const myPkScript = chunkKMPNH7NS_cjs.ArkAddress.decode(await this.getAddress()).pkScript;
15945
16053
  let { spendable, unclaimed } = this.classifyCashVtxos(vtxos);
15946
16054
  let swept = 0;
15947
16055
  const drainable = vtxos.filter(
@@ -16017,7 +16125,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16017
16125
  const spendable = [];
16018
16126
  const unclaimed = [];
16019
16127
  for (const vtxo of vtxos) {
16020
- if (chunk6FTHFJAN_cjs.hasTerminalSpend(vtxo)) {
16128
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(vtxo)) {
16021
16129
  unclaimed.push(cashReport(vtxo, "already-spent"));
16022
16130
  } else if (vtxo.isUnrolled) {
16023
16131
  unclaimed.push(cashReport(vtxo, "exited"));
@@ -16039,7 +16147,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16039
16147
  const all = [];
16040
16148
  const seen = /* @__PURE__ */ new Set();
16041
16149
  for (let pageIndex = 0; ; pageIndex++) {
16042
- const { vtxos, page } = await chunk6FTHFJAN_cjs.getNormalizedVtxos(this.indexerProvider, {
16150
+ const { vtxos, page } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(this.indexerProvider, {
16043
16151
  scripts,
16044
16152
  pageIndex,
16045
16153
  pageSize
@@ -16086,7 +16194,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16086
16194
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
16087
16195
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
16088
16196
  const message = { type: "get-pending-tx", expire_at: 0 };
16089
- const proof = chunk6FTHFJAN_cjs.Intent.create(message, batch, []);
16197
+ const proof = chunkKMPNH7NS_cjs.Intent.create(message, batch, []);
16090
16198
  const signedProof = await identity.sign(
16091
16199
  proof,
16092
16200
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -16108,7 +16216,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16108
16216
  try {
16109
16217
  const checkpointTxs = pendingTx.signedCheckpointTxs.map((checkpoint) => {
16110
16218
  const tx = btcSigner.Transaction.fromPSBT(base.base64.decode(checkpoint));
16111
- chunk6FTHFJAN_cjs.assertAllowedSighashTypes(tx);
16219
+ chunkKMPNH7NS_cjs.assertAllowedSighashTypes(tx);
16112
16220
  return tx;
16113
16221
  });
16114
16222
  assertCheckpointsMatchInputs(
@@ -16307,7 +16415,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16307
16415
  script: recipient.script,
16308
16416
  amount: BigInt(recipient.amount),
16309
16417
  // Already checked against the recipient address in `validateRecipients`.
16310
- ...recipient.tapTree ? { tapTree: chunk6FTHFJAN_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16418
+ ...recipient.tapTree ? { tapTree: chunkKMPNH7NS_cjs.TapTreeCoder.decode(recipient.tapTree) } : {}
16311
16419
  }));
16312
16420
  const totalBtcOutput = outputs.reduce((sum, o) => sum + Number(o.amount), 0);
16313
16421
  let changeAmount = totalBtcSelected - totalBtcOutput;
@@ -16451,10 +16559,10 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16451
16559
  const serverPubKey = this.arkServerPublicKey;
16452
16560
  const serverUnrollScript = this.serverUnrollScript;
16453
16561
  const arkAddress = offchainTapscript.address(this.network.hrp, serverPubKey);
16454
- const normalizedInputs = inputs.map(chunk6FTHFJAN_cjs.normalizeVtxo);
16455
- const at = now ?? await chunk6FTHFJAN_cjs.resolveTimeHeight(this.onchainProvider);
16562
+ const normalizedInputs = inputs.map(chunkKMPNH7NS_cjs.normalizeVtxo);
16563
+ const at = now ?? await chunkKMPNH7NS_cjs.resolveTimeHeight(this.onchainProvider);
16456
16564
  for (const input of normalizedInputs) {
16457
- if (!chunk6FTHFJAN_cjs.canSpendOffchain(input, at)) {
16565
+ if (!chunkKMPNH7NS_cjs.canSpendOffchain(input, at)) {
16458
16566
  throw new Error(
16459
16567
  `sendSelectedVtxosToSelf: input ${input.txid}:${input.vout} is not cooperatively spendable`
16460
16568
  );
@@ -16524,7 +16632,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16524
16632
  );
16525
16633
  const arkTxJobs = inputs.map((input, index) => ({
16526
16634
  index,
16527
- lookupScript: chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).pkScript
16635
+ lookupScript: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
16528
16636
  }));
16529
16637
  const identity = this.identity;
16530
16638
  const signer = {
@@ -16560,18 +16668,33 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16560
16668
  this.inputSigningJobsFromWitnessUtxos(checkpoint)
16561
16669
  )
16562
16670
  };
16563
- return submitOffchainTx(this.arkProvider, offchainTx, signer, {
16564
- // Mark pending before submitting — if we crash between submit and
16565
- // finalize, the next init recovers via finalizePendingTxs.
16566
- beforeSubmit: () => this.setPendingTxFlag(true),
16567
- afterFinalize: async () => {
16568
- try {
16569
- await this.setPendingTxFlag(false);
16570
- } catch (error) {
16571
- console.error("Failed to clear pending tx flag:", error);
16671
+ return submitOffchainTx(
16672
+ this.arkProvider,
16673
+ offchainTx,
16674
+ signer,
16675
+ {
16676
+ // Mark pending before submitting — if we crash between submit and
16677
+ // finalize, the next init recovers via finalizePendingTxs.
16678
+ beforeSubmit: () => this.setPendingTxFlag(true),
16679
+ afterFinalize: async () => {
16680
+ try {
16681
+ await this.setPendingTxFlag(false);
16682
+ } catch (error) {
16683
+ console.error("Failed to clear pending tx flag:", error);
16684
+ }
16685
+ }
16686
+ },
16687
+ {
16688
+ // Deprecated keys too: a vtxo built before a rotation is still
16689
+ // spent under the signer its leaf names.
16690
+ verifyServerSignatures: {
16691
+ serverPubkey: this._arkServerPublicKey,
16692
+ deprecatedServerPubkeys: [...this._deprecatedSigners.keys()].map(
16693
+ (h) => base.hex.decode(h)
16694
+ )
16572
16695
  }
16573
16696
  }
16574
- });
16697
+ );
16575
16698
  }
16576
16699
  // mark virtual outputs as spent, save change outputs if any.
16577
16700
  // `offchainTapscript` and `serverPubKey` are the epoch snapshot the
@@ -16610,14 +16733,14 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16610
16733
  const spentBy = checkpointIdByOutpoint.get(`${vtxo.txid}:${vtxo.vout}`);
16611
16734
  spentVtxos.push({
16612
16735
  ...spentFacts,
16613
- virtualStatus: chunk6FTHFJAN_cjs.toVirtualStatus(spentFacts),
16736
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(spentFacts),
16614
16737
  ...spentBy ? { spentBy } : {},
16615
16738
  arkTxId: arkTxid
16616
16739
  });
16617
16740
  for (const id of vtxo.commitmentTxIds) {
16618
16741
  commitmentTxIds.add(id);
16619
16742
  }
16620
- const vtxoExpiry = chunk6FTHFJAN_cjs.toBatchExpiry(vtxo);
16743
+ const vtxoExpiry = chunkKMPNH7NS_cjs.toBatchExpiry(vtxo);
16621
16744
  if (vtxoExpiry) {
16622
16745
  batchExpiry = Math.min(batchExpiry, vtxoExpiry);
16623
16746
  }
@@ -16630,7 +16753,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16630
16753
  isSwept: false,
16631
16754
  isPreconfirmed: true,
16632
16755
  commitmentTxIds: Array.from(commitmentTxIds),
16633
- ...chunk6FTHFJAN_cjs.parseLegacyExpiry(batchExpiry)
16756
+ ...chunkKMPNH7NS_cjs.parseLegacyExpiry(batchExpiry)
16634
16757
  };
16635
16758
  changeVtxo = {
16636
16759
  txid: arkTxid,
@@ -16642,7 +16765,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16642
16765
  tapTree: offchainTapscript.encode(),
16643
16766
  value: Number(changeAmount),
16644
16767
  ...changeFacts,
16645
- virtualStatus: chunk6FTHFJAN_cjs.toVirtualStatus(changeFacts),
16768
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(changeFacts),
16646
16769
  spentBy: "",
16647
16770
  status: {
16648
16771
  confirmed: false
@@ -16711,12 +16834,12 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16711
16834
  const spentVtxos = [];
16712
16835
  const inputArkTxIds = /* @__PURE__ */ new Set();
16713
16836
  const boardingRemovalsByAddress = /* @__PURE__ */ new Map();
16714
- const vtxoInputs = inputs.filter(chunk6FTHFJAN_cjs.isVirtualCoin);
16837
+ const vtxoInputs = inputs.filter(chunkKMPNH7NS_cjs.isVirtualCoin);
16715
16838
  const cm = await this.getContractManager();
16716
16839
  const annotatedVtxos = await cm.annotateVtxos(vtxoInputs);
16717
16840
  const annotatedByKey = new Map(annotatedVtxos.map((v) => [`${v.txid}:${v.vout}`, v]));
16718
16841
  for (const input of inputs) {
16719
- if (chunk6FTHFJAN_cjs.isVirtualCoin(input)) {
16842
+ if (chunkKMPNH7NS_cjs.isVirtualCoin(input)) {
16720
16843
  const outpoint = `${input.txid}:${input.vout}`;
16721
16844
  const vtxo = annotatedByKey.get(outpoint);
16722
16845
  if (!vtxo) {
@@ -16728,13 +16851,13 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16728
16851
  const settledFacts = { ...vtxo, isSpent: true };
16729
16852
  spentVtxos.push({
16730
16853
  ...settledFacts,
16731
- virtualStatus: chunk6FTHFJAN_cjs.toVirtualStatus(settledFacts),
16854
+ virtualStatus: chunkKMPNH7NS_cjs.toVirtualStatus(settledFacts),
16732
16855
  settledBy: commitmentTxid
16733
16856
  });
16734
16857
  } else {
16735
16858
  let sourceAddress;
16736
16859
  try {
16737
- sourceAddress = chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16860
+ sourceAddress = chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).onchainAddress(
16738
16861
  this.network
16739
16862
  );
16740
16863
  } catch {
@@ -16792,9 +16915,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
16792
16915
  }
16793
16916
  };
16794
16917
  function selectVirtualCoins(coins, targetAmount) {
16795
- const sortedCoins = coins.map(chunk6FTHFJAN_cjs.normalizeVtxo).sort((a, b) => {
16796
- const expiryA = chunk6FTHFJAN_cjs.toBatchExpiry(a) || Number.MAX_SAFE_INTEGER;
16797
- const expiryB = chunk6FTHFJAN_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;
16798
16921
  if (expiryA !== expiryB) {
16799
16922
  return expiryA - expiryB;
16800
16923
  }
@@ -17163,7 +17286,7 @@ var MessageBus = class {
17163
17286
  this.initialized = true;
17164
17287
  }
17165
17288
  async buildServices(config) {
17166
- const arkProvider = new chunk6FTHFJAN_cjs.RestArkProvider(config.arkServer.url);
17289
+ const arkProvider = new chunkKMPNH7NS_cjs.RestArkProvider(config.arkServer.url);
17167
17290
  const storage = {
17168
17291
  walletRepository: this.walletRepository,
17169
17292
  contractRepository: this.contractRepository,
@@ -17505,7 +17628,7 @@ var offboardNetworkNames = [
17505
17628
  function offboardDestinationScript(destinationAddress) {
17506
17629
  for (const networkName of offboardNetworkNames) {
17507
17630
  try {
17508
- const network = chunk6FTHFJAN_cjs.networks[networkName];
17631
+ const network = chunkKMPNH7NS_cjs.networks[networkName];
17509
17632
  const addr = btcSigner.Address(network).decode(destinationAddress);
17510
17633
  return btcSigner.OutScript.encode(addr);
17511
17634
  } catch {
@@ -17514,6 +17637,23 @@ function offboardDestinationScript(destinationAddress) {
17514
17637
  }
17515
17638
  throw new Error(`Failed to decode destination address: ${destinationAddress}`);
17516
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
+ }
17517
17657
  var Ramps = class {
17518
17658
  /**
17519
17659
  * Create convenience wrappers for onboarding and offboarding flows.
@@ -17567,9 +17707,22 @@ var Ramps = class {
17567
17707
  }
17568
17708
  change = totalAmount - amount;
17569
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
+ }
17570
17723
  amount = amount ?? totalAmount;
17571
17724
  const offchainAddress = await this.wallet.getAddress();
17572
- const offchainAddr = chunk6FTHFJAN_cjs.ArkAddress.decode(offchainAddress);
17725
+ const offchainAddr = chunkKMPNH7NS_cjs.ArkAddress.decode(offchainAddress);
17573
17726
  const offchainScript = base.hex.encode(offchainAddr.pkScript);
17574
17727
  const outputFee = estimator.evalOffchainOutput({
17575
17728
  amount,
@@ -17588,7 +17741,6 @@ var Ramps = class {
17588
17741
  }
17589
17742
  ];
17590
17743
  if (change > 0n) {
17591
- const boardingAddress = await this.wallet.getBoardingAddress();
17592
17744
  outputs.push({
17593
17745
  address: boardingAddress,
17594
17746
  amount: change
@@ -17609,6 +17761,10 @@ var Ramps = class {
17609
17761
  * @param feeInfo - The fee info to deduct from the offboard amount.
17610
17762
  * @param amount - The amount to offboard. If not provided, the total amount of virtual outputs will be offboarded.
17611
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.
17612
17768
  * @returns The Arkade transaction id created by settlement
17613
17769
  * @throws Error if no virtual outputs remain after fee deduction or the destination address cannot be decoded
17614
17770
  * @see IWallet.getSpendableVtxos
@@ -17620,8 +17776,10 @@ var Ramps = class {
17620
17776
  * await ramps.offboard('bc1q...', feeInfo);
17621
17777
  * ```
17622
17778
  */
17623
- async offboard(destinationAddress, feeInfo, amount, eventCallback) {
17624
- 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({
17625
17783
  withRecoverable: true,
17626
17784
  withUnrolled: false
17627
17785
  });
@@ -17629,8 +17787,13 @@ var Ramps = class {
17629
17787
  const filteredVtxos = [];
17630
17788
  let totalAmount = 0n;
17631
17789
  for (const vtxo of vtxos) {
17632
- const inputFee = estimator.evalOffchainInput(chunk6FTHFJAN_cjs.toOffchainInputFeeParams(vtxo));
17790
+ const inputFee = estimator.evalOffchainInput(chunkKMPNH7NS_cjs.toOffchainInputFeeParams(vtxo));
17633
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
+ }
17634
17797
  continue;
17635
17798
  }
17636
17799
  filteredVtxos.push(vtxo);
@@ -17646,6 +17809,15 @@ var Ramps = class {
17646
17809
  }
17647
17810
  change = totalAmount - amount;
17648
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
+ }
17649
17821
  const dustAmount = getDustAmount(this.wallet);
17650
17822
  if (change > 0n && change < dustAmount) {
17651
17823
  throw new DustChangeError(change, dustAmount);
@@ -17669,7 +17841,7 @@ var Ramps = class {
17669
17841
  }
17670
17842
  ];
17671
17843
  if (change > 0n) {
17672
- const offchainAddress = await this.wallet.getAddress();
17844
+ const offchainAddress = changeAddress;
17673
17845
  outputs.push({
17674
17846
  address: offchainAddress,
17675
17847
  amount: change
@@ -18500,7 +18672,7 @@ var WalletMessageHandler = class {
18500
18672
  // Wallet methods
18501
18673
  async handleInitWallet({ payload }) {
18502
18674
  const { arkServerUrl } = payload;
18503
- this.indexerProvider = new chunk4C5PMGBB_cjs.RestIndexerProvider(arkServerUrl);
18675
+ this.indexerProvider = new chunkAS3W34MG_cjs.RestIndexerProvider(arkServerUrl);
18504
18676
  await this.onWalletInitialized();
18505
18677
  }
18506
18678
  /**
@@ -18788,7 +18960,7 @@ var WalletMessageHandler = class {
18788
18960
  if (v.isUnrolled) {
18789
18961
  return withUnrolled;
18790
18962
  }
18791
- if (chunk6FTHFJAN_cjs.hasTerminalSpend(v)) {
18963
+ if (chunkKMPNH7NS_cjs.hasTerminalSpend(v)) {
18792
18964
  return false;
18793
18965
  }
18794
18966
  if (includeRecoverable) {
@@ -18797,10 +18969,10 @@ var WalletMessageHandler = class {
18797
18969
  if (dustAmount != null && isSubdust(v, dustAmount)) {
18798
18970
  return false;
18799
18971
  }
18800
- if (chunk6FTHFJAN_cjs.isRecoverable(v)) {
18972
+ if (chunkKMPNH7NS_cjs.isRecoverable(v)) {
18801
18973
  return false;
18802
18974
  }
18803
- if (chunk6FTHFJAN_cjs.isExpired(v)) {
18975
+ if (chunkKMPNH7NS_cjs.isExpired(v)) {
18804
18976
  return false;
18805
18977
  }
18806
18978
  return true;
@@ -18908,7 +19080,7 @@ var WalletMessageHandler = class {
18908
19080
  this.readonlyWallet.getBoardingTxs()
18909
19081
  ]);
18910
19082
  const indexerProvider = this.indexerProvider;
18911
- const resolveTxCreatedAt = indexerProvider ? (txids) => chunk6FTHFJAN_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
19083
+ const resolveTxCreatedAt = indexerProvider ? (txids) => chunkKMPNH7NS_cjs.fetchVtxoCreatedAtByTxid(indexerProvider, txids) : void 0;
18912
19084
  return buildTransactionHistory(
18913
19085
  vtxos,
18914
19086
  boardingTxs,
@@ -19616,7 +19788,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19616
19788
  };
19617
19789
  try {
19618
19790
  const response = await this.sendMessage(message);
19619
- return response.payload.vtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo);
19791
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
19620
19792
  } catch (error) {
19621
19793
  throw new Error(`Failed to get vtxos: ${error}`);
19622
19794
  }
@@ -19641,7 +19813,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19641
19813
  };
19642
19814
  try {
19643
19815
  const response = await this.sendMessage(message);
19644
- return response.payload.vtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo);
19816
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
19645
19817
  } catch (error) {
19646
19818
  throw new Error(`Failed to get spendable vtxos: ${error}`);
19647
19819
  }
@@ -19812,7 +19984,7 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
19812
19984
  };
19813
19985
  try {
19814
19986
  const response = await sendContractMessage(message);
19815
- return response.payload.vtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo);
19987
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
19816
19988
  } catch (e) {
19817
19989
  throw new Error("Failed to annotate vtxos");
19818
19990
  }
@@ -20424,7 +20596,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
20424
20596
  };
20425
20597
  try {
20426
20598
  const response = await wallet.sendMessage(message);
20427
- return response.payload.vtxos.map(chunk6FTHFJAN_cjs.normalizeVtxo);
20599
+ return response.payload.vtxos.map(chunkKMPNH7NS_cjs.normalizeVtxo);
20428
20600
  } catch (e) {
20429
20601
  throw new Error(`Failed to get expiring vtxos: ${e}`);
20430
20602
  }
@@ -20536,12 +20708,12 @@ var OnchainWallet = class _OnchainWallet {
20536
20708
  * @returns Configured onchain wallet
20537
20709
  * @throws Error if the configured identity cannot produce a valid x-only public key
20538
20710
  */
20539
- static async create(identity, networkName = chunk6FTHFJAN_cjs.DEFAULT_NETWORK_NAME, provider) {
20711
+ static async create(identity, networkName = chunkKMPNH7NS_cjs.DEFAULT_NETWORK_NAME, provider) {
20540
20712
  const pubkey = await identity.xOnlyPublicKey();
20541
20713
  if (!pubkey) {
20542
20714
  throw new Error("Invalid configured public key");
20543
20715
  }
20544
- const network = chunk6FTHFJAN_cjs.getNetwork(networkName);
20716
+ const network = chunkKMPNH7NS_cjs.getNetwork(networkName);
20545
20717
  const onchainProvider = provider || new EsploraProvider(ESPLORA_URL[networkName]);
20546
20718
  const onchainP2TR = btcSigner.p2tr(pubkey, void 0, network);
20547
20719
  return new _OnchainWallet(identity, network, onchainP2TR, onchainProvider);
@@ -20647,7 +20819,7 @@ var OnchainWallet = class _OnchainWallet {
20647
20819
  if (!inputs) {
20648
20820
  throw new Error("Fee estimation failed");
20649
20821
  }
20650
- let tx = new chunk6FTHFJAN_cjs.Transaction();
20822
+ let tx = new chunkKMPNH7NS_cjs.Transaction();
20651
20823
  for (const input of inputs) {
20652
20824
  tx.addInput({
20653
20825
  txid: input.txid,
@@ -20705,7 +20877,7 @@ var OnchainWallet = class _OnchainWallet {
20705
20877
  * @throws If the parent has no anchor, or funding cannot be selected/signed
20706
20878
  */
20707
20879
  async bumpAnchor(parentHex, feeRate) {
20708
- const parent = chunk6FTHFJAN_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20880
+ const parent = chunkKMPNH7NS_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
20709
20881
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
20710
20882
  const child = await this.buildBumpPackage(parent, feeRate, coins);
20711
20883
  return [parent.hex, child.hex];
@@ -21612,7 +21784,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21612
21784
  try {
21613
21785
  const { txs } = await source.getVirtualTxs(wanted);
21614
21786
  for (const psbt of txs) {
21615
- const tx = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21787
+ const tx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt));
21616
21788
  resolved.set(tx.id, tx.toBytes());
21617
21789
  }
21618
21790
  } catch (err) {
@@ -21645,7 +21817,7 @@ async function resolvePrevTxs(txids, source, onchain) {
21645
21817
  async function attachPrevArkTxs(tx, txids, source, onchain) {
21646
21818
  const pending = [];
21647
21819
  for (let i = 0; i < tx.inputsLength; i++) {
21648
- if (chunk6FTHFJAN_cjs.getArkPsbtFields(tx, i, chunk6FTHFJAN_cjs.PrevArkTxField).length === 0) pending.push(i);
21820
+ if (chunkKMPNH7NS_cjs.getArkPsbtFields(tx, i, chunkKMPNH7NS_cjs.PrevArkTxField).length === 0) pending.push(i);
21649
21821
  }
21650
21822
  if (pending.length === 0) return;
21651
21823
  const resolved = await resolvePrevTxs(
@@ -21654,13 +21826,13 @@ async function attachPrevArkTxs(tx, txids, source, onchain) {
21654
21826
  onchain
21655
21827
  );
21656
21828
  for (const i of pending) {
21657
- chunk6FTHFJAN_cjs.setArkPsbtField(tx, i, chunk6FTHFJAN_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21829
+ chunkKMPNH7NS_cjs.setArkPsbtField(tx, i, chunkKMPNH7NS_cjs.PrevArkTxField, resolved.get(txidAt(txids, i)));
21658
21830
  }
21659
21831
  }
21660
21832
  async function attachPrevoutTxs(tx, source) {
21661
21833
  const pending = [];
21662
21834
  for (let i = 0; i < tx.inputsLength; i++) {
21663
- if (chunk6FTHFJAN_cjs.getArkPsbtFields(tx, i, chunk6FTHFJAN_cjs.PrevoutTxField).length > 0) continue;
21835
+ if (chunkKMPNH7NS_cjs.getArkPsbtFields(tx, i, chunkKMPNH7NS_cjs.PrevoutTxField).length > 0) continue;
21664
21836
  const input = tx.getInput(i);
21665
21837
  if (!input?.txid) throw new PrevTxUnavailableError(`input ${i} has no outpoint`);
21666
21838
  pending.push({ index: i, txid: base.hex.encode(input.txid) });
@@ -21671,7 +21843,7 @@ async function attachPrevoutTxs(tx, source) {
21671
21843
  resolved.set(txid, await source.getRawTransaction(txid));
21672
21844
  }
21673
21845
  for (const { index, txid } of pending) {
21674
- chunk6FTHFJAN_cjs.setArkPsbtField(tx, index, chunk6FTHFJAN_cjs.PrevoutTxField, resolved.get(txid));
21846
+ chunkKMPNH7NS_cjs.setArkPsbtField(tx, index, chunkKMPNH7NS_cjs.PrevoutTxField, resolved.get(txid));
21675
21847
  }
21676
21848
  }
21677
21849
  async function withPrevTxs(coins, source, onchain) {
@@ -21697,7 +21869,7 @@ exports.BIP322 = void 0;
21697
21869
  async function sign2(message, identity, network) {
21698
21870
  const xOnlyPubKey = await identity.xOnlyPublicKey();
21699
21871
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
21700
- const toSpend = chunk6FTHFJAN_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21872
+ const toSpend = chunkKMPNH7NS_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
21701
21873
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
21702
21874
  const signed = await identity.sign(toSign, [0]);
21703
21875
  signed.finalizeIdx(0);
@@ -21755,7 +21927,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
21755
21927
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
21756
21928
  return false;
21757
21929
  }
21758
- const toSpend = chunk6FTHFJAN_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21930
+ const toSpend = chunkKMPNH7NS_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21759
21931
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
21760
21932
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
21761
21933
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -21776,7 +21948,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
21776
21948
  }
21777
21949
  const sighashType = sigWithHash[sigWithHash.length - 1];
21778
21950
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
21779
- const toSpend = chunk6FTHFJAN_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21951
+ const toSpend = chunkKMPNH7NS_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
21780
21952
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
21781
21953
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
21782
21954
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -21829,7 +22001,7 @@ function encodeCompactSize(n) {
21829
22001
  return buf;
21830
22002
  }
21831
22003
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21832
- const tx = new chunk6FTHFJAN_cjs.Transaction({ version: 0 });
22004
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 0 });
21833
22005
  tx.addInput({
21834
22006
  txid: toSpend.id,
21835
22007
  index: 0,
@@ -21843,12 +22015,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
21843
22015
  });
21844
22016
  tx.addOutput({
21845
22017
  amount: 0n,
21846
- script: chunk6FTHFJAN_cjs.OP_RETURN_EMPTY_PKSCRIPT
22018
+ script: chunkKMPNH7NS_cjs.OP_RETURN_EMPTY_PKSCRIPT
21847
22019
  });
21848
22020
  return tx;
21849
22021
  }
21850
22022
  function craftBIP322ToSignSimple(toSpend, pkScript) {
21851
- const tx = new chunk6FTHFJAN_cjs.Transaction({ version: 0 });
22023
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 0 });
21852
22024
  tx.addInput({
21853
22025
  txid: toSpend.id,
21854
22026
  index: 0,
@@ -21860,7 +22032,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
21860
22032
  });
21861
22033
  tx.addOutput({
21862
22034
  amount: 0n,
21863
- script: chunk6FTHFJAN_cjs.OP_RETURN_EMPTY_PKSCRIPT
22035
+ script: chunkKMPNH7NS_cjs.OP_RETURN_EMPTY_PKSCRIPT
21864
22036
  });
21865
22037
  return tx;
21866
22038
  }
@@ -21873,7 +22045,7 @@ var RestEmulatorProvider = class {
21873
22045
  serverUrl;
21874
22046
  async getInfo() {
21875
22047
  const url = `${this.serverUrl}/v1/info`;
21876
- const response = await chunk6FTHFJAN_cjs.baseFetch(url);
22048
+ const response = await chunkKMPNH7NS_cjs.baseFetch(url);
21877
22049
  if (!response.ok) {
21878
22050
  const errorText2 = await response.text();
21879
22051
  throw new Error(`Failed to get emulator info: ${errorText2}`);
@@ -21991,7 +22163,7 @@ var RestEmulatorProvider = class {
21991
22163
  }
21992
22164
  };
21993
22165
  function finalizeVirtualTx(type, psbtBase64) {
21994
- const tx = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
22166
+ const tx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
21995
22167
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
21996
22168
  const input = tx.getInput(0);
21997
22169
  if (!input) {
@@ -22018,14 +22190,14 @@ var ExitPathError = class extends Error {
22018
22190
  reason;
22019
22191
  };
22020
22192
  function delayWeight(sequence) {
22021
- const t = chunk6FTHFJAN_cjs.sequenceToTimelock(sequence);
22193
+ const t = chunkKMPNH7NS_cjs.sequenceToTimelock(sequence);
22022
22194
  return t.type === "blocks" ? Number(t.value) : Number(t.value) / 600;
22023
22195
  }
22024
22196
  async function resolveUnilateralPath(params) {
22025
22197
  const { vtxo, scriptHex, contractRepository } = params;
22026
22198
  const contract = contractRepository ? (await contractRepository.getContracts({ script: scriptHex }))[0] : void 0;
22027
22199
  if (contract) {
22028
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
22200
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
22029
22201
  if (!handler) {
22030
22202
  throw new ExitPathError(
22031
22203
  "no-handler",
@@ -22048,12 +22220,12 @@ async function resolveUnilateralPath(params) {
22048
22220
  paths.sort((a, b) => delayWeight(a.sequence) - delayWeight(b.sequence));
22049
22221
  return { selection: paths[0], label: `${contract.type}:unilateral` };
22050
22222
  }
22051
- const decoded = chunk6FTHFJAN_cjs.VtxoScript.decode(vtxo.tapTree);
22223
+ const decoded = chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree);
22052
22224
  let best;
22053
22225
  for (const exit of decoded.exitPaths()) {
22054
22226
  const leaf = decoded.findLeaf(base.hex.encode(exit.script));
22055
22227
  if (!leaf) continue;
22056
- const sequence = chunk6FTHFJAN_cjs.timelockToSequence(exit.params.timelock);
22228
+ const sequence = chunkKMPNH7NS_cjs.timelockToSequence(exit.params.timelock);
22057
22229
  const weight = delayWeight(sequence);
22058
22230
  if (!best || weight < best.weight) {
22059
22231
  best = { selection: { leaf, sequence }, weight };
@@ -22273,7 +22445,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22273
22445
  let totalAmount = 0n;
22274
22446
  const txWeightEstimator = TxWeightEstimator.create();
22275
22447
  for (const vtxo of vtxos) {
22276
- if (!chunk6FTHFJAN_cjs.canSweepOnchain(vtxo)) {
22448
+ if (!chunkKMPNH7NS_cjs.canSweepOnchain(vtxo)) {
22277
22449
  throw new Error(
22278
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`
22279
22451
  );
@@ -22284,14 +22456,14 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22284
22456
  }
22285
22457
  const resolved = await resolveUnilateralPath({
22286
22458
  vtxo,
22287
- scriptHex: base.hex.encode(chunk6FTHFJAN_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22459
+ scriptHex: base.hex.encode(chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22288
22460
  contractRepository: wallet.contractRepository,
22289
22461
  walletPubKeyHex: base.hex.encode(await wallet.identity.xOnlyPublicKey()),
22290
22462
  currentTime: Date.now()
22291
22463
  });
22292
22464
  const spendingLeaf = resolved.selection.leaf;
22293
22465
  const sequence = resolved.selection.sequence;
22294
- const timelock = chunk6FTHFJAN_cjs.sequenceToTimelock(sequence);
22466
+ const timelock = chunkKMPNH7NS_cjs.sequenceToTimelock(sequence);
22295
22467
  const elapsed = timelock.type === "blocks" ? chainTip.height >= txStatus.blockHeight + Number(timelock.value) : chainTip.time >= txStatus.blockTime + Number(timelock.value);
22296
22468
  if (!elapsed) {
22297
22469
  throw new Error(`no available exit path found for vtxo ${vtxo.txid}:${vtxo.vout}`);
@@ -22304,7 +22476,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22304
22476
  sequence,
22305
22477
  witnessUtxo: {
22306
22478
  amount: BigInt(vtxo.value),
22307
- script: chunk6FTHFJAN_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22479
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript
22308
22480
  },
22309
22481
  sighashType: btcSigner.SigHash.DEFAULT
22310
22482
  });
@@ -22314,7 +22486,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
22314
22486
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
22315
22487
  );
22316
22488
  }
22317
- const tx = new chunk6FTHFJAN_cjs.Transaction({ version: 2 });
22489
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 2 });
22318
22490
  for (const input of inputs) {
22319
22491
  tx.addInput(input);
22320
22492
  }
@@ -22397,7 +22569,7 @@ async function buildSignedSweep(params) {
22397
22569
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
22398
22570
  );
22399
22571
  }
22400
- const tx = new chunk6FTHFJAN_cjs.Transaction({ version: 2 });
22572
+ const tx = new chunkKMPNH7NS_cjs.Transaction({ version: 2 });
22401
22573
  tx.addInput({
22402
22574
  txid: vtxo.txid,
22403
22575
  index: vtxo.vout,
@@ -22422,7 +22594,7 @@ async function buildSignedSweep(params) {
22422
22594
  finalScriptWitness: [
22423
22595
  tapScriptSig[0][1],
22424
22596
  ...path.extraWitness,
22425
- chunk6FTHFJAN_cjs.scriptFromTapLeafScript(path.leaf),
22597
+ chunkKMPNH7NS_cjs.scriptFromTapLeafScript(path.leaf),
22426
22598
  btcSigner.TaprootControlBlock.encode(controlBlock)
22427
22599
  ]
22428
22600
  });
@@ -22452,7 +22624,7 @@ async function resolveFeeRate(opts) {
22452
22624
  }
22453
22625
  async function selectExitVtxos(opts) {
22454
22626
  if (!opts.vtxos) return opts.wallet.getVtxos();
22455
- const res = await chunk6FTHFJAN_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22627
+ const res = await chunkKMPNH7NS_cjs.getNormalizedVtxos(opts.wallet.indexerProvider, { outpoints: opts.vtxos });
22456
22628
  const tapTrees = /* @__PURE__ */ new Map();
22457
22629
  const out = [];
22458
22630
  for (const vtxo of res.vtxos) {
@@ -22467,7 +22639,7 @@ async function selectExitVtxos(opts) {
22467
22639
  `no contract registered for vtxo script ${vtxo.script} \u2014 register the contract before exiting`
22468
22640
  );
22469
22641
  }
22470
- const handler = chunkNPM5YZBC_cjs.contractHandlers.get(contract.type);
22642
+ const handler = chunkDXLVCFVK_cjs.contractHandlers.get(contract.type);
22471
22643
  if (!handler) {
22472
22644
  throw new Error(`no contract handler registered for type '${contract.type}'`);
22473
22645
  }
@@ -22497,7 +22669,7 @@ async function computeExitLayout(opts, feeRate) {
22497
22669
  if (pendingNodes.length > 0) {
22498
22670
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
22499
22671
  for (const psbt of txs) {
22500
- psbts.set(chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22672
+ psbts.set(chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
22501
22673
  }
22502
22674
  }
22503
22675
  const childVsize = Number(
@@ -22533,7 +22705,7 @@ async function computeExitLayout(opts, feeRate) {
22533
22705
  try {
22534
22706
  const resolved = await resolveUnilateralPath({
22535
22707
  vtxo,
22536
- scriptHex: base.hex.encode(chunk6FTHFJAN_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22708
+ scriptHex: base.hex.encode(chunkKMPNH7NS_cjs.VtxoScript.decode(vtxo.tapTree).pkScript),
22537
22709
  contractRepository: wallet.contractRepository,
22538
22710
  walletPubKeyHex,
22539
22711
  currentTime: Date.now()
@@ -22552,7 +22724,7 @@ async function computeExitLayout(opts, feeRate) {
22552
22724
  });
22553
22725
  continue;
22554
22726
  }
22555
- const t = chunk6FTHFJAN_cjs.sequenceToTimelock(resolved.selection.sequence);
22727
+ const t = chunkKMPNH7NS_cjs.sequenceToTimelock(resolved.selection.sequence);
22556
22728
  const delay = { type: t.type, value: Number(t.value) };
22557
22729
  infos.push({ outpoint, value: vtxo.value, sweepFee, path: resolved.label, delay });
22558
22730
  sweeps.push({ vtxo, resolved, sweepFee, delay });
@@ -22953,7 +23125,7 @@ async function prepare(opts) {
22953
23125
  txid: sweep.vtxo.txid,
22954
23126
  vout: sweep.vtxo.vout,
22955
23127
  value: sweep.vtxo.value,
22956
- pkScript: chunk6FTHFJAN_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
23128
+ pkScript: chunkKMPNH7NS_cjs.VtxoScript.decode(sweep.vtxo.tapTree).pkScript
22957
23129
  },
22958
23130
  path: sweep.resolved.selection,
22959
23131
  outputAddress: opts.sweepAddress,
@@ -23041,7 +23213,7 @@ async function prepare(opts) {
23041
23213
  if (newFee <= splitterFee) break;
23042
23214
  splitterFee = newFee;
23043
23215
  }
23044
- const splitter = new chunk6FTHFJAN_cjs.Transaction({ version: 2 });
23216
+ const splitter = new chunkKMPNH7NS_cjs.Transaction({ version: 2 });
23045
23217
  for (const coin of selected.inputs) {
23046
23218
  splitter.addInput({
23047
23219
  txid: coin.txid,
@@ -23185,41 +23357,41 @@ var UnilateralExit = {
23185
23357
  // src/arkade/index.ts
23186
23358
  var arkade_exports = {};
23187
23359
  chunk5BLDMQED_cjs.__export(arkade_exports, {
23188
- ARKADE_OP: () => chunkNPM5YZBC_cjs.ARKADE_OP,
23189
- ARKADE_OPCODES: () => chunkNPM5YZBC_cjs.ARKADE_OPCODES,
23190
- ARKADE_OPCODE_NAMES: () => chunkNPM5YZBC_cjs.ARKADE_OPCODE_NAMES,
23191
- ARKADE_OPCODE_VALUES: () => chunkNPM5YZBC_cjs.ARKADE_OPCODE_VALUES,
23192
- ARKADE_OPS: () => chunkNPM5YZBC_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,
23193
23365
  Arkade: () => Arkade,
23194
23366
  ArkadeContract: () => ArkadeContract,
23195
- ArkadeProgramScript: () => chunkNPM5YZBC_cjs.ArkadeProgramScript,
23196
- ArkadeScript: () => chunkNPM5YZBC_cjs.ArkadeScript,
23367
+ ArkadeProgramScript: () => chunkDXLVCFVK_cjs.ArkadeProgramScript,
23368
+ ArkadeScript: () => chunkDXLVCFVK_cjs.ArkadeScript,
23197
23369
  ArkadeTransactionBuilder: () => ArkadeTransactionBuilder,
23198
- BigNum: () => chunkNPM5YZBC_cjs.bignum_exports,
23370
+ BigNum: () => chunkDXLVCFVK_cjs.bignum_exports,
23199
23371
  OP: () => btcSigner.OP,
23200
- OPCODE_NAMES: () => chunkNPM5YZBC_cjs.OPCODE_NAMES,
23201
- OPCODE_VALUES: () => chunkNPM5YZBC_cjs.OPCODE_VALUES,
23202
- SUPPORTED_PROGRAM_VERSION: () => chunkNPM5YZBC_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,
23203
23375
  Script: () => btcSigner.Script,
23204
- arkadeScriptHash: () => chunkNPM5YZBC_cjs.arkadeScriptHash,
23205
- arkadeWitnessHash: () => chunkNPM5YZBC_cjs.arkadeWitnessHash,
23206
- asmToBytes: () => chunkNPM5YZBC_cjs.asmToBytes,
23207
- bytesToASM: () => chunkNPM5YZBC_cjs.bytesToASM,
23208
- computeArkadeScriptPublicKey: () => chunkNPM5YZBC_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,
23209
23381
  createArkadeBatchHandler: () => createArkadeBatchHandler,
23210
- deserializeArkadeContractParams: () => chunkNPM5YZBC_cjs.deserializeArkadeContractParams,
23211
- fromASM: () => chunkNPM5YZBC_cjs.fromASM,
23212
- getOpcodeName: () => chunkNPM5YZBC_cjs.getOpcodeName,
23213
- getOpcodeValue: () => chunkNPM5YZBC_cjs.getOpcodeValue,
23214
- parseArtifact: () => chunkNPM5YZBC_cjs.parseArtifact,
23215
- resolveAsm: () => chunkNPM5YZBC_cjs.resolveAsm,
23216
- serializeArkadeContractParams: () => chunkNPM5YZBC_cjs.serializeArkadeContractParams,
23217
- stringifyArtifact: () => chunkNPM5YZBC_cjs.stringifyArtifact,
23218
- toASM: () => chunkNPM5YZBC_cjs.toASM,
23219
- validateProgram: () => chunkNPM5YZBC_cjs.validateProgram,
23220
- witnessRefToBytes: () => chunkNPM5YZBC_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
23221
23393
  });
23222
- var isVtxoCoin = (input) => chunk6FTHFJAN_cjs.isVirtualCoin(input);
23394
+ var isVtxoCoin = (input) => chunkKMPNH7NS_cjs.isVirtualCoin(input);
23223
23395
  function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message, session, arkProvider, emulator, network, recipients, batchExpiryPolicy) {
23224
23396
  let batchId;
23225
23397
  let sweepTapTreeRoot;
@@ -23240,26 +23412,32 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23240
23412
  );
23241
23413
  await arkProvider.confirmRegistration(intentId);
23242
23414
  batchId = event.id;
23243
- const sweepTapscript = chunk6FTHFJAN_cjs.CSVMultisigTapscript.encode({
23415
+ const sweepTapscript = chunkKMPNH7NS_cjs.CSVMultisigTapscript.encode({
23244
23416
  timelock,
23245
- pubkeys: [chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23417
+ pubkeys: [chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(info.forfeitPubkey), "forfeit key")]
23246
23418
  }).script;
23247
23419
  sweepTapTreeRoot = payment_js.tapLeafHash(sweepTapscript);
23248
23420
  return { skip: false };
23249
23421
  },
23250
23422
  onTreeSigningStarted: async (event, vtxoTree) => {
23251
23423
  const signerPubKey = await session.getPublicKey();
23252
- const xonlySignerPubKey = chunkNPM5YZBC_cjs.toXOnly(signerPubKey, "signer key");
23424
+ const xonlySignerPubKey = chunkDXLVCFVK_cjs.toXOnly(signerPubKey, "signer key");
23253
23425
  const xOnlyPubkeys = event.cosignersPublicKeys.map(
23254
- (k) => base.hex.encode(chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23426
+ (k) => base.hex.encode(chunkDXLVCFVK_cjs.toXOnly(base.hex.decode(k), "cosigner key"))
23255
23427
  );
23256
23428
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
23257
23429
  return { skip: true };
23258
23430
  }
23259
- const commitmentTx = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23431
+ const commitmentTx = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
23260
23432
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
23261
23433
  if (recipients && recipients.length > 0) {
23262
23434
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
23435
+ } else {
23436
+ validateBatchAgainstIntent(
23437
+ commitmentTx,
23438
+ vtxoTree.leaves(),
23439
+ declaredIntentOutputs(signedProof, message.onchain_output_indexes)
23440
+ );
23263
23441
  }
23264
23442
  const sharedOutput = commitmentTx.getOutput(0);
23265
23443
  if (!sharedOutput?.amount) {
@@ -23288,14 +23466,21 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23288
23466
  if (connectorTree) {
23289
23467
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
23290
23468
  }
23291
- let commitmentPsbt = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23469
+ let commitmentPsbt = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
23292
23470
  assertFinalCommitmentMatchesValidated(
23293
23471
  commitmentPsbt,
23294
23472
  validatedCommitmentTxid,
23295
23473
  "arkade batch finalization"
23296
23474
  );
23297
- if (!validatedCommitmentTxid && recipients && recipients.length > 0) {
23298
- validateBatchRecipientsWithoutTree(commitmentPsbt, recipients, network);
23475
+ if (!validatedCommitmentTxid) {
23476
+ if (recipients && recipients.length > 0) {
23477
+ validateBatchRecipientsWithoutTree(commitmentPsbt, recipients, network);
23478
+ } else {
23479
+ validateBatchAgainstIntentWithoutTree(
23480
+ commitmentPsbt,
23481
+ declaredIntentOutputs(signedProof, message.onchain_output_indexes)
23482
+ );
23483
+ }
23299
23484
  }
23300
23485
  const signedForfeits = [];
23301
23486
  let connectorIndex = 0;
@@ -23323,7 +23508,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23323
23508
  boardingIndices.push(boardingIdx);
23324
23509
  continue;
23325
23510
  }
23326
- if (chunk6FTHFJAN_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
23511
+ if (chunkKMPNH7NS_cjs.isRecoverable(input) || isSubdust(input, info.dust)) {
23327
23512
  continue;
23328
23513
  }
23329
23514
  if (connectorIndex >= connectorLeaves.length) {
@@ -23344,7 +23529,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
23344
23529
  index: input.vout,
23345
23530
  witnessUtxo: {
23346
23531
  amount: BigInt(input.value),
23347
- script: chunk6FTHFJAN_cjs.VtxoScript.decode(input.tapTree).pkScript
23532
+ script: chunkKMPNH7NS_cjs.VtxoScript.decode(input.tapTree).pkScript
23348
23533
  },
23349
23534
  sighashType: btcSigner.SigHash.DEFAULT,
23350
23535
  tapLeafScript: [input.forfeitTapLeafScript]
@@ -23435,16 +23620,16 @@ var Arkade = class _Arkade {
23435
23620
  /** Connect and resolve the server key, checkpoint closure and (if present) the co-signer key. */
23436
23621
  static async connect(opts) {
23437
23622
  const info = await opts.arkade.getInfo();
23438
- const serverKey = chunkNPM5YZBC_cjs.toXOnly(base.hex.decode(info.signerPubkey), "ark signer key");
23439
- const checkpoint = chunk6FTHFJAN_cjs.CSVMultisigTapscript.decode(base.hex.decode(info.checkpointTapscript));
23440
- const network = opts.network ?? chunk6FTHFJAN_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;
23441
23626
  let emulatorKey;
23442
23627
  if (opts.emulator) {
23443
- emulatorKey = base.hex.decode(chunk6FTHFJAN_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23628
+ emulatorKey = base.hex.decode(chunkKMPNH7NS_cjs.resolveEmulatorPubkey(network, opts.emulatorPubkey));
23444
23629
  }
23445
23630
  let userKey;
23446
23631
  if (opts.identity) {
23447
- userKey = chunkNPM5YZBC_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23632
+ userKey = chunkDXLVCFVK_cjs.toXOnly(await opts.identity.xOnlyPublicKey(), "identity key");
23448
23633
  }
23449
23634
  return new _Arkade({
23450
23635
  arkProvider: opts.arkade,
@@ -23470,7 +23655,7 @@ var Arkade = class _Arkade {
23470
23655
  * key respectively; explicit args always win.
23471
23656
  */
23472
23657
  contract(program, args = {}) {
23473
- const declared = (program.params ?? []).map(chunkNPM5YZBC_cjs.inputName);
23658
+ const declared = (program.params ?? []).map(chunkDXLVCFVK_cjs.inputName);
23474
23659
  if (declared.includes("server") && args.server === void 0) {
23475
23660
  args = { ...args, server: this.serverKey };
23476
23661
  }
@@ -23490,7 +23675,7 @@ var ArkadeContract = class _ArkadeContract {
23490
23675
  userKey: client.userKey,
23491
23676
  emulatorKey: client.emulatorKey
23492
23677
  };
23493
- this.vtxoScript = new chunkNPM5YZBC_cjs.ArkadeProgramScript(program, args, this.keys);
23678
+ this.vtxoScript = new chunkDXLVCFVK_cjs.ArkadeProgramScript(program, args, this.keys);
23494
23679
  this.tapTree = this.vtxoScript.encode();
23495
23680
  this.compiled = this.vtxoScript.compiled;
23496
23681
  }
@@ -23518,7 +23703,7 @@ var ArkadeContract = class _ArkadeContract {
23518
23703
  `ArkadeContract.fromContract: expected contract type 'arkade', got '${contract.type}'`
23519
23704
  );
23520
23705
  }
23521
- const typed = chunkNPM5YZBC_cjs.deserializeArkadeContractParams(contract.params);
23706
+ const typed = chunkDXLVCFVK_cjs.deserializeArkadeContractParams(contract.params);
23522
23707
  return new _ArkadeContract(client, typed.program, typed.args, {
23523
23708
  serverKey: typed.serverKey,
23524
23709
  userKey: typed.userKey,
@@ -23559,7 +23744,7 @@ var ArkadeContract = class _ArkadeContract {
23559
23744
  toContractParams() {
23560
23745
  return {
23561
23746
  type: "arkade",
23562
- params: chunkNPM5YZBC_cjs.serializeArkadeContractParams({
23747
+ params: chunkDXLVCFVK_cjs.serializeArkadeContractParams({
23563
23748
  program: this.program,
23564
23749
  args: this.args,
23565
23750
  serverKey: this.keys.serverKey,
@@ -23609,18 +23794,18 @@ var ArkadeContract = class _ArkadeContract {
23609
23794
  if (registered) {
23610
23795
  const [withVtxos] = await manager.getContractsWithVtxos({ script: scriptHex });
23611
23796
  return (withVtxos?.vtxos ?? []).filter(
23612
- (v) => !chunk6FTHFJAN_cjs.hasTerminalSpend(v) && !v.isUnrolled
23797
+ (v) => !chunkKMPNH7NS_cjs.hasTerminalSpend(v) && !v.isUnrolled
23613
23798
  );
23614
23799
  }
23615
23800
  }
23616
23801
  if (!this.client.indexer) {
23617
23802
  throw new Error("ArkadeContract.getUtxos: an indexer is required");
23618
23803
  }
23619
- const { vtxos } = await chunk6FTHFJAN_cjs.getNormalizedVtxos(this.client.indexer, {
23804
+ const { vtxos } = await chunkKMPNH7NS_cjs.getNormalizedVtxos(this.client.indexer, {
23620
23805
  scripts: [scriptHex],
23621
23806
  spendableOnly: true
23622
23807
  });
23623
- return vtxos.filter((v) => !chunk6FTHFJAN_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23808
+ return vtxos.filter((v) => !chunkKMPNH7NS_cjs.hasTerminalSpend(v) && !v.isUnrolled);
23624
23809
  }
23625
23810
  /** Total spendable balance (requires an indexer). */
23626
23811
  async getBalance() {
@@ -23718,7 +23903,7 @@ var ArkadeTransactionBuilder = class {
23718
23903
  this.contract.client.checkpoint
23719
23904
  );
23720
23905
  if (coin.sourceTx) {
23721
- chunk6FTHFJAN_cjs.setArkPsbtField(arkTx, 0, chunk6FTHFJAN_cjs.PrevArkTxField, coin.sourceTx);
23906
+ chunkKMPNH7NS_cjs.setArkPsbtField(arkTx, 0, chunkKMPNH7NS_cjs.PrevArkTxField, coin.sourceTx);
23722
23907
  }
23723
23908
  if (this.fn.arkadeScript) {
23724
23909
  const indexer = this.contract.client.indexer;
@@ -23735,8 +23920,8 @@ var ArkadeTransactionBuilder = class {
23735
23920
  }
23736
23921
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
23737
23922
  if (condition.length > 0) {
23738
- chunk6FTHFJAN_cjs.setArkPsbtField(arkTx, 0, chunk6FTHFJAN_cjs.ConditionWitness, condition);
23739
- chunk6FTHFJAN_cjs.setArkPsbtField(checkpoints[0], 0, chunk6FTHFJAN_cjs.ConditionWitness, condition);
23923
+ chunkKMPNH7NS_cjs.setArkPsbtField(arkTx, 0, chunkKMPNH7NS_cjs.ConditionWitness, condition);
23924
+ chunkKMPNH7NS_cjs.setArkPsbtField(checkpoints[0], 0, chunkKMPNH7NS_cjs.ConditionWitness, condition);
23740
23925
  }
23741
23926
  const packets = [];
23742
23927
  if (this.assetSpecs.length > 0) {
@@ -23775,7 +23960,7 @@ var ArkadeTransactionBuilder = class {
23775
23960
  base.base64.encode(signedArk2.toPSBT()),
23776
23961
  signedCps.map((c) => base.base64.encode(c.toPSBT()))
23777
23962
  );
23778
- const txid = chunk6FTHFJAN_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23963
+ const txid = chunkKMPNH7NS_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
23779
23964
  return {
23780
23965
  txid,
23781
23966
  signedArkTx: res2.signedArkTx,
@@ -23834,23 +24019,23 @@ var ArkadeTransactionBuilder = class {
23834
24019
  }
23835
24020
  buildAssetPacket() {
23836
24021
  const groups = this.assetSpecs.map((s) => {
23837
- const id = typeof s.assetId === "string" ? chunk4C5PMGBB_cjs.AssetId.fromString(s.assetId) : chunk4C5PMGBB_cjs.AssetId.fromBytes(s.assetId);
23838
- return chunk4C5PMGBB_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(
23839
24024
  id,
23840
24025
  null,
23841
- s.inputs.map((i) => chunk4C5PMGBB_cjs.AssetInput.create(i.vin, i.amount)),
23842
- s.outputs.map((o) => chunk4C5PMGBB_cjs.AssetOutput.create(o.vout, o.amount)),
23843
- (s.metadata ?? []).map((m) => chunk4C5PMGBB_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))
23844
24029
  );
23845
24030
  });
23846
- return chunk4C5PMGBB_cjs.Packet.create(groups);
24031
+ return chunkAS3W34MG_cjs.Packet.create(groups);
23847
24032
  }
23848
24033
  witnessBytes(ref) {
23849
- return chunkNPM5YZBC_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
24034
+ return chunkDXLVCFVK_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
23850
24035
  }
23851
24036
  };
23852
24037
  function bindInputs(fn, callArgs) {
23853
- const names = (fn.def.inputs ?? []).map(chunkNPM5YZBC_cjs.inputName);
24038
+ const names = (fn.def.inputs ?? []).map(chunkDXLVCFVK_cjs.inputName);
23854
24039
  if (callArgs.length !== names.length) {
23855
24040
  throw new Error(`${fn.name}: expected ${names.length} argument(s), got ${callArgs.length}`);
23856
24041
  }
@@ -24054,6 +24239,16 @@ function assertNoAssets(railId, req) {
24054
24239
  );
24055
24240
  }
24056
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
+ }
24057
24252
  function resolveAssetAmount(railId, req) {
24058
24253
  const assets = assetsOf(req);
24059
24254
  if (assets.length !== 1) {
@@ -24197,13 +24392,17 @@ function arkRail() {
24197
24392
  const address = arkTarget(req.raw);
24198
24393
  assertNoAssets("ark", req);
24199
24394
  const amt = resolveSendAmount("ark", req.raw, req.amount);
24395
+ const selectedVtxos = selectionOf(req);
24200
24396
  return {
24201
24397
  railId: "ark",
24202
24398
  amount: amt,
24203
24399
  fee: 0,
24204
24400
  total: amt,
24205
24401
  send: async () => makeHandle("ark", async (emit) => {
24206
- 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 });
24207
24406
  const result = { railId: "ark", txid };
24208
24407
  emit({ status: "settled", result });
24209
24408
  return result;
@@ -24226,6 +24425,7 @@ function arkAssetRail() {
24226
24425
  const asset = resolveAssetAmount("ark-asset", req);
24227
24426
  if (req.amount !== void 0) assertSendableAmount("ark-asset", req.amount);
24228
24427
  const carrier = tryResolveSendAmount(req.raw, req.amount) ?? ASSET_CARRIER_SATS;
24428
+ const selectedVtxos = selectionOf(req);
24229
24429
  return {
24230
24430
  railId: "ark-asset",
24231
24431
  amount: carrier,
@@ -24233,11 +24433,8 @@ function arkAssetRail() {
24233
24433
  total: carrier,
24234
24434
  assets: { delivered: asset, spent: asset },
24235
24435
  send: async () => makeHandle("ark-asset", async (emit) => {
24236
- const txid = await ctx.wallet.send({
24237
- address,
24238
- amount: carrier,
24239
- assets: [asset]
24240
- });
24436
+ const recipient = { address, amount: carrier, assets: [asset] };
24437
+ const txid = selectedVtxos ? await ctx.wallet.send({ recipients: [recipient], selectedVtxos }) : await ctx.wallet.send(recipient);
24241
24438
  const result = { railId: "ark-asset", txid };
24242
24439
  emit({ status: "settled", result });
24243
24440
  return result;
@@ -24259,6 +24456,13 @@ function grossUpOffboard(net, feeInfo, script) {
24259
24456
  }
24260
24457
  return { gross, fee: gross - net };
24261
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
+ }
24262
24466
  function onchainRail(deps) {
24263
24467
  if (typeof deps?.feeInfo !== "function") {
24264
24468
  throw new Error("onchain rail: a feeInfo source is required");
@@ -24275,17 +24479,22 @@ function onchainRail(deps) {
24275
24479
  const fees = await deps.feeInfo();
24276
24480
  const script = base.hex.encode(offboardDestinationScript(address));
24277
24481
  const { gross, fee } = grossUpOffboard(amt, fees, script);
24482
+ const selectedVtxos = selectionOf(req);
24483
+ const inputFee = selectedVtxos ? offchainInputFees(selectedVtxos, fees) : 0;
24278
24484
  return {
24279
24485
  railId: "onchain",
24280
24486
  amount: amt,
24281
- fee,
24282
- total: gross,
24487
+ fee: fee + inputFee,
24488
+ total: gross + inputFee,
24283
24489
  send: async () => makeHandle("onchain", async (emit) => {
24284
- const txid = await new Ramps(ctx.wallet).offboard(
24490
+ const ramps = new Ramps(ctx.wallet);
24491
+ const txid = selectedVtxos ? await ramps.offboard(
24285
24492
  address,
24286
24493
  fees,
24287
- BigInt(gross)
24288
- );
24494
+ BigInt(gross),
24495
+ void 0,
24496
+ selectedVtxos
24497
+ ) : await ramps.offboard(address, fees, BigInt(gross));
24289
24498
  const result = { railId: "onchain", txid };
24290
24499
  emit({ status: "settled", result });
24291
24500
  return result;
@@ -24413,6 +24622,7 @@ exports.arkade_exports = arkade_exports;
24413
24622
  exports.assertFinalCommitmentMatchesValidated = assertFinalCommitmentMatchesValidated;
24414
24623
  exports.assertIntentIdUnique = assertIntentIdUnique;
24415
24624
  exports.assertNoAssets = assertNoAssets;
24625
+ exports.assertNoSelection = assertNoSelection;
24416
24626
  exports.assertSendableAmount = assertSendableAmount;
24417
24627
  exports.assertSubmittedArkTxid = assertSubmittedArkTxid;
24418
24628
  exports.assertValidBatchExpiry = assertValidBatchExpiry;
@@ -24515,6 +24725,7 @@ exports.saveVtxosForContract = saveVtxosForContract;
24515
24725
  exports.scriptFromArkAddress = scriptFromArkAddress;
24516
24726
  exports.selectCoinsWithAsset = selectCoinsWithAsset;
24517
24727
  exports.selectVirtualCoins = selectVirtualCoins;
24728
+ exports.selectionOf = selectionOf;
24518
24729
  exports.serializeAssets = serializeAssets;
24519
24730
  exports.serializeExitPackage = serializeExitPackage;
24520
24731
  exports.serializeUtxo = serializeUtxo;
@@ -24534,5 +24745,5 @@ exports.waitForIncomingFunds = waitForIncomingFunds;
24534
24745
  exports.walletFeeSource = walletFeeSource;
24535
24746
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
24536
24747
  exports.withPrevTxs = withPrevTxs;
24537
- //# sourceMappingURL=chunk-U5I3ITV7.cjs.map
24538
- //# sourceMappingURL=chunk-U5I3ITV7.cjs.map
24748
+ //# sourceMappingURL=chunk-WIHSU3YS.cjs.map
24749
+ //# sourceMappingURL=chunk-WIHSU3YS.cjs.map