@arkade-os/sdk 0.4.48 → 0.4.49

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/{ark-CjE0KkGp.d.cts → ark-nkSiPYNf.d.cts} +86 -24
  8. package/dist/{ark-CjE0KkGp.d.ts → ark-nkSiPYNf.d.ts} +86 -24
  9. package/dist/{asyncStorageTaskQueue-D9SOPMPC.d.ts → asyncStorageTaskQueue-DCaEE83p.d.ts} +1 -1
  10. package/dist/{asyncStorageTaskQueue-CeLZhZFU.d.cts → asyncStorageTaskQueue-DdxhsEz6.d.cts} +1 -1
  11. package/dist/{chunk-ENZ4YPR2.cjs → chunk-2LAJ3RTH.cjs} +491 -418
  12. package/dist/chunk-2LAJ3RTH.cjs.map +1 -0
  13. package/dist/{chunk-NYR5H6GR.js → chunk-5QVBJUOG.js} +154 -81
  14. package/dist/chunk-5QVBJUOG.js.map +1 -0
  15. package/dist/{chunk-SYDANBJI.cjs → chunk-6UI5BFE7.cjs} +9 -9
  16. package/dist/{chunk-SYDANBJI.cjs.map → chunk-6UI5BFE7.cjs.map} +1 -1
  17. package/dist/{chunk-G6J6AEMH.js → chunk-BLJQV3N4.js} +4 -4
  18. package/dist/{chunk-G6J6AEMH.js.map → chunk-BLJQV3N4.js.map} +1 -1
  19. package/dist/{chunk-BHHLRZCS.js → chunk-CPO2UB7L.js} +4 -4
  20. package/dist/{chunk-BHHLRZCS.js.map → chunk-CPO2UB7L.js.map} +1 -1
  21. package/dist/{chunk-7TXSPRN5.cjs → chunk-E7HB3GKK.cjs} +31 -2
  22. package/dist/chunk-E7HB3GKK.cjs.map +1 -0
  23. package/dist/{chunk-ZDDBTFVO.js → chunk-EFNLTS6Q.js} +29 -3
  24. package/dist/chunk-EFNLTS6Q.js.map +1 -0
  25. package/dist/{chunk-XFMGIFBL.js → chunk-HN25T276.js} +4 -4
  26. package/dist/{chunk-XFMGIFBL.js.map → chunk-HN25T276.js.map} +1 -1
  27. package/dist/{chunk-5XMVTK5S.cjs → chunk-LJQ2VQBE.cjs} +211 -230
  28. package/dist/chunk-LJQ2VQBE.cjs.map +1 -0
  29. package/dist/{chunk-4VVTRPH3.js → chunk-MBSYQ3WX.js} +183 -201
  30. package/dist/chunk-MBSYQ3WX.js.map +1 -0
  31. package/dist/{chunk-EB3ALGTM.cjs → chunk-QDXQULVM.cjs} +13 -13
  32. package/dist/{chunk-EB3ALGTM.cjs.map → chunk-QDXQULVM.cjs.map} +1 -1
  33. package/dist/{chunk-ENDNQPZA.cjs → chunk-XOLH3LFO.cjs} +17 -17
  34. package/dist/{chunk-ENDNQPZA.cjs.map → chunk-XOLH3LFO.cjs.map} +1 -1
  35. package/dist/contracts/handlers/index.cjs +8 -8
  36. package/dist/contracts/handlers/index.d.cts +3 -3
  37. package/dist/contracts/handlers/index.d.ts +3 -3
  38. package/dist/contracts/handlers/index.js +2 -2
  39. package/dist/{delegate-D3dY-2vS.d.cts → delegate-Cqqw1T1J.d.cts} +1 -1
  40. package/dist/{delegate-DhGZk1r2.d.ts → delegate-D6Orvyq7.d.ts} +1 -1
  41. package/dist/{index-DK4_iWYy.d.ts → index-CWoogah0.d.ts} +2 -2
  42. package/dist/{index-D6RQROds.d.cts → index-Yd4hecbM.d.cts} +2 -2
  43. package/dist/index.cjs +181 -181
  44. package/dist/index.d.cts +8 -8
  45. package/dist/index.d.ts +8 -8
  46. package/dist/index.js +4 -4
  47. package/dist/repositories/realm/index.cjs +19 -19
  48. package/dist/repositories/realm/index.d.cts +2 -2
  49. package/dist/repositories/realm/index.d.ts +2 -2
  50. package/dist/repositories/realm/index.js +5 -5
  51. package/dist/repositories/sqlite/index.cjs +18 -18
  52. package/dist/repositories/sqlite/index.d.cts +2 -2
  53. package/dist/repositories/sqlite/index.d.ts +2 -2
  54. package/dist/repositories/sqlite/index.js +5 -5
  55. package/dist/{taskRunner-Brnak0Rc.d.cts → taskRunner-BjB5QINR.d.cts} +1 -1
  56. package/dist/{taskRunner-B-2MHCYG.d.ts → taskRunner-Dw7xs60Q.d.ts} +1 -1
  57. package/dist/wallet/expo/background.cjs +14 -14
  58. package/dist/wallet/expo/background.d.cts +3 -3
  59. package/dist/wallet/expo/background.d.ts +3 -3
  60. package/dist/wallet/expo/background.js +6 -6
  61. package/dist/wallet/expo/index.cjs +14 -14
  62. package/dist/wallet/expo/index.d.cts +4 -4
  63. package/dist/wallet/expo/index.d.ts +4 -4
  64. package/dist/wallet/expo/index.js +5 -5
  65. package/dist/{wallet-B5bwixQa.d.ts → wallet-CGkWu3xV.d.cts} +2 -2
  66. package/dist/{wallet-DiOrtYic.d.cts → wallet-DyUHrPyN.d.ts} +2 -2
  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-4VVTRPH3.js.map +0 -1
  73. package/dist/chunk-5XMVTK5S.cjs.map +0 -1
  74. package/dist/chunk-7TXSPRN5.cjs.map +0 -1
  75. package/dist/chunk-ENZ4YPR2.cjs.map +0 -1
  76. package/dist/chunk-NYR5H6GR.js.map +0 -1
  77. package/dist/chunk-ZDDBTFVO.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, timelockToSequence, sequenceToTimelock, getNormalizedVtxos } from './chunk-ZDDBTFVO.js';
