@arkade-os/sdk 0.4.14 → 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 (203) hide show
  1. package/README.md +287 -215
  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 +25 -1
  12. package/dist/cjs/contracts/handlers/vhtlc.js +2 -4
  13. package/dist/cjs/extension/asset/assetGroup.js +92 -5
  14. package/dist/cjs/extension/asset/assetId.js +67 -3
  15. package/dist/cjs/extension/asset/assetInput.js +18 -0
  16. package/dist/cjs/extension/asset/assetOutput.js +15 -0
  17. package/dist/cjs/extension/asset/assetRef.js +66 -0
  18. package/dist/cjs/extension/asset/metadata.js +15 -0
  19. package/dist/cjs/extension/asset/packet.js +4 -1
  20. package/dist/cjs/extension/index.js +1 -1
  21. package/dist/cjs/forfeit.js +14 -0
  22. package/dist/cjs/identity/index.js +6 -0
  23. package/dist/cjs/identity/seedIdentity.js +5 -5
  24. package/dist/cjs/identity/singleKey.js +4 -0
  25. package/dist/cjs/index.js +5 -3
  26. package/dist/cjs/intent/index.js +28 -12
  27. package/dist/cjs/providers/ark.js +3 -2
  28. package/dist/cjs/providers/delegator.js +20 -1
  29. package/dist/cjs/providers/expoArk.js +2 -2
  30. package/dist/cjs/providers/indexer.js +2 -2
  31. package/dist/cjs/providers/onchain.js +2 -1
  32. package/dist/cjs/repositories/realm/schemas.js +2 -2
  33. package/dist/cjs/repositories/realm/types.js +1 -1
  34. package/dist/cjs/script/address.js +37 -6
  35. package/dist/cjs/script/base.js +70 -1
  36. package/dist/cjs/script/default.js +3 -0
  37. package/dist/cjs/script/delegate.js +4 -0
  38. package/dist/cjs/script/tapscript.js +25 -4
  39. package/dist/cjs/script/vhtlc.js +35 -27
  40. package/dist/cjs/storage/fileSystem.js +1 -1
  41. package/dist/cjs/storage/inMemory.js +1 -1
  42. package/dist/cjs/storage/indexedDB.js +1 -1
  43. package/dist/cjs/storage/localStorage.js +1 -1
  44. package/dist/cjs/tree/validation.js +1 -1
  45. package/dist/cjs/utils/arkTransaction.js +5 -5
  46. package/dist/cjs/utils/bip21.js +16 -3
  47. package/dist/cjs/utils/syncCursors.js +4 -4
  48. package/dist/cjs/utils/transaction.js +1 -1
  49. package/dist/cjs/utils/transactionHistory.js +11 -11
  50. package/dist/cjs/utils/unknownFields.js +3 -3
  51. package/dist/cjs/wallet/asset-manager.js +4 -4
  52. package/dist/cjs/wallet/batch.js +5 -5
  53. package/dist/cjs/wallet/delegator.js +9 -8
  54. package/dist/cjs/wallet/expo/background.js +3 -3
  55. package/dist/cjs/wallet/expo/wallet.js +7 -7
  56. package/dist/cjs/wallet/index.js +43 -0
  57. package/dist/cjs/wallet/onchain.js +43 -5
  58. package/dist/cjs/wallet/ramps.js +44 -14
  59. package/dist/cjs/wallet/serviceWorker/wallet-message-handler.js +22 -22
  60. package/dist/cjs/wallet/serviceWorker/wallet.js +28 -24
  61. package/dist/cjs/wallet/unroll.js +12 -8
  62. package/dist/cjs/wallet/utils.js +1 -1
  63. package/dist/cjs/wallet/vtxo-manager.js +123 -82
  64. package/dist/cjs/wallet/wallet.js +231 -98
  65. package/dist/cjs/worker/expo/asyncStorageTaskQueue.js +1 -1
  66. package/dist/cjs/worker/expo/processors/contractPollProcessor.js +2 -2
  67. package/dist/cjs/worker/expo/taskRunner.js +3 -3
  68. package/dist/cjs/worker/messageBus.js +3 -0
  69. package/dist/esm/arkfee/estimator.js +1 -1
  70. package/dist/esm/arkfee/types.js +2 -1
  71. package/dist/esm/arknote/index.js +43 -4
  72. package/dist/esm/bip322/index.js +1 -1
  73. package/dist/esm/contracts/arkcontract.js +1 -1
  74. package/dist/esm/contracts/contractManager.js +40 -24
  75. package/dist/esm/contracts/contractWatcher.js +29 -22
  76. package/dist/esm/contracts/handlers/default.js +1 -1
  77. package/dist/esm/contracts/handlers/delegate.js +1 -1
  78. package/dist/esm/contracts/handlers/helpers.js +24 -1
  79. package/dist/esm/contracts/handlers/vhtlc.js +3 -5
  80. package/dist/esm/extension/asset/assetGroup.js +92 -5
  81. package/dist/esm/extension/asset/assetId.js +67 -3
  82. package/dist/esm/extension/asset/assetInput.js +18 -0
  83. package/dist/esm/extension/asset/assetOutput.js +15 -0
  84. package/dist/esm/extension/asset/assetRef.js +66 -0
  85. package/dist/esm/extension/asset/metadata.js +15 -0
  86. package/dist/esm/extension/asset/packet.js +4 -1
  87. package/dist/esm/extension/index.js +1 -1
  88. package/dist/esm/forfeit.js +14 -0
  89. package/dist/esm/identity/index.js +5 -0
  90. package/dist/esm/identity/seedIdentity.js +5 -5
  91. package/dist/esm/identity/singleKey.js +4 -0
  92. package/dist/esm/index.js +3 -2
  93. package/dist/esm/intent/index.js +28 -12
  94. package/dist/esm/providers/ark.js +3 -2
  95. package/dist/esm/providers/delegator.js +20 -1
  96. package/dist/esm/providers/expoArk.js +2 -2
  97. package/dist/esm/providers/indexer.js +2 -2
  98. package/dist/esm/providers/onchain.js +2 -1
  99. package/dist/esm/repositories/realm/schemas.js +2 -2
  100. package/dist/esm/repositories/realm/types.js +1 -1
  101. package/dist/esm/script/address.js +37 -6
  102. package/dist/esm/script/base.js +70 -1
  103. package/dist/esm/script/default.js +3 -0
  104. package/dist/esm/script/delegate.js +4 -0
  105. package/dist/esm/script/tapscript.js +25 -4
  106. package/dist/esm/script/vhtlc.js +35 -27
  107. package/dist/esm/storage/fileSystem.js +1 -1
  108. package/dist/esm/storage/inMemory.js +1 -1
  109. package/dist/esm/storage/indexedDB.js +1 -1
  110. package/dist/esm/storage/localStorage.js +1 -1
  111. package/dist/esm/tree/validation.js +1 -1
  112. package/dist/esm/utils/arkTransaction.js +5 -5
  113. package/dist/esm/utils/bip21.js +16 -3
  114. package/dist/esm/utils/syncCursors.js +4 -4
  115. package/dist/esm/utils/transaction.js +1 -1
  116. package/dist/esm/utils/transactionHistory.js +11 -11
  117. package/dist/esm/utils/unknownFields.js +3 -3
  118. package/dist/esm/wallet/asset-manager.js +4 -4
  119. package/dist/esm/wallet/batch.js +5 -5
  120. package/dist/esm/wallet/delegator.js +9 -8
  121. package/dist/esm/wallet/expo/background.js +3 -3
  122. package/dist/esm/wallet/expo/wallet.js +7 -7
  123. package/dist/esm/wallet/index.js +43 -0
  124. package/dist/esm/wallet/onchain.js +43 -5
  125. package/dist/esm/wallet/ramps.js +44 -14
  126. package/dist/esm/wallet/serviceWorker/wallet-message-handler.js +22 -22
  127. package/dist/esm/wallet/serviceWorker/wallet.js +28 -24
  128. package/dist/esm/wallet/unroll.js +12 -8
  129. package/dist/esm/wallet/utils.js +1 -1
  130. package/dist/esm/wallet/vtxo-manager.js +122 -81
  131. package/dist/esm/wallet/wallet.js +232 -99
  132. package/dist/esm/worker/expo/asyncStorageTaskQueue.js +1 -1
  133. package/dist/esm/worker/expo/processors/contractPollProcessor.js +2 -2
  134. package/dist/esm/worker/expo/taskRunner.js +3 -3
  135. package/dist/esm/worker/messageBus.js +3 -0
  136. package/dist/types/arkfee/estimator.d.ts +1 -1
  137. package/dist/types/arkfee/types.d.ts +2 -1
  138. package/dist/types/arknote/index.d.ts +44 -4
  139. package/dist/types/bip322/index.d.ts +1 -1
  140. package/dist/types/contracts/arkcontract.d.ts +1 -1
  141. package/dist/types/contracts/contractManager.d.ts +40 -63
  142. package/dist/types/contracts/contractWatcher.d.ts +39 -18
  143. package/dist/types/contracts/handlers/default.d.ts +1 -1
  144. package/dist/types/contracts/handlers/delegate.d.ts +1 -1
  145. package/dist/types/contracts/handlers/helpers.d.ts +11 -1
  146. package/dist/types/contracts/types.d.ts +36 -26
  147. package/dist/types/extension/asset/assetGroup.d.ts +92 -1
  148. package/dist/types/extension/asset/assetId.d.ts +67 -3
  149. package/dist/types/extension/asset/assetInput.d.ts +18 -0
  150. package/dist/types/extension/asset/assetOutput.d.ts +15 -0
  151. package/dist/types/extension/asset/assetRef.d.ts +66 -0
  152. package/dist/types/extension/asset/metadata.d.ts +15 -0
  153. package/dist/types/extension/asset/packet.d.ts +4 -1
  154. package/dist/types/extension/index.d.ts +1 -1
  155. package/dist/types/forfeit.d.ts +14 -0
  156. package/dist/types/identity/index.d.ts +36 -0
  157. package/dist/types/identity/seedIdentity.d.ts +10 -8
  158. package/dist/types/identity/singleKey.d.ts +4 -0
  159. package/dist/types/index.d.ts +3 -3
  160. package/dist/types/intent/index.d.ts +19 -6
  161. package/dist/types/providers/ark.d.ts +40 -2
  162. package/dist/types/providers/delegator.d.ts +54 -1
  163. package/dist/types/providers/expoArk.d.ts +2 -2
  164. package/dist/types/providers/indexer.d.ts +105 -2
  165. package/dist/types/providers/onchain.d.ts +62 -1
  166. package/dist/types/repositories/realm/schemas.d.ts +2 -2
  167. package/dist/types/repositories/realm/types.d.ts +2 -2
  168. package/dist/types/repositories/walletRepository.d.ts +16 -0
  169. package/dist/types/script/address.d.ts +35 -2
  170. package/dist/types/script/base.d.ts +66 -1
  171. package/dist/types/script/default.d.ts +3 -0
  172. package/dist/types/script/delegate.d.ts +4 -0
  173. package/dist/types/script/tapscript.d.ts +17 -2
  174. package/dist/types/script/vhtlc.d.ts +35 -27
  175. package/dist/types/storage/fileSystem.d.ts +1 -1
  176. package/dist/types/storage/inMemory.d.ts +1 -1
  177. package/dist/types/storage/index.d.ts +1 -1
  178. package/dist/types/storage/indexedDB.d.ts +1 -1
  179. package/dist/types/storage/localStorage.d.ts +1 -1
  180. package/dist/types/utils/arkTransaction.d.ts +3 -3
  181. package/dist/types/utils/bip21.d.ts +17 -0
  182. package/dist/types/utils/syncCursors.d.ts +4 -4
  183. package/dist/types/utils/transaction.d.ts +1 -1
  184. package/dist/types/utils/transactionHistory.d.ts +3 -3
  185. package/dist/types/utils/unknownFields.d.ts +5 -5
  186. package/dist/types/wallet/asset-manager.d.ts +3 -3
  187. package/dist/types/wallet/batch.d.ts +27 -7
  188. package/dist/types/wallet/delegator.d.ts +10 -0
  189. package/dist/types/wallet/expo/background.d.ts +4 -4
  190. package/dist/types/wallet/expo/wallet.d.ts +10 -10
  191. package/dist/types/wallet/index.d.ts +457 -25
  192. package/dist/types/wallet/onchain.d.ts +42 -4
  193. package/dist/types/wallet/ramps.d.ts +40 -10
  194. package/dist/types/wallet/serviceWorker/wallet-message-handler.d.ts +4 -4
  195. package/dist/types/wallet/serviceWorker/wallet.d.ts +71 -33
  196. package/dist/types/wallet/unroll.d.ts +8 -6
  197. package/dist/types/wallet/vtxo-manager.d.ts +146 -93
  198. package/dist/types/wallet/wallet.d.ts +91 -33
  199. package/dist/types/worker/expo/asyncStorageTaskQueue.d.ts +1 -1
  200. package/dist/types/worker/expo/processors/contractPollProcessor.d.ts +1 -1
  201. package/dist/types/worker/expo/taskRunner.d.ts +6 -6
  202. package/dist/types/worker/messageBus.d.ts +5 -3
  203. package/package.json +18 -10
