@arkade-os/sdk 0.4.59 → 0.4.60

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 (88) hide show
  1. package/README.md +34 -6
  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/{ark-C9DsPSm8.d.cts → ark-D2_yNhfz.d.cts} +1009 -523
  9. package/dist/{ark-C9DsPSm8.d.ts → ark-D2_yNhfz.d.ts} +1009 -523
  10. package/dist/{asyncStorageTaskQueue-CYHXFfvn.d.cts → asyncStorageTaskQueue-CqijAAPG.d.cts} +1 -1
  11. package/dist/{asyncStorageTaskQueue-BwuWQ1Qc.d.ts → asyncStorageTaskQueue-Vsp6uk8e.d.ts} +1 -1
  12. package/dist/{chunk-PN5RD7ZI.js → chunk-2DINXHGQ.js} +1665 -1149
  13. package/dist/chunk-2DINXHGQ.js.map +1 -0
  14. package/dist/{chunk-IPFGYVF3.cjs → chunk-2XLNQHG4.cjs} +10 -10
  15. package/dist/chunk-2XLNQHG4.cjs.map +1 -0
  16. package/dist/{chunk-VSHY5TBY.js → chunk-3Q7BBUWO.js} +4 -4
  17. package/dist/{chunk-VSHY5TBY.js.map → chunk-3Q7BBUWO.js.map} +1 -1
  18. package/dist/{chunk-DSTYXT2D.cjs → chunk-4A4GRSTB.cjs} +44 -6
  19. package/dist/chunk-4A4GRSTB.cjs.map +1 -0
  20. package/dist/{chunk-H342JPPZ.js → chunk-B66RYHTB.js} +5 -5
  21. package/dist/chunk-B66RYHTB.js.map +1 -0
  22. package/dist/{chunk-YEHGCHIL.js → chunk-FSKANUV4.js} +12 -5
  23. package/dist/chunk-FSKANUV4.js.map +1 -0
  24. package/dist/{chunk-7FA36NOA.cjs → chunk-H7JCHFM6.cjs} +17 -17
  25. package/dist/{chunk-7FA36NOA.cjs.map → chunk-H7JCHFM6.cjs.map} +1 -1
  26. package/dist/{chunk-FIMOVH25.js → chunk-JBULXTCC.js} +40 -7
  27. package/dist/chunk-JBULXTCC.js.map +1 -0
  28. package/dist/{chunk-DYNB6POO.cjs → chunk-KNS5MTTI.cjs} +3820 -2915
  29. package/dist/chunk-KNS5MTTI.cjs.map +1 -0
  30. package/dist/{chunk-2XO43UHI.cjs → chunk-MZNLCMUP.cjs} +1686 -1169
  31. package/dist/chunk-MZNLCMUP.cjs.map +1 -0
  32. package/dist/{chunk-V2KENVN6.cjs → chunk-PRFL62ID.cjs} +22 -15
  33. package/dist/chunk-PRFL62ID.cjs.map +1 -0
  34. package/dist/{chunk-OVSNY3HC.js → chunk-Y54MUBT7.js} +3476 -2584
  35. package/dist/chunk-Y54MUBT7.js.map +1 -0
  36. package/dist/contracts/handlers/index.cjs +12 -8
  37. package/dist/contracts/handlers/index.d.cts +3 -3
  38. package/dist/contracts/handlers/index.d.ts +3 -3
  39. package/dist/contracts/handlers/index.js +2 -2
  40. package/dist/{delegate-D0eGaz3J.d.cts → delegate-DNEuM_nK.d.cts} +1 -1
  41. package/dist/{delegate-B_oKWm1k.d.ts → delegate-DidNTsKm.d.ts} +1 -1
  42. package/dist/{index-BmK6tEqf.d.ts → index-BP8-zniX.d.cts} +182 -26
  43. package/dist/{index-BG2AL2Ie.d.cts → index-DzQbNQUG.d.ts} +182 -26
  44. package/dist/index.cjs +302 -230
  45. package/dist/index.d.cts +286 -48
  46. package/dist/index.d.ts +286 -48
  47. package/dist/index.js +4 -4
  48. package/dist/repositories/realm/index.cjs +43 -23
  49. package/dist/repositories/realm/index.cjs.map +1 -1
  50. package/dist/repositories/realm/index.d.cts +21 -9
  51. package/dist/repositories/realm/index.d.ts +21 -9
  52. package/dist/repositories/realm/index.js +29 -9
  53. package/dist/repositories/realm/index.js.map +1 -1
  54. package/dist/repositories/sqlite/index.cjs +48 -23
  55. package/dist/repositories/sqlite/index.cjs.map +1 -1
  56. package/dist/repositories/sqlite/index.d.cts +9 -3
  57. package/dist/repositories/sqlite/index.d.ts +9 -3
  58. package/dist/repositories/sqlite/index.js +35 -10
  59. package/dist/repositories/sqlite/index.js.map +1 -1
  60. package/dist/{taskRunner-Cy4Gh8n7.d.ts → taskRunner-9gnlYEpb.d.ts} +1 -1
  61. package/dist/{taskRunner-CBvKIttE.d.cts → taskRunner-BEQNFEa4.d.cts} +1 -1
  62. package/dist/wallet/expo/background.cjs +14 -14
  63. package/dist/wallet/expo/background.d.cts +3 -3
  64. package/dist/wallet/expo/background.d.ts +3 -3
  65. package/dist/wallet/expo/background.js +6 -6
  66. package/dist/wallet/expo/index.cjs +17 -14
  67. package/dist/wallet/expo/index.cjs.map +1 -1
  68. package/dist/wallet/expo/index.d.cts +5 -4
  69. package/dist/wallet/expo/index.d.ts +5 -4
  70. package/dist/wallet/expo/index.js +8 -5
  71. package/dist/wallet/expo/index.js.map +1 -1
  72. package/dist/{wallet-EyVDhqzP.d.ts → wallet-C_MYHyOj.d.ts} +155 -17
  73. package/dist/{wallet-DlXemAzP.d.cts → wallet-ipUA1XCp.d.cts} +155 -17
  74. package/dist/worker/expo/index.cjs +9 -9
  75. package/dist/worker/expo/index.d.cts +5 -5
  76. package/dist/worker/expo/index.d.ts +5 -5
  77. package/dist/worker/expo/index.js +5 -5
  78. package/package.json +4 -2
  79. package/dist/chunk-2XO43UHI.cjs.map +0 -1
  80. package/dist/chunk-DSTYXT2D.cjs.map +0 -1
  81. package/dist/chunk-DYNB6POO.cjs.map +0 -1
  82. package/dist/chunk-FIMOVH25.js.map +0 -1
  83. package/dist/chunk-H342JPPZ.js.map +0 -1
  84. package/dist/chunk-IPFGYVF3.cjs.map +0 -1
  85. package/dist/chunk-OVSNY3HC.js.map +0 -1
  86. package/dist/chunk-PN5RD7ZI.js.map +0 -1
  87. package/dist/chunk-V2KENVN6.cjs.map +0 -1
  88. package/dist/chunk-YEHGCHIL.js.map +0 -1
