@arkade-os/sdk 0.4.15 → 0.4.17

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 (197) hide show
  1. package/README.md +102 -96
  2. package/dist/cjs/arkfee/estimator.js +1 -1
  3. package/dist/cjs/arkfee/types.js +2 -1
  4. package/dist/cjs/arknote/index.js +43 -4
  5. package/dist/cjs/bip322/index.js +1 -1
  6. package/dist/cjs/contracts/arkcontract.js +1 -1
  7. package/dist/cjs/contracts/contractManager.js +60 -28
  8. package/dist/cjs/contracts/contractWatcher.js +29 -22
  9. package/dist/cjs/contracts/handlers/default.js +1 -1
  10. package/dist/cjs/contracts/handlers/delegate.js +1 -1
  11. package/dist/cjs/contracts/handlers/helpers.js +1 -1
  12. package/dist/cjs/extension/asset/assetGroup.js +92 -5
  13. package/dist/cjs/extension/asset/assetId.js +67 -3
  14. package/dist/cjs/extension/asset/assetInput.js +18 -0
  15. package/dist/cjs/extension/asset/assetOutput.js +15 -0
  16. package/dist/cjs/extension/asset/assetRef.js +66 -0
  17. package/dist/cjs/extension/asset/metadata.js +15 -0
  18. package/dist/cjs/extension/asset/packet.js +4 -1
  19. package/dist/cjs/extension/index.js +1 -1
  20. package/dist/cjs/forfeit.js +14 -0
  21. package/dist/cjs/identity/seedIdentity.js +2 -2
  22. package/dist/cjs/identity/singleKey.js +4 -0
  23. package/dist/cjs/intent/index.js +28 -12
  24. package/dist/cjs/providers/ark.js +3 -2
  25. package/dist/cjs/providers/delegator.js +20 -1
  26. package/dist/cjs/providers/expoArk.js +2 -2
  27. package/dist/cjs/providers/indexer.js +2 -2
  28. package/dist/cjs/providers/onchain.js +2 -1
  29. package/dist/cjs/repositories/realm/schemas.js +2 -2
  30. package/dist/cjs/repositories/realm/types.js +1 -1
  31. package/dist/cjs/script/address.js +37 -6
  32. package/dist/cjs/script/base.js +70 -1
  33. package/dist/cjs/script/default.js +3 -0
  34. package/dist/cjs/script/delegate.js +4 -0
  35. package/dist/cjs/script/tapscript.js +17 -2
  36. package/dist/cjs/script/vhtlc.js +35 -27
  37. package/dist/cjs/storage/fileSystem.js +1 -1
  38. package/dist/cjs/storage/inMemory.js +1 -1
  39. package/dist/cjs/storage/indexedDB.js +1 -1
  40. package/dist/cjs/storage/localStorage.js +1 -1
  41. package/dist/cjs/tree/validation.js +1 -1
  42. package/dist/cjs/utils/arkTransaction.js +5 -5
  43. package/dist/cjs/utils/bip21.js +16 -3
  44. package/dist/cjs/utils/syncCursors.js +4 -4
  45. package/dist/cjs/utils/transaction.js +1 -1
  46. package/dist/cjs/utils/transactionHistory.js +11 -11
  47. package/dist/cjs/utils/unknownFields.js +3 -3
  48. package/dist/cjs/wallet/asset-manager.js +4 -4
  49. package/dist/cjs/wallet/batch.js +5 -5
  50. package/dist/cjs/wallet/delegator.js +9 -8
  51. package/dist/cjs/wallet/expo/background.js +3 -3
  52. package/dist/cjs/wallet/expo/wallet.js +7 -7
  53. package/dist/cjs/wallet/index.js +43 -0
  54. package/dist/cjs/wallet/onchain.js +43 -5
  55. package/dist/cjs/wallet/ramps.js +44 -14
  56. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +22 -22
  57. package/dist/cjs/wallet/serviceWorker/wallet.js +28 -24
  58. package/dist/cjs/wallet/unroll.js +12 -8
  59. package/dist/cjs/wallet/utils.js +1 -1
  60. package/dist/cjs/wallet/vtxo-manager.js +122 -82
  61. package/dist/cjs/wallet/wallet.js +140 -77
  62. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +1 -1
  63. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +2 -2
  64. package/dist/cjs/worker/expo/taskRunner.js +3 -3
  65. package/dist/cjs/worker/messageBus.js +3 -0
  66. package/dist/esm/arkfee/estimator.js +1 -1
  67. package/dist/esm/arkfee/types.js +2 -1
  68. package/dist/esm/arknote/index.js +43 -4
  69. package/dist/esm/bip322/index.js +1 -1
  70. package/dist/esm/contracts/arkcontract.js +1 -1
  71. package/dist/esm/contracts/contractManager.js +60 -28
  72. package/dist/esm/contracts/contractWatcher.js +29 -22
  73. package/dist/esm/contracts/handlers/default.js +1 -1
  74. package/dist/esm/contracts/handlers/delegate.js +1 -1
  75. package/dist/esm/contracts/handlers/helpers.js +1 -1
  76. package/dist/esm/extension/asset/assetGroup.js +92 -5
  77. package/dist/esm/extension/asset/assetId.js +67 -3
  78. package/dist/esm/extension/asset/assetInput.js +18 -0
  79. package/dist/esm/extension/asset/assetOutput.js +15 -0
  80. package/dist/esm/extension/asset/assetRef.js +66 -0
  81. package/dist/esm/extension/asset/metadata.js +15 -0
  82. package/dist/esm/extension/asset/packet.js +4 -1
  83. package/dist/esm/extension/index.js +1 -1
  84. package/dist/esm/forfeit.js +14 -0
  85. package/dist/esm/identity/seedIdentity.js +2 -2
  86. package/dist/esm/identity/singleKey.js +4 -0
  87. package/dist/esm/index.js +1 -1
  88. package/dist/esm/intent/index.js +28 -12
  89. package/dist/esm/providers/ark.js +3 -2
  90. package/dist/esm/providers/delegator.js +20 -1
  91. package/dist/esm/providers/expoArk.js +2 -2
  92. package/dist/esm/providers/indexer.js +2 -2
  93. package/dist/esm/providers/onchain.js +2 -1
  94. package/dist/esm/repositories/realm/schemas.js +2 -2
  95. package/dist/esm/repositories/realm/types.js +1 -1
  96. package/dist/esm/script/address.js +37 -6
  97. package/dist/esm/script/base.js +70 -1
  98. package/dist/esm/script/default.js +3 -0
  99. package/dist/esm/script/delegate.js +4 -0
  100. package/dist/esm/script/tapscript.js +17 -2
  101. package/dist/esm/script/vhtlc.js +35 -27
  102. package/dist/esm/storage/fileSystem.js +1 -1
  103. package/dist/esm/storage/inMemory.js +1 -1
  104. package/dist/esm/storage/indexedDB.js +1 -1
  105. package/dist/esm/storage/localStorage.js +1 -1
  106. package/dist/esm/tree/validation.js +1 -1
  107. package/dist/esm/utils/arkTransaction.js +5 -5
  108. package/dist/esm/utils/bip21.js +16 -3
  109. package/dist/esm/utils/syncCursors.js +4 -4
  110. package/dist/esm/utils/transaction.js +1 -1
  111. package/dist/esm/utils/transactionHistory.js +11 -11
  112. package/dist/esm/utils/unknownFields.js +3 -3
  113. package/dist/esm/wallet/asset-manager.js +4 -4
  114. package/dist/esm/wallet/batch.js +5 -5
  115. package/dist/esm/wallet/delegator.js +9 -8
  116. package/dist/esm/wallet/expo/background.js +3 -3
  117. package/dist/esm/wallet/expo/wallet.js +7 -7
  118. package/dist/esm/wallet/index.js +43 -0
  119. package/dist/esm/wallet/onchain.js +43 -5
  120. package/dist/esm/wallet/ramps.js +44 -14
  121. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +22 -22
  122. package/dist/esm/wallet/serviceWorker/wallet.js +28 -24
  123. package/dist/esm/wallet/unroll.js +12 -8
  124. package/dist/esm/wallet/utils.js +1 -1
  125. package/dist/esm/wallet/vtxo-manager.js +121 -81
  126. package/dist/esm/wallet/wallet.js +140 -77
  127. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +1 -1
  128. package/dist/esm/worker/expo/processors/contractPollProcessor.js +2 -2
  129. package/dist/esm/worker/expo/taskRunner.js +3 -3
  130. package/dist/esm/worker/messageBus.js +3 -0
  131. package/dist/types/arkfee/estimator.d.ts +1 -1
  132. package/dist/types/arkfee/types.d.ts +2 -1
  133. package/dist/types/arknote/index.d.ts +44 -4
  134. package/dist/types/bip322/index.d.ts +1 -1
  135. package/dist/types/contracts/arkcontract.d.ts +1 -1
  136. package/dist/types/contracts/contractManager.d.ts +39 -65
  137. package/dist/types/contracts/contractWatcher.d.ts +39 -18
  138. package/dist/types/contracts/handlers/default.d.ts +1 -1
  139. package/dist/types/contracts/handlers/delegate.d.ts +1 -1
  140. package/dist/types/contracts/handlers/helpers.d.ts +1 -1
  141. package/dist/types/contracts/types.d.ts +36 -26
  142. package/dist/types/extension/asset/assetGroup.d.ts +92 -1
  143. package/dist/types/extension/asset/assetId.d.ts +67 -3
  144. package/dist/types/extension/asset/assetInput.d.ts +18 -0
  145. package/dist/types/extension/asset/assetOutput.d.ts +15 -0
  146. package/dist/types/extension/asset/assetRef.d.ts +66 -0
  147. package/dist/types/extension/asset/metadata.d.ts +15 -0
  148. package/dist/types/extension/asset/packet.d.ts +4 -1
  149. package/dist/types/extension/index.d.ts +1 -1
  150. package/dist/types/forfeit.d.ts +14 -0
  151. package/dist/types/identity/index.d.ts +16 -0
  152. package/dist/types/identity/seedIdentity.d.ts +8 -6
  153. package/dist/types/identity/singleKey.d.ts +4 -0
  154. package/dist/types/intent/index.d.ts +19 -6
  155. package/dist/types/providers/ark.d.ts +40 -2
  156. package/dist/types/providers/delegator.d.ts +54 -1
  157. package/dist/types/providers/expoArk.d.ts +2 -2
  158. package/dist/types/providers/indexer.d.ts +105 -2
  159. package/dist/types/providers/onchain.d.ts +62 -1
  160. package/dist/types/repositories/realm/schemas.d.ts +2 -2
  161. package/dist/types/repositories/realm/types.d.ts +2 -2
  162. package/dist/types/repositories/walletRepository.d.ts +16 -0
  163. package/dist/types/script/address.d.ts +35 -2
  164. package/dist/types/script/base.d.ts +66 -1
  165. package/dist/types/script/default.d.ts +3 -0
  166. package/dist/types/script/delegate.d.ts +4 -0
  167. package/dist/types/script/tapscript.d.ts +17 -2
  168. package/dist/types/script/vhtlc.d.ts +35 -27
  169. package/dist/types/storage/fileSystem.d.ts +1 -1
  170. package/dist/types/storage/inMemory.d.ts +1 -1
  171. package/dist/types/storage/index.d.ts +1 -1
  172. package/dist/types/storage/indexedDB.d.ts +1 -1
  173. package/dist/types/storage/localStorage.d.ts +1 -1
  174. package/dist/types/utils/arkTransaction.d.ts +3 -3
  175. package/dist/types/utils/bip21.d.ts +17 -0
  176. package/dist/types/utils/syncCursors.d.ts +4 -4
  177. package/dist/types/utils/transaction.d.ts +1 -1
  178. package/dist/types/utils/transactionHistory.d.ts +3 -3
  179. package/dist/types/utils/unknownFields.d.ts +5 -5
  180. package/dist/types/wallet/asset-manager.d.ts +3 -3
  181. package/dist/types/wallet/batch.d.ts +27 -7
  182. package/dist/types/wallet/delegator.d.ts +10 -0
  183. package/dist/types/wallet/expo/background.d.ts +4 -4
  184. package/dist/types/wallet/expo/wallet.d.ts +10 -10
  185. package/dist/types/wallet/index.d.ts +457 -25
  186. package/dist/types/wallet/onchain.d.ts +42 -4
  187. package/dist/types/wallet/ramps.d.ts +40 -10
  188. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +4 -4
  189. package/dist/types/wallet/serviceWorker/wallet.d.ts +71 -33
  190. package/dist/types/wallet/unroll.d.ts +8 -6
  191. package/dist/types/wallet/vtxo-manager.d.ts +146 -93
  192. package/dist/types/wallet/wallet.d.ts +91 -33
  193. package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
  194. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
  195. package/dist/types/worker/expo/taskRunner.d.ts +6 -6
  196. package/dist/types/worker/messageBus.d.ts +5 -3
  197. package/package.json +1 -1
