@arkade-os/sdk 0.4.67 → 0.4.69

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 (78) hide show
  1. package/README.md +38 -0
  2. package/dist/adapters/expo.cjs +5 -5
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +3 -3
  6. package/dist/adapters/indexedDB.cjs +5 -5
  7. package/dist/adapters/indexedDB.js +4 -4
  8. package/dist/{asyncStorageTaskQueue-Za-e_zMk.d.ts → asyncStorageTaskQueue-BgUJN-3X.d.ts} +2 -2
  9. package/dist/{asyncStorageTaskQueue-LTpeXYaD.d.cts → asyncStorageTaskQueue-Cstx6hS7.d.cts} +2 -2
  10. package/dist/{chunk-6TAQF6EV.js → chunk-2PPL3O7Z.js} +72 -120
  11. package/dist/chunk-2PPL3O7Z.js.map +1 -0
  12. package/dist/{chunk-2JV4VQ7C.cjs → chunk-5MLC2HU3.cjs} +17 -3
  13. package/dist/chunk-5MLC2HU3.cjs.map +1 -0
  14. package/dist/{chunk-MJUTO3PY.cjs → chunk-EBYCTLET.cjs} +832 -488
  15. package/dist/chunk-EBYCTLET.cjs.map +1 -0
  16. package/dist/{chunk-CO3KKSWM.cjs → chunk-GVHUHTRH.cjs} +17 -17
  17. package/dist/{chunk-CO3KKSWM.cjs.map → chunk-GVHUHTRH.cjs.map} +1 -1
  18. package/dist/{chunk-YDRZDZPP.cjs → chunk-HQ4DMGA4.cjs} +10 -10
  19. package/dist/{chunk-YDRZDZPP.cjs.map → chunk-HQ4DMGA4.cjs.map} +1 -1
  20. package/dist/{chunk-3WIWNE4P.js → chunk-L5SCQYHF.js} +16 -4
  21. package/dist/chunk-L5SCQYHF.js.map +1 -0
  22. package/dist/{chunk-MZFUZUTQ.js → chunk-MNMPGEK2.js} +4 -4
  23. package/dist/{chunk-MZFUZUTQ.js.map → chunk-MNMPGEK2.js.map} +1 -1
  24. package/dist/{chunk-AEWJU6NZ.js → chunk-TA7XLEP2.js} +411 -68
  25. package/dist/chunk-TA7XLEP2.js.map +1 -0
  26. package/dist/{chunk-OIZ2V2VD.cjs → chunk-WIFL5QYZ.cjs} +118 -166
  27. package/dist/chunk-WIFL5QYZ.cjs.map +1 -0
  28. package/dist/{chunk-EALWOVHK.js → chunk-XLWDX7QZ.js} +4 -4
  29. package/dist/{chunk-EALWOVHK.js.map → chunk-XLWDX7QZ.js.map} +1 -1
  30. package/dist/{chunk-R2YAMONM.cjs → chunk-XQPN5YP2.cjs} +17 -17
  31. package/dist/{chunk-R2YAMONM.cjs.map → chunk-XQPN5YP2.cjs.map} +1 -1
  32. package/dist/{chunk-X3VEMUVV.js → chunk-YG7T6LI3.js} +3 -3
  33. package/dist/{chunk-X3VEMUVV.js.map → chunk-YG7T6LI3.js.map} +1 -1
  34. package/dist/contracts/handlers/index.cjs +9 -9
  35. package/dist/contracts/handlers/index.d.cts +3 -3
  36. package/dist/contracts/handlers/index.d.ts +3 -3
  37. package/dist/contracts/handlers/index.js +2 -2
  38. package/dist/{delegate-cdmzb2f9.d.ts → delegate-BPdzTbwN.d.ts} +1 -1
  39. package/dist/{delegate-Bz2e2zXY.d.cts → delegate-DrwIar11.d.cts} +1 -1
  40. package/dist/{hdWalletCapable-Hi12xjCJ.d.ts → hdWalletCapable-D4WH35z0.d.cts} +49 -5
  41. package/dist/{hdWalletCapable-BSjuUYOO.d.cts → hdWalletCapable-DyxCiNVE.d.ts} +49 -5
  42. package/dist/{index-BiACuWaf.d.ts → index-BqhpAqqj.d.cts} +96 -119
  43. package/dist/{index-D2GjZxBr.d.cts → index-TZJvbIaA.d.ts} +96 -119
  44. package/dist/{index-DU5o_hz7.d.cts → index-dWRqYSdS.d.cts} +70 -2
  45. package/dist/{index-DU5o_hz7.d.ts → index-dWRqYSdS.d.ts} +70 -2
  46. package/dist/index.cjs +297 -289
  47. package/dist/index.d.cts +29 -8
  48. package/dist/index.d.ts +29 -8
  49. package/dist/index.js +4 -4
  50. package/dist/repositories/realm/index.cjs +19 -19
  51. package/dist/repositories/realm/index.d.cts +2 -2
  52. package/dist/repositories/realm/index.d.ts +2 -2
  53. package/dist/repositories/realm/index.js +5 -5
  54. package/dist/repositories/sqlite/index.cjs +18 -18
  55. package/dist/repositories/sqlite/index.d.cts +2 -2
  56. package/dist/repositories/sqlite/index.d.ts +2 -2
  57. package/dist/repositories/sqlite/index.js +5 -5
  58. package/dist/{taskRunner-BZJMLQ6g.d.cts → taskRunner-CzYKyJ9c.d.cts} +2 -2
  59. package/dist/{taskRunner-DATaRQus.d.ts → taskRunner-D2fnbqYw.d.ts} +2 -2
  60. package/dist/wallet/expo/background.cjs +14 -14
  61. package/dist/wallet/expo/background.d.cts +3 -3
  62. package/dist/wallet/expo/background.d.ts +3 -3
  63. package/dist/wallet/expo/background.js +6 -6
  64. package/dist/wallet/expo/index.cjs +14 -14
  65. package/dist/wallet/expo/index.d.cts +4 -4
  66. package/dist/wallet/expo/index.d.ts +4 -4
  67. package/dist/wallet/expo/index.js +5 -5
  68. package/dist/worker/expo/index.cjs +9 -9
  69. package/dist/worker/expo/index.d.cts +4 -4
  70. package/dist/worker/expo/index.d.ts +4 -4
  71. package/dist/worker/expo/index.js +5 -5
  72. package/package.json +1 -1
  73. package/dist/chunk-2JV4VQ7C.cjs.map +0 -1
  74. package/dist/chunk-3WIWNE4P.js.map +0 -1
  75. package/dist/chunk-6TAQF6EV.js.map +0 -1
  76. package/dist/chunk-AEWJU6NZ.js.map +0 -1
  77. package/dist/chunk-MJUTO3PY.cjs.map +0 -1
  78. package/dist/chunk-OIZ2V2VD.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunk2JV4VQ7C_cjs = require('./chunk-2JV4VQ7C.cjs');