@@ -1,34 +1,38 @@
1
1
  'use strict';
2
2
 
3
- var chunk2XO43UHI_cjs = require('../../chunk-2XO43UHI.cjs');
4
- require('../../chunk-DSTYXT2D.cjs');
3
+ var chunkMZNLCMUP_cjs = require('../../chunk-MZNLCMUP.cjs');
4
+ require('../../chunk-4A4GRSTB.cjs');
5
5
  require('../../chunk-5BLDMQED.cjs');
6
6
 
7
7
 
8
8
 
9
9
  Object.defineProperty(exports, "ArkadeContractHandler", {
10
10
  enumerable: true,
11
- get: function () { return chunk2XO43UHI_cjs.ArkadeContractHandler; }
11
+ get: function () { return chunkMZNLCMUP_cjs.ArkadeContractHandler; }
12
12
  });
13
13
  Object.defineProperty(exports, "BoardingContractHandler", {
14
14
  enumerable: true,
15
- get: function () { return chunk2XO43UHI_cjs.BoardingContractHandler; }
15
+ get: function () { return chunkMZNLCMUP_cjs.BoardingContractHandler; }
16
16
  });
17
17
  Object.defineProperty(exports, "DefaultContractHandler", {
18
18
  enumerable: true,
19
- get: function () { return chunk2XO43UHI_cjs.DefaultContractHandler; }
19
+ get: function () { return chunkMZNLCMUP_cjs.DefaultContractHandler; }
20
20
  });
21
21
  Object.defineProperty(exports, "DelegateContractHandler", {
22
22
  enumerable: true,
23
- get: function () { return chunk2XO43UHI_cjs.DelegateContractHandler; }
23
+ get: function () { return chunkMZNLCMUP_cjs.DelegateContractHandler; }
24
24
  });
25
25
  Object.defineProperty(exports, "VHTLCContractHandler", {
26
26
  enumerable: true,
27
- get: function () { return chunk2XO43UHI_cjs.VHTLCContractHandler; }
27
+ get: function () { return chunkMZNLCMUP_cjs.VHTLCContractHandler; }
28
+ });
29
+ Object.defineProperty(exports, "VHTLCV2ContractHandler", {
30
+ enumerable: true,
31
+ get: function () { return chunkMZNLCMUP_cjs.VHTLCV2ContractHandler; }
28
32
  });
29
33
  Object.defineProperty(exports, "contractHandlers", {
30
34
  enumerable: true,
31
- get: function () { return chunk2XO43UHI_cjs.contractHandlers; }
35
+ get: function () { return chunkMZNLCMUP_cjs.contractHandlers; }
32
36
  });
33
37
  //# sourceMappingURL=index.cjs.map
34
38
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
- export { n as ArkadeContractHandler, B as BoardingContractHandler, o as BoardingContractParams, D as DefaultContractHandler, q as DefaultContractParams, t as DelegateContractHandler, u as DelegateContractParams, x as VHTLCContractHandler, y as VHTLCContractParams, z as contractHandlers } from '../../index-BG2AL2Ie.cjs';
2
- import '../../ark-C9DsPSm8.cjs';
1
+ export { n as ArkadeContractHandler, B as BoardingContractHandler, o as BoardingContractParams, D as DefaultContractHandler, q as DefaultContractParams, t as DelegateContractHandler, u as DelegateContractParams, x as VHTLCContractHandler, y as VHTLCContractParams, z as VHTLCV2ContractHandler, E as VHTLCV2ContractParams, F as contractHandlers } from '../../index-BP8-zniX.cjs';
2
+ import '../../ark-D2_yNhfz.cjs';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
6
6
  import '@scure/btc-signer';