@@ -15,26 +15,91 @@ export declare const TapTreeCoder: (typeof PSBTOutput.tapTree)[2];
15
15
  export declare function scriptFromTapLeafScript(leaf: TapLeafScript): Bytes;
16
16
  /**
17
17
  * VtxoScript is a script that contains a list of tapleaf scripts.
18
- * It is used to create vtxo scripts.
18
+ * It is used to create virtual output scripts.
19
+ *
20
+ * @see ArkAddress
19
21
  *
20
22
  * @example
21
23
  * ```typescript
22
24
  * const vtxoScript = new VtxoScript([new Uint8Array(32), new Uint8Array(32)]);
25
+ * ```
23
26
  */
24
27
  export declare class VtxoScript {
25
28
  readonly scripts: Bytes[];
26
29
  readonly leaves: TapLeafScript[];
27
30
  readonly tweakedPublicKey: Bytes;
31
+ /**
32
+ * Decode a virtual output script from an encoded TapTree.
33
+ *
34
+ * @param tapTree - Encoded TapTree bytes
35
+ * @returns Decoded virtual output script
36
+ * @throws Error if the TapTree cannot be decoded into a valid script set
37
+ * @see encode
38
+ */
28
39
  static decode(tapTree: Bytes): VtxoScript;
40
+ /**
41
+ * Create a virtual output script from its tapleaf scripts.
42
+ *
43
+ * @param scripts - Raw tapscript bytes for each leaf
44
+ * @throws Error if the provided leaves cannot produce a valid Taproot tree
45
+ */
29
46
  constructor(scripts: Bytes[]);
47
+ /**
48
+ * Encode the virtual output script to a TapTree byte representation.
49
+ *
50
+ * @returns Encoded TapTree bytes
51
+ * @see decode
52
+ */
30
53
  encode(): Bytes;
54
+ /**
55
+ * Build the Arkade address corresponding to this virtual output script.
56
+ *
57
+ * @param prefix - Bech32 human-readable prefix
58
+ * @param serverPubKey - 32-byte Arkade server public key
59
+ * @returns Arkade address for this script
60
+ * @see ArkAddress
61
+ */
31
62
  address(prefix: string, serverPubKey: Bytes): ArkAddress;
32
63
  get pkScript(): Bytes;
64
+ /**
65
+ * Build the Taproot onchain address corresponding to this virtual output script.
66
+ *
67
+ * @param network - Bitcoin network descriptor
68
+ * @returns Taproot onchain address
69
+ * @see address
70
+ */
33
71
  onchainAddress(network: typeof NETWORK): string;
72
+ /**
73
+ * Look up a tapleaf script by its hex-encoded tapscript body.
74
+ *
75
+ * @param scriptHex - Hex-encoded tapscript body without the leaf version byte
76
+ * @returns Matching tapleaf script
77
+ * @throws Error if no matching leaf exists
78
+ */
34
79
  findLeaf(scriptHex: string): TapLeafScript;
80
+ /**
81
+ * Return all unilateral exit paths embedded in the virtual output script.
82
+ *
83
+ * @returns CSV-based exit paths found in the leaves
84
+ * @see getSequence
85
+ */
35
86
  exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
36
87
  }