1
+ import { VtxoScript, MultisigTapscript, CSVMultisigTapscript, ConditionMultisigTapscript, CLTVMultisigTapscript, ConditionCSVMultisigTapscript, timelockToSequence, sequenceToTimelock, SCRIPT_QUERY_CHUNK_SIZE, getNormalizedVtxos, DEFAULT_PAGE_SIZE } from './chunk-EFNLTS6Q.js';
2
2
  import { __export } from './chunk-NSBPE2FW.js';
3
3
  import { hex } from '@scure/base';
4
4
  import { networks, expand } from '@bitcoinerlab/descriptors-scure';
@@ -192,8 +192,8 @@ function deriveDescriptorLeafPubKey(descriptor) {
192
192
  return key.pubkey;
193
193
  }
194
194
 
195
- // src/contracts/constants.ts
196
- var DEFAULT_PAGE_SIZE = 500;
195
+ // src/contracts/metadata.ts
196
+ var WALLET_RECEIVE_SOURCE = "wallet-receive";
197
197
 
198
198
  // src/contracts/handlers/helpers.ts
199
199
  function extractRawPubKey(value) {
@@ -238,6 +238,12 @@ function resolveRole(contract, context) {
238
238
  }
239
239
  return void 0;
240
240
  }
241
+ function extractPubKeyBytes(value) {
242
+ return hex.decode(extractPubKey(normalizeToDescriptor(value)));
243
+ }
244
+ function deserializeCsvTimelock(value) {
245
+ return value !== void 0 && value !== "" ? sequenceToTimelock(Number(value)) : DefaultVtxo.Script.DEFAULT_TIMELOCK;
246
+ }
241
247
  var CLTV_HEIGHT_THRESHOLD = 500000000n;