7
- import '../../delegate-D0eGaz3J.cjs';
7
+ import '../../delegate-DNEuM_nK.cjs';
@@ -1,7 +1,7 @@
1
- export { n as ArkadeContractHandler, B as BoardingContractHandler, o as BoardingContractParams, D as DefaultContractHandler, q as DefaultContractParams, t as DelegateContractHandler, u as DelegateContractParams, x as VHTLCContractHandler, y as VHTLCContractParams, z as contractHandlers } from '../../index-BmK6tEqf.js';
2
- import '../../ark-C9DsPSm8.js';
1
+ export { n as ArkadeContractHandler, B as BoardingContractHandler, o as BoardingContractParams, D as DefaultContractHandler, q as DefaultContractParams, t as DelegateContractHandler, u as DelegateContractParams, x as VHTLCContractHandler, y as VHTLCContractParams, z as VHTLCV2ContractHandler, E as VHTLCV2ContractParams, F as contractHandlers } from '../../index-DzQbNQUG.js';
2
+ import '../../ark-D2_yNhfz.js';
3
3
  import '@scure/btc-signer/transaction.js';
4
4
  import '@scure/btc-signer/utils.js';
5
5
  import '@scure/btc-signer/psbt.js';
6
6
  import '@scure/btc-signer';
7
- import '../../delegate-B_oKWm1k.js';
7
+ import '../../delegate-DidNTsKm.js';
@@ -1,5 +1,5 @@
1
- export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, contractHandlers } from '../../chunk-PN5RD7ZI.js';
2
- import '../../chunk-FIMOVH25.js';
1
+ export { ArkadeContractHandler, BoardingContractHandler, DefaultContractHandler, DelegateContractHandler, VHTLCContractHandler, VHTLCV2ContractHandler, contractHandlers } from '../../chunk-2DINXHGQ.js';
2
+ import '../../chunk-JBULXTCC.js';
3
3
  import '../../chunk-NSBPE2FW.js';
4
4
  //# sourceMappingURL=index.js.map
5
5
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { Bytes } from '@scure/btc-signer/utils.js';
2
- import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript } from './ark-C9DsPSm8.cjs';
2
+ import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript } from './ark-D2_yNhfz.cjs';
3
3
 
4
4
  /**
5
5
  * DefaultVtxo is the default implementation of a VtxoScript.
@@ -1,5 +1,5 @@
1
1
  import { Bytes } from '@scure/btc-signer/utils.js';
2
- import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript } from './ark-C9DsPSm8.js';
2
+ import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript } from './ark-D2_yNhfz.js';
3
3
 
4
4
  /**
5
5
  * DefaultVtxo is the default implementation of a VtxoScript.
@@ -1,10 +1,10 @@
1
- import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript, b9 as ContractHandler, bk as Discoverable, cC as TapscriptDeriving } from './ark-C9DsPSm8.js';
2
- import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-B_oKWm1k.js';
1
+ import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript, ba as ContractHandler, bl as Discoverable, cN as TapscriptDeriving } from './ark-D2_yNhfz.cjs';
2
+ import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-DNEuM_nK.cjs';
3
3
  import { Bytes } from '@scure/btc-signer/utils.js';
4
4
 
5
5
  /** Virtual Hash Time Lock Contract (VHTLC) namespace. */
