@arkade-os/sdk 0.4.15 → 0.4.16

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 +40 -24
  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 +125 -67
  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 +40 -24
  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 +125 -67
  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 +40 -63
  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
package/README.md CHANGED
@@ -45,7 +45,7 @@ The SDK supports read-only wallets that allow you to query wallet state without
45
45
  #### Creating a Read-Only Wallet
46
46
 
47
47
  ```typescript
48
- import { ReadonlySingleKey, ReadonlyWallet } from '@arkade-os/sdk'
48
+ import { SingleKey, ReadonlySingleKey, ReadonlyWallet } from '@arkade-os/sdk'
49
49
 
50
50
  // Create a read-only identity from a public key
51
51
  const identity = SingleKey.fromHex('e09ca...56609')
@@ -221,8 +221,8 @@ const identity = new MyBrowserWallet()
221
221
  console.log(isBatchSignable(identity)) // true
222
222
 
223
223
  // Wallet.send() uses one popup instead of N+1
224
- const wallet = await Wallet.create({ identity, arkServerUrl: '...' })
225
- await wallet.sendBitcoin({ address: arkAddress, amount: 1000 })
224
+ const wallet = await Wallet.create({ identity, arkServerUrl: 'https://arkade.computer' })
225
+ await wallet.send({ address: 'ark1q...', amount: 1000 })
226
226
  ```
227
227
 
228
228
  Identities without `signMultiple` continue to work unchanged — each checkpoint is signed individually via `sign()`.
@@ -240,17 +240,17 @@ console.log('Boarding (Mainnet) Address:', boardingAddress)
240
240
 
241
241
  const incomingFunds = await waitForIncomingFunds(wallet)
242
242
  if (incomingFunds.type === "vtxo") {
243
- // Virtual UTXOs received
244
- console.log("VTXOs: ", incomingFunds.vtxos)
243
+ // Virtual outputs received
244
+ console.log("VTXOs: ", incomingFunds.newVtxos)
245
245
  } else if (incomingFunds.type === "utxo") {
246
- // Boarding UTXOs received
246
+ // Boarding inputs received
247
247
  console.log("UTXOs: ", incomingFunds.coins)
248
248
  }
249
249
  ```
250
250
 
251
251
  ### Onboarding
252
252
 
253
- Onboarding allows you to swap on-chain funds into VTXOs:
253
+ Onboarding allows you to swap onchain funds into virtual outputs:
254
254
 
255
255
  ```typescript
256
256
  import { Ramps } from '@arkade-os/sdk'
@@ -270,11 +270,11 @@ console.log('Offchain Settled:', balance.settled)
270
270
  console.log('Offchain Preconfirmed:', balance.preconfirmed)
271
271
  console.log('Recoverable:', balance.recoverable)
272
272
 
273
- // Get virtual UTXOs (off-chain)
274
- const virtualUtxos = await wallet.getVtxos()
273
+ // Get virtual outputs (available for offchain spending)
274
+ const vtxos = await wallet.getVtxos()
275
275
 
276
- // Get boarding UTXOs
277
- const boardingUtxos = await wallet.getBoardingUtxos()
276
+ // Get boarding inputs
277
+ const boardingInputs = await wallet.getBoardingUtxos()
278
278
  ```
279
279
 
280
280
  ### Sending Bitcoin
@@ -304,6 +304,9 @@ const { assetId: controlAssetId } = await wallet.assetManager.issue({
304
304
  const { assetId } = await wallet.assetManager.issue({
305
305
  amount: 500,
306
306
  controlAssetId,
307
+ metadata: {
308
+ ticker: 'MTK'
309
+ }
307
310
  })
308
311
 
309
312
  // Reissue more supply of the asset (requires ownership of the control asset)
@@ -331,18 +334,18 @@ const assetBalance = assets.find(asset => asset.assetId === assetId)?.amount
331
334
 
332
335
  ### Batch Settlement
333
336
 
334
- The `settle` method can be used to move preconfirmed balances into finalized balances and to manually convert UTXOs to VTXOs.
337
+ The `settle` method can be used to move preconfirmed balances into finalized balances and to manually convert onchain funds to virtual outputs.
335
338
 
336
339
  ```typescript
