@arkade-os/sdk 0.4.49 → 0.4.51

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 (64) hide show
  1. package/README.md +33 -8
  2. package/dist/adapters/expo.cjs +4 -4
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +2 -2
  6. package/dist/adapters/indexedDB.cjs +3 -3
  7. package/dist/adapters/indexedDB.js +2 -2
  8. package/dist/{ark-nkSiPYNf.d.cts → ark-9V45Anrs.d.cts} +164 -53
  9. package/dist/{ark-nkSiPYNf.d.ts → ark-9V45Anrs.d.ts} +164 -53
  10. package/dist/{asyncStorageTaskQueue-DdxhsEz6.d.cts → asyncStorageTaskQueue-B6nXJv7m.d.cts} +1 -1
  11. package/dist/{asyncStorageTaskQueue-DCaEE83p.d.ts → asyncStorageTaskQueue-BZjR843B.d.ts} +1 -1
  12. package/dist/{chunk-CPO2UB7L.js → chunk-3AOTJZQ4.js} +3 -3
  13. package/dist/{chunk-CPO2UB7L.js.map → chunk-3AOTJZQ4.js.map} +1 -1
  14. package/dist/{chunk-6UI5BFE7.cjs → chunk-3E4GDBYU.cjs} +7 -7
  15. package/dist/{chunk-6UI5BFE7.cjs.map → chunk-3E4GDBYU.cjs.map} +1 -1
  16. package/dist/{chunk-BLJQV3N4.js → chunk-4KGT3IP2.js} +3 -3
  17. package/dist/{chunk-BLJQV3N4.js.map → chunk-4KGT3IP2.js.map} +1 -1
  18. package/dist/{chunk-XOLH3LFO.cjs → chunk-5AT2NV5G.cjs} +11 -11
  19. package/dist/{chunk-XOLH3LFO.cjs.map → chunk-5AT2NV5G.cjs.map} +1 -1
  20. package/dist/{chunk-HN25T276.js → chunk-6T5BBPKO.js} +3 -3
  21. package/dist/{chunk-HN25T276.js.map → chunk-6T5BBPKO.js.map} +1 -1
  22. package/dist/{chunk-2LAJ3RTH.cjs → chunk-6XF6ZATZ.cjs} +458 -203
  23. package/dist/chunk-6XF6ZATZ.cjs.map +1 -0
  24. package/dist/{chunk-QDXQULVM.cjs → chunk-FHDUEBBC.cjs} +3 -3
  25. package/dist/{chunk-QDXQULVM.cjs.map → chunk-FHDUEBBC.cjs.map} +1 -1
  26. package/dist/{chunk-5QVBJUOG.js → chunk-TS2MTRP4.js} +354 -99
  27. package/dist/chunk-TS2MTRP4.js.map +1 -0
  28. package/dist/contracts/handlers/index.d.cts +3 -3
  29. package/dist/contracts/handlers/index.d.ts +3 -3
  30. package/dist/{delegate-D6Orvyq7.d.ts → delegate-CJkolr2s.d.ts} +1 -1
  31. package/dist/{delegate-Cqqw1T1J.d.cts → delegate-tVTPM4fm.d.cts} +1 -1
  32. package/dist/{index-CWoogah0.d.ts → index-B5Fdwzs_.d.ts} +2 -2
  33. package/dist/{index-Yd4hecbM.d.cts → index-BBAffp_8.d.cts} +2 -2
  34. package/dist/index.cjs +145 -145
  35. package/dist/index.d.cts +24 -8
  36. package/dist/index.d.ts +24 -8
  37. package/dist/index.js +2 -2
  38. package/dist/repositories/realm/index.cjs +17 -17
  39. package/dist/repositories/realm/index.d.cts +2 -2
  40. package/dist/repositories/realm/index.d.ts +2 -2
  41. package/dist/repositories/realm/index.js +3 -3
  42. package/dist/repositories/sqlite/index.cjs +16 -16
  43. package/dist/repositories/sqlite/index.d.cts +2 -2
  44. package/dist/repositories/sqlite/index.d.ts +2 -2
  45. package/dist/repositories/sqlite/index.js +3 -3
  46. package/dist/{taskRunner-BjB5QINR.d.cts → taskRunner-4CrJaWHv.d.cts} +1 -1
  47. package/dist/{taskRunner-Dw7xs60Q.d.ts → taskRunner-TgdjRf_b.d.ts} +1 -1
  48. package/dist/wallet/expo/background.cjs +12 -12
  49. package/dist/wallet/expo/background.d.cts +3 -3
  50. package/dist/wallet/expo/background.d.ts +3 -3
  51. package/dist/wallet/expo/background.js +4 -4
  52. package/dist/wallet/expo/index.cjs +12 -12
  53. package/dist/wallet/expo/index.d.cts +4 -4
  54. package/dist/wallet/expo/index.d.ts +4 -4
  55. package/dist/wallet/expo/index.js +3 -3
  56. package/dist/{wallet-DyUHrPyN.d.ts → wallet-BBfhZx_Z.d.cts} +22 -3
  57. package/dist/{wallet-CGkWu3xV.d.cts → wallet-CSSTN8Yc.d.ts} +22 -3
  58. package/dist/worker/expo/index.cjs +7 -7
  59. package/dist/worker/expo/index.d.cts +4 -4
  60. package/dist/worker/expo/index.d.ts +4 -4
  61. package/dist/worker/expo/index.js +3 -3
  62. package/package.json +1 -1
  63. package/dist/chunk-2LAJ3RTH.cjs.map +0 -1
  64. package/dist/chunk-5QVBJUOG.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkQDXQULVM_cjs = require('./chunk-QDXQULVM.cjs');
3
+ var chunkFHDUEBBC_cjs = require('./chunk-FHDUEBBC.cjs');
4
4
  var chunkLJQ2VQBE_cjs = require('./chunk-LJQ2VQBE.cjs');
5
5
  var chunkE7HB3GKK_cjs = require('./chunk-E7HB3GKK.cjs');
6
6
  var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