6
6
  declare namespace VHTLC {
7
- interface Options {
7
+ export interface Options {
8
8
  sender: Bytes;
9
9
  receiver: Bytes;
10
10
  server: Bytes;
@@ -13,6 +13,73 @@ declare namespace VHTLC {
13
13
  unilateralClaimDelay: RelativeTimelock;
14
14
  unilateralRefundDelay: RelativeTimelock;
15
15
  unilateralRefundWithoutReceiverDelay: RelativeTimelock;
16
+ /**
17
+ * Optional non-interactive claim leaf: `server` plus a covenant-tweaked
18
+ * emulator co-signer, pinned to `receiverPkScript`. Lets the receiver's
19
+ * claim be pushed by the emulator without the receiver being online.
20
+ */
21
+ nonInteractiveClaim?: {
22
+ receiverPkScript: Bytes;
23
+ emulatorPubkey: Bytes;
24
+ };
25
+ /**
26
+ * Optional non-interactive refund leaf: `server` + `receiver` + a
27
+ * covenant-tweaked emulator co-signer, pinned to `senderPkScript`, no
28
+ * timelock. Every OTHER refund-side leaf in this contract requires
29
+ * the sender's own signature — if the sender permanently loses that
30
+ * key, none of them are reachable. This leaf is the one exception:
31
+ * it needs neither the sender's presence nor their key, so funds
32
+ * remain recoverable to the sender's pre-committed address even
33
+ * then. It still needs the receiver (unlike `nonInteractiveClaim`,
34
+ * which needs only server + emulator) — deliberately: this is what
35
+ * lets server + receiver release the refund immediately, the moment
36
+ * they agree the swap has failed, rather than making the sender wait
37
+ * out `refundLocktime` the way {@link Script.refundWithoutReceiver}
38
+ * does.
39
+ */
40
+ nonInteractiveRefund?: {
41
+ senderPkScript: Bytes;
42
+ emulatorPubkey: Bytes;
43
+ };
44
+ }
45
+ /**
46
+ * Shared construction and accessors for every VHTLC script version. The
47
+ * only thing that varies between versions is which preimage-condition
48
+ * fragment `claim`/`unilateralClaim`/`nonInteractiveClaim` are built
49
+ * from — everything else (the multisig/timelock leaves, the
50
+ * non-interactive covenant leaves, the accessor methods) is identical,
51
+ * so versions are expressed as thin subclasses over one builder rather
52
+ * than as separate, independently-maintained copies of this class.
53
+ */
54
+ abstract class BaseScript extends VtxoScript {
55
+ readonly options: Options;
56
+ readonly claimScript: string;
57
+ readonly refundScript: string;
58
+ readonly refundWithoutReceiverScript: string;
59
+ readonly unilateralClaimScript: string;
60
+ readonly unilateralRefundScript: string;
61
+ readonly unilateralRefundWithoutReceiverScript: string;
62
+ readonly nonInteractiveClaimScript?: string;
63
+ readonly nonInteractiveClaimArkadeScript?: Bytes;
64
+ readonly nonInteractiveRefundScript?: string;
65
+ readonly nonInteractiveRefundArkadeScript?: Bytes;
66
+ protected constructor(options: Options, preimageCondition: (hash: Bytes) => Bytes);
67
+ /** Return the collaborative claim tapleaf script. */
68
+ claim(): TapLeafScript;
69
+ /** Return the collaborative refund tapleaf script. */
70
+ refund(): TapLeafScript;
71
+ /** Return the refund-without-receiver tapleaf script. */
72
+ refundWithoutReceiver(): TapLeafScript;
73
+ /** Return the unilateral claim tapleaf script. */
74
+ unilateralClaim(): TapLeafScript;
75
+ /** Return the unilateral refund tapleaf script. */
76
+ unilateralRefund(): TapLeafScript;
77
+ /** Return the unilateral refund-without-receiver tapleaf script. */
78
+ unilateralRefundWithoutReceiver(): TapLeafScript;
79
+ /** Return the non-interactive claim tapleaf script as well as the ArkadeScript. */
80
+ nonInteractiveClaim(): [TapLeafScript, Bytes];
81
+ /** Return the non-interactive refund tapleaf script as well as the ArkadeScript. */
82
+ nonInteractiveRefund(): [TapLeafScript, Bytes];
16
83
  }
17
84
  /**
18
85
  * Virtual Hash Time Lock Contract (VHTLC) script implementation.
@@ -26,6 +93,16 @@ declare namespace VHTLC {
26
93
  * - **unilateralClaim**: Receiver can claim unilaterally after delay
27
94
  * - **unilateralRefund**: Sender and receiver can refund unilaterally after delay
28
95
  * - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay
96
+ * - **nonInteractiveClaim** (optional): server + emulator can push the
97
+ * receiver's claim, pinned to a pre-committed destination
98
+ * - **nonInteractiveRefund** (optional): server + receiver + emulator
99
+ * can push the sender's refund immediately, no timelock, pinned to a
100
+ * pre-committed destination — recoverable even if the sender's own key
101
+ * is lost
102
+ *
103
+ * See {@link ScriptV2} for the current recommended construction — same
104
+ * leaf ladder, same options shape, an added length check on the claim
105
+ * preimage. This class is unchanged and stays available as-is.
29
106
  *
30
107
  * @example
31
108
  * ```typescript
@@ -41,29 +118,24 @@ declare namespace VHTLC {
41
118
  * });
42
119
  * ```
43
120
  */
44
- class Script extends VtxoScript {
45
- readonly options: Options;
46
- readonly claimScript: string;
47
- readonly refundScript: string;
48
- readonly refundWithoutReceiverScript: string;
49
- readonly unilateralClaimScript: string;
50
- readonly unilateralRefundScript: string;
51
- readonly unilateralRefundWithoutReceiverScript: string;
52
- /** Create a VHTLC script from the supplied participant keys, hash, and timelocks. */
121
+ export class Script extends BaseScript {
53
122
  constructor(options: Options);
54
- /** Return the collaborative claim tapleaf script. */
55
- claim(): TapLeafScript;
56
- /** Return the collaborative refund tapleaf script. */
57
- refund(): TapLeafScript;
58
- /** Return the refund-without-receiver tapleaf script. */
59
- refundWithoutReceiver(): TapLeafScript;
60
- /** Return the unilateral claim tapleaf script. */
61
- unilateralClaim(): TapLeafScript;
62
- /** Return the unilateral refund tapleaf script. */
63
- unilateralRefund(): TapLeafScript;
64
- /** Return the unilateral refund-without-receiver tapleaf script. */
65
- unilateralRefundWithoutReceiver(): TapLeafScript;
66
123
  }
124
+ /**
125
+ * Same leaf ladder as {@link Script}, built with {@link
126
+ * preimageConditionScriptV2} instead of {@link preimageConditionScript}
127
+ * for every leaf that gates on the preimage (`claim`, `unilateralClaim`,
128
+ * and, when present, `nonInteractiveClaim`) — see that function's doc
129
+ * comment for what differs and why. A distinct class rather than a flag
130
+ * on {@link Script}: the two produce different script bytes (and so
131
+ * different addresses) for the same participant keys, and keeping them
132
+ * as separate types makes that a compile-time-visible choice at every
133
+ * call site instead of a runtime option that's easy to get wrong.
134
+ */
135
+ export class ScriptV2 extends BaseScript {
136
+ constructor(options: Options);
137
+ }
138
+ export { };
67
139
  }
68
140
 
69
141
  /**
@@ -194,7 +266,91 @@ interface VHTLCContractParams {
194
266
  * - unilateralRefund: Sender + Receiver after CSV delay
195
267
  * - unilateralRefundWithoutReceiver: Sender after CSV delay
196
268
  */
197
- declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script>;
269
+ declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script> & TapscriptDeriving<VHTLC.Script>;
270
+
271
+ /**
272
+ * Typed parameters for {@link VHTLC.ScriptV2} contracts.
273
+ *
274
+ * The eight mandatory fields are `VHTLCContractParams` verbatim — the two
275
+ * script versions take the same {@link VHTLC.Options}, so a divergent shape
276
+ * here would be a difference with no cause. What V1's handler has no field for
277
+ * is the two optional covenant leaves, and those are exactly what the swap
278
+ * corridor's lockup carries, so leaving them out would make this handler unable
279
+ * to round-trip the contract it exists to serve.
280
+ */
281
+ interface VHTLCV2ContractParams {
282
+ sender: Uint8Array;
283
+ receiver: Uint8Array;
284
+ server: Uint8Array;
285
+ preimageHash: Uint8Array;
286
+ refundLocktime: bigint;
287
+ unilateralClaimDelay: RelativeTimelock;
288
+ unilateralRefundDelay: RelativeTimelock;
289
+ unilateralRefundWithoutReceiverDelay: RelativeTimelock;
290
+ /** @see VHTLC.Options.nonInteractiveClaim */
291
+ nonInteractiveClaim?: {
292
+ receiverPkScript: Uint8Array;
293
+ emulatorPubkey: Uint8Array;
294
+ };
295
+ /** @see VHTLC.Options.nonInteractiveRefund */
296
+ nonInteractiveRefund?: {
297
+ senderPkScript: Uint8Array;
298
+ emulatorPubkey: Uint8Array;
299
+ };
300
+ }
301
+ /**
302
+ * Handler for {@link VHTLC.ScriptV2} — the VHTLC whose preimage leaves carry an
303
+ * explicit `OP_SIZE 32 OP_EQUALVERIFY` before the hash check, and which the RFQ
304
+ * swap corridor builds (`@arkade-os/swap`'s `lightningSendVtxoScript`).
305
+ *
306
+ * **Why a separate type string rather than a flag on `vhtlc`.** A handler's
307
+ * `type` names the script class it derives, the way every other registered type
308
+ * does (`default` → `DefaultVtxo.Script`, `vhtlc` → `VHTLC.Script`, `boarding`,
309
+ * `arkade`). V1 and V2 produce different script bytes — and so different
310
+ * pkScripts — for identical participant keys, and `upsertContractRow` derives
311
+ * the script from `params` and refuses any row whose supplied `script` does not
312
+ * match. One type cannot serve both. `vhtlc-v2` also cannot COLLIDE with
313
+ * `vhtlc`: a colliding row needs one pkScript claimed by two types, and the two
314
+ * versions' preimage conditions differ in every tree, so no parameters make
315
+ * them equal. A use-named type (`swap-lockup`) was the alternative and is
316
+ * worse: contracts are keyed by script, so the moment a second use registered
317
+ * the same ScriptV2 the two uses would fight over one row.
318
+ *
319
+ * **Which leaves this offers, and why the set is smaller than the ladder.**
320
+ * ScriptV2 has eight leaves; a wallet holding ONE of the two participant keys
321
+ * can satisfy four of them, and offering a leaf whose signature the caller
322
+ * cannot produce is worse than offering fewer — it turns a refusal into a
323
+ * transaction that gets built and then rejected.
324
+ *
325
+ * | leaf | needs | offered |
326
+ * |-----------------------------------|--------------------------------|---------|
327
+ * | `claim` | receiver + server, preimage | yes, to the receiver |
328
+ * | `refund` | sender + receiver + server | no — needs the counterparty live |
329
+ * | `refundWithoutReceiver` | sender + server, CLTV | yes, to the sender |
330
+ * | `unilateralClaim` | receiver, CSV | yes, to the receiver |
331
+ * | `unilateralRefund` | sender + receiver, CSV | no — needs the counterparty live |
332
+ * | `unilateralRefundWithoutReceiver` | sender, CSV | yes, to the sender |
333
+ * | `nonInteractiveClaim` | server + emulator | no — the wallet holds neither key |
334
+ * | `nonInteractiveRefund` | server + receiver + emulator | no — the wallet holds neither key |
335
+ *
336
+ * The two omitted interactive leaves are the same two the `vhtlc` handler
337
+ * omits, for the same reason: `refund` and `unilateralRefund` both need the
338
+ * OTHER party's signature, and this protocol has no message that asks for one
339
+ * (see `@arkade-os/swap`'s `refund.ts` module doc). The two covenant leaves are
340
+ * pushed by the emulator on the counterparty's behalf and are not this wallet's
341
+ * to build at all.
342
+ *
343
+ * So `refundWithoutReceiver` is the sender's only collaborative way out, gated
344
+ * on the CLTV the quote committed to — which is exactly the leaf
345
+ * `pushRefundWithoutReceiver` builds. The CSV leaves are offered only in the
346
+ * non-collaborative context, where the caller has already accepted that
347
+ * spending them means a real unilateral exit first.
348
+ *
349
+ * The selection discipline is deliberately identical to the `vhtlc` handler's,
350
+ * and `test/contracts/vhtlcV2-handler.test.ts` pins the two against each other
351
+ * rung-for-rung across every role and timelock context so they cannot drift.
352
+ */
353
+ declare const VHTLCV2ContractHandler: ContractHandler<VHTLCV2ContractParams, VHTLC.ScriptV2> & TapscriptDeriving<VHTLC.ScriptV2>;
198
354
 
199
355
  /**
200
356
  * Typed parameters for boarding contracts.
@@ -509,4 +665,4 @@ declare function deserializeArkadeContractParams(params: Record<string, string>)
509
665
  */
510
666
  declare const ArkadeContractHandler: ContractHandler<ArkadeContractParams, ArkadeProgramScript> & TapscriptDeriving<ArkadeProgramScript>;
511
667
 
512
- export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, deserializeArkadeContractParams as l, stringifyArtifact as m, ArkadeContractHandler as n, type BoardingContractParams as o, parseArtifact as p, type DefaultContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, DelegateContractHandler as t, type DelegateContractParams as u, validateProgram as v, witnessRefToBytes as w, VHTLCContractHandler as x, type VHTLCContractParams as y, contractHandlers as z };
668
+ export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, type VHTLCV2ContractParams as E, contractHandlers as F, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, deserializeArkadeContractParams as l, stringifyArtifact as m, ArkadeContractHandler as n, type BoardingContractParams as o, parseArtifact as p, type DefaultContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, DelegateContractHandler as t, type DelegateContractParams as u, validateProgram as v, witnessRefToBytes as w, VHTLCContractHandler as x, type VHTLCContractParams as y, VHTLCV2ContractHandler as z };
@@ -1,10 +1,10 @@
1
- import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript, b9 as ContractHandler, bk as Discoverable, cC as TapscriptDeriving } from './ark-C9DsPSm8.cjs';
2
- import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-D0eGaz3J.cjs';
1
+ import { p as RelativeTimelock, V as VtxoScript, q as TapLeafScript, ba as ContractHandler, bl as Discoverable, cN as TapscriptDeriving } from './ark-D2_yNhfz.js';
2
+ import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-DidNTsKm.js';
3
3
  import { Bytes } from '@scure/btc-signer/utils.js';