3
+ var chunk5MLC2HU3_cjs = require('./chunk-5MLC2HU3.cjs');
4
4
  var chunk5BLDMQED_cjs = require('./chunk-5BLDMQED.cjs');
5
5
  var base = require('@scure/base');
6
6
  var descriptorsScure = require('@bitcoinerlab/descriptors-scure');
@@ -76,14 +76,14 @@ var ContractHandlerRegistry = class {
76
76
  var contractHandlers = new ContractHandlerRegistry();
77
77
  exports.DefaultVtxo = void 0;
78
78
  ((DefaultVtxo2) => {
79
- class Script3 extends chunk2JV4VQ7C_cjs.VtxoScript {
79
+ class Script3 extends chunk5MLC2HU3_cjs.VtxoScript {
80
80
  /** Create the default virtual output script with one forfeit path and one exit path. */
81
81
  constructor(options) {
82
82
  const { pubKey, serverPubKey, csvTimelock } = options;
83
- const forfeitScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
83
+ const forfeitScript = chunk5MLC2HU3_cjs.MultisigTapscript.encode({
84
84
  pubkeys: [pubKey, serverPubKey]
85
85
  }).script;
86
- const exitScript = chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({
86
+ const exitScript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({
87
87
  timelock: csvTimelock,
88
88
  pubkeys: [pubKey]
89
89
  }).script;
@@ -288,7 +288,7 @@ function extractPubKeyBytes(value) {
288
288
  return base.hex.decode(extractPubKey(normalizeToDescriptor(value)));
289
289
  }
290
290
  function deserializeCsvTimelock(value) {
291
- return value !== void 0 && value !== "" ? chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
291
+ return value !== void 0 && value !== "" ? chunk5MLC2HU3_cjs.sequenceToTimelock(Number(value)) : exports.DefaultVtxo.Script.DEFAULT_TIMELOCK;
292
292
  }
293
293
  var CLTV_HEIGHT_THRESHOLD = 500000000n;
294
294
  function isCltvSatisfied(context, locktime) {
@@ -330,7 +330,7 @@ function assertVhtlcSpendableNow(contract, context) {
330
330
  function isCsvSpendable(context, sequence) {
331
331
  if (sequence === void 0) return true;
332
332
  if (!context.vtxo) return false;
333
- const timelock = chunk2JV4VQ7C_cjs.sequenceToTimelock(sequence);
333
+ const timelock = chunk5MLC2HU3_cjs.sequenceToTimelock(sequence);
334
334
  if (timelock.type === "blocks") {
335
335
  if (context.blockHeight === void 0 || context.vtxo.status.block_height === void 0) {
336
336
  return false;
@@ -388,21 +388,21 @@ function forfeitExitSpendablePaths(script, contract, context) {
388
388
  async function detectUsedScripts(indexerProvider, scriptHexes) {
389
389
  const used = /* @__PURE__ */ new Set();
390
390
  const unique = [...new Set(scriptHexes)];
391
- for (let offset = 0; offset < unique.length; offset += chunk2JV4VQ7C_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
392
- const scripts = unique.slice(offset, offset + chunk2JV4VQ7C_cjs.SCRIPT_QUERY_CHUNK_SIZE);
391
+ for (let offset = 0; offset < unique.length; offset += chunk5MLC2HU3_cjs.SCRIPT_QUERY_CHUNK_SIZE) {
392
+ const scripts = unique.slice(offset, offset + chunk5MLC2HU3_cjs.SCRIPT_QUERY_CHUNK_SIZE);
393
393
  const remaining = new Set(scripts);
394
394
  let pageIndex = 0;
395
395
  let hasMore = true;
396
396
  while (hasMore && remaining.size > 0) {
397
- const { vtxos, page } = await chunk2JV4VQ7C_cjs.getNormalizedVtxos(indexerProvider, {
397
+ const { vtxos, page } = await chunk5MLC2HU3_cjs.getNormalizedVtxos(indexerProvider, {
398
398
  scripts,
399
399
  pageIndex,
400
- pageSize: chunk2JV4VQ7C_cjs.DEFAULT_PAGE_SIZE
400
+ pageSize: chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE
401
401
  });
402
402
  for (const vtxo of vtxos) {
403
403
  if (remaining.delete(vtxo.script)) used.add(vtxo.script);
404
404
  }
405
- hasMore = page ? vtxos.length === chunk2JV4VQ7C_cjs.DEFAULT_PAGE_SIZE : false;
405
+ hasMore = page ? vtxos.length === chunk5MLC2HU3_cjs.DEFAULT_PAGE_SIZE : false;
406
406
  pageIndex++;
407
407
  }
408
408
  }
@@ -463,7 +463,7 @@ var DefaultContractHandler = {
463
463
  return {
464
464
  pubKey: base.hex.encode(params.pubKey),
465
465
  serverPubKey: base.hex.encode(params.serverPubKey),
466
- csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(params.csvTimelock).toString()
466
+ csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(params.csvTimelock).toString()
467
467
  };
468
468
  },
469
469
  deserializeParams(params) {
@@ -498,7 +498,7 @@ function defaultCandidatesAt(_index, descriptor, deps) {
498
498
  params: {
499
499
  pubKey: base.hex.encode(c.pubKey),
500
500
  serverPubKey: base.hex.encode(c.serverPubKey),
501
- csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(c.csvTimelock).toString()
501
+ csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(c.csvTimelock).toString()
502
502
  },
503
503
  script: c.scriptHex,
504
504
  address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
@@ -514,12 +514,12 @@ function discoverDefaultRange(entries, deps) {
514
514
  }
515
515
  exports.DelegateVtxo = void 0;
516
516
  ((DelegateVtxo2) => {
517
- class Script3 extends chunk2JV4VQ7C_cjs.VtxoScript {
517
+ class Script3 extends chunk5MLC2HU3_cjs.VtxoScript {
518
518
  /** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
519
519
  constructor(options) {
520
520
  const defaultVtxo = new exports.DefaultVtxo.Script(options);
521
521
  const { delegatePubKey, pubKey, serverPubKey } = options;
522
- const delegateScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
522
+ const delegateScript = chunk5MLC2HU3_cjs.MultisigTapscript.encode({
523
523
  pubkeys: [pubKey, delegatePubKey, serverPubKey]
524
524
  }).script;
525
525
  super([...defaultVtxo.scripts, delegateScript]);
@@ -558,7 +558,7 @@ var DelegateContractHandler = {
558
558
  pubKey: base.hex.encode(params.pubKey),
559
559
  serverPubKey: base.hex.encode(params.serverPubKey),
560
560
  delegatePubKey: base.hex.encode(params.delegatePubKey),
561
- csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(params.csvTimelock).toString()
561
+ csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(params.csvTimelock).toString()
562
562
  };
563
563
  },
564
564
  deserializeParams(params) {
@@ -602,7 +602,7 @@ function delegateCandidatesAt(_index, descriptor, deps) {
602
602
  pubKey: base.hex.encode(c.pubKey),
603
603
  serverPubKey: base.hex.encode(c.serverPubKey),
604
604
  delegatePubKey: base.hex.encode(delegatePubKey),
605
- csvTimelock: chunk2JV4VQ7C_cjs.timelockToSequence(c.csvTimelock).toString()
605
+ csvTimelock: chunk5MLC2HU3_cjs.timelockToSequence(c.csvTimelock).toString()
606
606
  },
607
607
  script: c.scriptHex,
608
608
  address: c.script.address(deps.network.hrp, c.serverPubKey).encode()
@@ -1445,7 +1445,7 @@ function computeArkadeScriptPublicKey(pubKey, script) {
1445
1445
  // src/script/vhtlc.ts
1446
1446
  exports.VHTLC = void 0;
1447
1447
  ((VHTLC2) => {
1448
- class BaseScript extends chunk2JV4VQ7C_cjs.VtxoScript {
1448
+ class BaseScript extends chunk5MLC2HU3_cjs.VtxoScript {
1449
1449
  options;
1450
1450
  claimScript;
1451
1451
  refundScript;
@@ -1472,27 +1472,27 @@ exports.VHTLC = void 0;
1472
1472
  unilateralRefundWithoutReceiverDelay
1473
1473
  } = options;
1474
1474
  const conditionScript = preimageCondition(preimageHash);
1475
- const claimScript = chunk2JV4VQ7C_cjs.ConditionMultisigTapscript.encode({
1475
+ const claimScript = chunk5MLC2HU3_cjs.ConditionMultisigTapscript.encode({
1476
1476
  conditionScript,
1477
1477
  pubkeys: [receiver, server]
1478
1478
  }).script;
1479
- const refundScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
1479
+ const refundScript = chunk5MLC2HU3_cjs.MultisigTapscript.encode({
1480
1480
  pubkeys: [sender, receiver, server]
1481
1481
  }).script;
1482
- const refundWithoutReceiverScript = chunk2JV4VQ7C_cjs.CLTVMultisigTapscript.encode({
1482
+ const refundWithoutReceiverScript = chunk5MLC2HU3_cjs.CLTVMultisigTapscript.encode({
1483
1483
  absoluteTimelock: refundLocktime,
1484
1484
  pubkeys: [sender, server]
1485
1485
  }).script;
1486
- const unilateralClaimScript = chunk2JV4VQ7C_cjs.ConditionCSVMultisigTapscript.encode({
1486
+ const unilateralClaimScript = chunk5MLC2HU3_cjs.ConditionCSVMultisigTapscript.encode({
1487
1487
  conditionScript,
1488
1488
  timelock: unilateralClaimDelay,
1489
1489
  pubkeys: [receiver]
1490
1490
  }).script;
1491
- const unilateralRefundScript = chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({
1491
+ const unilateralRefundScript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({
1492
1492
  timelock: unilateralRefundDelay,
1493
1493
  pubkeys: [sender, receiver]
1494
1494
  }).script;
1495
- const unilateralRefundWithoutReceiverScript = chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({
1495
+ const unilateralRefundWithoutReceiverScript = chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({
1496
1496
  timelock: unilateralRefundWithoutReceiverDelay,
1497
1497
  pubkeys: [sender]
1498
1498
  }).script;
@@ -1506,42 +1506,31 @@ exports.VHTLC = void 0;
1506
1506
  ];
1507
1507
  let arkadeScriptNic;
1508
1508
  let nonInteractiveClaimScript;
1509
- if (options.nonInteractiveClaim) {
1510
- arkadeScriptNic = enforcePayToMaybeAsset(
1511
- options.nonInteractiveClaim.receiverPkScript,
1512
- options.asset,
1513
- options.nonInteractiveClaim.strict
1514
- );
1515
- nonInteractiveClaimScript = chunk2JV4VQ7C_cjs.ConditionMultisigTapscript.encode({
1509
+ let arkadeScriptNir;
1510
+ let nonInteractiveRefundScript;
1511
+ let nonInteractiveRefundWithoutReceiverScript;
1512
+ const covenants = options.nonInteractiveParameters;
1513
+ if (covenants) {
1514
+ arkadeScriptNic = enforcePayToMaybeAsset(covenants.receiverPkScript, options.asset);
1515
+ nonInteractiveClaimScript = chunk5MLC2HU3_cjs.ConditionMultisigTapscript.encode({
1516
1516
  conditionScript,
1517
1517
  pubkeys: [
1518
1518
  server,
1519
- computeArkadeScriptPublicKey(
1520
- options.nonInteractiveClaim.emulatorPubkey,
1521
- arkadeScriptNic
1522
- )
1519
+ computeArkadeScriptPublicKey(covenants.emulatorPubkey, arkadeScriptNic)
1523
1520
  ]
1524
1521
  }).script;
1525
1522
  scripts.push(nonInteractiveClaimScript);
1526
- }
1527
- let arkadeScriptNir;
1528
- let nonInteractiveRefundScript;
1529
- let nonInteractiveRefundWithoutReceiverScript;
1530
- if (options.nonInteractiveRefund) {
1531
- arkadeScriptNir = enforcePayToMaybeAsset(
1532
- options.nonInteractiveRefund.senderPkScript,
1533
- options.asset
1534
- );
1523
+ arkadeScriptNir = enforcePayToMaybeAsset(covenants.senderPkScript, options.asset);
1535
1524
  const nirCosigner = computeArkadeScriptPublicKey(
1536
- options.nonInteractiveRefund.emulatorPubkey,
1525
+ covenants.emulatorPubkey,
1537
1526
  arkadeScriptNir
1538
1527
  );
1539
- nonInteractiveRefundScript = chunk2JV4VQ7C_cjs.MultisigTapscript.encode({
1528
+ nonInteractiveRefundScript = chunk5MLC2HU3_cjs.MultisigTapscript.encode({
1540
1529
  pubkeys: [server, receiver, nirCosigner]
1541
1530
  }).script;
1542
1531
  scripts.push(nonInteractiveRefundScript);
1543
- if (options.nonInteractiveRefund.withoutReceiver) {
1544
- nonInteractiveRefundWithoutReceiverScript = chunk2JV4VQ7C_cjs.CLTVMultisigTapscript.encode({
1532
+ if (covenants.legacy !== "preTimelockedRefund") {
1533
+ nonInteractiveRefundWithoutReceiverScript = chunk5MLC2HU3_cjs.CLTVMultisigTapscript.encode({
1545
1534
  absoluteTimelock: refundLocktime,
1546
1535
  pubkeys: [server, nirCosigner]
1547
1536
  }).script;
@@ -1705,47 +1694,25 @@ exports.VHTLC = void 0;
1705
1694
  if (!preimageHash || preimageHash.length !== 20) {
1706
1695
  throw new Error("preimage hash must be 20 bytes");
1707
1696
  }
1708
- if (options.asset !== void 0 && !options.nonInteractiveClaim && !options.nonInteractiveRefund) {
1709
- throw new Error(
1710
- "asset has no effect without nonInteractiveClaim or nonInteractiveRefund"
1711
- );
1697
+ if (options.asset !== void 0 && !options.nonInteractiveParameters) {
1698
+ throw new Error("asset has no effect without nonInteractiveParameters");
1712
1699
  }
1713
- const strict = options.nonInteractiveClaim?.strict;
1714
- if (strict !== void 0) {
1715
- if (strict.amount <= 0n) {
1716
- throw new Error(`strict claim amount must be positive, got ${strict.amount}`);
1717
- }
1718
- if (options.asset !== void 0 && strict.assetAmount === void 0) {
1719
- throw new Error(
1720
- "strict claim needs assetAmount when the contract is denominated in an asset: bounding only the sats would leave the asset amount unenforced"
1721
- );
1722
- }
1723
- if (options.asset === void 0 && strict.assetAmount !== void 0) {
1724
- throw new Error("strict claim assetAmount has no effect without asset");
1725
- }
1726
- if (strict.assetAmount !== void 0 && strict.assetAmount <= 0n) {
1727
- throw new Error(
1728
- `strict claim assetAmount must be positive, got ${strict.assetAmount}`
1729
- );
1730
- }
1731
- }
1732
- if (options.nonInteractiveClaim) {
1733
- const { emulatorPubkey, receiverPkScript } = options.nonInteractiveClaim;
1700
+ if (options.nonInteractiveParameters) {
1701
+ const { emulatorPubkey, receiverPkScript, senderPkScript, legacy } = options.nonInteractiveParameters;
1734
1702
  if (!emulatorPubkey || emulatorPubkey.length !== 32 && emulatorPubkey.length !== 33) {
1735
1703
  throw new Error("Invalid public key length (emulator)");
1736
1704
  }
1737
1705
  if (!receiverPkScript || !isP2trPkScript(receiverPkScript)) {
1738
1706
  throw new Error("Invalid P2TR script");
1739
1707
  }
1740
- }
1741
- if (options.nonInteractiveRefund) {
1742
- const { emulatorPubkey, senderPkScript } = options.nonInteractiveRefund;
1743
- if (!emulatorPubkey || emulatorPubkey.length !== 32 && emulatorPubkey.length !== 33) {
1744
- throw new Error("Invalid public key length (emulator)");
1745
- }
1746
1708
  if (!senderPkScript || !isP2trPkScript(senderPkScript)) {
1747
1709
  throw new Error("Invalid P2TR script");
1748
1710
  }
1711
+ if (legacy !== void 0 && legacy !== "preTimelockedRefund") {
1712
+ throw new Error(
1713
+ `nonInteractiveParameters.legacy must be "preTimelockedRefund" when set, got ${JSON.stringify(legacy)}`
1714
+ );
1715
+ }
1749
1716
  }
1750
1717
  if (!receiver || receiver.length !== 32) {
1751
1718
  throw new Error("Invalid public key length (receiver)");
@@ -1797,7 +1764,7 @@ function preimageConditionScriptV2(preimageHash) {
1797
1764
  function isP2trPkScript(pkScript) {
1798
1765
  return pkScript.length === 34 && pkScript[0] === 81 && pkScript[1] === 32;
1799
1766
  }
1800
- function satClause(destinationPkScript, quotedSats) {
1767
+ function satClause(destinationPkScript) {
1801
1768
  return [
1802
1769
  "PUSHCURRENTINPUTINDEX",
1803
1770
  "DUP",
@@ -1807,21 +1774,18 @@ function satClause(destinationPkScript, quotedSats) {
1807
1774
  destinationPkScript.subarray(2),
1808
1775
  "EQUALVERIFY",
1809
1776
  "INSPECTOUTPUTVALUE",
1810
- // `DUP` because the output value is needed twice: once against the
1811
- // quote, once against the input.
1812
- ...quotedSats === void 0 ? [] : ["DUP", quotedSats, "GREATERTHANOREQUAL", "VERIFY"],
1813
1777
  "PUSHCURRENTINPUTINDEX",
1814
1778
  "INSPECTINPUTVALUE",
1815
1779
  "GREATERTHANOREQUAL"
1816
1780
  ];
1817
1781
  }
1818
- function enforcePayTo(destinationPkScript, quotedSats) {
1782
+ function enforcePayTo(destinationPkScript) {
1819
1783
  if (!isP2trPkScript(destinationPkScript)) {
1820
1784
  throw new Error("invalid P2TR script");
1821
1785
  }
1822
- return ArkadeScript.encode(satClause(destinationPkScript, quotedSats));
1786
+ return ArkadeScript.encode(satClause(destinationPkScript));
1823
1787
  }
1824
- function enforcePayToAsset(destinationPkScript, asset, strict) {
1788
+ function enforcePayToAsset(destinationPkScript, asset) {
1825
1789
  if (!isP2trPkScript(destinationPkScript)) {
1826
1790
  throw new Error("invalid P2TR script");
1827
1791
  }
@@ -1845,10 +1809,6 @@ function enforcePayToAsset(destinationPkScript, asset, strict) {
1845
1809
  "INSPECTOUTASSETLOOKUP",
1846
1810
  "VERIFY",
1847
1811
  // PRESENT on the output, not merely "zero of it"
1848
- // The quoted bound, when the caller opted in — added to the input
1849
- // comparison below, not substituted for it. `DUP` because the output's
1850
- // asset amount is needed twice.
1851
- ...strict?.assetAmount === void 0 ? [] : ["DUP", strict.assetAmount, "GREATERTHANOREQUAL", "VERIFY"],
1852
1812
  "PUSHCURRENTINPUTINDEX",
1853
1813
  inspectionTxid,
1854
1814
  asset.groupIndex,
@@ -1863,11 +1823,11 @@ function enforcePayToAsset(destinationPkScript, asset, strict) {
1863
1823
  1,
1864
1824
  "EQUALVERIFY",
1865
1825
  // ...then the sat covenant, the same tokens `enforcePayTo` emits.
1866
- ...satClause(destinationPkScript, strict?.amount)
1826
+ ...satClause(destinationPkScript)
1867
1827
  ]);
1868
1828
  }
1869
- function enforcePayToMaybeAsset(destinationPkScript, asset, strict) {
1870
- return asset === void 0 ? enforcePayTo(destinationPkScript, strict?.amount) : enforcePayToAsset(destinationPkScript, asset, strict);
1829
+ function enforcePayToMaybeAsset(destinationPkScript, asset) {
1830
+ return asset === void 0 ? enforcePayTo(destinationPkScript) : enforcePayToAsset(destinationPkScript, asset);
1871
1831
  }
1872
1832
 
1873
1833
  // src/contracts/handlers/vhtlc.ts
@@ -1884,9 +1844,9 @@ var VHTLCContractHandler = {
1884
1844
  server: base.hex.encode(params.server),
1885
1845
  hash: base.hex.encode(params.preimageHash),
1886
1846
  refundLocktime: params.refundLocktime.toString(),
1887
- claimDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
1888
- refundDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
1889
- refundNoReceiverDelay: chunk2JV4VQ7C_cjs.timelockToSequence(
1847
+ claimDelay: chunk5MLC2HU3_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
1848
+ refundDelay: chunk5MLC2HU3_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
1849
+ refundNoReceiverDelay: chunk5MLC2HU3_cjs.timelockToSequence(
1890
1850
  params.unilateralRefundWithoutReceiverDelay
1891
1851
  ).toString()
1892
1852
  };
@@ -1898,9 +1858,9 @@ var VHTLCContractHandler = {
1898
1858
  server: base.hex.decode(params.server),
1899
1859
  preimageHash: base.hex.decode(params.hash),
1900
1860
  refundLocktime: BigInt(params.refundLocktime),
1901
- unilateralClaimDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.claimDelay)),
1902
- unilateralRefundDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.refundDelay)),
1903
- unilateralRefundWithoutReceiverDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(
1861
+ unilateralClaimDelay: chunk5MLC2HU3_cjs.sequenceToTimelock(Number(params.claimDelay)),
1862
+ unilateralRefundDelay: chunk5MLC2HU3_cjs.sequenceToTimelock(Number(params.refundDelay)),
1863
+ unilateralRefundWithoutReceiverDelay: chunk5MLC2HU3_cjs.sequenceToTimelock(
1904
1864
  Number(params.refundNoReceiverDelay)
1905
1865
  )
1906
1866
  };
@@ -2139,50 +2099,43 @@ var VHTLCV2ContractHandler = {
2139
2099
  return new exports.VHTLC.ScriptV2(typed);
2140
2100
  },
2141
2101
  serializeParams(params) {
2102
+ const covenants = params.nonInteractiveParameters;
2142
2103
  return {
2143
2104
  sender: base.hex.encode(params.sender),
2144
2105
  receiver: base.hex.encode(params.receiver),
2145
2106
  server: base.hex.encode(params.server),
2146
2107
  hash: base.hex.encode(params.preimageHash),
2147
2108
  refundLocktime: params.refundLocktime.toString(),
2148
- claimDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
2149
- refundDelay: chunk2JV4VQ7C_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
2150
- refundNoReceiverDelay: chunk2JV4VQ7C_cjs.timelockToSequence(
2109
+ claimDelay: chunk5MLC2HU3_cjs.timelockToSequence(params.unilateralClaimDelay).toString(),
2110
+ refundDelay: chunk5MLC2HU3_cjs.timelockToSequence(params.unilateralRefundDelay).toString(),
2111
+ refundNoReceiverDelay: chunk5MLC2HU3_cjs.timelockToSequence(
2151
2112
  params.unilateralRefundWithoutReceiverDelay
2152
2113
  ).toString(),
2114
+ // The on-disk keys keep their per-leaf names even though the typed
2115
+ // param is ONE group: rows written by older SDKs carry exactly
2116
+ // these keys, and changing the storage encoding would orphan them.
2117
+ // The group maps onto them without loss — one emulator key serves
2118
+ // both covenant destinations by construction (see the option's doc
2119
+ // on VHTLC.Options), so the two emulator-key columns always hold
2120
+ // the same value on a row written from here.
2121
+ //
2153
2122
  // Spread rather than written as `undefined`: a `Record<string,
2154
2123
  // string>` round-tripped through a repository must not gain keys
2155
2124
  // whose value is the string "undefined".
2156
- ...params.nonInteractiveClaim && {
2157
- nonInteractiveClaimReceiverPkScript: base.hex.encode(
2158
- params.nonInteractiveClaim.receiverPkScript
2159
- ),
2160
- nonInteractiveClaimEmulatorPubkey: base.hex.encode(
2161
- params.nonInteractiveClaim.emulatorPubkey
2162
- ),
2163
- // The opt-in quoted bound. Dropping it re-derives the DEFAULT
2164
- // claim covenant a strictly weaker one and registration dies
2165
- // at `upsertContractRow` with an opaque `Script mismatch`. Same
2166
- // silent-drop class as the asset keys above.
2167
- ...params.nonInteractiveClaim.strict && {
2168
- strictClaimAmount: params.nonInteractiveClaim.strict.amount.toString(),
2169
- ...params.nonInteractiveClaim.strict.assetAmount !== void 0 && {
2170
- strictClaimAssetAmount: params.nonInteractiveClaim.strict.assetAmount.toString()
2171
- }
2172
- }
2173
- },
2174
- ...params.nonInteractiveRefund && {
2175
- nonInteractiveRefundSenderPkScript: base.hex.encode(
2176
- params.nonInteractiveRefund.senderPkScript
2177
- ),
2178
- nonInteractiveRefundEmulatorPubkey: base.hex.encode(
2179
- params.nonInteractiveRefund.emulatorPubkey
2180
- ),
2181
- // Spread rather than a "false"/"undefined" string: a dropped
2182
- // flag re-derives the EIGHT-leaf script, a different pkScript,
2183
- // and registration dies at `upsertContractRow` with an opaque
2184
- // `Script mismatch`. Same silent-drop class as the asset keys.
2185
- ...params.nonInteractiveRefund.withoutReceiver && {
2125
+ ...covenants && {
2126
+ nonInteractiveClaimReceiverPkScript: base.hex.encode(covenants.receiverPkScript),
2127
+ nonInteractiveClaimEmulatorPubkey: base.hex.encode(covenants.emulatorPubkey),
2128
+ nonInteractiveRefundSenderPkScript: base.hex.encode(covenants.senderPkScript),
2129
+ nonInteractiveRefundEmulatorPubkey: base.hex.encode(covenants.emulatorPubkey),
2130
+ // The legacy marker is precisely the ABSENCE of this key: a
2131
+ // row carrying it re-derives the full suite (nine leaves), a
2132
+ // row lacking it the pre-timelocked-refund eight the same
2133
+ // encoding older SDKs wrote for eight-leaf rows, so those rows
2134
+ // read back unchanged. Spread rather than a "false"/"undefined"
2135
+ // string: a dropped flag re-derives the EIGHT-leaf script, a
2136
+ // different pkScript, and registration dies at
2137
+ // `upsertContractRow` with an opaque `Script mismatch`.
2138
+ ...covenants.legacy === void 0 && {
2186
2139
  nonInteractiveRefundWithoutReceiver: "1"
2187
2140
  }
2188
2141
  },
@@ -2214,19 +2167,29 @@ var VHTLCV2ContractHandler = {
2214
2167
  "nonInteractiveRefundEmulatorPubkey",
2215
2168
  "nonInteractiveRefund"
2216
2169
  );
2170
+ if (claim === void 0 !== (refund === void 0)) {
2171
+ throw new Error(
2172
+ "emulator covenant params are all-or-nothing: the claim keys (nonInteractiveClaim*) and the refund keys (nonInteractiveRefund*) must both be present or both absent \u2014 a row carrying one side was written for a leaf subset this handler no longer derives"
2173
+ );
2174
+ }
2175
+ if (claim && refund && base.hex.encode(claim.emulatorPubkey) !== base.hex.encode(refund.emulatorPubkey)) {
2176
+ throw new Error(
2177
+ "emulator covenant params name two different emulator pubkeys: the suite derives both covenant cosigners from ONE key, so this row cannot be rebuilt as a group"
2178
+ );
2179
+ }
2217
2180
  if (params.assetTxid === void 0 !== (params.assetGroupIndex === void 0)) {
2218
2181
  throw new Error(
2219
2182
  "asset params are incomplete: assetTxid and assetGroupIndex must both be present or both absent"
2220
2183
  );
2221
2184
  }
2222
- if (params.strictClaimAssetAmount !== void 0 && params.strictClaimAmount === void 0) {
2185
+ if (params.strictClaimAmount !== void 0 || params.strictClaimAssetAmount !== void 0) {
2223
2186
  throw new Error(
2224
- "strictClaimAssetAmount without strictClaimAmount: reading this as 'not strict' would re-derive the default claim covenant, which is weaker than the row asked for"
2187
+ "strict claim params on a stored row: the strict claim bound was removed and this row's lockup cannot be re-derived without it \u2014 restore it with the SDK version that wrote it"
2225
2188
  );
2226
2189
  }
2227
2190
  if (params.nonInteractiveRefundWithoutReceiver !== void 0 && !refund) {
2228
2191
  throw new Error(
2229
- "nonInteractiveRefundWithoutReceiver without the nonInteractiveRefund keys it extends: reading this as 'not set' would re-derive a script without the leaf"
2192
+ "nonInteractiveRefundWithoutReceiver without the emulator covenant keys it extends: reading this as 'not set' would re-derive a script without the leaf"
2230
2193
  );
2231
2194
  }
2232
2195
  if (params.nonInteractiveRefundWithoutReceiver !== void 0 && params.nonInteractiveRefundWithoutReceiver !== "1") {
@@ -2245,31 +2208,20 @@ var VHTLCV2ContractHandler = {
2245
2208
  preimageHash: base.hex.decode(params.hash),
2246
2209
  refundLocktime: BigInt(params.refundLocktime),
2247
2210
  ...asset && { asset },
2248
- unilateralClaimDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.claimDelay)),
2249
- unilateralRefundDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(Number(params.refundDelay)),
2250
- unilateralRefundWithoutReceiverDelay: chunk2JV4VQ7C_cjs.sequenceToTimelock(
2211
+ unilateralClaimDelay: chunk5MLC2HU3_cjs.sequenceToTimelock(Number(params.claimDelay)),
2212
+ unilateralRefundDelay: chunk5MLC2HU3_cjs.sequenceToTimelock(Number(params.refundDelay)),
2213
+ unilateralRefundWithoutReceiverDelay: chunk5MLC2HU3_cjs.sequenceToTimelock(
2251
2214
  Number(params.refundNoReceiverDelay)
2252
2215
  ),
2253
- ...claim && {
2254
- nonInteractiveClaim: {
2216
+ ...claim && refund && {
2217
+ nonInteractiveParameters: {
2255
2218
  receiverPkScript: claim.destination,
2256
- emulatorPubkey: claim.emulatorPubkey,
2257
- ...params.strictClaimAmount !== void 0 && {
2258
- strict: {
2259
- amount: BigInt(params.strictClaimAmount),
2260
- ...params.strictClaimAssetAmount !== void 0 && {
2261
- assetAmount: BigInt(params.strictClaimAssetAmount)
2262
- }
2263
- }
2264
- }
2265
- }
2266
- },
2267
- ...refund && {
2268
- nonInteractiveRefund: {
2269
2219
  senderPkScript: refund.destination,
2270
- emulatorPubkey: refund.emulatorPubkey,
2271
- ...params.nonInteractiveRefundWithoutReceiver === "1" && {
2272
- withoutReceiver: true
2220
+ emulatorPubkey: claim.emulatorPubkey,
2221
+ // Absence of the flag IS the legacy marker — the same
2222
+ // encoding older SDKs wrote for eight-leaf rows.
2223
+ ...params.nonInteractiveRefundWithoutReceiver !== "1" && {
2224
+ legacy: "preTimelockedRefund"
2273
2225
  }
2274
2226
  }
2275
2227
  }
@@ -2531,7 +2483,7 @@ var BoardingContractHandler = {
2531
2483
  const coins = await deps.onchainProvider.getCoins(onchainAddress);
2532
2484
  if (coins.length === 0) return [];
2533
2485
  const scriptHex = base.hex.encode(script.pkScript);
2534
- const boardingSeq = chunk2JV4VQ7C_cjs.timelockToSequence(deps.boardingTimelock);
2486
+ const boardingSeq = chunk5MLC2HU3_cjs.timelockToSequence(deps.boardingTimelock);
2535
2487
  return [
2536
2488
  {
2537
2489
  type: "boarding",
@@ -2692,27 +2644,27 @@ function encodeTapscriptSegment(seg, pubkeys, args) {
2692
2644
  if (seg.csv) {
2693
2645
  const timelock = { type: seg.csv.type, value: resolveTimelockValue(seg.csv.value, args) };
2694
2646
  if (seg.asm) {
2695
- return chunk2JV4VQ7C_cjs.ConditionCSVMultisigTapscript.encode({
2647
+ return chunk5MLC2HU3_cjs.ConditionCSVMultisigTapscript.encode({
2696
2648
  conditionScript: resolveAsm(seg.asm, args),
2697
2649
  timelock,
2698
2650
  pubkeys
2699
2651
  });
2700
2652
  }
2701
- return chunk2JV4VQ7C_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
2653
+ return chunk5MLC2HU3_cjs.CSVMultisigTapscript.encode({ timelock, pubkeys });
2702
2654
  }
2703
2655
  if (seg.cltv !== void 0) {
2704
- return chunk2JV4VQ7C_cjs.CLTVMultisigTapscript.encode({
2656
+ return chunk5MLC2HU3_cjs.CLTVMultisigTapscript.encode({
2705
2657
  absoluteTimelock: resolveTimelockValue(seg.cltv, args),
2706
2658
  pubkeys
2707
2659
  });
2708
2660
  }
2709
2661
  if (seg.asm) {
2710
- return chunk2JV4VQ7C_cjs.ConditionMultisigTapscript.encode({
2662
+ return chunk5MLC2HU3_cjs.ConditionMultisigTapscript.encode({
2711
2663
  conditionScript: resolveAsm(seg.asm, args),
2712
2664
  pubkeys
2713
2665
  });
2714
2666
  }
2715
- return chunk2JV4VQ7C_cjs.MultisigTapscript.encode({ pubkeys });
2667
+ return chunk5MLC2HU3_cjs.MultisigTapscript.encode({ pubkeys });
2716
2668
  }
2717
2669
  function compileFunctions(program, args, keys) {
2718
2670
  if (program.version !== SUPPORTED_PROGRAM_VERSION) {
@@ -2742,7 +2694,7 @@ function compileFunctions(program, args, keys) {
2742
2694
  return { name: names[i], def, leafScript, arkadeScript, signerKeys: pubkeys };
2743
2695
  });
2744
2696
  }
2745
- var ArkadeProgramScript = class extends chunk2JV4VQ7C_cjs.VtxoScript {
2697
+ var ArkadeProgramScript = class extends chunk5MLC2HU3_cjs.VtxoScript {
2746
2698
  constructor(program, args, keys) {
2747
2699
  const partial = compileFunctions(program, args, keys);
2748
2700
  super(partial.map((p) => p.leafScript));
@@ -2955,7 +2907,7 @@ function pathsFor(script, context, opts) {
2955
2907
  continue;
2956
2908
  }
2957
2909
  if (requiresServer) continue;
2958
- const sequence = csv ? Number(chunk2JV4VQ7C_cjs.timelockToSequence(csv)) : void 0;
2910
+ const sequence = csv ? Number(chunk5MLC2HU3_cjs.timelockToSequence(csv)) : void 0;
2959
2911
  if (opts.checkTimelocks && csv && !isCsvSpendable(context, sequence)) continue;
2960
2912
  if (opts.checkTimelocks && cltv !== void 0 && !isCltvSatisfied(context, cltv)) {
2961
2913
  continue;
@@ -3084,5 +3036,5 @@ exports.toASM = toASM;
3084
3036
  exports.toXOnly = toXOnly;
3085
3037
  exports.validateProgram = validateProgram;
3086
3038
  exports.witnessRefToBytes = witnessRefToBytes;
3087
- //# sourceMappingURL=chunk-OIZ2V2VD.cjs.map
3088
- //# sourceMappingURL=chunk-OIZ2V2VD.cjs.map
3039
+ //# sourceMappingURL=chunk-WIFL5QYZ.cjs.map
3040
+ //# sourceMappingURL=chunk-WIFL5QYZ.cjs.map