37
88
  export type EncodedVtxoScript = {
38
89
  tapTree: Bytes;
39
90
  };
91
+ /**
92
+ * Extract the timelock value encoded in a timelocked tapleaf, if any.
93
+ *
94
+ * The return value is unit-ambiguous: for a CSV leaf it is a BIP-68
95
+ * nSequence (relative timelock); for a CLTV leaf it is an absolute
96
+ * nLockTime. Callers must know which leaf shape they are inspecting to
97
+ * interpret the number correctly, and must not copy a CSV result into
98
+ * `Transaction.lockTime` (or vice versa).
99
+ *
100
+ * @param tapLeafScript - Tapleaf script to inspect
101
+ * @returns The encoded timelock value, or `undefined` when neither a CSV
102
+ * nor CLTV path is present
103
+ * @see VtxoScript.exitPaths
104
+ */
40
105
  export declare function getSequence(tapLeafScript: TapLeafScript): number | undefined;
@@ -34,8 +34,11 @@ export declare namespace DefaultVtxo {
34
34
  static readonly DEFAULT_TIMELOCK: RelativeTimelock;
35
35
  readonly forfeitScript: string;
36
36
  readonly exitScript: string;
37
+ /** Create the default virtual output script with one forfeit path and one exit path. */
37
38
  constructor(options: Options);
39
+ /** Return the forfeit tapleaf script. */
38
40
  forfeit(): TapLeafScript;
41
+ /** Return the unilateral exit tapleaf script. */
39
42
  exit(): TapLeafScript;
40
43
  }