@@ -185,7 +185,7 @@ var TreeSignerSession = class _TreeSignerSession {
185
185
  noncesByPubkey.set(base.hex.encode(myPublicKey.subarray(1)), myNonce);
186
186
  const tx = this.graph.find(txid);
187
187
  if (!tx) throw new Error(`missing tx for txid ${txid}`);
188
- const cosigners = chunkQDXQULVM_cjs.getArkPsbtFields(tx.root, 0, chunkQDXQULVM_cjs.CosignerPublicKey).map(
188
+ const cosigners = chunkFHDUEBBC_cjs.getArkPsbtFields(tx.root, 0, chunkFHDUEBBC_cjs.CosignerPublicKey).map(
189
189
  (c) => base.hex.encode(c.key.subarray(1))
190
190
  // xonly pubkey
191
191
  );
@@ -237,7 +237,7 @@ var TreeSignerSession = class _TreeSignerSession {
237
237
  if (!aggNonce) throw new Error("missing aggregate nonce");
238
238
  const prevoutAmounts = [];
239
239
  const prevoutScripts = [];
240
- const cosigners = chunkQDXQULVM_cjs.getArkPsbtFields(g.root, 0, chunkQDXQULVM_cjs.CosignerPublicKey).map((c) => c.key);
240
+ const cosigners = chunkFHDUEBBC_cjs.getArkPsbtFields(g.root, 0, chunkFHDUEBBC_cjs.CosignerPublicKey).map((c) => c.key);
241
241
  const { finalKey } = aggregateKeys(cosigners, true, {
242
242
  taprootTweak: this.scriptRoot
243
243
  });
@@ -986,14 +986,14 @@ var RestDelegateProvider = class {
986
986
  */
987
987
  async delegate(intent, forfeitTxs, options) {
988
988
  const url = `${this.url}/v1/delegate`;
989
- const response = await chunkQDXQULVM_cjs.baseFetch(url, {
989
+ const response = await chunkFHDUEBBC_cjs.baseFetch(url, {
990
990
  method: "POST",
991
991
  headers: {
992
992
  "Content-Type": "application/json"
993
993
  },
994
994
  body: JSON.stringify({
995
995
  intent: {
996
- message: chunkQDXQULVM_cjs.Intent.encodeMessage(intent.message),
996
+ message: chunkFHDUEBBC_cjs.Intent.encodeMessage(intent.message),
997
997
  proof: intent.proof
998
998
  },
999
999
  forfeit_txs: forfeitTxs,
@@ -1013,7 +1013,7 @@ var RestDelegateProvider = class {
1013
1013
  */
1014
1014
  async getDelegateInfo() {
1015
1015
  const url = `${this.url}/v1/delegator/info`;
1016
- const response = await chunkQDXQULVM_cjs.rateGate.runHttp(url, () => chunkQDXQULVM_cjs.baseFetch(url));
1016
+ const response = await chunkFHDUEBBC_cjs.rateGate.runHttp(url, () => chunkFHDUEBBC_cjs.baseFetch(url));
1017
1017
  if (!response.ok) {
1018
1018
  const errorText2 = await response.text();
1019
1019
  throw new Error(`Failed to get delegate info: ${errorText2}`);
@@ -1049,14 +1049,14 @@ var EsploraProvider = class {
1049
1049
  pollingInterval;
1050
1050
  forcePolling;
1051
1051
  async getCoins(address) {
1052
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1052
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/address/${address}/utxo`);
1053
1053
  if (!response.ok) {
1054
1054
  throw new Error(`Failed to fetch UTXOs: ${response.statusText}`);
1055
1055
  }
1056
1056
  return response.json();
1057
1057
  }
1058
1058
  async getFeeRate() {
1059
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1059
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/fee-estimates`);
1060
1060
  if (response.status === 404) {
1061
1061
  return void 0;
1062
1062
  }
@@ -1077,7 +1077,7 @@ var EsploraProvider = class {
1077
1077
  }
1078
1078
  }
1079
1079
  async getTxOutspends(txid) {
1080
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1080
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/outspends`);
1081
1081
  if (!response.ok) {
1082
1082
  const error = await response.text();
1083
1083
  throw new Error(`Failed to get transaction outspends: ${error}`);
@@ -1085,7 +1085,7 @@ var EsploraProvider = class {
1085
1085
  return response.json();
1086
1086
  }
1087
1087
  async getTransactions(address) {
1088
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1088
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/address/${address}/txs`);
1089
1089
  if (!response.ok) {
1090
1090
  const error = await response.text();
1091
1091
  throw new Error(`Failed to get transactions: ${error}`);
@@ -1093,7 +1093,7 @@ var EsploraProvider = class {
1093
1093
  return response.json();
1094
1094
  }
1095
1095
  async getTxStatus(txid) {
1096
- const txresponse = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1096
+ const txresponse = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx/${txid}`);
1097
1097
  if (!txresponse.ok) {
1098
1098
  throw new Error(txresponse.statusText);
1099
1099
  }
@@ -1101,7 +1101,7 @@ var EsploraProvider = class {
1101
1101
  if (!tx.status.confirmed) {
1102
1102
  return { confirmed: false };
1103
1103
  }
1104
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1104
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx/${txid}/status`);
1105
1105
  if (!response.ok) {
1106
1106
  throw new Error(`Failed to get transaction status: ${response.statusText}`);
1107
1107
  }
@@ -1185,7 +1185,7 @@ var EsploraProvider = class {
1185
1185
  return stopFunc;
1186
1186
  }
1187
1187
  async getChainTip() {
1188
- const tipBlocks = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/blocks`);
1188
+ const tipBlocks = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/blocks`);
1189
1189
  if (!tipBlocks.ok) {
1190
1190
  throw new Error(`Failed to get chain tip: ${tipBlocks.statusText}`);
1191
1191
  }
@@ -1204,7 +1204,7 @@ var EsploraProvider = class {
1204
1204
  };
1205
1205
  }
1206
1206
  async broadcastPackage(parent, child) {
1207
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
1207
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/txs/package`, {
1208
1208
  method: "POST",
1209
1209
  headers: {
1210
1210
  "Content-Type": "application/json"
@@ -1218,7 +1218,7 @@ var EsploraProvider = class {
1218
1218
  return response.json();
1219
1219
  }
1220
1220
  async broadcastTx(tx) {
1221
- const response = await chunkQDXQULVM_cjs.baseFetch(`${this.baseUrl}/tx`, {
1221
+ const response = await chunkFHDUEBBC_cjs.baseFetch(`${this.baseUrl}/tx`, {
1222
1222
  method: "POST",
1223
1223
  headers: {
1224
1224
  "Content-Type": "text/plain"
@@ -1380,7 +1380,7 @@ function findP2AOutput(tx) {
1380
1380
  var CHILD_DUST_AMOUNT = 546;
1381
1381
  function buildAnchorChild(params) {
1382
1382
  const { parent, feeRate, fundingCoins, changeAddress, tapInternalKey, network } = params;
1383
- const child = new chunkQDXQULVM_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
1383
+ const child = new chunkFHDUEBBC_cjs.Transaction({ version: 3, allowLegacyWitnessUtxo: true });
1384
1384
  child.addInput(findP2AOutput(parent));
1385
1385
  const estimator = TxWeightEstimator.create().addP2AInput();
1386
1386
  for (const _ of fundingCoins) {
@@ -1428,7 +1428,7 @@ function buildForfeitTx(inputs, forfeitPkScript, txLocktime) {
1428
1428
  );
1429
1429
  }
1430
1430
  function buildForfeitTxWithOutput(inputs, output, txLocktime) {
1431
- const tx = new chunkQDXQULVM_cjs.Transaction({
1431
+ const tx = new chunkFHDUEBBC_cjs.Transaction({
1432
1432
  version: 3,
1433
1433
  lockTime: txLocktime
1434
1434
  });
@@ -1504,7 +1504,7 @@ function validateVtxoTxGraph(graph, roundTransaction, sweepTapTreeRoot) {
1504
1504
  if (previousScriptKey.length !== 32) {
1505
1505
  throw new Error(`parent output ${childIndex} has invalid script`);
1506
1506
  }
1507
- const cosigners = chunkQDXQULVM_cjs.getArkPsbtFields(child.root, 0, chunkQDXQULVM_cjs.CosignerPublicKey);
1507
+ const cosigners = chunkFHDUEBBC_cjs.getArkPsbtFields(child.root, 0, chunkFHDUEBBC_cjs.CosignerPublicKey);
1508
1508
  if (cosigners.length === 0) {
1509
1509
  throw ErrMissingCosignersPublicKeys;
1510
1510
  }
@@ -1562,7 +1562,7 @@ var EmulatorPacket = class _EmulatorPacket {
1562
1562
  return new _EmulatorPacket(entries);
1563
1563
  }
1564
1564
  static fromBytes(data) {
1565
- const reader = new chunkQDXQULVM_cjs.BufferReader(data);
1565
+ const reader = new chunkFHDUEBBC_cjs.BufferReader(data);
1566
1566
  const entryCount = reader.readCompactSize();
1567
1567
  const entries = [];
1568
1568
  for (let i = 0; i < entryCount; i++) {
@@ -1580,7 +1580,7 @@ var EmulatorPacket = class _EmulatorPacket {
1580
1580
  return _EmulatorPacket.PACKET_TYPE;
1581
1581
  }
1582
1582
  serialize() {
1583
- const writer = new chunkQDXQULVM_cjs.BufferWriter();
1583
+ const writer = new chunkFHDUEBBC_cjs.BufferWriter();
1584
1584
  writer.writeCompactSize(this.entries.length);
1585
1585
  for (const entry of this.entries) {
1586
1586
  writer.writeUint16LE(entry.vin);
@@ -1667,7 +1667,7 @@ var Extension = class _Extension {
1667
1667
  `expected magic prefix ${base.hex.encode(ARKADE_MAGIC)}, got ${base.hex.encode(payload.slice(0, Math.min(payload.length, ARKADE_MAGIC.length)))}`
1668
1668
  );
1669
1669
  }
1670
- const reader = new chunkQDXQULVM_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
1670
+ const reader = new chunkFHDUEBBC_cjs.BufferReader(payload.slice(ARKADE_MAGIC.length));
1671
1671
  const packets = [];
1672
1672
  while (reader.remaining() > 0) {
1673
1673
  const packetType = reader.readByte();
@@ -1741,7 +1741,7 @@ var Extension = class _Extension {
1741
1741
  */
1742
1742
  getAssetPacket() {
1743
1743
  for (const p of this.packets) {
1744
- if (p instanceof chunkQDXQULVM_cjs.Packet) {
1744
+ if (p instanceof chunkFHDUEBBC_cjs.Packet) {
1745
1745
  return p;
1746
1746
  }
1747
1747
  }
@@ -1779,8 +1779,8 @@ var Extension = class _Extension {
1779
1779
  };
1780
1780
  function parsePacket(packetType, data) {
1781
1781
  switch (packetType) {
1782
- case chunkQDXQULVM_cjs.Packet.PACKET_TYPE:
1783
- return chunkQDXQULVM_cjs.Packet.fromBytes(data);
1782
+ case chunkFHDUEBBC_cjs.Packet.PACKET_TYPE:
1783
+ return chunkFHDUEBBC_cjs.Packet.fromBytes(data);
1784
1784
  case EmulatorPacket.PACKET_TYPE:
1785
1785
  return EmulatorPacket.fromBytes(data);
1786
1786
  default:
@@ -2077,7 +2077,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
2077
2077
  const existing = inputsByAssetId.get(asset.assetId);
2078
2078
  inputsByAssetId.set(asset.assetId, [
2079
2079
  ...existing ?? [],
2080
- chunkQDXQULVM_cjs.AssetInput.create(inputIndex, asset.amount)
2080
+ chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount)
2081
2081
  ]);
2082
2082
  }
2083
2083
  }
@@ -2089,7 +2089,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
2089
2089
  const existing = outputsByAssetId.get(asset.assetId);
2090
2090
  outputsByAssetId.set(asset.assetId, [
2091
2091
  ...existing ?? [],
2092
- chunkQDXQULVM_cjs.AssetOutput.create(outputIndex, asset.amount)
2092
+ chunkFHDUEBBC_cjs.AssetOutput.create(outputIndex, asset.amount)
2093
2093
  ]);
2094
2094
  }
2095
2095
  }
@@ -2100,7 +2100,7 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
2100
2100
  const existing = outputsByAssetId.get(asset.assetId);
2101
2101
  outputsByAssetId.set(asset.assetId, [
2102
2102
  ...existing ?? [],
2103
- chunkQDXQULVM_cjs.AssetOutput.create(outputIndex, asset.amount)
2103
+ chunkFHDUEBBC_cjs.AssetOutput.create(outputIndex, asset.amount)
2104
2104
  ]);
2105
2105
  }
2106
2106
  }
@@ -2109,11 +2109,11 @@ function createAssetPacket(assetInputs, receivers, changeReceiver) {
2109
2109
  for (const assetIdStr of allAssetIds) {
2110
2110
  const inputs = inputsByAssetId.get(assetIdStr);
2111
2111
  const outputs = outputsByAssetId.get(assetIdStr);
2112
- const assetId = chunkQDXQULVM_cjs.AssetId.fromString(assetIdStr);
2113
- const group = chunkQDXQULVM_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
2112
+ const assetId = chunkFHDUEBBC_cjs.AssetId.fromString(assetIdStr);
2113
+ const group = chunkFHDUEBBC_cjs.AssetGroup.create(assetId, null, inputs ?? [], outputs ?? [], []);
2114
2114
  groups.push(group);
2115
2115
  }
2116
- return chunkQDXQULVM_cjs.Packet.create(groups);
2116
+ return chunkFHDUEBBC_cjs.Packet.create(groups);
2117
2117
  }
2118
2118
  function selectCoinsWithAsset(coins, assetId, requiredAmount) {
2119
2119
  const coinsWithAsset = coins.filter((coin) => coin.assets?.some((a) => a.assetId === assetId));
@@ -2230,7 +2230,7 @@ function buildVirtualTx(inputs, outputs) {
2230
2230
  }
2231
2231
  }
2232
2232
  }
2233
- const tx = new chunkQDXQULVM_cjs.Transaction({
2233
+ const tx = new chunkFHDUEBBC_cjs.Transaction({
2234
2234
  version: 3,
2235
2235
  lockTime: Number(lockTime)
2236
2236
  });
@@ -2245,7 +2245,7 @@ function buildVirtualTx(inputs, outputs) {
2245
2245
  },
2246
2246
  tapLeafScript: [input.tapLeafScript]
2247
2247
  });
2248
- chunkQDXQULVM_cjs.setArkPsbtField(tx, i, chunkQDXQULVM_cjs.VtxoTaprootTree, input.tapTree);
2248
+ chunkFHDUEBBC_cjs.setArkPsbtField(tx, i, chunkFHDUEBBC_cjs.VtxoTaprootTree, input.tapTree);
2249
2249
  }
2250
2250
  for (const output of outputs) {
2251
2251
  tx.addOutput(output);
@@ -2428,14 +2428,14 @@ async function submitOffchainTx(provider, offchainTx, signer, hooks) {
2428
2428
  let finalCheckpoints;
2429
2429
  if (userSignedCheckpoints) {
2430
2430
  finalCheckpoints = signedCheckpointTxs.map((c, i) => {
2431
- const serverSigned = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(c));
2431
+ const serverSigned = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(c));
2432
2432
  combineTapscriptSigs(userSignedCheckpoints[i], serverSigned);
2433
2433
  return base.base64.encode(serverSigned.toPSBT());
2434
2434
  });
2435
2435
  } else {
2436
2436
  finalCheckpoints = await Promise.all(
2437
2437
  signedCheckpointTxs.map(async (c) => {
2438
- const tx = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(c));
2438
+ const tx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(c));
2439
2439
  const signed = await signer.signCheckpoint(tx);
2440
2440
  return base.base64.encode(signed.toPSBT());
2441
2441
  })
@@ -3339,7 +3339,7 @@ var VtxoManager = class _VtxoManager {
3339
3339
  `Sweep not economical: output ${outputAmount} sats after ${fee} sats fee is below dust (${dustAmount} sats)`
3340
3340
  );
3341
3341
  }
3342
- const tx = new chunkQDXQULVM_cjs.Transaction();
3342
+ const tx = new chunkFHDUEBBC_cjs.Transaction();
3343
3343
  for (const utxo of expiredUtxos) {
3344
3344
  const utxoScript = chunkE7HB3GKK_cjs.VtxoScript.decode(utxo.tapTree);
3345
3345
  const utxoExitLeaf = utxoScript.leaves.find(
@@ -3998,8 +3998,8 @@ var VtxoManager = class _VtxoManager {
3998
3998
  * or doesn't carry the metadata.
3999
3999
  */
4000
4000
  extractSpentOutpoint(error) {
4001
- const ark = chunkQDXQULVM_cjs.maybeArkError(error);
4002
- if (!chunkQDXQULVM_cjs.isArkError(ark, chunkQDXQULVM_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
4001
+ const ark = chunkFHDUEBBC_cjs.maybeArkError(error);
4002
+ if (!chunkFHDUEBBC_cjs.isArkError(ark, chunkFHDUEBBC_cjs.ArkErrorName.VTXO_ALREADY_SPENT)) return void 0;
4003
4003
  const raw = ark.metadata?.vtxo_outpoint;
4004
4004
  if (typeof raw !== "string") return void 0;
4005
4005
  const [txid, voutStr] = raw.split(":");
@@ -4734,7 +4734,7 @@ async function captureExitBranch(params) {
4734
4734
  const nonCommitment = ordered.filter((c) => chainTxTypeToChainedExit(c.type) !== 1 /* Commitment */).map((c) => c.txid);
4735
4735
  if (nonCommitment.length > 0) {
4736
4736
  for (const psbt of await resolver.getVirtualTxs(nonCommitment)) {
4737
- psbtByTxid.set(chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
4737
+ psbtByTxid.set(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
4738
4738
  }
4739
4739
  }
4740
4740
  }
@@ -4795,7 +4795,7 @@ var IndexerExitDataSource = class {
4795
4795
  pageSize: chunkE7HB3GKK_cjs.DEFAULT_PAGE_SIZE
4796
4796
  });
4797
4797
  for (const psbt of txs) {
4798
- out.set(chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
4798
+ out.set(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
4799
4799
  }
4800
4800
  hasMore = page ? txs.length === chunkE7HB3GKK_cjs.DEFAULT_PAGE_SIZE : false;
4801
4801
  pageIndex++;
@@ -4818,7 +4818,7 @@ function chainedTxTypeToChainTxType(t) {
4818
4818
  }
4819
4819
  }
4820
4820
  function psbtInputTxids(psbtBase64) {
4821
- const tx = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
4821
+ const tx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
4822
4822
  const ids = [];
4823
4823
  for (let i = 0; i < tx.inputsLength; i++) {
4824
4824
  const txid = tx.getInput(i).txid;
@@ -4921,7 +4921,7 @@ function createExitChainResolver(params) {
4921
4921
 
4922
4922
  // src/providers/availability.ts
4923
4923
  function isRetryableProviderError(error) {
4924
- return error instanceof chunkQDXQULVM_cjs.ProviderUnavailableError || error instanceof chunkQDXQULVM_cjs.FetchError || chunkQDXQULVM_cjs.isFetchTimeoutError(error);
4924
+ return error instanceof chunkFHDUEBBC_cjs.ProviderUnavailableError || error instanceof chunkFHDUEBBC_cjs.FetchError || chunkFHDUEBBC_cjs.isFetchTimeoutError(error);
4925
4925
  }
4926
4926
 
4927
4927
  // src/utils/syncCursors.ts
@@ -5174,7 +5174,7 @@ async function resolveArkInfo(arkProvider, walletRepository) {
5174
5174
  if (!isRetryableProviderError(err)) throw err;
5175
5175
  const snapshot = await loadArkInfoSnapshot(walletRepository);
5176
5176
  if (!snapshot) {
5177
- throw new chunkQDXQULVM_cjs.ProviderUnavailableError(
5177
+ throw new chunkFHDUEBBC_cjs.ProviderUnavailableError(
5178
5178
  "Arkade server info is unavailable and no cached snapshot exists",
5179
5179
  { cause: err }
5180
5180
  );
@@ -5709,7 +5709,7 @@ var AssetManager = class extends ReadonlyAssetManager {
5709
5709
  const virtualCoins = await this.wallet.getVtxos({
5710
5710
  withRecoverable: false
5711
5711
  });
5712
- const controlAssetRef = params.controlAssetId ? chunkQDXQULVM_cjs.AssetRef.fromId(chunkQDXQULVM_cjs.AssetId.fromString(params.controlAssetId)) : null;
5712
+ const controlAssetRef = params.controlAssetId ? chunkFHDUEBBC_cjs.AssetRef.fromId(chunkFHDUEBBC_cjs.AssetId.fromString(params.controlAssetId)) : null;
5713
5713
  const coinSelection = selectVirtualCoins(virtualCoins, Number(this.wallet.dustAmount));
5714
5714
  let totalBtcSelected = 0n;
5715
5715
  const assetChanges = /* @__PURE__ */ new Map();
@@ -5722,8 +5722,8 @@ var AssetManager = class extends ReadonlyAssetManager {
5722
5722
  }
5723
5723
  }
5724
5724
  const groups = [];
5725
- const issuedAssetOutput = chunkQDXQULVM_cjs.AssetOutput.create(0, params.amount);
5726
- const issuedAssetGroup = chunkQDXQULVM_cjs.AssetGroup.create(
5725
+ const issuedAssetOutput = chunkFHDUEBBC_cjs.AssetOutput.create(0, params.amount);
5726
+ const issuedAssetGroup = chunkFHDUEBBC_cjs.AssetGroup.create(
5727
5727
  null,
5728
5728
  controlAssetRef,
5729
5729
  [],
@@ -5738,15 +5738,15 @@ var AssetManager = class extends ReadonlyAssetManager {
5738
5738
  for (const [inputIndex, assets] of assetInputs) {
5739
5739
  for (const asset of assets) {
5740
5740
  if (asset.assetId !== assetId) continue;
5741
- changeInputs.push(chunkQDXQULVM_cjs.AssetInput.create(inputIndex, asset.amount));
5741
+ changeInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
5742
5742
  }
5743
5743
  }
5744
5744
  groups.push(
5745
- chunkQDXQULVM_cjs.AssetGroup.create(
5746
- chunkQDXQULVM_cjs.AssetId.fromString(assetId),
5745
+ chunkFHDUEBBC_cjs.AssetGroup.create(
5746
+ chunkFHDUEBBC_cjs.AssetId.fromString(assetId),
5747
5747
  null,
5748
5748
  changeInputs,
5749
- [chunkQDXQULVM_cjs.AssetOutput.create(0, amount)],
5749
+ [chunkFHDUEBBC_cjs.AssetOutput.create(0, amount)],
5750
5750
  []
5751
5751
  )
5752
5752
  );
@@ -5759,7 +5759,7 @@ var AssetManager = class extends ReadonlyAssetManager {
5759
5759
  script: outputAddress.pkScript,
5760
5760
  amount: BigInt(totalBtcSelected)
5761
5761
  },
5762
- Extension.create([chunkQDXQULVM_cjs.Packet.create(groups)]).txOut()
5762
+ Extension.create([chunkFHDUEBBC_cjs.Packet.create(groups)]).txOut()
5763
5763
  ];
5764
5764
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(
5765
5765
  coinSelection.inputs,
@@ -5767,7 +5767,7 @@ var AssetManager = class extends ReadonlyAssetManager {
5767
5767
  );
5768
5768
  return {
5769
5769
  arkTxId: arkTxid,
5770
- assetId: chunkQDXQULVM_cjs.AssetId.create(arkTxid, 0).toString()
5770
+ assetId: chunkFHDUEBBC_cjs.AssetId.create(arkTxid, 0).toString()
5771
5771
  };
5772
5772
  }
5773
5773
  /**
@@ -5839,16 +5839,16 @@ var AssetManager = class extends ReadonlyAssetManager {
5839
5839
  for (const [inputIndex, assets] of assetInputs) {
5840
5840
  for (const asset of assets) {
5841
5841
  if (asset.assetId !== params.assetId) continue;
5842
- reissueInputs.push(chunkQDXQULVM_cjs.AssetInput.create(inputIndex, asset.amount));
5842
+ reissueInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
5843
5843
  }
5844
5844
  }
5845
5845
  const totalAssetAmount = assetToReissueAmount + params.amount;
5846
- const reissueAssetIdObj = chunkQDXQULVM_cjs.AssetId.fromString(params.assetId);
5847
- const reissueAssetGroup = chunkQDXQULVM_cjs.AssetGroup.create(
5846
+ const reissueAssetIdObj = chunkFHDUEBBC_cjs.AssetId.fromString(params.assetId);
5847
+ const reissueAssetGroup = chunkFHDUEBBC_cjs.AssetGroup.create(
5848
5848
  reissueAssetIdObj,
5849
5849
  null,
5850
5850
  reissueInputs,
5851
- [chunkQDXQULVM_cjs.AssetOutput.create(0, totalAssetAmount)],
5851
+ [chunkFHDUEBBC_cjs.AssetOutput.create(0, totalAssetAmount)],
5852
5852
  []
5853
5853
  );
5854
5854
  const groups = [reissueAssetGroup];
@@ -5857,15 +5857,15 @@ var AssetManager = class extends ReadonlyAssetManager {
5857
5857
  for (const [inputIndex, assets] of assetInputs) {
5858
5858
  for (const asset of assets) {
5859
5859
  if (asset.assetId !== assetId) continue;
5860
- changeInputs.push(chunkQDXQULVM_cjs.AssetInput.create(inputIndex, asset.amount));
5860
+ changeInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
5861
5861
  }
5862
5862
  }
5863
5863
  groups.push(
5864
- chunkQDXQULVM_cjs.AssetGroup.create(
5865
- chunkQDXQULVM_cjs.AssetId.fromString(assetId),
5864
+ chunkFHDUEBBC_cjs.AssetGroup.create(
5865
+ chunkFHDUEBBC_cjs.AssetId.fromString(assetId),
5866
5866
  null,
5867
5867
  changeInputs,
5868
- [chunkQDXQULVM_cjs.AssetOutput.create(0, amount)],
5868
+ [chunkFHDUEBBC_cjs.AssetOutput.create(0, amount)],
5869
5869
  []
5870
5870
  )
5871
5871
  );
@@ -5877,7 +5877,7 @@ var AssetManager = class extends ReadonlyAssetManager {
5877
5877
  script: outputAddress.pkScript,
5878
5878
  amount: BigInt(totalBtcSelected)
5879
5879
  },
5880
- Extension.create([chunkQDXQULVM_cjs.Packet.create(groups)]).txOut()
5880
+ Extension.create([chunkFHDUEBBC_cjs.Packet.create(groups)]).txOut()
5881
5881
  ];
5882
5882
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
5883
5883
  return arkTxid;
@@ -5944,15 +5944,15 @@ var AssetManager = class extends ReadonlyAssetManager {
5944
5944
  for (const [inputIndex, assets] of assetInputs) {
5945
5945
  for (const asset of assets) {
5946
5946
  if (asset.assetId !== assetId) continue;
5947
- changeInputs.push(chunkQDXQULVM_cjs.AssetInput.create(inputIndex, asset.amount));
5947
+ changeInputs.push(chunkFHDUEBBC_cjs.AssetInput.create(inputIndex, asset.amount));
5948
5948
  }
5949
5949
  }
5950
5950
  groups.push(
5951
- chunkQDXQULVM_cjs.AssetGroup.create(
5952
- chunkQDXQULVM_cjs.AssetId.fromString(assetId),
5951
+ chunkFHDUEBBC_cjs.AssetGroup.create(
5952
+ chunkFHDUEBBC_cjs.AssetId.fromString(assetId),
5953
5953
  null,
5954
5954
  changeInputs,
5955
- amount > 0n ? [chunkQDXQULVM_cjs.AssetOutput.create(0, amount)] : [],
5955
+ amount > 0n ? [chunkFHDUEBBC_cjs.AssetOutput.create(0, amount)] : [],
5956
5956
  []
5957
5957
  )
5958
5958
  );
@@ -5964,7 +5964,7 @@ var AssetManager = class extends ReadonlyAssetManager {
5964
5964
  script: outputAddress.pkScript,
5965
5965
  amount: BigInt(totalBtcSelected)
5966
5966
  },
5967
- Extension.create([chunkQDXQULVM_cjs.Packet.create(groups)]).txOut()
5967
+ Extension.create([chunkFHDUEBBC_cjs.Packet.create(groups)]).txOut()
5968
5968
  ];
5969
5969
  const { arkTxid } = await this.wallet.buildAndSubmitOffchainTx(selectedCoins, outputs);
5970
5970
  return arkTxid;
@@ -5989,7 +5989,7 @@ function castMetadata(metadata) {
5989
5989
  } else {
5990
5990
  throw new Error("Invalid metadata value type");
5991
5991
  }
5992
- md.push(chunkQDXQULVM_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
5992
+ md.push(chunkFHDUEBBC_cjs.Metadata.create(textEncoder.encode(key), valueBytes));
5993
5993
  }
5994
5994
  return md;
5995
5995
  }
@@ -6273,7 +6273,7 @@ async function makeSignedDelegateIntent(identity, coins, outputs, onchainOutputs
6273
6273
  expire_at: 0,
6274
6274
  cosigners_public_keys: cosignerPubKeys
6275
6275
  };
6276
- const proof = chunkQDXQULVM_cjs.Intent.create(message, coins, outputs);
6276
+ const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, outputs);
6277
6277
  const signedProof = await identity.sign(proof);
6278
6278
  return {
6279
6279
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -8136,10 +8136,10 @@ var ContractWatcher = class {
8136
8136
  /**
8137
8137
  * Add a contract to be watched.
8138
8138
  *
8139
- * Active contracts are immediately subscribed.
8139
+ * Once watching, every contract is subscribed and polled whatever
8140
+ * its state.
8140
8141
  *
8141
- * All contracts are polled to discover any existing virtual outputs
8142
- * (which may cause them to be watched even if inactive).
8142
+ * @see getWatchedContracts
8143
8143
  */
8144
8144
  async addContract(contract) {
8145
8145
  const state = {
@@ -8207,18 +8207,18 @@ var ContractWatcher = class {
8207
8207
  return Array.from(this.contracts.values()).map((s) => s.contract);
8208
8208
  }
8209
8209
  /**
8210
- * Contracts the watcher is actually tracking:
8211
- * - all active contracts, plus
8212
- * - inactive contracts that still hold known virtual outputs
8213
- * (the subscription keeps watching them so `vtxo_spent` events for
8214
- * those unspent outputs are still observed).
8210
+ * Every registered contract, retired (`inactive`) ones included.
8215
8211
  *
8216
- * This is the single source of truth for "contracts whose VTXO state
8217
- * we still care about" callers and the subscription itself fan out
8218
- * over the same set so nothing is reconciled that isn't also watched.
8212
+ * Feeds both the subscription and the indexer sweep scope, so
8213
+ * narrowing it drops a contract from every background channel at
8214
+ * once. Nothing may be narrowed out: an Ark receive address can be
8215
+ * paid again after the wallet has rotated past it, and a payment
8216
+ * that lands outside every background channel is invisible until
8217
+ * some foreground read happens to sweep it. Retirement therefore
8218
+ * governs receive-address selection, not coverage.
8219
8219
  */
8220
8220
  getWatchedContracts() {
8221
- return Array.from(this.contracts.values()).filter((s) => s.contract.state === "active" || s.lastKnownVtxos.size > 0).map((s) => s.contract);
8221
+ return this.getAllContracts();
8222
8222
  }
8223
8223
  /**
8224
8224
  * Get virtual outputs for contracts, grouped by contract script.
@@ -8247,7 +8247,7 @@ var ContractWatcher = class {
8247
8247
  return new Map(results.flat(1));
8248
8248
  }
8249
8249
  /**
8250
- * Start watching for virtual output events across all active contracts.
8250
+ * Start watching for virtual output events across all watched contracts.
8251
8251
  */
8252
8252
  async startWatching(callback) {
8253
8253
  if (this.isWatching) {
@@ -8298,7 +8298,7 @@ var ContractWatcher = class {
8298
8298
  return this.connectionState;
8299
8299
  }
8300
8300
  /**
8301
- * Force a poll of all active contracts.
8301
+ * Force a poll of all watched contracts.
8302
8302
  * Useful for manual refresh or after app resume.
8303
8303
  */
8304
8304
  async forcePoll() {
@@ -8322,7 +8322,7 @@ var ContractWatcher = class {
8322
8322
  this.connectionState = "connected";
8323
8323
  this.reconnectAttempts = 0;
8324
8324
  this.listenLoop().catch((e) => {
8325
- if (chunkQDXQULVM_cjs.isEventSourceError(e)) {
8325
+ if (chunkFHDUEBBC_cjs.isEventSourceError(e)) {
8326
8326
  console.debug("ContractWatcher subscription disconnected; reconnecting");
8327
8327
  } else {
8328
8328
  console.error(e);
@@ -8486,7 +8486,7 @@ var ContractWatcher = class {
8486
8486
  /**
8487
8487
  * Update the subscription with scripts that should be watched.
8488
8488
  *
8489
- * Watches both active contracts and contracts with virtual outputs.
8489
+ * @see getWatchedContracts
8490
8490
  */
8491
8491
  async updateSubscription() {
8492
8492
  const scriptsToWatch = this.getWatchedContracts().map((c) => c.script);
@@ -8735,6 +8735,9 @@ function dedupeOutpoints(outpoints) {
8735
8735
  function areCoalescibleContractTypes(a, b) {
8736
8736
  return a === "default" && b === "boarding" || a === "boarding" && b === "default";
8737
8737
  }
8738
+ function toWatchOnlyContract(params) {
8739
+ return { ...params, state: params.state ?? "active", createdAt: Date.now() };
8740
+ }
8738
8741
  var SCAN_MAX_INDEX = 1e4;
8739
8742
  var DEFAULT_SCAN_BATCH = 10;
8740
8743
  var ContractManager = class _ContractManager {
@@ -8747,6 +8750,12 @@ var ContractManager = class _ContractManager {
8747
8750
  syncDegradedReason;
8748
8751
  /** Epoch-ms of the last successful provider sync, if any. */
8749
8752
  lastSyncedAt;
8753
+ /** Speculative look-ahead scripts, keyed by script. @see LookAheadEntry */
8754
+ lookAheadEntries = /* @__PURE__ */ new Map();
8755
+ /** In-flight look-ahead drain, if any. @see scheduleLookAheadDrain */
8756
+ lookAheadDrain;
8757
+ /** A refill was requested while a drain was running. */
8758
+ lookAheadDirty = false;
8750
8759
  constructor(config) {
8751
8760
  this.config = config;
8752
8761
  this.watcher = new ContractWatcher({
@@ -8759,8 +8768,8 @@ var ContractManager = class _ContractManager {
8759
8768
  * Static factory method for creating a new ContractManager.
8760
8769
  * Initialize the manager by loading persisted contracts and starting to watch.
8761
8770
  *
8762
- * After initialization, the manager automatically watches all active contracts
8763
- * and contracts with virtual outputs. Use `onContractEvent()` to register event callbacks.
8771
+ * After initialization, the manager automatically watches every persisted
8772
+ * contract. Use `onContractEvent()` to register event callbacks.
8764
8773
  *
8765
8774
  * @param config ContractManagerConfig
8766
8775
  */
@@ -8797,6 +8806,7 @@ var ContractManager = class _ContractManager {
8797
8806
  for (const contract of contracts) {
8798
8807
  await this.watcher.addContract(contract);
8799
8808
  }
8809
+ await this.scheduleLookAheadDrain();
8800
8810
  try {
8801
8811
  await this.reconcileWatched();
8802
8812
  this.markSyncOnline();
@@ -8848,6 +8858,156 @@ var ContractManager = class _ContractManager {
8848
8858
  console.error("ContractManager: intent reconciliation failed", e);
8849
8859
  }
8850
8860
  }
8861
+ /** @see IContractManager.refillLookAhead */
8862
+ refillLookAhead() {
8863
+ return this.scheduleLookAheadDrain();
8864
+ }
8865
+ /**
8866
+ * Serialized drain of the look-ahead band: concurrent callers join the
8867
+ * active drain and mark it dirty, an idle call starts a new one. Promotion
8868
+ * can uncover more funded indices, and boot / SSE / rotate / reconnect can
8869
+ * all request a refill at once, so the loop coalesces them instead of
8870
+ * recursing.
8871
+ */
8872
+ scheduleLookAheadDrain() {
8873
+ if (!this.config.lookAhead) return Promise.resolve();
8874
+ if (this.lookAheadDrain) {
8875
+ this.lookAheadDirty = true;
8876
+ return this.lookAheadDrain;
8877
+ }
8878
+ const drain = (async () => {
8879
+ do {
8880
+ this.lookAheadDirty = false;
8881
+ await this.ensureLookAhead();
8882
+ } while (this.lookAheadDirty);
8883
+ })().finally(() => {
8884
+ this.lookAheadDrain = void 0;
8885
+ });
8886
+ this.lookAheadDrain = drain;
8887
+ return drain;
8888
+ }
8889
+ /**
8890
+ * Request a drain without awaiting it. Used from inside a sync (promotion),
8891
+ * where awaiting the drain that the sync itself is part of would deadlock.
8892
+ */
8893
+ requestLookAheadDrain() {
8894
+ if (!this.config.lookAhead) return;
8895
+ if (this.lookAheadDrain) {
8896
+ this.lookAheadDirty = true;
8897
+ return;
8898
+ }
8899
+ void this.scheduleLookAheadDrain().catch((err) => {
8900
+ console.error("ContractManager: look-ahead refill failed", err);
8901
+ });
8902
+ }
8903
+ /**
8904
+ * Rebuild the speculative watch band around the allocation watermark.
8905
+ *
8906
+ * NArk needs no analogue because it *is* the address issuer: it persists a
8907
+ * contract row at derivation time, so its watched set is a superset of
8908
+ * every address it ever advertised. This SDK, when a third party issues
8909
+ * addresses from the shared seed, cannot observe those allocations at all —
8910
+ * the window is how a non-issuer compensates.
8911
+ *
8912
+ * Entries are registered with the watcher but NOT persisted: they become
8913
+ * repository rows only once funded (see {@link promoteLookAheadHits}).
8914
+ */
8915
+ async ensureLookAhead() {
8916
+ const lookAhead = this.config.lookAhead;
8917
+ if (!lookAhead) return;
8918
+ const watermark = await lookAhead.currentWatermark();
8919
+ const from = Math.max(0, watermark - lookAhead.size);
8920
+ const to = watermark + lookAhead.size;
8921
+ const band = /* @__PURE__ */ new Map();
8922
+ for (let index = from; index <= to; index++) {
8923
+ const params = lookAhead.materialize(index);
8924
+ band.set(params.script, { index, params });
8925
+ }
8926
+ await this.watcher.withCoalescedSubscription(async () => {
8927
+ const persisted = await this.config.contractRepository.getContracts({
8928
+ script: [...band.keys()]
8929
+ });
8930
+ const persistedScripts = new Set(persisted.map((c) => c.script));
8931
+ for (const [script, { index, params }] of band) {
8932
+ if (persistedScripts.has(script)) {
8933
+ this.lookAheadEntries.delete(script);
8934
+ continue;
8935
+ }
8936
+ if (this.lookAheadEntries.has(script)) continue;
8937
+ const contract = toWatchOnlyContract(params);
8938
+ this.lookAheadEntries.set(script, {
8939
+ index,
8940
+ params,
8941
+ contract,
8942
+ catchUpPending: true
8943
+ });
8944
+ await this.watcher.addContract(contract);
8945
+ }
8946
+ const stale = [...this.lookAheadEntries.keys()].filter((s) => !band.has(s));
8947
+ if (stale.length > 0) {
8948
+ const rows = await this.config.contractRepository.getContracts({ script: stale });
8949
+ const nowPersisted = new Set(rows.map((c) => c.script));
8950
+ for (const script of stale) {
8951
+ this.lookAheadEntries.delete(script);
8952
+ if (!nowPersisted.has(script)) await this.watcher.removeContract(script);
8953
+ }
8954
+ }
8955
+ });
8956
+ await this.runLookAheadCatchUp();
8957
+ }
8958
+ /**
8959
+ * One-time full-history sync for speculative entries the manager has not
8960
+ * successfully caught up on yet.
8961
+ *
8962
+ * Every normal sync uses the cursor-derived delta window and SSE only
8963
+ * delivers events after a script is subscribed, so a script first
8964
+ * registered after its funding time would otherwise be skipped forever
8965
+ * (upgrade migration, or a band that slid over an already-funded index).
8966
+ * The entries are passed as in-memory contracts because `refreshVtxos`
8967
+ * resolves scripts through the repository, where they deliberately do not
8968
+ * exist. Targeted + explicitly windowed, so the global cursor stays put.
8969
+ */
8970
+ async runLookAheadCatchUp() {
8971
+ const pending = [...this.lookAheadEntries.values()].filter((e) => e.catchUpPending);
8972
+ if (pending.length === 0) return;
8973
+ try {
8974
+ await this.syncContracts({
8975
+ contracts: pending.map((e) => e.contract),
8976
+ window: { after: 0 }
8977
+ });
8978
+ for (const entry of pending) entry.catchUpPending = false;
8979
+ } catch (err) {
8980
+ if (!isRetryableProviderError(err)) throw err;
8981
+ this.markSyncDegraded(err);
8982
+ }
8983
+ }
8984
+ /**
8985
+ * Promote every look-ahead entry funded by `vtxos` into a real repository
8986
+ * row, returning the persisted rows keyed by script.
8987
+ *
8988
+ * MUST run on each raw indexer fetch before `annotateVtxos`:
8989
+ * `extendVirtualCoinForContract` throws when a VTXO's script has no
8990
+ * contract row, so a funded window entry has to be persisted before its
8991
+ * VTXOs are annotated and saved. Callers also swap the returned rows into
8992
+ * the local contract maps they built pre-promotion, so `saveVtxosForContract`
8993
+ * and `onVtxosPersisted` never see the synthetic watcher object.
8994
+ */
8995
+ async promoteLookAheadHits(vtxos) {
8996
+ const promoted = /* @__PURE__ */ new Map();
8997
+ if (this.lookAheadEntries.size === 0) return promoted;
8998
+ const hits = /* @__PURE__ */ new Map();
8999
+ for (const vtxo of vtxos) {
9000
+ const entry = this.lookAheadEntries.get(vtxo.script);
9001
+ if (entry) hits.set(vtxo.script, entry);
9002
+ }
9003
+ if (hits.size === 0) return promoted;
9004
+ for (const [script, entry] of hits) {
9005
+ promoted.set(script, await this.persistAndWatchContract(entry.params));
9006
+ await this.config.lookAhead?.onPromoted?.(entry.index);
9007
+ }
9008
+ this.requestLookAheadDrain();
9009
+ return promoted;
9010
+ }
8851
9011
  /**
8852
9012
  * Create and register a new contract.
8853
9013
  *
@@ -8893,6 +9053,11 @@ var ContractManager = class _ContractManager {
8893
9053
  * `persisted` is `true`.
8894
9054
  */
8895
9055
  async upsertContract(params) {
9056
+ const result = await this.upsertContractRow(params);
9057
+ this.lookAheadEntries.delete(params.script);
9058
+ return result;
9059
+ }
9060
+ async upsertContractRow(params) {
8896
9061
  const handler = chunkLJQ2VQBE_cjs.contractHandlers.get(params.type);
8897
9062
  if (!handler) {
8898
9063
  throw new Error(`No handler registered for contract type '${params.type}'`);
@@ -9207,13 +9372,17 @@ var ContractManager = class _ContractManager {
9207
9372
  return updated;
9208
9373
  }
9209
9374
  /**
9210
- * Set a contract's state.
9375
+ * Set a contract's state. Retiring (`inactive`) keeps it watched;
9376
+ * see {@link ContractState}. To stop watching, use
9377
+ * {@link deleteContract}.
9211
9378
  */
9212
9379
  async setContractState(script, state) {
9213
9380
  await this.updateContract(script, { state });
9214
9381
  }
9215
9382
  /**
9216
- * Delete a contract.
9383
+ * Delete a contract. Also removes it from the watcher — the only way
9384
+ * to stop watching a contract (retiring it via
9385
+ * {@link setContractState} does not).
9217
9386
  *
9218
9387
  * @param script - Contract script
9219
9388
  */
@@ -9288,22 +9457,10 @@ var ContractManager = class _ContractManager {
9288
9457
  /**
9289
9458
  * Force refresh virtual outputs from the indexer.
9290
9459
  *
9291
- * Without options, re-fetches every contract in the watcher's
9292
- * watched set and advances the global cursor.
9293
- *
9294
- * `scripts` narrows the refresh to a specific list (subset query —
9295
- * cursor is not advanced because contracts outside the list may
9296
- * have data we'd skip).
9297
- *
9298
- * `includeInactive: true` (and no `scripts`) widens the refresh to
9299
- * every contract in the repository, including ones marked
9300
- * `inactive` and ones that have dropped out of the watcher's
9301
- * active set. This is a *superset* of the watched set, so the
9302
- * cursor invariant still holds and the cursor advances normally.
9303
- *
9304
- * `after` / `before` apply a caller-supplied time window. The
9305
- * cursor never advances on a windowed query because the window
9306
- * may skip data outside its bounds.
9460
+ * Without options, re-fetches the watcher's watched set and
9461
+ * advances the global cursor. Each option narrows or widens that
9462
+ * scope and may hold the cursor back — see
9463
+ * {@link RefreshVtxosOptions}.
9307
9464
  */
9308
9465
  async refreshVtxos(opts) {
9309
9466
  const contracts = opts?.scripts ? await this.getContracts({ script: opts.scripts }) : void 0;
@@ -9390,6 +9547,7 @@ var ContractManager = class _ContractManager {
9390
9547
  }
9391
9548
  break;
9392
9549
  case "connection_reset":
9550
+ await this.scheduleLookAheadDrain();
9393
9551
  await this.reconcileWatched();
9394
9552
  this.markSyncOnline();
9395
9553
  break;
@@ -9419,11 +9577,10 @@ var ContractManager = class _ContractManager {
9419
9577
  * Sync virtual outputs for the given contracts against the indexer.
9420
9578
  *
9421
9579
  * When `options.contracts` is omitted the sync covers the full
9422
- * watched set (active contracts plus any inactive contracts still
9423
- * holding cached VTXOs) and the global cursor is advanced on
9424
- * success. Passing an explicit subset leaves the cursor alone so a
9425
- * narrow poll can't hide data that other contracts still need to
9426
- * pick up.
9580
+ * watched set ({@link ContractWatcher.getWatchedContracts}) and the
9581
+ * global cursor is advanced on success. Passing an explicit subset
9582
+ * leaves the cursor alone so a narrow poll can't hide data that
9583
+ * other contracts still need to pick up.
9427
9584
  */
9428
9585
  async syncContracts(options) {
9429
9586
  const cursor = await getSyncCursor(this.config.walletRepository);
@@ -9450,11 +9607,16 @@ var ContractManager = class _ContractManager {
9450
9607
  contracts.map((c) => c.script),
9451
9608
  { pendingOnly: true }
9452
9609
  );
9610
+ for (const [script, contract] of await this.promoteLookAheadHits(vtxos)) {
9611
+ scriptToContract.set(script, contract);
9612
+ }
9453
9613
  const owned = vtxos.filter((v) => scriptToContract.has(v.script));
9454
9614
  const annotated = await this.annotateVtxos(owned);
9455
9615
  const byContract = /* @__PURE__ */ new Map();
9616
+ const contractByAddress = /* @__PURE__ */ new Map();
9456
9617
  for (const vtxo of annotated) {
9457
9618
  const contract = scriptToContract.get(vtxo.script);
9619
+ contractByAddress.set(contract.address, contract);
9458
9620
  let arr = byContract.get(contract.address);
9459
9621
  if (!arr) {
9460
9622
  arr = [];
@@ -9466,7 +9628,7 @@ var ContractManager = class _ContractManager {
9466
9628
  });
9467
9629
  }
9468
9630
  for (const [addr, contractVtxos] of byContract) {
9469
- const contract = contracts.find((c) => c.address === addr);
9631
+ const contract = contractByAddress.get(addr);
9470
9632
  const filtered = warnAndFilterVtxosForScript(
9471
9633
  contractVtxos,
9472
9634
  contract.script,
@@ -9487,11 +9649,15 @@ var ContractManager = class _ContractManager {
9487
9649
  }
9488
9650
  }
9489
9651
  async fetchContractVxosFromIndexer(contracts, pageSize, syncWindow) {
9490
- const fetched = await this.fetchContractVtxosBulk(contracts, pageSize, syncWindow);
9652
+ const { vtxosByScript, promoted } = await this.fetchContractVtxosBulk(
9653
+ contracts,
9654
+ pageSize,
9655
+ syncWindow
9656
+ );
9491
9657
  const result = /* @__PURE__ */ new Map();
9492
- for (const [contractScript, vtxos] of fetched) {
9658
+ for (const [contractScript, vtxos] of vtxosByScript) {
9493
9659
  result.set(contractScript, vtxos);
9494
- const contract = contracts.find((c) => c.script === contractScript);
9660
+ const contract = promoted.get(contractScript) ?? contracts.find((c) => c.script === contractScript);
9495
9661
  if (contract) {
9496
9662
  const filtered = warnAndFilterVtxosForScript(
9497
9663
  vtxos,
@@ -9519,7 +9685,7 @@ var ContractManager = class _ContractManager {
9519
9685
  }
9520
9686
  async fetchContractVtxosBulk(contracts, pageSize = chunkE7HB3GKK_cjs.DEFAULT_PAGE_SIZE, syncWindow) {
9521
9687
  if (contracts.length === 0) {
9522
- return /* @__PURE__ */ new Map();
9688
+ return { vtxosByScript: /* @__PURE__ */ new Map(), promoted: /* @__PURE__ */ new Map() };
9523
9689
  }
9524
9690
  const scriptToContract = new Map(contracts.map((c) => [c.script, c]));
9525
9691
  const result = new Map(
@@ -9538,6 +9704,10 @@ var ContractManager = class _ContractManager {
9538
9704
  contracts.map((c) => c.script),
9539
9705
  { ...windowOpts, pageSize }
9540
9706
  );
9707
+ const promoted = await this.promoteLookAheadHits(vtxos);
9708
+ for (const [script, contract] of promoted) {
9709
+ scriptToContract.set(script, contract);
9710
+ }
9541
9711
  const owned = vtxos.filter((v) => scriptToContract.has(v.script));
9542
9712
  const annotated = await this.annotateVtxos(owned);
9543
9713
  for (const vtxo of annotated) {
@@ -9546,7 +9716,7 @@ var ContractManager = class _ContractManager {
9546
9716
  contractScript: vtxo.script
9547
9717
  });
9548
9718
  }
9549
- return result;
9719
+ return { vtxosByScript: result, promoted };
9550
9720
  }
9551
9721
  /**
9552
9722
  * Dispose of the ContractManager and release all resources.
@@ -9560,6 +9730,7 @@ var ContractManager = class _ContractManager {
9560
9730
  this.stopWatcherFn?.();
9561
9731
  this.stopWatcherFn = void 0;
9562
9732
  this.eventCallbacks.clear();
9733
+ this.lookAheadEntries.clear();
9563
9734
  this.initialized = false;
9564
9735
  }
9565
9736
  /**
@@ -9625,6 +9796,15 @@ var HDDescriptorProvider = class _HDDescriptorProvider {
9625
9796
  if (settings.lastIndexUsed === void 0) return void 0;
9626
9797
  return this.materializeDescriptorAt(settings.lastIndexUsed);
9627
9798
  }
9799
+ /**
9800
+ * The most recently allocated index, or `undefined` when nothing has ever
9801
+ * been allocated on this repo. Read-only peek at the watermark that
9802
+ * {@link getNextSigningDescriptor} advances.
9803
+ */
9804
+ async getLastIndexUsed() {
9805
+ const state = await this.walletRepository.getWalletState();
9806
+ return this.parseSettings(state ?? {}).lastIndexUsed;
9807
+ }
9628
9808
  /**
9629
9809
  * Monotonically advance the allocation watermark so the next
9630
9810
  * `getNextSigningDescriptor()` skips indices discovered by a restore
@@ -10007,58 +10187,26 @@ var WalletReceiveRotator = class _WalletReceiveRotator {
10007
10187
  */
10008
10188
  async rotate(wallet) {
10009
10189
  const descriptor = await this.provider.getNextSigningDescriptor();
10010
- const pubKey = deriveLeafPubkey(descriptor);
10011
- const newTapscript = rebuildTapscript(wallet.offchainTapscript, pubKey);
10012
- const newScript = base.hex.encode(newTapscript.pkScript);
10013
- const newAddress = newTapscript.address(wallet.network.hrp, wallet.arkServerPublicKey).encode();
10190
+ const { tapscript: newTapscript, params } = buildReceiveContract(
10191
+ wallet.offchainTapscript,
10192
+ descriptor,
10193
+ wallet.network.hrp,
10194
+ true
10195
+ );
10196
+ const newScript = params.script;
10014
10197
  const manager = await wallet.getContractManager();
10015
- const csvTimelock = newTapscript.options.csvTimelock;
10016
- const csvTimelockStr = chunkE7HB3GKK_cjs.timelockToSequence(csvTimelock).toString();
10017
- const serverPubKeyHex = base.hex.encode(newTapscript.options.serverPubKey);
10018
- const baseParams = {
10019
- script: newScript,
10020
- address: newAddress,
10021
- state: "active",
10022
- // Persist the materialized signing descriptor alongside the
10023
- // source tag. The wallet's spending paths read this at sign
10024
- // time to route inputs locked by a rotated pubkey through
10025
- // `DescriptorProvider.signWithDescriptor` instead of the
10026
- // identity's index-0 key. Without it, post-rotation sends
10027
- // produce unsigned PSBTs that the server rejects with
10028
- // `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
10029
- metadata: {
10030
- source: chunkLJQ2VQBE_cjs.WALLET_RECEIVE_SOURCE,
10031
- signingDescriptor: descriptor
10032
- }
10033
- };
10034
- if (newTapscript instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script) {
10035
- await manager.createContract({
10036
- ...baseParams,
10037
- type: "delegate",
10038
- params: {
10039
- pubKey: base.hex.encode(pubKey),
10040
- serverPubKey: serverPubKeyHex,
10041
- delegatePubKey: base.hex.encode(newTapscript.options.delegatePubKey),
10042
- csvTimelock: csvTimelockStr
10043
- }
10044
- });
10045
- } else {
10046
- await manager.createContract({
10047
- ...baseParams,
10048
- type: "default",
10049
- params: {
10050
- pubKey: base.hex.encode(pubKey),
10051
- serverPubKey: serverPubKeyHex,
10052
- csvTimelock: csvTimelockStr
10053
- }
10054
- });
10055
- }
10198
+ await manager.createContract(params);
10056
10199
  wallet.setOffchainTapscriptForRotation(newTapscript);
10057
10200
  const previousTagged = this.currentTaggedScript;
10058
10201
  if (previousTagged !== void 0 && previousTagged !== newScript) {
10059
10202
  await manager.setContractState(previousTagged, "inactive");
10060
10203
  }
10061
10204
  this.currentTaggedScript = newScript;
10205
+ try {
10206
+ await manager.refillLookAhead();
10207
+ } catch (err) {
10208
+ this.logger.error("WalletReceiveRotator: look-ahead refill failed", err);
10209
+ }
10062
10210
  }
10063
10211
  };
10064
10212
  function deriveLeafPubkey(descriptor) {
@@ -10071,6 +10219,45 @@ function deriveLeafPubkey(descriptor) {
10071
10219
  );
10072
10220
  }
10073
10221
  }
10222
+ function buildReceiveContract(current, descriptor, hrp, tagSource) {
10223
+ const pubKey = deriveLeafPubkey(descriptor);
10224
+ const tapscript = rebuildTapscript(current, pubKey);
10225
+ const serverPubKey = tapscript.options.serverPubKey;
10226
+ const csvTimelock = chunkE7HB3GKK_cjs.timelockToSequence(tapscript.options.csvTimelock).toString();
10227
+ const base$1 = {
10228
+ script: base.hex.encode(tapscript.pkScript),
10229
+ address: tapscript.address(hrp, serverPubKey).encode(),
10230
+ state: "active",
10231
+ // The materialized signing descriptor is read at sign time to route
10232
+ // inputs locked by a rotated pubkey through
10233
+ // `DescriptorProvider.signWithDescriptor` instead of the identity's
10234
+ // index-0 key. Without it, spends produce unsigned PSBTs that the
10235
+ // server rejects with `INVALID_PSBT_INPUT (5): missing tapscript spend sig`.
10236
+ metadata: {
10237
+ ...tagSource && { source: chunkLJQ2VQBE_cjs.WALLET_RECEIVE_SOURCE },
10238
+ signingDescriptor: descriptor
10239
+ }
10240
+ };
10241
+ const params = tapscript instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script ? {
10242
+ ...base$1,
10243
+ type: "delegate",
10244
+ params: {
10245
+ pubKey: base.hex.encode(pubKey),
10246
+ serverPubKey: base.hex.encode(serverPubKey),
10247
+ delegatePubKey: base.hex.encode(tapscript.options.delegatePubKey),
10248
+ csvTimelock
10249
+ }
10250
+ } : {
10251
+ ...base$1,
10252
+ type: "default",
10253
+ params: {
10254
+ pubKey: base.hex.encode(pubKey),
10255
+ serverPubKey: base.hex.encode(serverPubKey),
10256
+ csvTimelock
10257
+ }
10258
+ };
10259
+ return { tapscript, params };
10260
+ }
10074
10261
  function rebuildTapscript(current, pubKey) {
10075
10262
  if (current instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script) {
10076
10263
  return new chunkLJQ2VQBE_cjs.DelegateVtxo.Script({ ...current.options, pubKey });
@@ -10273,6 +10460,7 @@ function extractArkProviderUrl(provider) {
10273
10460
  const serverUrl = provider.serverUrl;
10274
10461
  return typeof serverUrl === "string" && serverUrl.length > 0 ? serverUrl : void 0;
10275
10462
  }
10463
+ var DEFAULT_LOOK_AHEAD_WINDOW = 20;
10276
10464
  var MAINNET_UNILATERAL_EXIT_DELAY = 605184n;
10277
10465
  function toXOnlyPubKey(pubkey) {
10278
10466
  if (pubkey.length === 33) return pubkey.slice(1);
@@ -10634,7 +10822,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
10634
10822
  */
10635
10823
  static async setupWalletConfig(config, pubKey) {
10636
10824
  const arkadeServerUrl = getArkadeServerUrl(config);
10637
- const arkProvider = config.arkProvider || new chunkQDXQULVM_cjs.RestArkProvider(arkadeServerUrl);
10825
+ const arkProvider = config.arkProvider || new chunkFHDUEBBC_cjs.RestArkProvider(arkadeServerUrl);
10638
10826
  let indexerProvider = config.indexerProvider;
10639
10827
  if (!indexerProvider) {
10640
10828
  let indexerUrl = config.indexerUrl;
@@ -10651,7 +10839,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
10651
10839
  indexerUrl = arkadeServerUrl;
10652
10840
  }
10653
10841
  }
10654
- indexerProvider = new chunkQDXQULVM_cjs.RestIndexerProvider(indexerUrl);
10842
+ indexerProvider = new chunkFHDUEBBC_cjs.RestIndexerProvider(indexerUrl);
10655
10843
  }
10656
10844
  const walletRepository = config.storage?.walletRepository ?? new IndexedDBWalletRepository();
10657
10845
  const contractRepository = config.storage?.contractRepository ?? new IndexedDBContractRepository();
@@ -11328,6 +11516,14 @@ var ReadonlyWallet = class _ReadonlyWallet {
11328
11516
  this._contractManagerInitializing = void 0;
11329
11517
  }
11330
11518
  }
11519
+ /**
11520
+ * HD look-ahead configuration for the contract manager. Readonly wallets
11521
+ * have no descriptor provider, hence no watermark to look ahead of.
11522
+ * @see Wallet.lookAheadConfig
11523
+ */
11524
+ lookAheadConfig() {
11525
+ return void 0;
11526
+ }
11331
11527
  async initializeContractManager() {
11332
11528
  const virtualTxRepository = this.virtualTxRepository;
11333
11529
  let onVtxosPersisted;
@@ -11362,7 +11558,8 @@ var ReadonlyWallet = class _ReadonlyWallet {
11362
11558
  intentRepository: this.intentRepository,
11363
11559
  onVtxosPersisted,
11364
11560
  onVtxosSpent,
11365
- watcherConfig: this.watcherConfig
11561
+ watcherConfig: this.watcherConfig,
11562
+ lookAhead: this.lookAheadConfig()
11366
11563
  });
11367
11564
  const baselinePubkey = await this.identity.xOnlyPublicKey();
11368
11565
  const delegatePubKey = this.offchainTapscript instanceof chunkLJQ2VQBE_cjs.DelegateVtxo.Script ? this.offchainTapscript.options.delegatePubKey : void 0;
@@ -11456,7 +11653,7 @@ var ReadonlyWallet = class _ReadonlyWallet {
11456
11653
  }
11457
11654
  };
11458
11655
  var Wallet2 = class _Wallet extends ReadonlyWallet {
11459
- constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider) {
11656
+ constructor(identity, network, onchainProvider, arkProvider, indexerProvider, arkServerPublicKey, offchainTapscript, boardingTapscript, serverUnrollScript, forfeitOutputScript, forfeitPubkey, dustAmount, walletRepository, contractRepository, renewalConfig, delegateProvider, watcherConfig, settlementConfig, walletContractTimelocks, receiveRotator, descriptorProvider, lookAheadWindow) {
11460
11657
  super(
11461
11658
  identity,
11462
11659
  network,
@@ -11496,6 +11693,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11496
11693
  this._serverUnrollScript = serverUnrollScript;
11497
11694
  this._receiveRotator = receiveRotator;
11498
11695
  this._descriptorProvider = descriptorProvider;
11696
+ this._lookAheadWindow = lookAheadWindow ?? DEFAULT_LOOK_AHEAD_WINDOW;
11499
11697
  this._signerRouter = new InputSignerRouter({
11500
11698
  identity,
11501
11699
  contractRepository,
@@ -11568,6 +11766,36 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11568
11766
  * paths only ever take the identity-sign branch.
11569
11767
  */
11570
11768
  _descriptorProvider;
11769
+ /** Per-side width of the HD look-ahead band. @see WalletConfig.lookAheadWindow */
11770
+ _lookAheadWindow;
11771
+ /**
11772
+ * Watch a band of missing offchain receive scripts around the HD watermark
11773
+ * so payments to an externally-issued address land without a `restore()`.
11774
+ * Only HD wallets have a watermark to look ahead of; static / `auto`
11775
+ * wallets keep a single index-0 receive address, so the feature stays off.
11776
+ *
11777
+ * `materialize` reads `this.offchainTapscript` at call time, so a refill
11778
+ * after {@link rotateServerSigner} rebuilds the band under the active
11779
+ * signer (persisted old-signer rows stay watched through the repository).
11780
+ */
11781
+ lookAheadConfig() {
11782
+ const provider = this._descriptorProvider;
11783
+ if (!(provider instanceof HDDescriptorProvider)) return void 0;
11784
+ return {
11785
+ size: this._lookAheadWindow,
11786
+ currentWatermark: async () => await provider.getLastIndexUsed() ?? -1,
11787
+ materialize: (index) => buildReceiveContract(
11788
+ this.offchainTapscript,
11789
+ provider.materializeDescriptorAt(index),
11790
+ this.network.hrp,
11791
+ // Never tagged: a promoted entry was generated by someone
11792
+ // else, and the tag would make the next boot advertise a
11793
+ // third party's invoice address as our own.
11794
+ false
11795
+ ).params,
11796
+ onPromoted: (index) => provider.advanceLastIndexUsed(index)
11797
+ };
11798
+ }
11571
11799
  _signerRouter;
11572
11800
  /**
11573
11801
  * @internal Sole write path for `offchainTapscript` after construction.
@@ -11680,6 +11908,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11680
11908
  }
11681
11909
  });
11682
11910
  this.setBoardingTapscriptForRotation(newBoarding);
11911
+ try {
11912
+ await manager.refillLookAhead();
11913
+ } catch (e) {
11914
+ console.warn("look-ahead refill after boarding allocation failed", e);
11915
+ }
11683
11916
  return newBoarding.onchainAddress(this.network);
11684
11917
  }
11685
11918
  /**
@@ -11801,6 +12034,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11801
12034
  this.setBoardingTapscriptForRotation(newBoarding);
11802
12035
  this.setArkServerPublicKeyForRotation(xonly);
11803
12036
  this.setServerUnrollScriptForRotation(newServerUnrollScript);
12037
+ try {
12038
+ await manager.refillLookAhead();
12039
+ } catch (e) {
12040
+ console.warn("look-ahead refill after server-signer rotation failed", e);
12041
+ }
11804
12042
  }
11805
12043
  /**
11806
12044
  * Async mutex that serializes all operations submitting VTXOs to the Arkade
@@ -11916,6 +12154,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
11916
12154
  if (hd && result.highestConfirmedUsedIndex >= 0) {
11917
12155
  await provider.advanceLastIndexUsed(result.highestConfirmedUsedIndex);
11918
12156
  }
12157
+ await manager.refillLookAhead();
11919
12158
  await manager.refreshVtxos({ includeInactive: true, after: 0 });
11920
12159
  const causes = result.handlerErrors.map(
11921
12160
  (e) => e.error instanceof Error ? e.error : new Error(String(e.error))
@@ -12007,6 +12246,11 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12007
12246
  * ```
12008
12247
  */
12009
12248
  static async create(config) {
12249
+ if (config.lookAheadWindow !== void 0 && (!Number.isInteger(config.lookAheadWindow) || config.lookAheadWindow <= 0)) {
12250
+ throw new Error(
12251
+ `lookAheadWindow must be a positive integer (got ${String(config.lookAheadWindow)})`
12252
+ );
12253
+ }
12010
12254
  const pubkey = await config.identity.xOnlyPublicKey();
12011
12255
  if (!pubkey) {
12012
12256
  throw new Error("Invalid configured public key");
@@ -12044,7 +12288,8 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12044
12288
  config.settlementConfig,
12045
12289
  setup.walletContractTimelocks,
12046
12290
  boot?.rotator,
12047
- boot?.provider
12291
+ boot?.provider,
12292
+ config.lookAheadWindow
12048
12293
  );
12049
12294
  wallet._serverInfoSource = setup.serverInfoSource;
12050
12295
  if (setup.serverInfoSource === "live") {
@@ -12729,9 +12974,9 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12729
12974
  ...existing ?? {},
12730
12975
  intentTxId,
12731
12976
  registerProof: intent.proof,
12732
- registerProofMessage: chunkQDXQULVM_cjs.Intent.encodeMessage(intent.message),
12977
+ registerProofMessage: chunkFHDUEBBC_cjs.Intent.encodeMessage(intent.message),
12733
12978
  deleteProof: deleteIntent.proof,
12734
- deleteProofMessage: chunkQDXQULVM_cjs.Intent.encodeMessage(deleteIntent.message),
12979
+ deleteProofMessage: chunkFHDUEBBC_cjs.Intent.encodeMessage(deleteIntent.message),
12735
12980
  intentVtxos: inputs.map((i) => ({
12736
12981
  txid: i.txid,
12737
12982
  vout: i.vout
@@ -12763,7 +13008,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12763
13008
  try {
12764
13009
  return await this.arkProvider.registerIntent(intent);
12765
13010
  } catch (error) {
12766
- if (error instanceof chunkQDXQULVM_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
13011
+ if (error instanceof chunkFHDUEBBC_cjs.ArkError && error.code === 0 && error.message.includes("duplicated input")) {
12767
13012
  const deleteIntent = await this.makeDeleteIntentSignature(inputs);
12768
13013
  await this.arkProvider.deleteIntent(deleteIntent);
12769
13014
  return this.arkProvider.registerIntent(intent);
@@ -12779,7 +13024,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12779
13024
  expire_at: 0,
12780
13025
  cosigners_public_keys: cosignerPubKeys
12781
13026
  };
12782
- const proof = chunkQDXQULVM_cjs.Intent.create(message, coins, outputs);
13027
+ const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, outputs);
12783
13028
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
12784
13029
  return {
12785
13030
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -12791,7 +13036,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12791
13036
  type: "delete",
12792
13037
  expire_at: 0
12793
13038
  };
12794
- const proof = chunkQDXQULVM_cjs.Intent.create(message, coins, []);
13039
+ const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, []);
12795
13040
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
12796
13041
  return {
12797
13042
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -12803,7 +13048,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
12803
13048
  type: "get-pending-tx",
12804
13049
  expire_at: 0
12805
13050
  };
12806
- const proof = chunkQDXQULVM_cjs.Intent.create(message, coins, []);
13051
+ const proof = chunkFHDUEBBC_cjs.Intent.create(message, coins, []);
12807
13052
  const signedProof = await this._signerRouter.sign(proof, intentProofJobs(coins));
12808
13053
  return {
12809
13054
  proof: base.base64.encode(signedProof.toPSBT()),
@@ -13136,7 +13381,7 @@ var Wallet2 = class _Wallet extends ReadonlyWallet {
13136
13381
  for (let i = 0; i < inputs.length; i += MAX_INPUTS_PER_INTENT) {
13137
13382
  const batch = inputs.slice(i, i + MAX_INPUTS_PER_INTENT);
13138
13383
  const message = { type: "get-pending-tx", expire_at: 0 };
13139
- const proof = chunkQDXQULVM_cjs.Intent.create(message, batch, []);
13384
+ const proof = chunkFHDUEBBC_cjs.Intent.create(message, batch, []);
13140
13385
  const signedProof = await identity.sign(
13141
13386
  proof,
13142
13387
  Array.from({ length: batch.length + 1 }, (_, j) => j)
@@ -14019,7 +14264,7 @@ var MessageBus = class {
14019
14264
  this.initialized = true;
14020
14265
  }
14021
14266
  async buildServices(config) {
14022
- const arkProvider = new chunkQDXQULVM_cjs.RestArkProvider(config.arkServer.url);
14267
+ const arkProvider = new chunkFHDUEBBC_cjs.RestArkProvider(config.arkServer.url);
14023
14268
  const storage = {
14024
14269
  walletRepository: this.walletRepository,
14025
14270
  contractRepository: this.contractRepository
@@ -14038,7 +14283,8 @@ var MessageBus = class {
14038
14283
  delegateProvider,
14039
14284
  settlementConfig: config.settlementConfig,
14040
14285
  walletMode: config.walletMode,
14041
- watcherConfig: config.watcherConfig
14286
+ watcherConfig: config.watcherConfig,
14287
+ lookAheadWindow: config.lookAheadWindow
14042
14288
  });
14043
14289
  return { wallet, arkProvider, readonlyWallet: wallet };
14044
14290
  }
@@ -15179,7 +15425,7 @@ var WalletMessageHandler = class {
15179
15425
  // Wallet methods
15180
15426
  async handleInitWallet({ payload }) {
15181
15427
  const { arkServerUrl } = payload;
15182
- this.indexerProvider = new chunkQDXQULVM_cjs.RestIndexerProvider(arkServerUrl);
15428
+ this.indexerProvider = new chunkFHDUEBBC_cjs.RestIndexerProvider(arkServerUrl);
15183
15429
  await this.onWalletInitialized();
15184
15430
  }
15185
15431
  async handleGetBalance() {
@@ -16503,6 +16749,9 @@ var ServiceWorkerReadonlyWallet = class _ServiceWorkerReadonlyWallet {
16503
16749
  )
16504
16750
  );
16505
16751
  },
16752
+ refillLookAhead() {
16753
+ return Promise.resolve();
16754
+ },
16506
16755
  async isWatching() {
16507
16756
  const message = {
16508
16757
  type: "IS_CONTRACT_MANAGER_WATCHING",
@@ -16552,6 +16801,11 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
16552
16801
  return serializeSigningIdentity(this.identity);
16553
16802
  }
16554
16803
  static async create(options) {
16804
+ if (options.lookAheadWindow !== void 0 && (!Number.isInteger(options.lookAheadWindow) || options.lookAheadWindow <= 0)) {
16805
+ throw new Error(
16806
+ `lookAheadWindow must be a positive integer (got ${String(options.lookAheadWindow)})`
16807
+ );
16808
+ }
16555
16809
  const walletRepository = options.storage?.walletRepository ?? new IndexedDBWalletRepository();
16556
16810
  const contractRepository = options.storage?.contractRepository ?? new IndexedDBContractRepository();
16557
16811
  if (!isSigningCapable(options.identity)) {
@@ -16601,6 +16855,7 @@ var ServiceWorkerWallet = class _ServiceWorkerWallet extends ServiceWorkerReadon
16601
16855
  settlementConfig: options.settlementConfig,
16602
16856
  walletMode: options.walletMode,
16603
16857
  watcherConfig: options.watcherConfig,
16858
+ lookAheadWindow: options.lookAheadWindow,
16604
16859
  messageTimeouts
16605
16860
  };
16606
16861
  await initializeMessageBus(
@@ -17047,7 +17302,7 @@ var OnchainWallet = class _OnchainWallet {
17047
17302
  if (!inputs) {
17048
17303
  throw new Error("Fee estimation failed");
17049
17304
  }
17050
- let tx = new chunkQDXQULVM_cjs.Transaction();
17305
+ let tx = new chunkFHDUEBBC_cjs.Transaction();
17051
17306
  for (const input of inputs) {
17052
17307
  tx.addInput({
17053
17308
  txid: input.txid,
@@ -17105,7 +17360,7 @@ var OnchainWallet = class _OnchainWallet {
17105
17360
  * @throws If the parent has no anchor, or funding cannot be selected/signed
17106
17361
  */
17107
17362
  async bumpAnchor(parentHex, feeRate) {
17108
- const parent = chunkQDXQULVM_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
17363
+ const parent = chunkFHDUEBBC_cjs.Transaction.fromRaw(base.hex.decode(parentHex));
17109
17364
  const coins = (await this.getCoins()).filter((c) => c.status.confirmed);
17110
17365
  const child = await this.buildBumpPackage(parent, feeRate, coins);
17111
17366
  return [parent.hex, child.hex];
@@ -17870,7 +18125,7 @@ exports.BIP322 = void 0;
17870
18125
  async function sign2(message, identity, network) {
17871
18126
  const xOnlyPubKey = await identity.xOnlyPublicKey();
17872
18127
  const payment = btcSigner.p2tr(xOnlyPubKey, void 0, network);
17873
- const toSpend = chunkQDXQULVM_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
18128
+ const toSpend = chunkFHDUEBBC_cjs.craftToSpendTx(message, payment.script, TAG_BIP322);
17874
18129
  const toSign = craftBIP322ToSignP2TR(toSpend, payment.script, xOnlyPubKey);
17875
18130
  const signed = await identity.sign(toSign, [0]);
17876
18131
  signed.finalizeIdx(0);
@@ -17928,7 +18183,7 @@ function verifyP2TR(message, witnessItems, pkScript, pubkey) {
17928
18183
  if (sighashType !== btcSigner.SigHash.DEFAULT && sighashType !== btcSigner.SigHash.ALL) {
17929
18184
  return false;
17930
18185
  }
17931
- const toSpend = chunkQDXQULVM_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
18186
+ const toSpend = chunkFHDUEBBC_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
17932
18187
  const toSign = craftBIP322ToSignP2TR(toSpend, pkScript, pubkey);
17933
18188
  const sighash = toSign.preimageWitnessV1(0, [pkScript], sighashType, [0n]);
17934
18189
  const rawSig = sig.length === 65 ? sig.subarray(0, 64) : sig;
@@ -17949,7 +18204,7 @@ function verifyP2WPKH(message, witnessItems, pkScript, addressHash) {
17949
18204
  }
17950
18205
  const sighashType = sigWithHash[sigWithHash.length - 1];
17951
18206
  const derSig = sigWithHash.subarray(0, sigWithHash.length - 1);
17952
- const toSpend = chunkQDXQULVM_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
18207
+ const toSpend = chunkFHDUEBBC_cjs.craftToSpendTx(message, pkScript, TAG_BIP322);
17953
18208
  const toSign = craftBIP322ToSignSimple(toSpend, pkScript);
17954
18209
  const scriptCode = btcSigner.OutScript.encode({ type: "pkh", hash: addressHash });
17955
18210
  const sighash = toSign.preimageWitnessV0(0, scriptCode, sighashType, 0n);
@@ -18002,7 +18257,7 @@ function encodeCompactSize(n) {
18002
18257
  return buf;
18003
18258
  }
18004
18259
  function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
18005
- const tx = new chunkQDXQULVM_cjs.Transaction({ version: 0 });
18260
+ const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 0 });
18006
18261
  tx.addInput({
18007
18262
  txid: toSpend.id,
18008
18263
  index: 0,
@@ -18016,12 +18271,12 @@ function craftBIP322ToSignP2TR(toSpend, pkScript, tapInternalKey) {
18016
18271
  });
18017
18272
  tx.addOutput({
18018
18273
  amount: 0n,
18019
- script: chunkQDXQULVM_cjs.OP_RETURN_EMPTY_PKSCRIPT
18274
+ script: chunkFHDUEBBC_cjs.OP_RETURN_EMPTY_PKSCRIPT
18020
18275
  });
18021
18276
  return tx;
18022
18277
  }
18023
18278
  function craftBIP322ToSignSimple(toSpend, pkScript) {
18024
- const tx = new chunkQDXQULVM_cjs.Transaction({ version: 0 });
18279
+ const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 0 });
18025
18280
  tx.addInput({
18026
18281
  txid: toSpend.id,
18027
18282
  index: 0,
@@ -18033,7 +18288,7 @@ function craftBIP322ToSignSimple(toSpend, pkScript) {
18033
18288
  });
18034
18289
  tx.addOutput({
18035
18290
  amount: 0n,
18036
- script: chunkQDXQULVM_cjs.OP_RETURN_EMPTY_PKSCRIPT
18291
+ script: chunkFHDUEBBC_cjs.OP_RETURN_EMPTY_PKSCRIPT
18037
18292
  });
18038
18293
  return tx;
18039
18294
  }
@@ -18164,7 +18419,7 @@ var RestEmulatorProvider = class {
18164
18419
  }
18165
18420
  };
18166
18421
  function finalizeVirtualTx(type, psbtBase64) {
18167
- const tx = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
18422
+ const tx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbtBase64));
18168
18423
  if (type === "INDEXER_CHAINED_TX_TYPE_TREE" /* TREE */) {
18169
18424
  const input = tx.getInput(0);
18170
18425
  if (!input) {
@@ -18442,7 +18697,7 @@ async function prepareUnrollTransaction(wallet, vtxoTxIds, outputAddress) {
18442
18697
  btcSigner.TaprootControlBlock.encode(spendingLeaf[0]).length
18443
18698
  );
18444
18699
  }
18445
- const tx = new chunkQDXQULVM_cjs.Transaction({ version: 2 });
18700
+ const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 2 });
18446
18701
  for (const input of inputs) {
18447
18702
  tx.addInput(input);
18448
18703
  }
@@ -18509,7 +18764,7 @@ async function buildSignedSweep(params) {
18509
18764
  `uneconomic vtxo ${vtxo.txid}:${vtxo.vout}: value ${vtxo.value} - fee ${fee} < dust`
18510
18765
  );
18511
18766
  }
18512
- const tx = new chunkQDXQULVM_cjs.Transaction({ version: 2 });
18767
+ const tx = new chunkFHDUEBBC_cjs.Transaction({ version: 2 });
18513
18768
  tx.addInput({
18514
18769
  txid: vtxo.txid,
18515
18770
  index: vtxo.vout,
@@ -18609,7 +18864,7 @@ async function computeExitLayout(opts, feeRate) {
18609
18864
  if (pendingNodes.length > 0) {
18610
18865
  const txs = await resolver.getVirtualTxs(pendingNodes.map((n) => n.txid));
18611
18866
  for (const psbt of txs) {
18612
- psbts.set(chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
18867
+ psbts.set(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(psbt)).id, psbt);
18613
18868
  }
18614
18869
  }
18615
18870
  const childVsize = Number(
@@ -19056,7 +19311,7 @@ async function prepare(opts) {
19056
19311
  if (newFee <= splitterFee) break;
19057
19312
  splitterFee = newFee;
19058
19313
  }
19059
- const splitter = new chunkQDXQULVM_cjs.Transaction({ version: 2 });
19314
+ const splitter = new chunkFHDUEBBC_cjs.Transaction({ version: 2 });
19060
19315
  for (const coin of selected.inputs) {
19061
19316
  splitter.addInput({
19062
19317
  txid: coin.txid,
@@ -19263,7 +19518,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
19263
19518
  if (!xOnlyPubkeys.includes(base.hex.encode(xonlySignerPubKey))) {
19264
19519
  return { skip: true };
19265
19520
  }
19266
- const commitmentTx = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
19521
+ const commitmentTx = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(event.unsignedCommitmentTx));
19267
19522
  validateVtxoTxGraph(vtxoTree, commitmentTx, sweepTapTreeRoot);
19268
19523
  if (recipients && recipients.length > 0) {
19269
19524
  validateBatchRecipients(commitmentTx, vtxoTree.leaves(), recipients, network);
@@ -19294,7 +19549,7 @@ function createArkadeBatchHandler(intentId, inputs, signer, signedProof, message
19294
19549
  if (connectorTree) {
19295
19550
  validateConnectorsTxGraph(event.commitmentTx, connectorTree);
19296
19551
  }
19297
- let commitmentPsbt = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
19552
+ let commitmentPsbt = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(event.commitmentTx));
19298
19553
  const signedForfeits = [];
19299
19554
  let connectorIndex = 0;
19300
19555
  const connectorLeaves = connectorTree?.leaves() || [];
@@ -19702,12 +19957,12 @@ var ArkadeTransactionBuilder = class {
19702
19957
  this.contract.client.checkpoint
19703
19958
  );
19704
19959
  if (coin.sourceTx) {
19705
- chunkQDXQULVM_cjs.setArkPsbtField(arkTx, 0, chunkQDXQULVM_cjs.PrevArkTxField, coin.sourceTx);
19960
+ chunkFHDUEBBC_cjs.setArkPsbtField(arkTx, 0, chunkFHDUEBBC_cjs.PrevArkTxField, coin.sourceTx);
19706
19961
  }
19707
19962
  const condition = (def.tapscript.witness ?? []).map((w) => this.witnessBytes(w));
19708
19963
  if (condition.length > 0) {
19709
- chunkQDXQULVM_cjs.setArkPsbtField(arkTx, 0, chunkQDXQULVM_cjs.ConditionWitness, condition);
19710
- chunkQDXQULVM_cjs.setArkPsbtField(checkpoints[0], 0, chunkQDXQULVM_cjs.ConditionWitness, condition);
19964
+ chunkFHDUEBBC_cjs.setArkPsbtField(arkTx, 0, chunkFHDUEBBC_cjs.ConditionWitness, condition);
19965
+ chunkFHDUEBBC_cjs.setArkPsbtField(checkpoints[0], 0, chunkFHDUEBBC_cjs.ConditionWitness, condition);
19711
19966
  }
19712
19967
  const packets = [];
19713
19968
  if (this.assetSpecs.length > 0) {
@@ -19746,7 +20001,7 @@ var ArkadeTransactionBuilder = class {
19746
20001
  base.base64.encode(signedArk2.toPSBT()),
19747
20002
  signedCps.map((c) => base.base64.encode(c.toPSBT()))
19748
20003
  );
19749
- const txid = chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
20004
+ const txid = chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(res2.signedArkTx)).id;
19750
20005
  return {
19751
20006
  txid,
19752
20007
  signedArkTx: res2.signedArkTx,
@@ -19764,7 +20019,7 @@ var ArkadeTransactionBuilder = class {
19764
20019
  const finalCps = await Promise.all(
19765
20020
  res.signedCheckpointTxs.map(
19766
20021
  async (b) => base.base64.encode(
19767
- (await client.identity.sign(chunkQDXQULVM_cjs.Transaction.fromPSBT(base.base64.decode(b)), [0])).toPSBT()
20022
+ (await client.identity.sign(chunkFHDUEBBC_cjs.Transaction.fromPSBT(base.base64.decode(b)), [0])).toPSBT()
19768
20023
  )
19769
20024
  )
19770
20025
  );
@@ -19805,16 +20060,16 @@ var ArkadeTransactionBuilder = class {
19805
20060
  }
19806
20061
  buildAssetPacket() {
19807
20062
  const groups = this.assetSpecs.map((s) => {
19808
- const id = typeof s.assetId === "string" ? chunkQDXQULVM_cjs.AssetId.fromString(s.assetId) : chunkQDXQULVM_cjs.AssetId.fromBytes(s.assetId);
19809
- return chunkQDXQULVM_cjs.AssetGroup.create(
20063
+ const id = typeof s.assetId === "string" ? chunkFHDUEBBC_cjs.AssetId.fromString(s.assetId) : chunkFHDUEBBC_cjs.AssetId.fromBytes(s.assetId);
20064
+ return chunkFHDUEBBC_cjs.AssetGroup.create(
19810
20065
  id,
19811
20066
  null,
19812
- s.inputs.map((i) => chunkQDXQULVM_cjs.AssetInput.create(i.vin, i.amount)),
19813
- s.outputs.map((o) => chunkQDXQULVM_cjs.AssetOutput.create(o.vout, o.amount)),
19814
- (s.metadata ?? []).map((m) => chunkQDXQULVM_cjs.Metadata.create(m.key, m.value))
20067
+ s.inputs.map((i) => chunkFHDUEBBC_cjs.AssetInput.create(i.vin, i.amount)),
20068
+ s.outputs.map((o) => chunkFHDUEBBC_cjs.AssetOutput.create(o.vout, o.amount)),
20069
+ (s.metadata ?? []).map((m) => chunkFHDUEBBC_cjs.Metadata.create(m.key, m.value))
19815
20070
  );
19816
20071
  });
19817
- return chunkQDXQULVM_cjs.Packet.create(groups);
20072
+ return chunkFHDUEBBC_cjs.Packet.create(groups);
19818
20073
  }
19819
20074
  witnessBytes(ref) {
19820
20075
  return chunkLJQ2VQBE_cjs.witnessRefToBytes(ref, this.args, this.contract.args);
@@ -20037,5 +20292,5 @@ exports.validateVtxoTxGraph = validateVtxoTxGraph;
20037
20292
  exports.verifyTapscriptSignatures = verifyTapscriptSignatures;
20038
20293
  exports.waitForIncomingFunds = waitForIncomingFunds;
20039
20294
  exports.warnAndFilterVtxosForScript = warnAndFilterVtxosForScript;
20040
- //# sourceMappingURL=chunk-2LAJ3RTH.cjs.map
20041
- //# sourceMappingURL=chunk-2LAJ3RTH.cjs.map
20295
+ //# sourceMappingURL=chunk-6XF6ZATZ.cjs.map
20296
+ //# sourceMappingURL=chunk-6XF6ZATZ.cjs.map