@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
@@ -14,28 +14,54 @@ import { DelegatorProvider } from "../providers/delegator";
14
14
  /**
15
15
  * Base configuration options shared by all wallet types.
16
16
  *
17
- * Supports two configuration modes:
18
- * 1. URL-based: Provide arkServerUrl, indexerUrl (optional), and esploraUrl
19
- * 2. Provider-based: Provide arkProvider, indexerProvider, and onchainProvider instances
17
+ * Supports URL-based and provider-based configuration.
18
+ *
19
+ * URL-based configuration starts from `arkServerUrl` and can optionally override
20
+ * derived service URLs such as `indexerUrl` and `esploraUrl`.
21
+ *
22
+ * Provider-based configuration supplies concrete provider instances directly,
23
+ * including the ArkProvider, IndexerProvider, OnchainProvider, and DelegatorProvider.
20
24
  *
21
25
  * At least one of the following must be provided:
22
26
  * - arkServerUrl OR arkProvider
23
27
  *
24
28
  * The wallet will use provided URLs to create default providers if custom provider
25
29
  * instances are not supplied. If optional parameters are not provided, the wallet
26
- * will fetch configuration from the Ark server.
30
+ * will fetch configuration from the Arkade server.
31
+ *
32
+ * @remarks
33
+ * URL-based and provider-based configuration can be mixed, but provider instances
34
+ * always take precedence over URLs for the corresponding service.
35
+ *
36
+ * @see WalletConfig
37
+ * @see ReadonlyWalletConfig
38
+ * @see StorageConfig
27
39
  */
28
40
  export interface BaseWalletConfig {
41
+ /** Base URL of the Arkade server. */
29
42
  arkServerUrl?: string;
43
+ /** Optional override for the indexer URL. */
30
44
  indexerUrl?: string;
45
+ /** Optional override for the Esplora API URL. */
31
46
  esploraUrl?: string;
47
+ /** Optional Arkade server public key used to construct and validate Arkade addresses. */
32
48
  arkServerPublicKey?: string;
49
+ /** Relative timelock applied to boarding scripts. */
33
50
  boardingTimelock?: RelativeTimelock;
51
+ /** Relative timelock applied to unilateral exit paths. */
34
52
  exitTimelock?: RelativeTimelock;
53
+ /**
54
+ * Repository-backed storage configuration overrides.
55
+ * Defaults to IndexedDB if unset.
56
+ */
35
57
  storage?: StorageConfig;
58
+ /** Optional Arkade provider instance. */
36
59
  arkProvider?: ArkProvider;
60
+ /** Optional indexer provider instance. */
37
61
  indexerProvider?: IndexerProvider;
62
+ /** Optional onchain provider instance. */
38
63
  onchainProvider?: OnchainProvider;
64
+ /** Optional delegation service instance. */
39
65
  delegatorProvider?: DelegatorProvider;
40
66
  }
41
67
  /**
@@ -47,29 +73,35 @@ export interface BaseWalletConfig {
47
73
  * - Monitoring addresses
48
74
  * - Safe sharing of wallet state without private key exposure
49
75
  *
76
+ * @see BaseWalletConfig
77
+ * @see IReadonlyWallet
78
+ *
50
79
  * @example
51
80
  * ```typescript
52
81
  * // URL-based configuration
53
82
  * const wallet = await ReadonlyWallet.create({
54
83
  * identity: ReadonlySingleKey.fromPublicKey(pubkey),
55
- * arkServerUrl: 'https://ark.example.com',
84
+ * arkServerUrl: 'https://arkade.computer',
56
85
  * esploraUrl: 'https://mempool.space/api'
57
86
  * });
58
87
  *
59
88
  * // Provider-based configuration (e.g., for Expo/React Native)
60
89
  * const wallet = await ReadonlyWallet.create({
61
90
  * identity: ReadonlySingleKey.fromPublicKey(pubkey),
62
- * arkProvider: new ExpoArkProvider('https://ark.example.com'),
63
- * indexerProvider: new ExpoIndexerProvider('https://ark.example.com'),
91
+ * arkProvider: new ExpoArkProvider('https://arkade.computer'),
92
+ * indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
64
93
  * onchainProvider: new EsploraProvider('https://mempool.space/api')
65
94
  * });
66
95
  * ```
67
96
  */