41
44
  }
@@ -28,9 +28,13 @@ export declare namespace DelegateVtxo {
28
28
  readonly options: Options;
29
29
  readonly defaultVtxo: DefaultVtxo.Script;
30
30
  readonly delegateScript: string;
31
+ /** Create a delegated virtual output script with forfeit, exit, and delegate paths. */
31
32
  constructor(options: Options);
33
+ /** Return the forfeit tapleaf script. */
32
34
  forfeit(): TapLeafScript;
35
+ /** Return the unilateral exit tapleaf script. */
33
36
  exit(): TapLeafScript;
37
+ /** Return the delegate tapleaf script. */
34
38
  delegate(): TapLeafScript;
35
39
  }
36
40
  }
@@ -29,9 +29,9 @@ export interface ArkTapscript<T extends TapscriptType, Params> {
29
29
  script: Uint8Array;
30
30
  }
31
31
  /**
32
- * decodeTapscript is a function that decodes an ark tapsript from a raw script.
32
+ * decodeTapscript is a function that decodes an Arkade tapscript from a raw script.
33
33
  *
34
- * @throws {Error} if the script is not a valid ark tapscript
34
+ * @throws {Error} if the script is not a valid Arkade tapscript
35
35
  * @example
36
36
  * ```typescript
37
37
  * const arkTapscript = decodeTapscript(new Uint8Array(32));
@@ -59,8 +59,11 @@ export declare namespace MultisigTapscript {
59
59
  pubkeys: Bytes[];
60
60
  type?: MultisigType;
61
61
  };
62
+ /** Encode a plain multisig tapscript. */
62
63
  function encode(params: Params): Type;
64
+ /** Decode a plain multisig tapscript from raw script bytes. */
63
65
  function decode(script: Uint8Array): Type;
66
+ /** Return true when the tapscript is a plain multisig tapscript. */
64
67
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
65
68
  }
66
69
  /**
@@ -81,8 +84,11 @@ export declare namespace CSVMultisigTapscript {
81
84
  type Params = {
82
85
  timelock: RelativeTimelock;
83
86
  } & MultisigTapscript.Params;
87
+ /** Encode a CSV multisig tapscript. */
84
88
  function encode(params: Params): Type;
89
+ /** Decode a CSV multisig tapscript from raw script bytes. */
85
90
  function decode(script: Uint8Array): Type;
91
+ /** Return true when the tapscript is a CSV multisig tapscript. */
86
92
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
87
93
  }
88
94
  /**
@@ -102,8 +108,11 @@ export declare namespace ConditionCSVMultisigTapscript {
102
108
  type Params = {
103
109
  conditionScript: Bytes;
104
110
  } & CSVMultisigTapscript.Params;
111
+ /** Encode a condition + CSV multisig tapscript. */
105
112
  function encode(params: Params): Type;
113
+ /** Decode a condition + CSV multisig tapscript from raw script bytes. */
106
114
  function decode(script: Uint8Array): Type;
115
+ /** Return true when the tapscript is a condition + CSV multisig tapscript. */
107
116
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
108
117
  }
109
118
  /**
@@ -123,8 +132,11 @@ export declare namespace ConditionMultisigTapscript {
123
132
  type Params = {
124
133
  conditionScript: Bytes;
125
134
  } & MultisigTapscript.Params;
135
+ /** Encode a condition + multisig tapscript. */
126
136
  function encode(params: Params): Type;
137
+ /** Decode a condition + multisig tapscript from raw script bytes. */
127
138
  function decode(script: Uint8Array): Type;
139
+ /** Return true when the tapscript is a condition + multisig tapscript. */
128
140
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
129
141
  }
130
142
  /**
@@ -144,7 +156,10 @@ export declare namespace CLTVMultisigTapscript {
144
156
  type Params = {
145
157
  absoluteTimelock: bigint;
146
158
  } & MultisigTapscript.Params;
159
+ /** Encode a CLTV multisig tapscript. */
147
160
  function encode(params: Params): Type;
161
+ /** Decode a CLTV multisig tapscript from raw script bytes. */
148
162
  function decode(script: Uint8Array): Type;
163
+ /** Return true when the tapscript is a CLTV multisig tapscript. */
149
164
  function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
150
165
  }
@@ -1,33 +1,7 @@
1
1
  import { Bytes } from "@scure/btc-signer/utils.js";
2
2
  import { RelativeTimelock } from "./tapscript";