@@ -16,14 +16,57 @@ export type ExplorerTransaction = {
16
16
  };
17
17
  };
18
18
  export interface OnchainProvider {
19
+ /**
20
+ * Fetch spendable onchain outputs for an address.
21
+ *
22
+ * @param address - Bitcoin address to query
23
+ * @returns Spendable onchain outputs for the address
24
+ * @see Coin
25
+ */
19
26
  getCoins(address: string): Promise<Coin[]>;
27
+ /**
28
+ * Fetch the current fastest fee rate estimate.
29
+ *
30
+ * @returns Fee rate in sats/vB, if available
31
+ * @remarks
32
+ * Implementations may return `undefined` when the backing service does not expose
33
+ * a usable fee estimate.
34
+ */
20
35
  getFeeRate(): Promise<number | undefined>;
36
+ /**
37
+ * Broadcast a single transaction or a 1P1C package.
38
+ *
39
+ * @param txs - One or more raw transaction hex strings
40
+ * @returns Broadcast transaction id
41
+ * @throws Error if the broadcast request fails or the package shape is invalid
42
+ */
21
43
  broadcastTransaction(...txs: string[]): Promise<string>;
44
+ /**
45
+ * Fetch outspend information for every output in a transaction.
46
+ *
47
+ * @param txid - Transaction id to inspect
48
+ * @returns Per-output spend status information
49
+ * @see getTxStatus
50
+ */
22
51
  getTxOutspends(txid: string): Promise<{
23
52
  spent: boolean;
24
53
  txid: string;
25
54
  }[]>;
55
+ /**
56
+ * Fetch transactions associated with an address.
57
+ *
58
+ * @param address - Bitcoin address to query
59
+ * @returns Transactions involving the address
60
+ * @see ExplorerTransaction
61
+ */
26
62
  getTransactions(address: string): Promise<ExplorerTransaction[]>;
63
+ /**
64
+ * Fetch confirmation status for a transaction.
65
+ *
66
+ * @param txid - Transaction id to inspect
67
+ * @returns Confirmation status and block metadata when confirmed
68
+ * @see getTxOutspends
69
+ */
27
70
  getTxStatus(txid: string): Promise<{
28
71
  confirmed: false;
29
72
  } | {
@@ -31,20 +74,36 @@ export interface OnchainProvider {
31
74
  blockTime: number;
32
75
  blockHeight: number;
33
76
  }>;
77
+ /**
78
+ * Fetch the current chain tip.
79
+ *
80
+ * @returns Current chain height, block time, and block hash
81
+ */
34
82
  getChainTip(): Promise<{
35
83
  height: number;
36
84
  time: number;
37
85
  hash: string;
38
86
  }>;
87
+ /**
88
+ * Watch a set of addresses and invoke the callback when transactions are observed.
89
+ *
90
+ * @param addresses - Addresses to monitor
91
+ * @param eventCallback - Callback invoked when matching transactions are seen
92
+ * @returns Stop function that cancels the watch
93
+ * @remarks
94
+ * Implementations may use websockets, server-sent events, polling, or a hybrid strategy.
95
+ * @see getTransactions
96
+ */
39
97
  watchAddresses(addresses: string[], eventCallback: (txs: ExplorerTransaction[]) => void): Promise<() => void>;
40
98
  }
41
99
  /**
42
100
  * Implementation of the onchain provider interface for esplora REST API.
101
+ *
43
102
  * @see https://mempool.space/docs/api/rest
44
103
  * @example
45
104
  * ```typescript
46
105
  * const provider = new EsploraProvider("https://mempool.space/api");
47
- * const utxos = await provider.getCoins("bcrt1q679zsd45msawvr7782r0twvmukns3drlstjt77");
106
+ * const outputs = await provider.getCoins("bcrt1q679zsd45msawvr7782r0twvmukns3drlstjt77");
48
107
  * ```
49
108
  */
50
109
  export declare class EsploraProvider implements OnchainProvider {
@@ -52,7 +111,9 @@ export declare class EsploraProvider implements OnchainProvider {
52
111
  readonly pollingInterval: number;
53
112
  readonly forcePolling: boolean;
54
113
  constructor(baseUrl: string, opts?: {
114
+ /** Polling interval in milliseconds. */
55
115
  pollingInterval?: number;
116
+ /** Force polling even when websocket transport is available. */
56
117
  forcePolling?: boolean;
57
118
  });
58
119
  getCoins(address: string): Promise<Coin[]>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Realm object schemas for the Ark wallet.
2
+ * Realm object schemas for the Arkade wallet.
3
3
  *
4
4
  * All schema names are prefixed with "Ark" to avoid collisions with
5
5
  * other Realm schemas in the consuming application.
@@ -108,7 +108,7 @@ export declare const ArkContractSchema: {
108
108
  };
109
109
  };
110
110
  /**
111
- * All Realm schemas needed by the Ark wallet repositories.
111
+ * All Realm schemas needed by the Arkade wallet repositories.
112
112
  * Pass this array to your Realm configuration's `schema` property.
113
113
  */
114
114
  export declare const ArkRealmSchemas: ({
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Minimal interface for the subset of the Realm API used by the
3
- * Ark repositories. Consumers pass their real Realm instance and
3
+ * Arkade repositories. Consumers pass their real Realm instance and
4
4
  * the compiler validates it satisfies this shape.
5
5
  */
6
6
  /** Result set returned by `realm.objects()`. */
7
7
  export interface RealmResults<T = Record<string, unknown>> extends Iterable<T> {
8
8
  filtered(query: string, ...args: unknown[]): RealmResults<T>;
9
9
  }
10
- /** The Realm API surface used by Ark repositories. */
10
+ /** The Realm API surface used by Arkade repositories. */
11
11
  export interface RealmLike {
12
12
  write(callback: () => void): void;
13
13
  objects<T = Record<string, unknown>>(schemaName: string): RealmResults<T>;
@@ -1,10 +1,15 @@
1
1
  import { ArkTransaction, ExtendedCoin, ExtendedVirtualCoin } from "../wallet";
2
2
  export interface WalletState {
3
+ /** Timestamp of the last successful wallet sync, in milliseconds. */
3
4
  lastSyncTime?: number;
5
+ /** Arbitrary stored wallet settings. */
4
6
  settings?: Record<string, any>;
5
7
  }
8
+ /** Stored commitment transaction metadata. */
6
9
  export type CommitmentTxRecord = {
10
+ /** Commitment transaction id. */
7
11
  txid: string;
12
+ /** Creation timestamp in milliseconds. */
8
13
  createdAt: number;
9
14
  };
10
15
  export interface WalletRepository extends AsyncDisposable {
@@ -13,15 +18,26 @@ export interface WalletRepository extends AsyncDisposable {
13
18
  * Clear all data from storage.
14
19
  */
15
20
  clear(): Promise<void>;
21
+ /** Fetch stored virtual outputs for an address. */
16
22
  getVtxos(address: string): Promise<ExtendedVirtualCoin[]>;
23
+ /** Save virtual outputs for an address. */
17
24
  saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
25
+ /** Delete stored virtual outputs for an address. */
18
26
  deleteVtxos(address: string): Promise<void>;
27
+ /** Fetch stored boarding inputs for an address. */
19
28
  getUtxos(address: string): Promise<ExtendedCoin[]>;
29
+ /** Save boarding inputs for an address. */
20
30
  saveUtxos(address: string, utxos: ExtendedCoin[]): Promise<void>;
31
+ /** Delete stored boarding inputs for an address. */
21
32
  deleteUtxos(address: string): Promise<void>;
33
+ /** Fetch stored transaction history for an address. */
22
34
  getTransactionHistory(address: string): Promise<ArkTransaction[]>;
35
+ /** Save transaction history for an address. */
23
36
  saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
37
+ /** Delete stored transaction history for an address. */
24
38
  deleteTransactions(address: string): Promise<void>;
39
+ /** Fetch stored wallet state. */
25
40
  getWalletState(): Promise<WalletState | null>;
41
+ /** Save wallet state. */
26
42
  saveWalletState(state: WalletState): Promise<void>;
27
43
  }
@@ -1,12 +1,19 @@
1
1
  import { Bytes } from "@scure/btc-signer/utils.js";
2
2
  /**
3
- * ArkAddress allows to create and decode bech32m encoded ark address.
4
- * An ark address is composed of:
3
+ * ArkAddress allows creating and decoding bech32m-encoded Arkade addresses.
4
+ *
5
+ * An Arkade address is composed of:
5
6
  * - a human readable prefix (hrp)
6
7
  * - a version byte (1 byte)
7
8
  * - a server public key (32 bytes)
8
9
  * - a vtxo taproot public key (32 bytes)
9
10
  *
11
+ * @remarks
12
+ * This is an Arkade-specific address format.
13
+ * It is distinct from the Taproot onchain address returned by `VtxoScript.onchainAddress`.
14
+ *
15
+ * @see VtxoScript
16
+ *
10
17
  * @example
11
18
  * ```typescript
12
19
  * const address = new ArkAddress(
@@ -26,9 +33,35 @@ export declare class ArkAddress {
26
33
  readonly vtxoTaprootKey: Bytes;
27
34
  readonly hrp: string;
28
35
  readonly version: number;
36
+ /**
37
+ * Create an Arkade address from its server key, vtxo taproot public key, and prefix.
38
+ *
39
+ * @param serverPubKey - 32-byte Arkade server public key
40
+ * @param vtxoTaprootKey - 32-byte tweaked vtxo taproot public key
41
+ * @param hrp - Bech32 human-readable prefix
42
+ * @param version - Address version byte
43
+ * @defaultValue `version = 0`
44
+ * @throws Error if either public key is not 32 bytes long
45
+ */
29
46
  constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp: string, version?: number);
47
+ /**
48
+ * Decode an Arkade address from its bech32m string form.
49
+ *
50
+ * @param address - Bech32m-encoded Arkade address
51
+ * @returns Decoded Arkade address
52
+ * @throws Error if the address is malformed or has an invalid payload length
53
+ * @see encode
54
+ */
30
55
  static decode(address: string): ArkAddress;
56
+ /**
57
+ * Encode the address to its bech32m string form.
58
+ *
59
+ * @returns Bech32m-encoded Arkade address
60
+ * @see decode
61
+ */
31
62
  encode(): string;
63
+ /** ScriptPubKey used to send non-dust funds to the address. */
32
64
  get pkScript(): Bytes;
65
+ /** ScriptPubKey used to send sub-dust funds to the address. */
33
66
  get subdustPkScript(): Bytes;
34
67
  }
@@ -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;