4
4
 
5
5
  /** Virtual Hash Time Lock Contract (VHTLC) namespace. */
6
6
  declare namespace VHTLC {
7
- interface Options {
7
+ export interface Options {
8
8
  sender: Bytes;
9
9
  receiver: Bytes;
10
10
  server: Bytes;
@@ -13,6 +13,73 @@ declare namespace VHTLC {
13
13
  unilateralClaimDelay: RelativeTimelock;
14
14
  unilateralRefundDelay: RelativeTimelock;
15
15
  unilateralRefundWithoutReceiverDelay: RelativeTimelock;
16
+ /**
17
+ * Optional non-interactive claim leaf: `server` plus a covenant-tweaked
18
+ * emulator co-signer, pinned to `receiverPkScript`. Lets the receiver's
19
+ * claim be pushed by the emulator without the receiver being online.
20
+ */
21
+ nonInteractiveClaim?: {
22
+ receiverPkScript: Bytes;
23
+ emulatorPubkey: Bytes;
24
+ };
25
+ /**
26
+ * Optional non-interactive refund leaf: `server` + `receiver` + a
27
+ * covenant-tweaked emulator co-signer, pinned to `senderPkScript`, no
28
+ * timelock. Every OTHER refund-side leaf in this contract requires
29
+ * the sender's own signature — if the sender permanently loses that
30
+ * key, none of them are reachable. This leaf is the one exception:
31
+ * it needs neither the sender's presence nor their key, so funds
32
+ * remain recoverable to the sender's pre-committed address even
33
+ * then. It still needs the receiver (unlike `nonInteractiveClaim`,
34
+ * which needs only server + emulator) — deliberately: this is what
35
+ * lets server + receiver release the refund immediately, the moment
36
+ * they agree the swap has failed, rather than making the sender wait
37
+ * out `refundLocktime` the way {@link Script.refundWithoutReceiver}
38
+ * does.
39
+ */
40
+ nonInteractiveRefund?: {
41
+ senderPkScript: Bytes;
42
+ emulatorPubkey: Bytes;
43
+ };
44
+ }
45
+ /**
46
+ * Shared construction and accessors for every VHTLC script version. The
47
+ * only thing that varies between versions is which preimage-condition
48
+ * fragment `claim`/`unilateralClaim`/`nonInteractiveClaim` are built
49
+ * from — everything else (the multisig/timelock leaves, the
50
+ * non-interactive covenant leaves, the accessor methods) is identical,
51
+ * so versions are expressed as thin subclasses over one builder rather
52
+ * than as separate, independently-maintained copies of this class.
53
+ */
54
+ abstract class BaseScript extends VtxoScript {
55
+ readonly options: Options;
56
+ readonly claimScript: string;
57
+ readonly refundScript: string;
58
+ readonly refundWithoutReceiverScript: string;
59
+ readonly unilateralClaimScript: string;
60
+ readonly unilateralRefundScript: string;
61
+ readonly unilateralRefundWithoutReceiverScript: string;
62
+ readonly nonInteractiveClaimScript?: string;
63
+ readonly nonInteractiveClaimArkadeScript?: Bytes;
64
+ readonly nonInteractiveRefundScript?: string;
65
+ readonly nonInteractiveRefundArkadeScript?: Bytes;
66
+ protected constructor(options: Options, preimageCondition: (hash: Bytes) => Bytes);
67
+ /** Return the collaborative claim tapleaf script. */
68
+ claim(): TapLeafScript;
69
+ /** Return the collaborative refund tapleaf script. */
70
+ refund(): TapLeafScript;
71
+ /** Return the refund-without-receiver tapleaf script. */
72
+ refundWithoutReceiver(): TapLeafScript;
73
+ /** Return the unilateral claim tapleaf script. */
74
+ unilateralClaim(): TapLeafScript;
75
+ /** Return the unilateral refund tapleaf script. */
76
+ unilateralRefund(): TapLeafScript;
77
+ /** Return the unilateral refund-without-receiver tapleaf script. */
78
+ unilateralRefundWithoutReceiver(): TapLeafScript;
79
+ /** Return the non-interactive claim tapleaf script as well as the ArkadeScript. */
80
+ nonInteractiveClaim(): [TapLeafScript, Bytes];
81
+ /** Return the non-interactive refund tapleaf script as well as the ArkadeScript. */
82
+ nonInteractiveRefund(): [TapLeafScript, Bytes];
16
83
  }
17
84
  /**
18
85
  * Virtual Hash Time Lock Contract (VHTLC) script implementation.
@@ -26,6 +93,16 @@ declare namespace VHTLC {
26
93
  * - **unilateralClaim**: Receiver can claim unilaterally after delay
27
94
  * - **unilateralRefund**: Sender and receiver can refund unilaterally after delay
28
95
  * - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay
96
+ * - **nonInteractiveClaim** (optional): server + emulator can push the
97
+ * receiver's claim, pinned to a pre-committed destination
98
+ * - **nonInteractiveRefund** (optional): server + receiver + emulator
99
+ * can push the sender's refund immediately, no timelock, pinned to a
100
+ * pre-committed destination — recoverable even if the sender's own key
101
+ * is lost
102
+ *
103
+ * See {@link ScriptV2} for the current recommended construction — same
104
+ * leaf ladder, same options shape, an added length check on the claim
105
+ * preimage. This class is unchanged and stays available as-is.
29
106
  *
30
107
  * @example
31
108
  * ```typescript
@@ -41,29 +118,24 @@ declare namespace VHTLC {
41
118
  * });
42
119
  * ```
43
120
  */
44
- class Script extends VtxoScript {
45
- readonly options: Options;
46
- readonly claimScript: string;
47
- readonly refundScript: string;
48
- readonly refundWithoutReceiverScript: string;
49
- readonly unilateralClaimScript: string;
50
- readonly unilateralRefundScript: string;
51
- readonly unilateralRefundWithoutReceiverScript: string;
52
- /** Create a VHTLC script from the supplied participant keys, hash, and timelocks. */
121
+ export class Script extends BaseScript {
53
122
  constructor(options: Options);
54
- /** Return the collaborative claim tapleaf script. */
55
- claim(): TapLeafScript;
56
- /** Return the collaborative refund tapleaf script. */
57
- refund(): TapLeafScript;
58
- /** Return the refund-without-receiver tapleaf script. */
59
- refundWithoutReceiver(): TapLeafScript;
60
- /** Return the unilateral claim tapleaf script. */
61
- unilateralClaim(): TapLeafScript;
62
- /** Return the unilateral refund tapleaf script. */
63
- unilateralRefund(): TapLeafScript;
64
- /** Return the unilateral refund-without-receiver tapleaf script. */
65
- unilateralRefundWithoutReceiver(): TapLeafScript;
66
123
  }
124
+ /**
125
+ * Same leaf ladder as {@link Script}, built with {@link
126
+ * preimageConditionScriptV2} instead of {@link preimageConditionScript}
127
+ * for every leaf that gates on the preimage (`claim`, `unilateralClaim`,
128
+ * and, when present, `nonInteractiveClaim`) — see that function's doc
129
+ * comment for what differs and why. A distinct class rather than a flag
130
+ * on {@link Script}: the two produce different script bytes (and so
131
+ * different addresses) for the same participant keys, and keeping them
132
+ * as separate types makes that a compile-time-visible choice at every
133
+ * call site instead of a runtime option that's easy to get wrong.
134
+ */
135
+ export class ScriptV2 extends BaseScript {
136
+ constructor(options: Options);
137
+ }
138
+ export { };
67
139
  }
68
140
 
69
141
  /**
@@ -194,7 +266,91 @@ interface VHTLCContractParams {
194
266
  * - unilateralRefund: Sender + Receiver after CSV delay
195
267
  * - unilateralRefundWithoutReceiver: Sender after CSV delay
196
268
  */
197
- declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script>;
269
+ declare const VHTLCContractHandler: ContractHandler<VHTLCContractParams, VHTLC.Script> & TapscriptDeriving<VHTLC.Script>;
270
+
271
+ /**
272
+ * Typed parameters for {@link VHTLC.ScriptV2} contracts.
273
+ *
274
+ * The eight mandatory fields are `VHTLCContractParams` verbatim — the two
275
+ * script versions take the same {@link VHTLC.Options}, so a divergent shape
276
+ * here would be a difference with no cause. What V1's handler has no field for
277
+ * is the two optional covenant leaves, and those are exactly what the swap
278
+ * corridor's lockup carries, so leaving them out would make this handler unable
279
+ * to round-trip the contract it exists to serve.
280
+ */
281
+ interface VHTLCV2ContractParams {
282
+ sender: Uint8Array;
283
+ receiver: Uint8Array;
284
+ server: Uint8Array;
285
+ preimageHash: Uint8Array;
286
+ refundLocktime: bigint;
287
+ unilateralClaimDelay: RelativeTimelock;
288
+ unilateralRefundDelay: RelativeTimelock;
289
+ unilateralRefundWithoutReceiverDelay: RelativeTimelock;
290
+ /** @see VHTLC.Options.nonInteractiveClaim */
291
+ nonInteractiveClaim?: {
292
+ receiverPkScript: Uint8Array;
293
+ emulatorPubkey: Uint8Array;
294
+ };
295
+ /** @see VHTLC.Options.nonInteractiveRefund */
296
+ nonInteractiveRefund?: {
297
+ senderPkScript: Uint8Array;
298
+ emulatorPubkey: Uint8Array;
299
+ };
300
+ }
301
+ /**
302
+ * Handler for {@link VHTLC.ScriptV2} — the VHTLC whose preimage leaves carry an
303
+ * explicit `OP_SIZE 32 OP_EQUALVERIFY` before the hash check, and which the RFQ
304
+ * swap corridor builds (`@arkade-os/swap`'s `lightningSendVtxoScript`).
305
+ *
306
+ * **Why a separate type string rather than a flag on `vhtlc`.** A handler's
307
+ * `type` names the script class it derives, the way every other registered type
308
+ * does (`default` → `DefaultVtxo.Script`, `vhtlc` → `VHTLC.Script`, `boarding`,
309
+ * `arkade`). V1 and V2 produce different script bytes — and so different
310
+ * pkScripts — for identical participant keys, and `upsertContractRow` derives
311
+ * the script from `params` and refuses any row whose supplied `script` does not
312
+ * match. One type cannot serve both. `vhtlc-v2` also cannot COLLIDE with
313
+ * `vhtlc`: a colliding row needs one pkScript claimed by two types, and the two
314
+ * versions' preimage conditions differ in every tree, so no parameters make
315
+ * them equal. A use-named type (`swap-lockup`) was the alternative and is
316
+ * worse: contracts are keyed by script, so the moment a second use registered
317
+ * the same ScriptV2 the two uses would fight over one row.
318
+ *
319
+ * **Which leaves this offers, and why the set is smaller than the ladder.**
320
+ * ScriptV2 has eight leaves; a wallet holding ONE of the two participant keys
321
+ * can satisfy four of them, and offering a leaf whose signature the caller
322
+ * cannot produce is worse than offering fewer — it turns a refusal into a
323
+ * transaction that gets built and then rejected.
324
+ *
325
+ * | leaf | needs | offered |
326
+ * |-----------------------------------|--------------------------------|---------|
327
+ * | `claim` | receiver + server, preimage | yes, to the receiver |
328
+ * | `refund` | sender + receiver + server | no — needs the counterparty live |
329
+ * | `refundWithoutReceiver` | sender + server, CLTV | yes, to the sender |
330
+ * | `unilateralClaim` | receiver, CSV | yes, to the receiver |
331
+ * | `unilateralRefund` | sender + receiver, CSV | no — needs the counterparty live |
332
+ * | `unilateralRefundWithoutReceiver` | sender, CSV | yes, to the sender |
333
+ * | `nonInteractiveClaim` | server + emulator | no — the wallet holds neither key |
334
+ * | `nonInteractiveRefund` | server + receiver + emulator | no — the wallet holds neither key |
335
+ *
336
+ * The two omitted interactive leaves are the same two the `vhtlc` handler
337
+ * omits, for the same reason: `refund` and `unilateralRefund` both need the
338
+ * OTHER party's signature, and this protocol has no message that asks for one
339
+ * (see `@arkade-os/swap`'s `refund.ts` module doc). The two covenant leaves are
340
+ * pushed by the emulator on the counterparty's behalf and are not this wallet's
341
+ * to build at all.
342
+ *
343
+ * So `refundWithoutReceiver` is the sender's only collaborative way out, gated
344
+ * on the CLTV the quote committed to — which is exactly the leaf
345
+ * `pushRefundWithoutReceiver` builds. The CSV leaves are offered only in the
346
+ * non-collaborative context, where the caller has already accepted that
347
+ * spending them means a real unilateral exit first.
348
+ *
349
+ * The selection discipline is deliberately identical to the `vhtlc` handler's,
350
+ * and `test/contracts/vhtlcV2-handler.test.ts` pins the two against each other
351
+ * rung-for-rung across every role and timelock context so they cannot drift.
352
+ */
353
+ declare const VHTLCV2ContractHandler: ContractHandler<VHTLCV2ContractParams, VHTLC.ScriptV2> & TapscriptDeriving<VHTLC.ScriptV2>;
198
354
 
199
355
  /**
200
356
  * Typed parameters for boarding contracts.
@@ -509,4 +665,4 @@ declare function deserializeArkadeContractParams(params: Record<string, string>)
509
665
  */
510
666
  declare const ArkadeContractHandler: ContractHandler<ArkadeContractParams, ArkadeProgramScript> & TapscriptDeriving<ArkadeProgramScript>;
511
667
 
512
- export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, deserializeArkadeContractParams as l, stringifyArtifact as m, ArkadeContractHandler as n, type BoardingContractParams as o, parseArtifact as p, type DefaultContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, DelegateContractHandler as t, type DelegateContractParams as u, validateProgram as v, witnessRefToBytes as w, VHTLCContractHandler as x, type VHTLCContractParams as y, contractHandlers as z };
668
+ export { type ArkadeParamValue as A, BoardingContractHandler as B, type CompiledProgramFunction as C, DefaultContractHandler as D, type VHTLCV2ContractParams as E, contractHandlers as F, type InputRef as I, type Program as P, SUPPORTED_PROGRAM_VERSION as S, type TapscriptSegment as T, VHTLC as V, type WitnessRef as W, ArkadeProgramScript as a, type ProgramKeys as b, type ArkadeArgValue as c, type ArkadeFunction as d, type InputDef as e, type ArkadeValueType as f, type ArkadeArgType as g, type ArkadeContractParams as h, type ArkadeSegment as i, type AsmToken as j, type SignerRef as k, deserializeArkadeContractParams as l, stringifyArtifact as m, ArkadeContractHandler as n, type BoardingContractParams as o, parseArtifact as p, type DefaultContractParams as q, resolveAsm as r, serializeArkadeContractParams as s, DelegateContractHandler as t, type DelegateContractParams as u, validateProgram as v, witnessRefToBytes as w, VHTLCContractHandler as x, type VHTLCContractParams as y, VHTLCV2ContractHandler as z };