337
- // Fetch offchain preconfirmed VTXOs and onchain boarding UTXOs
338
- const [virtualUtxos, boardingUtxos] = await Promise.all([
340
+ // Fetch offchain preconfirmed outputs and onchain boarding inputs
341
+ const [vtxos, boardingInputs] = await Promise.all([
339
342
  wallet.getVtxos(),
340
343
  wallet.getBoardingUtxos()
341
344
  ])
342
345
 
343
346
  // For settling transactions
344
347
  const settlementTxId = await wallet.settle({
345
- inputs: [...virtualUtxos, ...boardingUtxos],
348
+ inputs: [...vtxos, ...boardingInputs],
346
349
  // Optional: specify a mainnet output
347
350
  outputs: [{
348
351
  address: "bc1p...",
@@ -351,19 +354,21 @@ const settlementTxId = await wallet.settle({
351
354
  })
352
355
  ```
353
356
 
354
- ### VTXO Management (Renewal & Recovery)
357
+ ### Virtual Output Management (Renewal & Recovery)
358
+
359
+ Virtual outputs have an expiration time (batch expiry).
355
360
 
356
- VTXOs have an expiration time (batch expiry). The SDK provides the `VtxoManager` class to handle:
361
+ The SDK provides the `VtxoManager` class to handle:
357
362
 
358
- - **Renewal**: Renew VTXOs before they expire to maintain unilateral control of the funds.
359
- - **Recovery**: Reclaim swept or expired VTXOs back to the wallet in case renewal window was missed.
360
- - **Boarding UTXO Sweep**: Sweep expired boarding UTXOs back to a fresh boarding address to restart the timelock.
363
+ - **Renewal**: Renew virtual outputs before they expire to maintain unilateral control of the funds.
364
+ - **Recovery**: Reclaim swept or expired virtual outputs back to the wallet in case renewal window was missed.
365
+ - **Boarding Input Sweep**: Sweep expired boarding inputs back to a fresh boarding address to restart the timelock.
361
366
 
362
367
  #### Settlement Configuration
363
368
 
364
369
  The recommended way to configure `VtxoManager` is via `settlementConfig` on the wallet.
365
370
  If you omit `settlementConfig`, settlement is enabled with the default behavior:
366
- VTXO renewal at 3 days and boarding UTXO sweep enabled.
371
+ Virtual output renewal at 3 days and boarding input sweep enabled.
367
372
 
368
373
  ```typescript
369
374
  const wallet = await Wallet.create({
@@ -371,24 +376,24 @@ const wallet = await Wallet.create({
371
376
  arkServerUrl: 'https://arkade.computer',
372
377
  // Enable settlement with defaults explicitly:
373
378
  settlementConfig: {
374
- // Seconds before VTXO expiry to trigger renewal
375
- vtxoThreshold: 259200, // 3 days
376
- // Whether to sweep expired boarding UTXOs back to a fresh boarding address
379
+ // Seconds before virtual output expiry to trigger renewal
380
+ vtxoThreshold: 60 * 60 * 24 * 3, // 3 days
381
+ // Whether to sweep expired boarding inputs back to a fresh boarding address
377
382
  boardingUtxoSweep: true,
378
- // Polling interval in milliseconds for checking boarding UTXOs
379
- pollIntervalMs: 60000 // 1 minute
383
+ // Polling interval in milliseconds for checking boarding inputs
384
+ pollIntervalMs: 60_000 // 1 minute
380
385
  },
381
386
  })
382
387
  ```
383
388
 
384
389
  ```typescript
385
- // Enable both VTXO renewal and boarding UTXO sweep
390
+ // Enable both virtual output renewal and boarding input sweep
386
391
  const wallet = await Wallet.create({
387
392
  identity,
388
393
  arkServerUrl: 'https://arkade.computer',
389
394
  settlementConfig: {
390
- vtxoThreshold: 86400, // renew when 24 hours remain (in seconds)
391
- boardingUtxoSweep: true, // sweep expired boarding UTXOs
395
+ vtxoThreshold: 60 * 60 * 24, // renew when 24 hours remain (in seconds)
396
+ boardingUtxoSweep: true, // sweep expired boarding inputs
392
397
  },
393
398
  })
394
399
  ```
@@ -402,61 +407,55 @@ const wallet = await Wallet.create({
402
407
  })
403
408
  ```
404
409
 
405
- Create the `VtxoManager` by passing the wallet and its settlement config:
410
+ Access the `VtxoManager` from the wallet after configuring `settlementConfig`:
406
411
 
407
412
  ```typescript
408
- import { VtxoManager } from '@arkade-os/sdk'
409
-
410
- const manager = new VtxoManager(
411
- wallet,
412
- undefined, // renewalConfig (deprecated)
413
- wallet.settlementConfig // new settlementConfig
414
- )
413
+ const manager = await wallet.getVtxoManager()
415
414
  ```
416
415
 
417
- > **Migration from `renewalConfig`:** The old `renewalConfig` with `enabled` and `thresholdMs` (milliseconds) is still supported but deprecated. If both are provided, `settlementConfig` takes precedence. The new `vtxoThreshold` uses **seconds** instead of milliseconds.
416
+ > **Migration from `renewalConfig`:** Directly initializing a `VtxoManager` with `renewalConfig` is still supported but deprecated. Prefer `settlementConfig` where `vtxoThreshold` is expressed in **seconds** instead of milliseconds.
418
417
 
419
418
  #### Renewal: Prevent Expiration
420
419
 
421
- Renew VTXOs before they expire to retain unilateral control of funds.
422
- This settles expiring and recoverable VTXOs back to your wallet, refreshing their expiration time.
420
+ Renew virtual outputs before they expire to retain unilateral control of funds.
421
+ This settles expiring and recoverable virtual outputs back to your wallet, refreshing their expiration time.
423
422
 
424
423
  ```typescript
425
- // Renew all VTXOs to prevent expiration
424
+ // Renew all virtual outputs to prevent expiration
426
425
  const txid = await manager.renewVtxos()
427
- // Check which VTXOs are expiring soon
426
+ // Check which virtual outputs are expiring soon
428
427
  const expiringVtxos = await manager.getExpiringVtxos()
429
- // Override thresholdMs (e.g., get VTXOs expiring in the next 60 seconds)
428
+ // Override thresholdMs (e.g., get virtual outputs expiring in the next 60 seconds)
430
429
  const urgentlyExpiring = await manager.getExpiringVtxos(60_000)
431
430
  ```
432
431
 
433
- #### Boarding UTXO Sweep
432
+ #### Boarding Input Sweep
434
433
 
435
- When a boarding UTXO's CSV timelock expires, it can no longer be onboarded into Arkade cooperatively. The sweep feature detects these expired UTXOs and builds a raw on-chain transaction that spends them via the unilateral exit path back to a fresh boarding address, restarting the timelock.
434
+ When a boarding input's CSV timelock expires, it can no longer be onboarded into Arkade cooperatively. The sweep feature detects these expired UTXOs and builds a raw onchain transaction that spends them via the unilateral exit path back to a fresh boarding address, restarting the timelock.
436
435
 
437
436
  - Multiple expired UTXOs are batched into a single transaction (many inputs, one output)
438
437
  - A dust check ensures the sweep is skipped if fees would consume the entire value
439
438
 
440
439
  ```typescript
441
- // Check for expired boarding UTXOs
440
+ // Check for expired boarding inputs
442
441
  const expired = await manager.getExpiredBoardingUtxos()
443
- console.log(`${expired.length} expired boarding UTXOs`)
442
+ console.log(`${expired.length} expired boarding inputs`)
444
443
 
445
444
  // Sweep them back to a fresh boarding address (requires boardingUtxoSweep: true)
446
445
  try {
447
446
  const txid = await manager.sweepExpiredBoardingUtxos()
448
- console.log('Swept expired boarding UTXOs:', txid)
447
+ console.log('Swept expired boarding inputs:', txid)
449
448
  } catch (e) {
450
- // "No expired boarding UTXOs to sweep" or "Sweep not economical"
449
+ // "No expired boarding inputs to sweep" or "Sweep not economical"
451
450
  }
452
451
  ```
453
452
 
454
453
  #### Recovery: Reclaim Swept VTXOs
455
454
 
456
- Recover VTXOs that have been swept by the server or consolidate small amounts (subdust).
455
+ Recover virtual outputs that have been swept by the server or consolidate small amounts (subdust).
457
456
 
458
457
  ```typescript
459
- // Recover swept VTXOs and preconfirmed subdust
458
+ // Recover swept virtual outputs and preconfirmed subdust
460
459
  const txid = await manager.recoverVtxos((event) => {
461
460
  console.log('Settlement event:', event.type)
462
461
  })
@@ -466,13 +465,17 @@ const balance = await manager.getRecoverableBalance()
466
465
  ```
467
466
 
468
467
 
469
- ### VTXO Delegation
468
+ ### Delegation
469
+
470
+ Delegation allows users to outsource virtual output renewal to a third-party delegation service.
471
+
472
+ Instead of the delegating user renewing virtual outputs by themself, their delegate will automatically settle them before they expire, sending the funds back to the delegator's wallet address (minus a service fee).
470
473
 
471
- Delegation allows you to outsource VTXO renewal to a third-party delegator service. Instead of renewing VTXOs yourself, the delegator will automatically settle them before they expire, sending the funds back to your wallet address (minus a service fee). This is useful for wallets that cannot be online 24/7.
474
+ This is useful for wallets that cannot be online 24/7.
472
475
 
473
- When a `delegatorProvider` is configured, the wallet address includes an extra tapscript path that authorizes the delegator to co-sign renewals alongside the Arkade server.
476
+ When a `delegatorProvider` is configured, the wallet address includes an extra tapscript path that authorizes the delegate to co-sign renewals alongside the Arkade server.
474
477
 
475
- To run a delegator, you'll need to set up a [Fulmine server](https://github.com/ArkLabsHQ/fulmine) with the [Delegation API](https://github.com/ArkLabsHQ/fulmine?tab=readme-ov-file#-delegate-api) enabled.
478
+ To run a delegation service, you'll need to set up a [Fulmine server](https://github.com/ArkLabsHQ/fulmine) with the [Delegation API](https://github.com/ArkLabsHQ/fulmine?tab=readme-ov-file#-delegate-api) enabled.
476
479
 
477
480
  #### Setting Up a Wallet with Delegation
478
481
 
@@ -488,25 +491,28 @@ const wallet = await Wallet.create({
488
491
 
489
492
  > **Note:** Adding a `delegatorProvider` changes your wallet address because the offchain tapscript includes an additional delegation path. Funds sent to an address without delegation cannot be delegated, and vice versa.
490
493
 
491
- #### Delegating VTXOs
494
+ #### Delegating Virtual Outputs
492
495
 
493
- Once the wallet is configured with a delegator, use `wallet.delegatorManager` to delegate your VTXOs:
496
+ Once the wallet is configured with a delegate, use `wallet.delegatorManager` to delegate your virtual outputs:
494
497
 
495
498
  ```typescript
496
- // Get spendable VTXOs (including recoverable)
497
- const vtxos = (await wallet.getVtxos({ withRecoverable: true }))
498
- .filter(v => v.virtualStatus.type === 'confirmed')
499
+ // Get spendable virtual outputs (including recoverable)
500
+ const vtxos = await wallet.getVtxos({ withRecoverable: true })
499
501
 
500
- // Delegate all VTXOs — the delegator will renew them before expiry
502
+ // Delegate all virtual outputs — the delegate will renew them before expiry
501
503
  const arkadeAddress = await wallet.getAddress()
502
504
  const delegatorManager = await wallet.getDelegatorManager();
503
505
  const delegationResult = await delegatorManager.delegate(vtxos, arkadeAddress)
504
506
 
505
- console.log('Delegated:', result.delegated.length)
506
- console.log('Failed:', result.failed.length)
507
+ console.log('Delegated:', delegationResult.delegated.length)
508
+ console.log('Failed:', delegationResult.failed.length)
507
509
  ```
508
510
 
509
- The `delegate` method groups VTXOs by expiry date and submits them to the delegator service. By default, delegation is scheduled at 90% of each VTXO's remaining lifetime. You can override this with an explicit date:
511
+ The `delegate` method groups virtual outputs by expiry date and submits them to the delegation service.
512
+
513
+ By default, delegation is scheduled at 90% of each virtual output's remaining lifetime.
514
+
515
+ You can override this with an explicit date:
510
516
 
511
517
  ```typescript
512
518
  // Delegate with a specific renewal time
@@ -516,7 +522,7 @@ await delegatorManager.delegate(vtxos, arkadeAddress, delegateAt)
516
522
 
517
523
  #### Service Worker Integration
518
524
 
519
- When using a service worker wallet, pass the `delegatorUrl` option. The service worker will automatically delegate VTXOs after each VTXO update:
525
+ When using a service worker wallet, pass the `delegatorUrl` option. The service worker will automatically delegate virtual outputs after each update:
520
526
 
521
527
  ```typescript
522
528
  import { ServiceWorkerWallet, MnemonicIdentity } from '@arkade-os/sdk'
@@ -529,9 +535,9 @@ const wallet = await ServiceWorkerWallet.setup({
529
535
  })
530
536
  ```
531
537
 
532
- #### Querying Delegator Info
538
+ #### Querying Delegate Info
533
539
 
534
- You can query the delegator service directly to inspect its public key, fee, and payment address:
540
+ You can query the delegation service directly to inspect its public key, fee, and payment address:
535
541
 
536
542
  ```typescript
537
543
  import { RestDelegatorProvider } from '@arkade-os/sdk'
@@ -539,7 +545,7 @@ import { RestDelegatorProvider } from '@arkade-os/sdk'
539
545
  const provider = new RestDelegatorProvider('https://delegator.example.com')
540
546
  const info = await provider.getDelegateInfo()
541
547
 
542
- console.log('Delegator public key:', info.pubkey)
548
+ console.log('Delegate public key:', info.pubkey)
543
549
  console.log('Service fee (sats):', info.fee)
544
550
  console.log('Fee address:', info.delegatorAddress)
545
551
  ```
@@ -590,7 +596,7 @@ const history = await wallet.getTransactionHistory()
590
596
 
591
597
  ### Offboarding
592
598
 
593
- Collaborative exit or "offboarding" allows you to withdraw your virtual funds to an on-chain address:
599
+ Collaborative exit or "offboarding" allows you to withdraw your virtual funds to an onchain address:
594
600
 
595
601
  ```typescript
596
602
  import { Wallet, MnemonicIdentity, Ramps } from '@arkade-os/sdk'
@@ -601,11 +607,11 @@ const wallet = await Wallet.create({
601
607
  })
602
608
 
603
609
  // Get fee information from the server
604
- const { fees } = await wallet.arkProvider.getInfo();
610
+ const { fees: feeInfo } = await wallet.arkProvider.getInfo();
605
611
 
606
612
  const exitTxid = await new Ramps(wallet).offboard(
607
613
  'bc1p...',
608
- fees
614
+ feeInfo
609
615
  );
610
616
  ```
611
617
 
@@ -613,10 +619,10 @@ const exitTxid = await new Ramps(wallet).offboard(
613
619
 
614
620
  Unilateral exit allows you to withdraw your funds from the Arkade protocol back to the Bitcoin blockchain without requiring cooperation from the Arkade server. This process involves two main steps:
615
621
 
616
- 1. **Unrolling**: Broadcasting the transaction chain from off-chain back to on-chain
617
- 2. **Completing the exit**: Spending the unrolled VTXOs after the timelock expires
622
+ 1. **Unrolling**: Broadcasting the transaction chain from offchain back to onchain
623
+ 2. **Completing the exit**: Spending the unrolled virtual outputs after the timelock expires
618
624
 
619
- #### Step 1: Unrolling VTXOs
625
+ #### Step 1: Unrolling Virtual Outputs
620
626
 
621
627
  ```typescript
622
628
  import { MnemonicIdentity, OnchainWallet, Unroll } from '@arkade-os/sdk'
@@ -624,11 +630,11 @@ import { MnemonicIdentity, OnchainWallet, Unroll } from '@arkade-os/sdk'
624
630
  // Create an identity for the onchain wallet
625
631
  const onchainIdentity = MnemonicIdentity.fromMnemonic('abandon abandon...')
626
632
 
627
- // Create an onchain wallet to pay for P2A outputs in VTXO branches
633
+ // Create an onchain wallet to pay for P2A outputs in virtual output branches
628
634
  // OnchainWallet implements the AnchorBumper interface
629
635
  const onchainWallet = await OnchainWallet.create(onchainIdentity, 'regtest');
630
636
 
631
- // Unroll a specific VTXO
637
+ // Unroll a specific virtual output
632
638
  const vtxo = { txid: 'your_vtxo_txid', vout: 0 };
633
639
  const session = await Unroll.Session.create(
634
640
  vtxo,
@@ -647,7 +653,7 @@ for await (const step of session) {
647
653
  console.log(`Broadcasting transaction ${step.tx.id}`);
648
654
  break;
649
655
  case Unroll.StepType.DONE:
650
- console.log(`Unrolling complete for VTXO ${step.vtxoTxid}`);
656
+ console.log(`Unrolling complete for virtual output ${step.vtxoTxid}`);
651
657
  break;
652
658
  }
653
659
  }
@@ -656,29 +662,29 @@ for await (const step of session) {
656
662
  The unrolling process works by:
657
663
 
658
664
  - Traversing the transaction chain from the root (most recent) to the leaf (oldest)
659
- - Broadcasting each transaction that isn't already on-chain
665
+ - Broadcasting each transaction that isn't already onchain
660
666
  - Waiting for confirmations between steps
661
667
  - Using P2A (Pay-to-Anchor) transactions to pay for fees
662
668
 
663
669
  #### Step 2: Completing the Exit
664
670
 
665
- Once VTXOs are fully unrolled and the unilateral exit timelock has expired, you can complete the exit:
671
+ Once virtual outputs are fully unrolled and the unilateral exit timelock has expired, you can complete the exit:
666
672
 
667
673
  ```typescript
668
- // Complete the exit for specific VTXOs
674
+ // Complete the exit for specific virtual outputs
669
675
  await Unroll.completeUnroll(
670
676
  wallet,
671
- [vtxo.txid], // Array of VTXO transaction IDs to complete
677
+ [vtxo.txid], // Array of virtual output transaction IDs to complete
672
678
  onchainWallet.address // Address to receive the exit amount
673
679
  );
674
680
  ```
675
681
 
676
682
  **Important Notes:**
677
683
 
678
- - Each VTXO may require multiple unroll steps depending on the transaction chain length
684
+ - Each virtual output may require multiple unroll steps depending on the transaction chain length
679
685
  - Each unroll step must be confirmed before proceeding to the next
680
- - The `completeUnroll` method can only be called after VTXOs are fully unrolled and the timelock has expired
681
- - You need sufficient on-chain funds in the `OnchainWallet` to pay for P2A transaction fees
686
+ - The `completeUnroll` method can only be called after all virtual outputs are fully unrolled and the timelock has expired
687
+ - You need sufficient onchain funds in the `OnchainWallet` to pay for P2A transaction fees
682
688
 
683
689
  ### Running the wallet in a service worker
684
690
 
@@ -970,7 +976,7 @@ const identity = MnemonicIdentity.fromMnemonic('abandon abandon...')
970
976
  const wallet = await Wallet.create({
971
977
  identity: identity,
972
978
  arkProvider: new ExpoArkProvider('https://arkade.computer'), // For settlement events and transactions streaming
973
- indexerProvider: new ExpoIndexerProvider('https://arkade.computer'), // For address subscriptions and VTXO updates
979
+ indexerProvider: new ExpoIndexerProvider('https://arkade.computer'), // For address subscriptions and virtual output state updates
974
980
  })
975
981
 
976
982
  // use expo/fetch for streaming support (SSE)
@@ -982,7 +988,7 @@ const address = await wallet.getAddress()
982
988
  Both ExpoArkProvider and ExpoIndexerProvider are available as adapters following the SDK's modular architecture pattern. This keeps the main SDK bundle clean while providing opt-in functionality for specific environments:
983
989
 
984
990
  - **ExpoArkProvider**: Handles settlement events and transaction streaming using expo/fetch for Server-Sent Events
985
- - **ExpoIndexerProvider**: Handles address subscriptions and VTXO updates using expo/fetch for JSON streaming
991
+ - **ExpoIndexerProvider**: Handles address subscriptions and virtual output state updates using expo/fetch for JSON streaming
986
992
 
987
993
  For persistence in Expo/React Native, use the SQLite repository with `expo-sqlite`:
988
994
 
@@ -1032,7 +1038,7 @@ This is required for MuSig2 settlements and cryptographic operations.
1032
1038
 
1033
1039
  ### Contract Management
1034
1040
 
1035
- Both `Wallet` and `ServiceWorkerWallet` use a `ContractManager` internally to watch for VTXOs. This provides resilient connection handling with automatic reconnection and failsafe polling - for your wallet's default address and any external contracts you register (Boltz swaps, HTLCs, etc.).
1041
+ Both `Wallet` and `ServiceWorkerWallet` use a `ContractManager` internally to watch for virtual outputs. This provides resilient connection handling with automatic reconnection and failsafe polling - for your wallet's default address and any external contracts you register (Boltz swaps, HTLCs, etc.).
1036
1042
 
1037
1043
  When you call `wallet.notifyIncomingFunds()` or use `waitForIncomingFunds()`, it uses the ContractManager under the hood, giving you automatic reconnection and failsafe polling for free - no code changes needed.
1038
1044
 
@@ -1063,10 +1069,10 @@ const contract = await manager.createContract({
1063
1069
  const unsubscribe = await manager.onContractEvent((event) => {
1064
1070
  switch (event.type) {
1065
1071
  case 'vtxo_received':
1066
- console.log(`Received ${event.vtxos.length} VTXOs on ${event.contractScript}`)
1072
+ console.log(`Received ${event.vtxos.length} virtual outputs to ${event.contractScript}`)
1067
1073
  break
1068
1074
  case 'vtxo_spent':
1069
- console.log(`Spent VTXOs on ${event.contractScript}`)
1075
+ console.log(`Spent virtual outputs from ${event.contractScript}`)
1070
1076
  break
1071
1077
  case 'contract_expired':
1072
1078
  console.log(`Contract ${event.contractScript} expired`)
@@ -1077,7 +1083,7 @@ const unsubscribe = await manager.onContractEvent((event) => {
1077
1083
  // Update contract data (e.g., set preimage when revealed)
1078
1084
  await manager.updateContractParams(contract.script, { preimage: revealedPreimage })
1079
1085
 
1080
- // Check spendable paths (requires a specific VTXO)
1086
+ // Check spendable paths (requires a specific virtual output)
1081
1087
  const [withVtxos] = await manager.getContractsWithVtxos({ script: contract.script })
1082
1088
  const vtxo = withVtxos.vtxos[0]
1083
1089
  const paths = manager.getSpendablePaths({
@@ -1091,17 +1097,17 @@ if (paths.length > 0) {
1091
1097
  }
1092
1098
 
1093
1099
  // Or list all possible paths for the current context (no spendability checks)
1094
- const allPaths = manager.getAllSpendingPaths({
1100
+ const allPaths = await manager.getAllSpendingPaths({
1095
1101
  contractScript: contract.script,
1096
1102
  collaborative: true,
1097
1103
  walletPubKey: myPubKey,
1098
1104
  })
1099
1105
 
1100
- // Get balances across all contracts
1101
- const balances = await manager.getAllBalances()
1106
+ // Fetch contracts together with their current virtual outputs
1107
+ const contractsWithVtxos = await manager.getContractsWithVtxos()
1102
1108
 
1103
- // Manually sweep all eligible contracts
1104
- const sweepResults = await manager.sweepAll()
1109
+ // Force a full refresh from the indexer when needed
1110
+ await manager.refreshVtxos()
1105
1111
 
1106
1112
  // Stop watching
1107
1113
  unsubscribe()
@@ -1117,7 +1123,7 @@ The watcher features:
1117
1123
  Access low-level data management through repositories:
1118
1124
 
1119
1125
  ```typescript
1120
- // VTXO management (automatically cached for performance)
1126
+ // Virtual output management (automatically cached for performance)
1121
1127
  const addr = await wallet.getAddress()
1122
1128
  const vtxos = await wallet.walletRepository.getVtxos(addr)
1123
1129
  await wallet.walletRepository.saveVtxos(addr, vtxos)
@@ -4,7 +4,7 @@ exports.Estimator = void 0;
4
4
  const celenv_js_1 = require("./celenv.js");
5
5
  const types_js_1 = require("./types.js");
6
6
  /**
7
- * Estimator evaluates CEL expressions to calculate fees for Ark intents
7
+ * Estimator evaluates CEL expressions to calculate fees for Arkade intents
8
8
  */
9
9
  class Estimator {
10
10
  /**
@@ -4,7 +4,6 @@ exports.FeeAmount = void 0;
4
4
  /**
5
5
  * FeeAmount is a wrapper around a number that represents a fee amount in satoshis floating point.
6
6
  * @param value - The fee amount in floating point.
7
- * @method satoshis - Returns the fee amount in satoshis as a integer.
8
7
  * @example
9
8
  * const fee = new FeeAmount(1.23456789);
10
9
  * console.log(fee.value); // 1.23456789
@@ -14,9 +13,11 @@ class FeeAmount {
14
13
  constructor(value) {
15
14
  this.value = value;
16
15
  }
16
+ /** Returns the fee amount rounded up to whole satoshis. */
17
17
  get satoshis() {
18
18
  return this.value ? Math.ceil(this.value) : 0;
19
19
  }
20
+ /** Add two fee amounts together. */
20
21
  add(other) {
21
22
  return new FeeAmount(this.value + other.value);
22
23
  }
@@ -6,10 +6,12 @@ const utils_js_1 = require("@scure/btc-signer/utils.js");
6
6
  const btc_signer_1 = require("@scure/btc-signer");
7
7
  const base_2 = require("../script/base");
8
8
  /**
9
- * ArkNotes are special virtual coins in the Ark protocol that can be created
10
- * and spent without requiring any transactions. The server mints them, and they
11
- * are encoded as base58 strings with a human-readable prefix. It contains a
12
- * preimage and value.
9
+ * ArkNotes are special virtual outputs in the Arkade protocol that
10
+ * can be created and spent without requiring any transactions.
11
+ * The server mints them, and they are encoded as base58 strings
12
+ * with a human-readable prefix, a preimage and a value.
13
+ *
14
+ * @see VtxoScript
13
15
  *
14
16
  * @example
15
17
  * ```typescript
@@ -24,6 +26,13 @@ const base_2 = require("../script/base");
24
26
  * ```
25
27
  */
26
28
  class ArkNote {
29
+ /**
30
+ * Create an ArkNote from a preimage and value.
31
+ *
32
+ * @param preimage - 32-byte preimage revealed to spend the note
33
+ * @param value - Note value in satoshis
34
+ * @param HRP - Optional human-readable prefix for string encoding
35
+ */
27
36
  constructor(preimage, value, HRP = ArkNote.DefaultHRP) {
28
37
  this.preimage = preimage;
29
38
  this.value = value;
@@ -40,12 +49,27 @@ class ArkNote {
40
49
  this.status = { confirmed: true };
41
50
  this.extraWitness = [this.preimage];
42
51
  }
52
+ /**
53
+ * Encode the note as raw bytes.
54
+ *
55
+ * @returns Serialized note bytes
56
+ * @see decode
57
+ */
43
58
  encode() {
44
59
  const result = new Uint8Array(ArkNote.Length);
45
60
  result.set(this.preimage, 0);
46
61
  writeUInt32BE(result, this.value, this.preimage.length);
47
62
  return result;
48
63
  }
64
+ /**
65
+ * Decode a note from raw bytes.
66
+ *
67
+ * @param data - Serialized note bytes
68
+ * @param hrp - Human-readable prefix expected for future string encoding
69
+ * @returns Decoded ArkNote
70
+ * @throws Error if the payload length is invalid
71
+ * @see encode
72
+ */
49
73
  static decode(data, hrp = ArkNote.DefaultHRP) {
50
74
  if (data.length !== ArkNote.Length) {
51
75
  throw new Error(`invalid data length: expected ${ArkNote.Length} bytes, got ${data.length}`);
@@ -54,6 +78,15 @@ class ArkNote {
54
78
  const value = readUInt32BE(data, ArkNote.PreimageLength);
55
79
  return new ArkNote(preimage, value, hrp);
56
80
  }
81
+ /**
82
+ * Decode a note from its base58 string form.
83
+ *
84
+ * @param noteStr - Base58-encoded note string
85
+ * @param hrp - Human-readable prefix expected on the note string
86
+ * @returns Decoded ArkNote
87
+ * @throws Error if the prefix or base58 payload is invalid
88
+ * @see toString
89
+ */
57
90
  static fromString(noteStr, hrp = ArkNote.DefaultHRP) {
58
91
  noteStr = noteStr.trim();
59
92
  if (!noteStr.startsWith(hrp)) {
@@ -66,6 +99,12 @@ class ArkNote {
66
99
  }
67
100
  return ArkNote.decode(decoded, hrp);
68
101
  }
102
+ /**
103
+ * Encode the note to its human-readable base58 string form.
104
+ *
105
+ * @returns Base58-encoded note string
106
+ * @see fromString
107
+ */
69
108
  toString() {
70
109
  return this.HRP + base_1.base58.encode(this.encode());
71
110
  }
@@ -17,7 +17,7 @@ const TAG_BIP322 = "BIP0322-signed-message";
17
17
  *
18
18
  * Reuses the same toSpend/toSign transaction construction as Intent proofs,
19
19
  * but with the standard BIP-322 tagged hash ("BIP0322-signed-message")
20
- * instead of the Ark-specific tag.
20
+ * instead of the Arkade-specific tag.
21
21
  *
22
22
  * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
23
23
  *
@@ -17,7 +17,7 @@ const ARKCONTRACT_PREFIX = "arkcontract";
17
17
  * Format: arkcontract={type}&{key1}={value1}&{key2}={value2}...
18
18
  *
19
19
  * This format is compatible with NArk and allows contracts to be
20
- * shared/imported across different Ark implementations.
20
+ * shared/imported across different Arkade SDKs.
21
21
  *
22
22
  * @example
23
23
  * ```typescript