242
248
  function isCltvSatisfied(context, locktime) {
243
249
  if (locktime < CLTV_HEIGHT_THRESHOLD) {
@@ -264,34 +270,112 @@ function isCsvSpendable(context, sequence) {
264
270
  }
265
271
  return false;
266
272
  }
273
+ function exitSequence(contract) {
274
+ return contract.params.csvTimelock ? Number(contract.params.csvTimelock) : void 0;
275
+ }
276
+ function selectForfeitOrExitPath(script, contract, context) {
277
+ if (context.collaborative) {
278
+ return { leaf: script.forfeit() };
279
+ }
280
+ const sequence = exitSequence(contract);
281
+ if (!isCsvSpendable(context, sequence)) {
282
+ return null;
283
+ }
284
+ return { leaf: script.exit(), sequence };
285
+ }
286
+ function forfeitExitAllPaths(script, contract, context) {
287
+ const paths = [];
288
+ if (context.collaborative) {
289
+ paths.push({ leaf: script.forfeit() });
290
+ }
291
+ const exitPath = { leaf: script.exit() };
292
+ const sequence = exitSequence(contract);
293
+ if (sequence !== void 0) {
294
+ exitPath.sequence = sequence;
295
+ }
296
+ paths.push(exitPath);
297
+ return paths;
298
+ }
299
+ function forfeitExitSpendablePaths(script, contract, context) {
300
+ const paths = [];
301
+ if (context.collaborative) {
302
+ paths.push({ leaf: script.forfeit() });
303
+ }
304
+ const sequence = exitSequence(contract);
305
+ if (isCsvSpendable(context, sequence)) {
306
+ const exitPath = { leaf: script.exit() };
307
+ if (sequence !== void 0) {
308
+ exitPath.sequence = sequence;
309
+ }
310
+ paths.push(exitPath);
311
+ }
312
+ return paths;
313
+ }
267
314
  async function detectUsedScripts(indexerProvider, scriptHexes) {
268
315
  const used = /* @__PURE__ */ new Set();
269
- if (scriptHexes.length === 0) return used;
270
- const remaining = new Set(scriptHexes);
271
- let pageIndex = 0;
272
- let hasMore = true;
273
- while (hasMore && remaining.size > 0) {
274
- const { vtxos, page } = await getNormalizedVtxos(indexerProvider, {
275
- scripts: scriptHexes,
276
- pageIndex,
277
- pageSize: DEFAULT_PAGE_SIZE
278
- });
279
- for (const vtxo of vtxos) {
280
- if (remaining.delete(vtxo.script)) used.add(vtxo.script);
316
+ const unique = [...new Set(scriptHexes)];
317
+ for (let offset = 0; offset < unique.length; offset += SCRIPT_QUERY_CHUNK_SIZE) {
318
+ const scripts = unique.slice(offset, offset + SCRIPT_QUERY_CHUNK_SIZE);
319
+ const remaining = new Set(scripts);
320
+ let pageIndex = 0;
321
+ let hasMore = true;
322
+ while (hasMore && remaining.size > 0) {
323
+ const { vtxos, page } = await getNormalizedVtxos(indexerProvider, {
324
+ scripts,
325
+ pageIndex,
326
+ pageSize: DEFAULT_PAGE_SIZE
327
+ });
328
+ for (const vtxo of vtxos) {
329
+ if (remaining.delete(vtxo.script)) used.add(vtxo.script);
330
+ }
331
+ hasMore = page ? vtxos.length === DEFAULT_PAGE_SIZE : false;
332
+ pageIndex++;
281
333
  }
282
- hasMore = page ? vtxos.length === DEFAULT_PAGE_SIZE : false;
283
- pageIndex++;
284
334
  }
285
335
  return used;
286
336
  }
287
-
288
- // src/contracts/metadata.ts
289
- var WALLET_RECEIVE_SOURCE = "wallet-receive";
337
+ async function discoverIndexerCandidates(indexerProvider, entries, buildCandidates, emit) {
338
+ const perIndex = entries.map((entry) => ({
339
+ ...entry,
340
+ candidates: buildCandidates(entry.index, entry.descriptor)
341
+ }));
342
+ const used = await detectUsedScripts(
343
+ indexerProvider,
344
+ perIndex.flatMap((e) => e.candidates.map((c) => c.scriptHex))
345
+ );
346
+ const out = /* @__PURE__ */ new Map();
347
+ for (const { index, descriptor, candidates } of perIndex) {
348
+ out.set(
349
+ index,
350
+ candidates.filter((c) => used.has(c.scriptHex)).map((c) => emit(c, index, descriptor))
351
+ );
352
+ }
353
+ return out;
354
+ }
355
+ function buildSignerTimelockCandidates(descriptor, deps, makeScript) {
356
+ const pubKey = deriveDescriptorLeafPubKey(descriptor);
357
+ const signers = [deps.serverPubKey, ...deps.deprecatedSignerPubKeys ?? []];
358
+ const seen = /* @__PURE__ */ new Set();
359
+ const candidates = [];
360
+ for (const serverPubKey of signers) {
361
+ for (const csvTimelock of deps.csvTimelocks) {
362
+ const script = makeScript({ pubKey, serverPubKey, csvTimelock });
363
+ const scriptHex = hex.encode(script.pkScript);
364
+ if (seen.has(scriptHex)) continue;
365
+ seen.add(scriptHex);
366
+ candidates.push({ pubKey, serverPubKey, csvTimelock, script, scriptHex });
367
+ }
368
+ }
369
+ return candidates;
370
+ }
371
+ function rotatedReceiveMetadata(index, descriptor) {
372
+ return index > 0 ? { metadata: { source: WALLET_RECEIVE_SOURCE, signingDescriptor: descriptor } } : {};
373
+ }
374
+ function discoverAtViaRange(discoverRange) {
375
+ return async (index, descriptor, deps) => (await discoverRange([{ index, descriptor }], deps)).get(index) ?? [];
376
+ }
290
377
 
291
378
  // src/contracts/handlers/default.ts
292
- function extractPubKeyBytes(value) {
293
- return hex.decode(extractPubKey(normalizeToDescriptor(value)));
294
- }
295
379
  var DefaultContractHandler = {
296
380
  type: "default",
297
381
  createScript(params) {
@@ -306,98 +390,45 @@ var DefaultContractHandler = {
306
390
  };
307
391
  },
308
392
  deserializeParams(params) {
309
- const csvTimelock = params.csvTimelock !== void 0 && params.csvTimelock !== "" ? sequenceToTimelock(Number(params.csvTimelock)) : DefaultVtxo.Script.DEFAULT_TIMELOCK;
310
393
  return {
311
394
  pubKey: extractPubKeyBytes(params.pubKey),
312
395
  serverPubKey: extractPubKeyBytes(params.serverPubKey),
313
- csvTimelock
396
+ csvTimelock: deserializeCsvTimelock(params.csvTimelock)
314
397
  };
315
398
  },
316
399
  selectPath(script, contract, context) {
317
- if (context.collaborative) {
318
- return { leaf: script.forfeit() };
319
- }
320
- const sequence = contract.params.csvTimelock ? Number(contract.params.csvTimelock) : void 0;
321
- if (!isCsvSpendable(context, sequence)) {
322
- return null;
323
- }
324
- return {
325
- leaf: script.exit(),
326
- sequence
327
- };
400
+ return selectForfeitOrExitPath(script, contract, context);
328
401
  },
329
402
  getAllSpendingPaths(script, contract, context) {
330
- const paths = [];
331
- if (context.collaborative) {
332
- paths.push({ leaf: script.forfeit() });
333
- }
334
- const exitPath = { leaf: script.exit() };
335
- if (contract.params.csvTimelock) {
336
- exitPath.sequence = Number(contract.params.csvTimelock);
337
- }
338
- paths.push(exitPath);
339
- return paths;
403
+ return forfeitExitAllPaths(script, contract, context);
340
404
  },
341
405
  getSpendablePaths(script, contract, context) {
342
- const paths = [];
343
- if (context.collaborative) {
344
- paths.push({ leaf: script.forfeit() });
345
- }
346
- const exitSequence = contract.params.csvTimelock ? Number(contract.params.csvTimelock) : void 0;
347
- if (isCsvSpendable(context, exitSequence)) {
348
- const exitPath = { leaf: script.exit() };
349
- if (exitSequence !== void 0) {
350
- exitPath.sequence = exitSequence;
351
- }
352
- paths.push(exitPath);
353
- }
354
- return paths;
406
+ return forfeitExitSpendablePaths(script, contract, context);
355
407
  },
356
- async discoverAt(index, descriptor, deps) {
357
- const pubKey = deriveDescriptorLeafPubKey(descriptor);
358
- const signers = [deps.serverPubKey, ...deps.deprecatedSignerPubKeys ?? []];
359
- const seen = /* @__PURE__ */ new Set();
360
- const candidates = [];
361
- for (const serverPubKey of signers) {
362
- for (const csvTimelock of deps.csvTimelocks) {
363
- const script = new DefaultVtxo.Script({
364
- pubKey,
365
- serverPubKey,
366
- csvTimelock
367
- });
368
- const scriptHex = hex.encode(script.pkScript);
369
- if (seen.has(scriptHex)) continue;
370
- seen.add(scriptHex);
371
- candidates.push({ serverPubKey, csvTimelock, script, scriptHex });
372
- }
373
- }
374
- const used = await detectUsedScripts(
375
- deps.indexerProvider,
376
- candidates.map((c) => c.scriptHex)
377
- );
378
- const out = [];
379
- for (const c of candidates) {
380
- if (!used.has(c.scriptHex)) continue;
381
- out.push({
382
- type: "default",
383
- params: {
384
- pubKey: hex.encode(pubKey),
385
- serverPubKey: hex.encode(c.serverPubKey),
386
- csvTimelock: timelockToSequence(c.csvTimelock).toString()
387
- },
388
- script: c.scriptHex,
389
- address: c.script.address(deps.network.hrp, c.serverPubKey).encode(),
390
- ...index > 0 ? {
391
- metadata: {
392
- source: WALLET_RECEIVE_SOURCE,
393
- signingDescriptor: descriptor
394
- }
395
- } : {}
396
- });
397
- }
398
- return out;
399
- }
408
+ discoverAt: discoverAtViaRange(discoverDefaultRange),
409
+ discoverRange: discoverDefaultRange
400
410
  };
411
+ function discoverDefaultRange(entries, deps) {
412
+ return discoverIndexerCandidates(
413
+ deps.indexerProvider,
414
+ entries,
415
+ (_index, descriptor) => buildSignerTimelockCandidates(descriptor, deps, (opts) => new DefaultVtxo.Script(opts)),
416
+ // The matched signer is threaded through the script (already built),
417
+ // the persisted params, and the encoded address so signing/forfeit
418
+ // later resolves the right key.
419
+ (c, index, descriptor) => ({
420
+ type: "default",
421
+ params: {
422
+ pubKey: hex.encode(c.pubKey),
423
+ serverPubKey: hex.encode(c.serverPubKey),
424
+ csvTimelock: timelockToSequence(c.csvTimelock).toString()
425
+ },
426
+ script: c.scriptHex,
427
+ address: c.script.address(deps.network.hrp, c.serverPubKey).encode(),
428
+ ...rotatedReceiveMetadata(index, descriptor)
429
+ })
430
+ );
431
+ }
401
432
  var DelegateVtxo;
402
433
  ((DelegateVtxo2) => {
403
434
  class Script3 extends VtxoScript {
@@ -448,105 +479,61 @@ var DelegateContractHandler = {
448
479
  };
449
480
  },
450
481
  deserializeParams(params) {
451
- const csvTimelock = sequenceToTimelock(Number(params.csvTimelock));
452
482
  return {
453
- pubKey: hex.decode(params.pubKey),
454
- serverPubKey: hex.decode(params.serverPubKey),
455
- delegatePubKey: hex.decode(params.delegatePubKey),
456
- csvTimelock
483
+ pubKey: extractPubKeyBytes(params.pubKey),
484
+ serverPubKey: extractPubKeyBytes(params.serverPubKey),
485
+ delegatePubKey: extractPubKeyBytes(params.delegatePubKey),
486
+ csvTimelock: deserializeCsvTimelock(params.csvTimelock)
457
487
  };
458
488
  },
459
489
  selectPath(script, contract, context) {
460
- if (context.collaborative) {
461
- return { leaf: script.forfeit() };
462
- }
463
- const sequence = contract.params.csvTimelock ? Number(contract.params.csvTimelock) : void 0;
464
- if (!isCsvSpendable(context, sequence)) {
465
- return null;
466
- }
467
- return {
468
- leaf: script.exit(),
469
- sequence
470
- };
490
+ return selectForfeitOrExitPath(script, contract, context);
471
491
  },
472
492
  getAllSpendingPaths(script, contract, context) {
473
- const paths = [];
474
- if (context.collaborative) {
475
- paths.push({ leaf: script.forfeit() });
476
- }
477
- const exitPath = { leaf: script.exit() };
478
- if (contract.params.csvTimelock) {
479
- exitPath.sequence = Number(contract.params.csvTimelock);
480
- }
481
- paths.push(exitPath);
482
- if (context.collaborative) {
483
- paths.push({ leaf: script.delegate() });
484
- }
485
- return paths;
493
+ return [
494
+ ...forfeitExitAllPaths(script, contract, context),
495
+ // Delegate path (Alice + Delegate + Server) — collaborative only,
496
+ // and last so the shared forfeit/exit ordering is unchanged.
497
+ ...context.collaborative ? [{ leaf: script.delegate() }] : []
498
+ ];
486
499
  },
487
500
  getSpendablePaths(script, contract, context) {
488
- const paths = [];
489
- if (context.collaborative) {
490
- paths.push({ leaf: script.forfeit() });
491
- }
492
- const exitSequence = contract.params.csvTimelock ? Number(contract.params.csvTimelock) : void 0;
493
- if (isCsvSpendable(context, exitSequence)) {
494
- const exitPath = { leaf: script.exit() };
495
- if (exitSequence !== void 0) {
496
- exitPath.sequence = exitSequence;
497
- }
498
- paths.push(exitPath);
499
- }
500
- return paths;
501
+ return forfeitExitSpendablePaths(script, contract, context);
501
502
  },
502
- async discoverAt(index, descriptor, deps) {
503
- if (!deps.delegatePubKey) return [];
504
- const pubKey = deriveDescriptorLeafPubKey(descriptor);
505
- const signers = [deps.serverPubKey, ...deps.deprecatedSignerPubKeys ?? []];
506
- const seen = /* @__PURE__ */ new Set();
507
- const candidates = [];
508
- for (const serverPubKey of signers) {
509
- for (const csvTimelock of deps.csvTimelocks) {
510
- const script = new DelegateVtxo.Script({
511
- pubKey,
512
- serverPubKey,
513
- delegatePubKey: deps.delegatePubKey,
514
- csvTimelock
515
- });
516
- const scriptHex = hex.encode(script.pkScript);
517
- if (seen.has(scriptHex)) continue;
518
- seen.add(scriptHex);
519
- candidates.push({ serverPubKey, csvTimelock, script, scriptHex });
520
- }
521
- }
522
- const used = await detectUsedScripts(
523
- deps.indexerProvider,
524
- candidates.map((c) => c.scriptHex)
525
- );
526
- const out = [];
527
- for (const c of candidates) {
528
- if (!used.has(c.scriptHex)) continue;
529
- out.push({
530
- type: "delegate",
531
- params: {
532
- pubKey: hex.encode(pubKey),
533
- serverPubKey: hex.encode(c.serverPubKey),
534
- delegatePubKey: hex.encode(deps.delegatePubKey),
535
- csvTimelock: timelockToSequence(c.csvTimelock).toString()
536
- },
537
- script: c.scriptHex,
538
- address: c.script.address(deps.network.hrp, c.serverPubKey).encode(),
539
- ...index > 0 ? {
540
- metadata: {
541
- source: WALLET_RECEIVE_SOURCE,
542
- signingDescriptor: descriptor
543
- }
544
- } : {}
545
- });
546
- }
547
- return out;
548
- }
503
+ discoverAt: discoverAtViaRange(discoverDelegateRange),
504
+ discoverRange: discoverDelegateRange
549
505
  };
506
+ function discoverDelegateRange(entries, deps) {
507
+ const delegatePubKey = deps.delegatePubKey;
508
+ if (!delegatePubKey) {
509
+ return Promise.resolve(new Map(entries.map((e) => [e.index, []])));
510
+ }
511
+ return discoverIndexerCandidates(
512
+ deps.indexerProvider,
513
+ entries,
514
+ // The delegate key is constant across the cross-product, so it rides
515
+ // the closure rather than being repeated on every candidate.
516
+ (_index, descriptor) => buildSignerTimelockCandidates(
517
+ descriptor,
518
+ deps,
519
+ (opts) => new DelegateVtxo.Script({ ...opts, delegatePubKey })
520
+ ),
521
+ // The matched signer is threaded through script, params, and address so
522
+ // signing/forfeit later resolves the right key.
523
+ (c, index, descriptor) => ({
524
+ type: "delegate",
525
+ params: {
526
+ pubKey: hex.encode(c.pubKey),
527
+ serverPubKey: hex.encode(c.serverPubKey),
528
+ delegatePubKey: hex.encode(delegatePubKey),
529
+ csvTimelock: timelockToSequence(c.csvTimelock).toString()
530
+ },
531
+ script: c.scriptHex,
532
+ address: c.script.address(deps.network.hrp, c.serverPubKey).encode(),
533
+ ...rotatedReceiveMetadata(index, descriptor)
534
+ })
535
+ );
536
+ }
550
537
  var VHTLC;
551
538
  ((VHTLC2) => {
552
539
  class Script3 extends VtxoScript {
@@ -941,12 +928,7 @@ var BoardingContractHandler = {
941
928
  // newest boarding address and descriptor-aware signing can
942
929
  // recover the per-index key (plan §6-II/§6-III.3). The index-0
943
930
  // baseline stays untagged, matching `default`/`delegate`.
944
- ...index > 0 ? {
945
- metadata: {
946
- source: WALLET_RECEIVE_SOURCE,
947
- signingDescriptor: descriptor
948
- }
949
- } : {}
931
+ ...rotatedReceiveMetadata(index, descriptor)
950
932
  }
951
933
  ];
952
934
  }
@@ -2239,6 +2221,6 @@ contractHandlers.register(VHTLCContractHandler);
2239
2221
  contractHandlers.register(BoardingContractHandler);
2240
2222
  contractHandlers.register(ArkadeContractHandler);
2241
2223
 
2242
- export { ARKADE_OP, ARKADE_OPCODES, ARKADE_OPCODE_NAMES, ARKADE_OPCODE_VALUES, ARKADE_OPS, ArkadeContractHandler, ArkadeProgramScript, ArkadeScript, BoardingContractHandler, DEFAULT_PAGE_SIZE, DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, OPCODE_NAMES, OPCODE_VALUES, SUPPORTED_PROGRAM_VERSION, VHTLC, VHTLCContractHandler, WALLET_RECEIVE_SOURCE, arkadeScriptHash, arkadeWitnessHash, asmToBytes, bignum_exports, bytesToASM, computeArkadeScriptPublicKey, contractHandlers, deriveDescriptorLeafPubKey, descriptorIsOurs, deserializeArkadeContractParams, fromASM, getOpcodeName, getOpcodeValue, inputName, isCltvSatisfied, isCsvSpendable, isMainnetDescriptor, parseArtifact, resolveAsm, serializeArkadeContractParams, stringifyArtifact, toASM, validateProgram, witnessRefToBytes };
2243
- //# sourceMappingURL=chunk-4VVTRPH3.js.map
2244
- //# sourceMappingURL=chunk-4VVTRPH3.js.map
2224
+ export { ARKADE_OP, ARKADE_OPCODES, ARKADE_OPCODE_NAMES, ARKADE_OPCODE_VALUES, ARKADE_OPS, ArkadeContractHandler, ArkadeProgramScript, ArkadeScript, BoardingContractHandler, DefaultContractHandler, DefaultVtxo, DelegateContractHandler, DelegateVtxo, OPCODE_NAMES, OPCODE_VALUES, SUPPORTED_PROGRAM_VERSION, VHTLC, VHTLCContractHandler, WALLET_RECEIVE_SOURCE, arkadeScriptHash, arkadeWitnessHash, asmToBytes, bignum_exports, bytesToASM, computeArkadeScriptPublicKey, contractHandlers, deriveDescriptorLeafPubKey, descriptorIsOurs, deserializeArkadeContractParams, fromASM, getOpcodeName, getOpcodeValue, inputName, isCltvSatisfied, isCsvSpendable, isMainnetDescriptor, parseArtifact, resolveAsm, serializeArkadeContractParams, stringifyArtifact, toASM, validateProgram, witnessRefToBytes };
2225
+ //# sourceMappingURL=chunk-MBSYQ3WX.js.map
2226
+ //# sourceMappingURL=chunk-MBSYQ3WX.js.map