3
3
  import { TapLeafScript, VtxoScript } from "./base";
4
- /**
5
- * Virtual Hash Time Lock Contract (VHTLC) implementation.
6
- *
7
- * VHTLC is a contract that enables atomic swaps and conditional payments
8
- * in the Ark protocol. It provides multiple spending paths:
9
- *
10
- * - **claim**: Receiver can claim funds by revealing the preimage
11
- * - **refund**: Sender and receiver can collaboratively refund
12
- * - **refundWithoutReceiver**: Sender can refund after locktime expires
13
- * - **unilateralClaim**: Receiver can claim unilaterally after delay
14
- * - **unilateralRefund**: Sender and receiver can refund unilaterally after delay
15
- * - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay
16
- *
17
- * @example
18
- * ```typescript
19
- * const vhtlc = new VHTLC.Script({
20
- * sender: alicePubKey,
21
- * receiver: bobPubKey,
22
- * server: serverPubKey,
23
- * preimageHash: hash160(secret),
24
- * refundLocktime: BigInt(chainTip + 10),
25
- * unilateralClaimDelay: { type: 'blocks', value: 100n },
26
- * unilateralRefundDelay: { type: 'blocks', value: 102n },
27
- * unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }
28
- * });
29
- * ```
30
- */
4
+ /** Virtual Hash Time Lock Contract (VHTLC) namespace. */
31
5
  export declare namespace VHTLC {
32
6
  interface Options {
33
7
  sender: Bytes;
@@ -39,6 +13,33 @@ export declare namespace VHTLC {
39
13
  unilateralRefundDelay: RelativeTimelock;
40
14
  unilateralRefundWithoutReceiverDelay: RelativeTimelock;
41
15
  }
16
+ /**
17
+ * Virtual Hash Time Lock Contract (VHTLC) script implementation.
18
+ *
19
+ * VHTLC enables atomic swaps and conditional payments in the Arkade protocol.
20
+ * It provides multiple spending paths:
21
+ *
22
+ * - **claim**: Receiver can claim funds by revealing the preimage
23
+ * - **refund**: Sender and receiver can collaboratively refund
24
+ * - **refundWithoutReceiver**: Sender can refund after locktime expires
25
+ * - **unilateralClaim**: Receiver can claim unilaterally after delay
26
+ * - **unilateralRefund**: Sender and receiver can refund unilaterally after delay
27
+ * - **unilateralRefundWithoutReceiver**: Sender can refund unilaterally after delay
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * const vhtlc = new VHTLC.Script({
32
+ * sender: alicePubKey,
33
+ * receiver: bobPubKey,
34
+ * server: serverPubKey,
35
+ * preimageHash: hash160(secret),
36
+ * refundLocktime: BigInt(chainTip + 10),
37
+ * unilateralClaimDelay: { type: 'blocks', value: 100n },
38
+ * unilateralRefundDelay: { type: 'blocks', value: 102n },
39
+ * unilateralRefundWithoutReceiverDelay: { type: 'blocks', value: 103n }
40
+ * });
41
+ * ```
42
+ */
42
43
  class Script extends VtxoScript {
43
44
  readonly options: Options;
44
45
  readonly claimScript: string;
@@ -47,12 +48,19 @@ export declare namespace VHTLC {
47
48
  readonly unilateralClaimScript: string;
48
49
  readonly unilateralRefundScript: string;
49
50
  readonly unilateralRefundWithoutReceiverScript: string;
51
+ /** Create a VHTLC script from the supplied participant keys, hash, and timelocks. */
50
52
  constructor(options: Options);
53
+ /** Return the collaborative claim tapleaf script. */
51
54
  claim(): TapLeafScript;
55
+ /** Return the collaborative refund tapleaf script. */
52
56
  refund(): TapLeafScript;
57
+ /** Return the refund-without-receiver tapleaf script. */
53
58
  refundWithoutReceiver(): TapLeafScript;
59
+ /** Return the unilateral claim tapleaf script. */
54
60
  unilateralClaim(): TapLeafScript;
61
+ /** Return the unilateral refund tapleaf script. */
55
62
  unilateralRefund(): TapLeafScript;
63
+ /** Return the unilateral refund-without-receiver tapleaf script. */
56
64
  unilateralRefundWithoutReceiver(): TapLeafScript;
57
65
  }
58
66
  }
@@ -1,6 +1,6 @@
1
1
  import type { StorageAdapter } from "./index";
2
2
  /**
3
- * @deprecated Use repositories instead
3
+ * @deprecated Use repository implementations via `StorageConfig` instead.
4
4
  */
5
5
  export declare class FileSystemStorageAdapter implements StorageAdapter {
6
6
  private readonly basePath;
@@ -1,6 +1,6 @@
1
1
  import type { StorageAdapter } from "./index";
2
2
  /**
3
- * @deprecated Use repositories instead
3
+ * @deprecated Use repository implementations via `StorageConfig` instead.
4
4
  */
5
5
  export declare class InMemoryStorageAdapter implements StorageAdapter {
6
6
  private store;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @deprecated Use StorageConfig instead
2
+ * @deprecated Use `StorageConfig` with repository implementations such as `IndexedDBWalletRepository` and `IndexedDBContractRepository` instead.
3
3
  */
4
4
  export interface StorageAdapter {
5
5
  getItem(key: string): Promise<string | null>;
@@ -1,6 +1,6 @@
1
1
  import type { StorageAdapter } from "./index";
2
2
  /**
3
- * @deprecated Use repositories instead
3
+ * @deprecated Use repository implementations via `StorageConfig` instead.
4
4
  */
5
5
  export declare class IndexedDBStorageAdapter implements StorageAdapter {
6
6
  private dbName;
@@ -1,6 +1,6 @@
1
1
  import type { StorageAdapter } from "./index";
2
2
  /**
3
- * @deprecated Use repositories instead
3
+ * @deprecated Use repository implementations via `StorageConfig` instead.
4
4
  */
5
5
  export declare class LocalStorageAdapter implements StorageAdapter {
6
6
  private getSafeLocalStorage;
@@ -16,7 +16,7 @@ export type OffchainTx = {
16
16
  *
17
17
  * Creates one checkpoint transaction per input and a virtual transaction that
18
18
  * combines all the checkpoints, sending to the specified outputs. This is the
19
- * core function for creating Ark transactions.
19
+ * core function for creating Arkade transactions.
20
20
  *
21
21
  * @param inputs - Array of virtual transaction inputs
22
22
  * @param outputs - Array of transaction outputs
@@ -42,8 +42,8 @@ export declare function verifyTapscriptSignatures(tx: Transaction, inputIndex: n
42
42
  */
43
43
  export declare function combineTapscriptSigs(signedTx: Transaction, originalTx: Transaction): Transaction;
44
44
  /**
45
- * Validates if a given string is a valid Ark address by attempting to decode it.
46
- * @param address The Ark address to validate.
45
+ * Validates if a given string is a valid Arkade address by attempting to decode it.
46
+ * @param address The Arkade address to validate.
47
47
  * @returns True if the address is valid, false otherwise.
48
48
  */
49
49
  export declare function isValidArkAddress(address: string): boolean;
@@ -1,12 +1,16 @@
1
+ /** Known BIP21 parameters including Arkade-specific extensions. */
1
2
  export interface BIP21Params {
2
3
  address?: string;
3
4
  amount?: number;
4
5
  label?: string;
5
6
  message?: string;
7
+ /** Optional Arkade address parameter. */
6
8
  ark?: string;
9
+ /** Optional Silent Payment address parameter. */
7
10
  sp?: string;
8
11
  [key: string]: string | number | undefined;
9
12
  }
13
+ /** Result returned by `BIP21.parse`. */
10
14
  export interface BIP21ParseResult {
11
15
  originalString: string;
12
16
  params: BIP21Params;
@@ -16,6 +20,19 @@ export declare enum BIP21Error {
16
20
  INVALID_ADDRESS = "Invalid address"
17
21
  }
18
22
  export declare class BIP21 {
23
+ /**
24
+ * Create a BIP21 URI from the provided parameters.
25
+ *
26
+ * @param params - BIP21 parameters to encode
27
+ * @returns Encoded BIP21 URI
28
+ */
19
29
  static create(params: BIP21Params): string;
30
+ /**
31
+ * Parse a BIP21 URI and return its decoded parameters.
32
+ *
33
+ * @param uri - BIP21 URI to parse
34
+ * @returns Parsed BIP21 URI data
35
+ * @throws Error if the URI does not start with the `bitcoin:` scheme
36
+ */
20
37
  static parse(uri: string): BIP21ParseResult;
21
38
  }
@@ -1,7 +1,7 @@
1
1
  import { WalletRepository, WalletState } from "../repositories/walletRepository";
2
2
  /** Lag behind real-time to avoid racing with indexer writes. */
3
3
  export declare const SAFETY_LAG_MS = 30000;
4
- /** Overlap window so boundary VTXOs are never missed. */
4
+ /** Overlap window so boundary virtual outputs are never missed. */
5
5
  export declare const OVERLAP_MS = 60000;
6
6
  type SyncCursors = Record<string, number>;
7
7
  /**
@@ -38,15 +38,15 @@ export declare function clearSyncCursors(repo: WalletRepository, scripts?: strin
38
38
  * Returns `undefined` when the script has no cursor (bootstrap needed).
39
39
  *
40
40
  * No upper bound (`before`) is applied to the query so that freshly
41
- * created VTXOs are never excluded. The safety lag is applied only
42
- * when advancing the cursor (see {@link cursorCutoff}).
41
+ * created virtual outputs are never excluded. The safety lag is applied only
42
+ * when advancing the cursor (see @see cursorCutoff).
43
43
  */
44
44
  export declare function computeSyncWindow(cursor: number | undefined): {
45
45
  after: number;
46
46
  } | undefined;
47
47
  /**
48
48
  * The safe high-water mark for cursor advancement.
49
- * Lags behind real-time by {@link SAFETY_LAG_MS} so that VTXOs still
49
+ * Lags behind real-time by @see SAFETY_LAG_MS so that virtual outputs still
50
50
  * being indexed are re-queried on the next sync.
51
51
  *
52
52
  * When `requestStartedAt` is provided the cutoff is frozen to the
@@ -3,7 +3,7 @@ import { TxOpts } from "@scure/btc-signer/transaction";
3
3
  import { Bytes } from "@scure/btc-signer/utils";
4
4
  /**
5
5
  * Transaction is a wrapper around the @scure/btc-signer Transaction class.
6
- * It adds the Ark protocol specific options to the transaction.
6
+ * It adds the Arkade protocol specific options to the transaction.
7
7
  */
8
8
  export declare class Transaction extends BtcSignerTransaction {
9
9
  static ARK_TX_OPTS: TxOpts;
@@ -3,13 +3,13 @@ type ExtendedArkTransaction = ArkTransaction & {
3
3
  tag: "offchain" | "boarding" | "exit" | "batch";
4
4
  };
5
5
  /**
6
- * Builds the transaction history by analyzing virtual coins (VTXOs), boarding transactions, and ignored commitments.
6
+ * Builds the transaction history by analyzing virtual outputs, boarding transactions, and ignored commitments.
7
7
  * History is sorted from newest to oldest and is composed only of SENT and RECEIVED transactions.
8
8
  *
9
- * @param {VirtualCoin[]} vtxos - An array of virtual coins representing the user's transactions and balances.
9
+ * @param {VirtualCoin[]} vtxos - An array of virtual outputs representing the user's transactions and balances.
10
10
  * @param {ArkTransaction[]} allBoardingTxs - An array of boarding transactions to include in the history.
11
11
  * @param {Set<string>} commitmentsToIgnore - A set of commitment IDs that should be excluded from processing.
12
- * @return {ExtendedArkTransaction[]} A sorted array of extended Ark transactions, representing the transaction history.
12
+ * @return {ExtendedArkTransaction[]} A sorted array of extended Arkade transactions, representing the transaction history.
13
13
  */
14
14
  export declare function buildTransactionHistory(vtxos: VirtualCoin[], allBoardingTxs: ArkTransaction[], commitmentsToIgnore: Set<string>, getTxCreatedAt?: (txid: string) => Promise<number | undefined>): Promise<ExtendedArkTransaction[]>;
15
15
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Transaction } from "@scure/btc-signer";
2
2
  import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
3
3
  /**
4
- * ArkPsbtFieldKey is the key values for ark psbt fields.
4
+ * ArkPsbtFieldKey are the available key names for the Arkade PSBT custom fields.
5
5
  */
6
6
  export declare enum ArkPsbtFieldKey {
7
7
  VtxoTaprootTree = "taptree",
@@ -10,13 +10,13 @@ export declare enum ArkPsbtFieldKey {
10
10
  ConditionWitness = "condition"
11
11
  }
12
12
  /**
13
- * ArkPsbtFieldKeyType is the type of the ark psbt field key.
14
- * Every ark psbt field has key type 222.
13
+ * ArkPsbtFieldKeyType is the key type of the Arkade PSBT custom field.
14
+ * Every Arkade PSBT field has key type 222.
15
15
  */
16
16
  export declare const ArkPsbtFieldKeyType = 222;
17
17
  /**
18
- * ArkPsbtFieldCoder is the coder for the ark psbt fields.
19
- * each type has its own coder.
18
+ * ArkPsbtFieldCoder is the coder for the Arkade PSBT custom fields.
19
+ * Each type has its own coder.
20
20
  */
21
21
  export interface ArkPsbtFieldCoder<T> {
22
22
  key: ArkPsbtFieldKey;
@@ -15,7 +15,7 @@ export declare class AssetManager extends ReadonlyAssetManager implements IAsset
15
15
  * @param params.amount - Amount of asset units to issue
16
16
  * @param params.controlAssetId - Optional control asset ID (for reissuable assets)
17
17
  * @param params.metadata - Optional metadata to attach to the asset
18
- * @returns Promise resolving to the ark transaction ID and asset ID
18
+ * @returns Promise resolving to the Arkade transaction ID and asset ID
19
19
  *
20
20
  * @example
21
21
  * ```typescript
@@ -39,7 +39,7 @@ export declare class AssetManager extends ReadonlyAssetManager implements IAsset
39
39
  * @param params - Parameters for asset reissuance
40
40
  * @param params.assetId - The asset ID to reissue (control asset ID is resolved via getAssetDetails)
41
41
  * @param params.amount - Amount of additional units to issue
42
- * @returns Promise resolving to the ark transaction ID
42
+ * @returns Promise resolving to the Arkade transaction ID
43
43
  *
44
44
  * @example
45
45
  * ```typescript
@@ -55,7 +55,7 @@ export declare class AssetManager extends ReadonlyAssetManager implements IAsset
55
55
  * @param params - Parameters for burning
56
56
  * @param params.assetId - The asset ID to burn
57
57
  * @param params.amount - Amount of units to burn
58
- * @returns Promise resolving to the ark transaction ID
58
+ * @returns Promise resolving to the Arkade transaction ID
59
59
  *
60
60
  * @example
61
61
  * ```typescript
@@ -10,7 +10,7 @@ import { TxTree } from "../tree/txTree";
10
10
  * const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
11
11
  *
12
12
  * const abortController = new AbortController();
13
- * // Get event stream from Ark provider
13
+ * // Get event stream from the Arkade provider
14
14
  * const eventStream = arkProvider.getEventStream(
15
15
  * abortController.signal,
16
16
  * ['your-topic-1', 'your-topic-2']
@@ -39,7 +39,7 @@ export declare namespace Batch {
39
39
  /**
40
40
  * Called when tree signing starts.
41
41
  * @param event The tree signing started event.
42
- * @param vtxoTree The unsigned VTXO tree, reconstructed from the TreeTxEvent events.
42
+ * @param vtxoTree The unsigned virtual output tree, reconstructed from the TreeTxEvent events.
43
43
  * @returns Promise resolving to a boolean indicating whether to continue processing.
44
44
  */
45
45
  onTreeSigningStarted(event: TreeSigningStartedEvent, vtxoTree: TxTree): Promise<{
@@ -56,21 +56,41 @@ export declare namespace Batch {
56
56
  /**
57
57
  * Called during batch finalization.
58
58
  * @param event The batch finalization event.
59
- * @param vtxoTree The signed VTXO tree, reconstructed from the TreeTxEvent events.
59
+ * @param vtxoTree The signed virtual output tree, reconstructed from the TreeTxEvent events.
60
60
  * @param connectorTree The connector transaction tree, reconstructed from the TreeTxEvent events.
61
61
  */
62
62
  onBatchFinalization(event: BatchFinalizationEvent, vtxoTree?: TxTree, connectorTree?: TxTree): Promise<void>;
63
+ /**
64
+ * Called when batch finalization completes successfully.
65
+ *
66
+ * @param event - Batch finalized event
67
+ */
63
68
  onBatchFinalized?(event: BatchFinalizedEvent): Promise<void>;
69
+ /**
70
+ * Called when batch processing fails.
71
+ *
72
+ * @param event - Batch failed event
73
+ */
64
74
  onBatchFailed?(event: BatchFailedEvent): Promise<void>;
75
+ /**
76
+ * Called for each virtual output tree transaction chunk received during batch processing.
77
+ *
78
+ * @param event - Tree transaction event
79
+ */
65
80
  onTreeTxEvent?(event: TreeTxEvent): Promise<void>;
81
+ /**
82
+ * Called for each tree signature event received during batch processing.
83
+ *
84
+ * @param event - Tree signature event
85
+ */
66
86
  onTreeSignatureEvent?(event: TreeSignatureEvent): Promise<void>;
67
87
  }
68
88
  /**
69
89
  * Options for the join function.
70
- * @param @optional abortController - The abort controller to use to abort the operation.
71
- * @param @optional skipVtxoTreeSigning - ignore events related to vtxo tree musig2 signing session.
72
- * @param @optional eventCallback - A callback to be called for each event.
73
- * @param eventCallback - A callback to be called for each event.
90
+ *
91
+ * @property abortController - Abort controller used to cancel batch processing.
92
+ * @property skipVtxoTreeSigning - Ignore events related to the virtual output tree musig2 signing session.
93
+ * @property eventCallback - Callback invoked for each settlement event received while joining the batch.
74
94
  */
75
95
  type JoinOptions = Partial<{
76
96
  abortController: AbortController;
@@ -3,6 +3,14 @@ import { ArkProvider, DelegateInfo, ExtendedVirtualCoin, Identity, Outpoint } fr
3
3
  import { DelegatorProvider } from "../providers/delegator";
4
4
  import { Bytes } from "@scure/btc-signer/utils";
5
5
  export interface IDelegatorManager {
6
+ /**
7
+ * Delegate virtual outputs to the remote delegation service.
8
+ *
9
+ * @param vtxos - Virtual outputs to delegate
10
+ * @param destination - Arkade address that should receive renewed funds
11
+ * @param delegateAt - Optional timestamp to force a specific delegation time
12
+ * @returns Successfully delegated and failed outpoint groups
13
+ */
6
14
  delegate(vtxos: ExtendedVirtualCoin[], destination: string, delegateAt?: Date): Promise<{
7
15
  delegated: Outpoint[];
8
16
  failed: {
@@ -10,12 +18,14 @@ export interface IDelegatorManager {
10
18
  error: unknown;
11
19
  }[];
12
20
  }>;
21
+ /** Fetch delegate metadata such as pubkey, fee, and delegate address. */
13
22
  getDelegateInfo(): Promise<DelegateInfo>;
14
23
  }
15
24
  export declare class DelegatorManagerImpl implements IDelegatorManager {
16
25
  readonly delegatorProvider: DelegatorProvider;
17
26
  readonly arkInfoProvider: Pick<ArkProvider, "getInfo">;
18
27
  readonly identity: Identity;
28
+ /** Create a delegator manager from the configured provider, Arkade info source, and wallet identity. */
19
29
  constructor(delegatorProvider: DelegatorProvider, arkInfoProvider: Pick<ArkProvider, "getInfo">, identity: Identity);
20
30
  getDelegateInfo(): Promise<DelegateInfo>;
21
31
  delegate(vtxos: ExtendedVirtualCoin[], destination: string, delegateAt?: Date): Promise<{
@@ -3,7 +3,7 @@ import type { ContractRepository } from "../../repositories/contractRepository";
3
3
  import type { AsyncStorageTaskQueue } from "../../worker/expo/asyncStorageTaskQueue";
4
4
  import type { TaskProcessor } from "../../worker/expo/taskRunner";
5
5
  /**
6
- * Wallet parameters persisted by {@link ExpoWallet.setup} and read
6
+ * Wallet parameters persisted by @see ExpoWallet.setup and read
7
7
  * by the background handler to reconstruct providers and `extendVtxo`
8
8
  * without a network call.
9
9
  */
@@ -15,7 +15,7 @@ export interface PersistedBackgroundConfig {
15
15
  exitTimelockType: "blocks" | "seconds";
16
16
  }
17
17
  /**
18
- * Options for {@link defineExpoBackgroundTask}.
18
+ * Options for @see defineExpoBackgroundTask.
19
19
  */
20
20
  export interface DefineBackgroundTaskOptions {
21
21
  /** AsyncStorage-backed queue (must match the one passed to ExpoWallet.setup). */
@@ -52,8 +52,8 @@ export declare function defineExpoBackgroundTask(taskName: string, options: Defi
52
52
  /**
53
53
  * Activate the OS-level background task scheduler.
54
54
  *
55
- * Call this after {@link defineExpoBackgroundTask} (typically inside
56
- * {@link ExpoWallet.setup} or in a React component after wallet init).
55
+ * Call this after @see defineExpoBackgroundTask (typically inside
56
+ * @see ExpoWallet.setup or in a React component after wallet init).
57
57
  *
58
58
  * @param minimumInterval - Minimum interval in minutes (default 15).
59
59
  */