68
97
  export interface ReadonlyWalletConfig extends BaseWalletConfig {
98
+ /** Readonly identity used to derive wallet addresses. */
69
99
  identity: ReadonlyIdentity;
70
100
  /**
71
101
  * Configuration for the ContractManager's watcher.
72
102
  * Controls reconnection behavior and failsafe polling.
103
+ *
104
+ * @see ContractWatcherConfig
73
105
  */
74
106
  watcherConfig?: Partial<Omit<ContractWatcherConfig, "indexerProvider">>;
75
107
  }
@@ -77,48 +109,72 @@ export interface ReadonlyWalletConfig extends BaseWalletConfig {
77
109
  * Configuration options for full wallet initialization.
78
110
  *
79
111
  * This config provides full wallet capabilities including sending transactions,
80
- * settling VTXOs, and all readonly operations.
112
+ * settling virtual outputs, and all readonly operations.
113
+ *
114
+ * @see ReadonlyWalletConfig
115
+ * @see IWallet
81
116
  *
82
117
  * @example
83
118
  * ```typescript
84
119
  * // URL-based configuration
85
120
  * const wallet = await Wallet.create({
86
- * identity: SingleKey.fromHex('...'),
87
- * arkServerUrl: 'https://ark.example.com',
121
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
122
+ * arkServerUrl: 'https://arkade.computer',
88
123
  * esploraUrl: 'https://mempool.space/api'
89
124
  * });
90
125
  *
91
126
  * // Provider-based configuration (e.g., for Expo/React Native)
92
127
  * const wallet = await Wallet.create({
93
- * identity: SingleKey.fromHex('...'),
94
- * arkProvider: new ExpoArkProvider('https://ark.example.com'),
95
- * indexerProvider: new ExpoIndexerProvider('https://ark.example.com'),
128
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
129
+ * arkProvider: new ExpoArkProvider('https://arkade.computer'),
130
+ * indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
96
131
  * onchainProvider: new EsploraProvider('https://mempool.space/api')
97
132
  * });
98
133
  *
99
134
  * // With settlement configuration
100
135
  * const wallet = await Wallet.create({
101
- * identity: SingleKey.fromHex('...'),
102
- * arkServerUrl: 'https://ark.example.com',
136
+ * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
137
+ * arkServerUrl: 'https://arkade.computer',
103
138
  * settlementConfig: {
104
- * vtxoThreshold: 86400, // 24 hours in seconds
139
+ * vtxoThreshold: 60 * 60 * 24, // 24 hours in seconds
105
140
  * boardingUtxoSweep: true,
106
141
  * },
107
142
  * });
108
143
  * ```
109
144
  */
110
145
  export interface WalletConfig extends ReadonlyWalletConfig {
146
+ /** Signing identity used to authorize transactions. */
111
147
  identity: Identity;
112
- /** @deprecated Use settlementConfig instead */
148
+ /**
149
+ * Legacy renewal configuration.
150
+ *
151
+ * @remarks
152
+ * This field is still accepted for backwards compatibility, but `settlementConfig`
153
+ * is the source of truth for new code.
154
+ *
155
+ * @deprecated Use `settlementConfig` instead.
156
+ */
113
157
  renewalConfig?: RenewalConfig;
114
158
  /**
115
159
  * Configuration for automatic settlement and renewal.
116
- * `false` = explicitly disabled, `undefined` = enabled by default, `{}` = enabled with defaults.
160
+ * `false` = explicitly disabled, `undefined` or `{}` = enabled with defaults.
161
+ *
162
+ * @defaultValue `undefined` (enabled with defaults)
163
+ * @see SettlementConfig
117
164
  */
118
165
  settlementConfig?: SettlementConfig | false;
119
166
  }
167
+ /**
168
+ * Repository implementations used to store wallet and contract state.
169
+ *
170
+ * @see BaseWalletConfig
171
+ * @see WalletRepository
172
+ * @see ContractRepository
173
+ */
120
174
  export type StorageConfig = {
175
+ /** Wallet-state repository implementation. */
121
176
  walletRepository: WalletRepository;
177
+ /** Contract-state repository implementation. */
122
178
  contractRepository: ContractRepository;
123
179
  };
124
180
  /**
@@ -126,186 +182,562 @@ export type StorageConfig = {
126
182
  * Ensures provider classes follow the consistent constructor pattern.
127
183
  */
128
184
  export interface ProviderClass<T> {
185
+ /**
186
+ * Create a provider instance for the given server URL.
187
+ *
188
+ * @param serverUrl - Base server URL used by the provider
189
+ */
129
190
  new (serverUrl: string): T;
130
191
  }
192
+ /**
193
+ * Balance summary returned by `IWallet.getBalance`.
194
+ *
195
+ * @see IWallet.getBalance
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const balance = await wallet.getBalance()
200
+ * console.log(balance.available, balance.boarding.total)
201
+ * ```
202
+ */
131
203
  export interface WalletBalance {
204
+ /** Boarding funds */
132
205
  boarding: {
206
+ /** Confirmed funds ready to swap for virtual outputs. */
133
207
  confirmed: number;
208
+ /** Pending funds awaiting confirmation on mainnet */
134
209
  unconfirmed: number;
210
+ /** Combined boarding balance (`confirmed` + `unconfirmed`) */
135
211
  total: number;
136
212
  };
213
+ /** Spendable settled (finalized) balance. */
137
214
  settled: number;
215
+ /** Spendable preconfirmed (unfinalized) balance. */
138
216
  preconfirmed: number;
217
+ /** Spendable offchain balance (`settled + preconfirmed`). */
139
218
  available: number;
219
+ /** Recoverable balance from subdust or expired (swept) virtual outputs. */
140
220
  recoverable: number;
221
+ /** Total balance across offchain, recoverable, and boarding funds. */
141
222
  total: number;
223
+ /** Asset balance entries (`assetId` & `amount`) */
142
224
  assets: Asset[];
143
225
  }
226
+ /**
227
+ * Parameters accepted by `OnchainWallet.send`.
228
+ *
229
+ * @remarks
230
+ * This shape was also used by the deprecated `Wallet.sendBitcoin` method.
231
+ * New wallet sends should use `Recipient` via `IWallet.send`.
232
+ *
233
+ * @see Recipient
234
+ */
144
235
  export interface SendBitcoinParams {
236
+ /** Destination address. */
145
237
  address: string;
238
+ /** Amount to send in satoshis. */
146
239
  amount: number;
240
+ /** Optional fee rate override in sats/vB. */
147
241
  feeRate?: number;
242
+ /**
243
+ * Optional memo associated with the transaction.
244
+ * @deprecated Does not appear to have ever been used.
245
+ */
148
246
  memo?: string;
247
+ /** Optional explicit virtual output selection used by `Wallet.sendBitcoin`. */
149
248
  selectedVtxos?: ExtendedVirtualCoin[];
150
249
  }
250
+ /**
251
+ * Asset amount paired with an asset id.
252
+ *
253
+ * @see AssetDetails
254
+ */
151
255
  export interface Asset {
256
+ /** Asset identifier. */
152
257
  assetId: string;
258
+ /** Asset amount in base units. */
153
259
  amount: number;
154
260
  }
261
+ /**
262
+ * Recipient accepted by `IWallet.send`.
263
+ *
264
+ * @see IWallet.send
265
+ */
155
266
  export interface Recipient {
156
267
  address: string;
268
+ /**
269
+ * BTC amount in satoshis.
270
+ *
271
+ * @defaultValue Dust amount (`330`).
272
+ */
157
273
  amount?: number;
274
+ /** Assets to send to the same recipient (`assetId` & `amount`) */
158
275
  assets?: Asset[];
159
276
  }
277
+ /**
278
+ * Known asset metadata fields.
279
+ *
280
+ * @remarks
281
+ * Additional metadata keys are allowed through `AssetMetadata`.
282
+ *
283
+ * @see AssetMetadata
284
+ */
160
285
  export type KnownMetadata = Partial<{
286
+ /** Asset name, e.g. "Tether USD" */
161
287
  name: string;
288
+ /** Asset symbol, e.g. "USDT" */
162
289
  ticker: string;
290
+ /**
291
+ * Amount of decimal places to adjust the `amount` for
292
+ * (e.g. `1_000_000` adjusted for `6` decimals = `1`)
293
+ */
163
294
  decimals: number;
295
+ /** Image source that can be passed to an `<img src>` attribute. */
164
296
  icon: string;
165
297
  }>;
298
+ /**
299
+ * Asset metadata including known fields and arbitrary extension keys.
300
+ *
301
+ * @see KnownMetadata
302
+ */
166
303
  export type AssetMetadata = KnownMetadata & Record<string, unknown>;
304
+ /**
305
+ * Asset details returned by `IAssetManager.getAssetDetails`.
306
+ *
307
+ * @see IAssetManager.getAssetDetails
308
+ * @see AssetMetadata
309
+ */
167
310
  export type AssetDetails = {
311
+ /** Asset identifier. */
168
312
  assetId: string;
313
+ /** Total issued supply in base units. */
169
314
  supply: number;
315
+ /** Optional immutable metadata associated with the asset. */
170
316
  metadata?: AssetMetadata;
317
+ /** Optional control asset id required for future reissuance. */
171
318
  controlAssetId?: string;
172
319
  };
320
+ /**
321
+ * Parameters accepted by `IAssetManager.issue`.
322
+ *
323
+ * @see IAssetManager.issue
324
+ * @see IssuanceResult
325
+ */
173
326
  export interface IssuanceParams {
327
+ /** Initial amount of asset to issue */
174
328
  amount: number;
329
+ /** Optional control asset ID that can be used for future reissuance */
175
330
  controlAssetId?: string;
331
+ /** Immutable asset metadata including `ticker`, `decimals`, `icon` */
176
332
  metadata?: AssetMetadata;
177
333
  }
334
+ /**
335
+ * Result returned by `IAssetManager.issue`.
336
+ *
337
+ * @see IAssetManager.issue
338
+ * @see IssuanceParams
339
+ */
178
340
  export interface IssuanceResult {
341
+ /** Arkade transaction ID where the asset was issued */
179
342
  arkTxId: string;
343
+ /** Permanent asset ID, made up of above `arkTxId` and zero-based asset group index */
180
344
  assetId: string;
181
345
  }
346
+ /**
347
+ * Parameters accepted by `IAssetManager.reissue`.
348
+ *
349
+ * @see IAssetManager.reissue
350
+ */
182
351
  export interface ReissuanceParams {
352
+ /** Existing asset ID, made up of genesis (Arkade) transaction ID and zero-based asset group index */
183
353
  assetId: string;
354
+ /** Amount of asset to issue */
184
355
  amount: number;
185
356
  }
357
+ /**
358
+ * Parameters accepted by `IAssetManager.burn`.
359
+ *
360
+ * @see IAssetManager.burn
361
+ */
186
362
  export interface BurnParams {
363
+ /** Existing asset ID, made up of genesis (Arkade) transaction ID and zero-based asset group index */
187
364
  assetId: string;
365
+ /** Amount of asset to burn */
188
366
  amount: number;
189
367
  }
368
+ /**
369
+ * Explicit inputs and outputs accepted by `IWallet.settle`.
370
+ *
371
+ * @remarks
372
+ * Inputs can include both offchain virtual outputs and onchain boarding inputs.
373
+ *
374
+ * @see IWallet.settle
375
+ * @see Output
376
+ */
190
377
  export interface SettleParams {
378
+ /** Offchain virtual outputs and/or onchain boarding inputs to settle. */
191
379
  inputs: ExtendedCoin[];
380
+ /** Optional onchain outputs to create (i.e., exit to). */
192
381
  outputs: Output[];
193
382
  }
383
+ /**
384
+ * Onchain output status
385
+ */
194
386
  export interface Status {
387
+ /** Whether the output is confirmed */
195
388
  confirmed: boolean;
389
+ /**
390
+ * Whether the output exists as a finalized batch leaf.
391
+ * In the current mapping this is `true` for settled and swept virtual outputs,
392
+ * and `false` for preconfirmed virtual outputs.
393
+ *
394
+ * @remarks
395
+ * `isLeaf` is currently derived from `!isPreconfirmed` in the indexer mapping.
396
+ * It is used primarily by transaction history classification to distinguish
397
+ * finalized batch outputs from preconfirmed offchain outputs.
398
+ */
196
399
  isLeaf?: boolean;
400
+ /** Block height where the output was confirmed, when known. */
197
401
  block_height?: number;
402
+ /** Block hash where the output was confirmed, when known. */
198
403
  block_hash?: string;
404
+ /** Block time where the output was confirmed, when known. */
199
405
  block_time?: number;
200
406
  }
407
+ /**
408
+ * Virtual output status
409
+ */
201
410
  export interface VirtualStatus {
411
+ /**
412
+ * Extended output status.
413
+ *
414
+ * - `preconfirmed`: not yet finalized in a batch
415
+ * - `settled`: finalized in a batch
416
+ * - `swept`: expired/swept and recoverable in a new batch
417
+ * - `spent`: destroyed by a later transaction
418
+ *
419
+ * @remarks
420
+ * `state` is the high-level lifecycle summary used throughout wallet balance,
421
+ * recovery, and transaction history logic.
422
+ */
202
423
  state: "preconfirmed" | "settled" | "swept" | "spent";
424
+ /**
425
+ * Which batch commitment transaction(s) this virtual output depends on.
426
+ *
427
+ * @remarks
428
+ * The history builder uses these ids to group received batch transactions and
429
+ * relate refreshed or forfeited virtual outputs back to the same batch.
430
+ */
203
431
  commitmentTxIds?: string[];
432
+ /**
433
+ * The earliest point at which this virtual output stops being safely preconfirmed.
434
+ *
435
+ * @remarks
436
+ * The value is stored in milliseconds in the wallet model and is used by expiry
437
+ * and recovery logic to decide when a virtual output can be swept or renewed.
438
+ */
204
439
  batchExpiry?: number;
205
440
  }
441
+ /** Onchain output location data. */
206
442
  export interface Outpoint {
443
+ /** Transaction ID where the output was created */
207
444
  txid: string;
445
+ /** Transaction output index for this output */
208
446
  vout: number;
209
447
  }
448
+ /**
449
+ * Onchain output data.
450
+ *
451
+ * @see Outpoint
452
+ */
210
453
  export interface Coin extends Outpoint {
454
+ /** Value of the output in satoshis */
211
455
  value: number;
456
+ /** Onchain output status */
212
457
  status: Status;
213
458
  }
459
+ /**
460
+ * Virtual output data.
461
+ *
462
+ * @see Coin
463
+ * @see VirtualStatus
464
+ */
214
465
  export interface VirtualCoin extends Coin {
466
+ /** Virtual output status */
215
467
  virtualStatus: VirtualStatus;
468
+ /** Transaction id that spent this virtual output, when known. */
216
469
  spentBy?: string;
470
+ /** Settlement transaction associated with this virtual output, when known. */
217
471
  settledBy?: string;
472
+ /** Arkade transaction id that created or spent this virtual output, when known. */
218
473
  arkTxId?: string;
474
+ /** Creation time of the virtual output. */
219
475
  createdAt: Date;
476
+ /** Whether this virtual output has been unrolled to onchain outputs. */
220
477
  isUnrolled: boolean;
478
+ /** Whether this virtual output is already spent. */
221
479
  isSpent?: boolean;
480
+ /** Assets carried by this virtual output, if any. */
222
481
  assets?: Asset[];
223
- /** The scriptPubKey (hex) locking this VTXO, as returned by the indexer. */
482
+ /** The scriptPubKey (hex) locking this virtual output, as returned by the indexer. */
224
483
  script?: string;
225
484
  }
485
+ /** Wallet transaction direction. */
226
486
  export declare enum TxType {
227
487
  TxSent = "SENT",
228
488
  TxReceived = "RECEIVED"
229
489
  }
490
+ /**
491
+ * Composite key used to correlate a wallet transaction across layers.
492
+ *
493
+ * @see ArkTransaction
494
+ */
230
495
  export interface TxKey {
496
+ /** Boarding transaction id, when applicable. */
231
497
  boardingTxid: string;
498
+ /** Batch commitment transaction id, when applicable. */
232
499
  commitmentTxid: string;
500
+ /** Arkade transaction id, when applicable. */
233
501
  arkTxid: string;
234
502
  }
503
+ /**
504
+ * Wallet transaction history entry.
505
+ *
506
+ * @see TxKey
507
+ * @see TxType
508
+ */
235
509
  export interface ArkTransaction {
510
+ /** Composite key referencing the related transaction ids. */
236
511
  key: TxKey;
512
+ /** Transaction direction. */
237
513
  type: TxType;
514
+ /** Net transaction amount in satoshis. */
238
515
  amount: number;
516
+ /** Whether the transaction is finalized. */
239
517
  settled: boolean;
518
+ /** Creation timestamp in milliseconds since epoch. */
240
519
  createdAt: number;
520
+ /** Assets sent or received by this transaction, if any. */
241
521
  assets?: Asset[];
242
522
  }
523
+ /**
524
+ * Tapleaves required to spend or settle a wallet output.
525
+ *
526
+ * @see ExtendedCoin
527
+ * @see ExtendedVirtualCoin
528
+ */
243
529
  export type TapLeaves = {
530
+ /** Tapleaf script used for the forfeit path. */
244
531
  forfeitTapLeafScript: TapLeafScript;
532
+ /** Tapleaf script used for the intent path. */
245
533
  intentTapLeafScript: TapLeafScript;
246
534
  };
535
+ /**
536
+ * Onchain output data enriched with tapscript and witness data.
537
+ *
538
+ * @see Coin
539
+ * @see TapLeaves
540
+ */
247
541
  export type ExtendedCoin = TapLeaves & EncodedVtxoScript & Coin & {
248
542
  extraWitness?: Bytes[];
249
543
  };
544
+ /**
545
+ * Virtual output data enriched with tapscript and witness data.
546
+ *
547
+ * @see VirtualCoin
548
+ * @see TapLeaves
549
+ */
250
550
  export type ExtendedVirtualCoin = TapLeaves & EncodedVtxoScript & VirtualCoin & {
251
551
  extraWitness?: Bytes[];
252
552
  };
553
+ /**
554
+ * Return whether a virtual output is still spendable.
555
+ *
556
+ * @param vtxo - virtual output to inspect
557
+ * @returns `true` when the virtual output is not marked as spent
558
+ *
559
+ * @see isRecoverable
560
+ * @see isExpired
561
+ */
253
562
  export declare function isSpendable(vtxo: VirtualCoin): boolean;
563
+ /**
564
+ * Return whether a virtual output is recoverable.
565
+ *
566
+ * @param vtxo - virtual output to inspect
567
+ * @returns `true` when the virtual output is swept but still spendable
568
+ *
569
+ * @remarks
570
+ * Recoverable virtual outputs are typically re-settled into fresh virtual outputs by the virtual output manager.
571
+ *
572
+ * @see isSpendable
573
+ * @see isExpired
574
+ */
254
575
  export declare function isRecoverable(vtxo: VirtualCoin): boolean;
576
+ /**
577
+ * Return whether a virtual output should be treated as expired.
578
+ *
579
+ * @param vtxo - virtual output to inspect
580
+ * @returns `true` when the virtual output is swept or its batch expiry has passed
581
+ * @remarks
582
+ * On regtest-like environments the upstream expiry value may be expressed as a block
583
+ * height instead of a timestamp. This helper intentionally ignores obviously non-time
584
+ * values to avoid false positives.
585
+ *
586
+ * @see VirtualStatus.batchExpiry
587
+ */
255
588
  export declare function isExpired(vtxo: VirtualCoin): boolean;
589
+ /**
590
+ * Return whether a virtual output is below the dust threshold.
591
+ *
592
+ * @param vtxo - virtual output to inspect
593
+ * @param dust - dust threshold in satoshis
594
+ * @returns `true` when the virtual output value is below `dust`
595
+ *
596
+ * @see isRecoverable
597
+ */
256
598
  export declare function isSubdust(vtxo: VirtualCoin, dust: bigint): boolean;
599
+ /**
600
+ * Filtering options for `IWallet.getVtxos`.
601
+ *
602
+ * @see IWallet.getVtxos
603
+ */
257
604
  export type GetVtxosFilter = {
605
+ /** Include swept but still unspent virtual outputs. */
258
606
  withRecoverable?: boolean;
607
+ /** Include virtual outputs that have been unrolled onchain. */
259
608
  withUnrolled?: boolean;
260
609
  };
261
610
  /**
262
611
  * Readonly asset manager interface for asset operations that do not require wallet identity.
612
+ *
613
+ * @see IAssetManager
263
614
  */
264
615
  export interface IReadonlyAssetManager {
616
+ /**
617
+ * Fetch metadata and supply data for an asset.
618
+ *
619
+ * @param assetId - Asset identifier
620
+ * @returns Asset details
621
+ * @see AssetDetails
622
+ */
265
623
  getAssetDetails(assetId: string): Promise<AssetDetails>;
266
624
  }
267
625
  /**
268
626
  * Asset manager interface for asset operations that require wallet identity.
627
+ *
628
+ * @see IReadonlyAssetManager
269
629
  */
270
630
  export interface IAssetManager extends IReadonlyAssetManager {
631
+ /**
632
+ * Issue a new asset.
633
+ *
634
+ * @param params - Asset issuance parameters
635
+ * @returns Asset issuance result
636
+ * @see IssuanceParams
637
+ * @see IssuanceResult
638
+ */
271
639
  issue(params: IssuanceParams): Promise<IssuanceResult>;
640
+ /**
641
+ * Reissue an existing asset.
642
+ *
643
+ * @param params - Asset reissuance parameters
644
+ * @returns Arkade transaction id
645
+ * @see ReissuanceParams
646
+ */
272
647
  reissue(params: ReissuanceParams): Promise<string>;
648
+ /**
649
+ * Burn an existing asset.
650
+ *
651
+ * @param params - Asset burn parameters
652
+ * @returns Arkade transaction id
653
+ * @see BurnParams
654
+ */
273
655
  burn(params: BurnParams): Promise<string>;
274
656
  }
275
657
  /**
276
- * Core wallet interface for Bitcoin transactions with Ark protocol support.
658
+ * Core wallet interface for Bitcoin transactions with Arkade protocol support.
277
659
  *
278
660
  * This interface defines the contract that all wallet implementations must follow.
279
- * It provides methods for address management, balance checking, virtual UTXO
661
+ * It provides methods for address management, balance checking, virtual output
280
662
  * operations, and transaction management including sending, settling, and unrolling.
663
+ *
664
+ * @see IReadonlyWallet
281
665
  */
282
666
  export interface IWallet extends IReadonlyWallet {
667
+ /** Signing identity associated with the wallet. */
283
668
  identity: Identity;
669
+ /**
670
+ * Send bitcoin to a single Arkade address.
671
+ *
672
+ * @param params - Destination, amount, fee rate override, etc
673
+ * @returns Arkade transaction id
674
+ * @deprecated Use `send`
675
+ * @see send
676
+ * @see Recipient
677
+ */
284
678
  sendBitcoin(params: SendBitcoinParams): Promise<string>;
679
+ /**
680
+ * Settle boarding inputs and/or preconfirmed virtual outputs into settled virtual outputs.
681
+ *
682
+ * @param params - Optional explicit settlement inputs and outputs
683
+ * @param eventCallback - Optional callback that receives settlement events
684
+ * @returns Arkade transaction id
685
+ * @see SettleParams
686
+ */
285
687
  settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
286
- send(...recipients: Recipient[]): Promise<string>;
688
+ /**
689
+ * Send bitcoin and/or assets to one or more Arkade recipients.
690
+ *
691
+ * @param recipients - One or more recipients
692
+ * @returns Arkade transaction id
693
+ * @example
694
+ * ```typescript
695
+ * await wallet.send({ address: 'ark1q...', amount: 1000 })
696
+ * ```
697
+ */
698
+ send(...recipients: [Recipient, ...Recipient[]]): Promise<string>;
699
+ /** Asset manager bound to this wallet instance. */
287
700
  assetManager: IAssetManager;
701
+ /** @returns Delegation manager, when configured. */
288
702
  getDelegatorManager(): Promise<IDelegatorManager | undefined>;
289
703
  }
290
704
  /**
291
- * Readonly wallet interface for Bitcoin transactions with Ark protocol support.
705
+ * Readonly wallet interface for Bitcoin transactions with Arkade protocol support.
292
706
  *
293
707
  * This interface defines the contract that all wallet implementations must follow.
294
- * It provides methods for address management, balance checking, virtual UTXO
708
+ * It provides methods for address management, balance checking, virtual output
295
709
  * operations, and transaction management including sending, settling, and unrolling.
710
+ *
711
+ * @see IWallet
296
712
  */
297
713
  export interface IReadonlyWallet {
714
+ /** Readonly identity associated with the wallet. */
298
715
  identity: ReadonlyIdentity;
716
+ /** @returns Arkade address used for offchain funds. */
299
717
  getAddress(): Promise<string>;
718
+ /** @returns Onchain boarding address used to move funds into Arkade. */
300
719
  getBoardingAddress(): Promise<string>;
720
+ /** @returns The wallet's combined onchain and offchain balance. */
301
721
  getBalance(): Promise<WalletBalance>;
722
+ /**
723
+ * Get virtual outputs tracked by the wallet.
724
+ *
725
+ * @param filter - Optional filtering flags
726
+ * @returns virtual outputs with tapscript and witness data
727
+ * @see GetVtxosFilter
728
+ */
302
729
  getVtxos(filter?: GetVtxosFilter): Promise<ExtendedVirtualCoin[]>;
730
+ /** @returns Onchain boarding inputs tracked by the wallet. */
303
731
  getBoardingUtxos(): Promise<ExtendedCoin[]>;
732
+ /** @returns Wallet transaction history derived from boarding and Arkade activity. */
304
733
  getTransactionHistory(): Promise<ArkTransaction[]>;
305
734
  /**
306
- * Returns the contract manager associated with this wallet.
735
+ * Get the contract manager associated with this wallet.
307
736
  * This is useful for querying contract state and watching for contract events.
737
+ *
738
+ * @returns Contract manager instance
308
739
  */
309
740
  getContractManager(): Promise<IContractManager>;
741
+ /** Readonly asset manager bound to this wallet instance. */
310
742
  assetManager: IReadonlyAssetManager;
311
743
  }