@arkade-os/sdk 0.3.0-alpha.7 → 0.3.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +115 -14
  2. package/dist/cjs/adapters/expo.js +8 -0
  3. package/dist/cjs/arknote/index.js +3 -3
  4. package/dist/cjs/forfeit.js +5 -2
  5. package/dist/cjs/identity/singleKey.js +5 -4
  6. package/dist/cjs/index.js +7 -3
  7. package/dist/cjs/{bip322 → intent}/index.js +37 -55
  8. package/dist/cjs/providers/ark.js +62 -23
  9. package/dist/cjs/providers/expoArk.js +82 -0
  10. package/dist/cjs/providers/expoIndexer.js +105 -0
  11. package/dist/cjs/providers/indexer.js +3 -1
  12. package/dist/cjs/providers/utils.js +122 -0
  13. package/dist/cjs/script/base.js +1 -2
  14. package/dist/cjs/script/tapscript.js +20 -21
  15. package/dist/cjs/script/vhtlc.js +2 -2
  16. package/dist/cjs/tree/signingSession.js +7 -8
  17. package/dist/cjs/tree/txTree.js +3 -4
  18. package/dist/cjs/tree/validation.js +2 -3
  19. package/dist/cjs/utils/arkTransaction.js +117 -12
  20. package/dist/cjs/utils/unknownFields.js +5 -5
  21. package/dist/cjs/wallet/index.js +1 -1
  22. package/dist/cjs/wallet/onchain.js +4 -5
  23. package/dist/cjs/wallet/serviceWorker/utils.js +2 -9
  24. package/dist/cjs/wallet/serviceWorker/wallet.js +4 -8
  25. package/dist/cjs/wallet/serviceWorker/worker.js +25 -23
  26. package/dist/cjs/wallet/unroll.js +6 -7
  27. package/dist/cjs/wallet/utils.js +11 -0
  28. package/dist/cjs/wallet/vtxo-manager.js +381 -0
  29. package/dist/cjs/wallet/wallet.js +130 -143
  30. package/dist/esm/adapters/expo.js +3 -0
  31. package/dist/esm/arknote/index.js +2 -2
  32. package/dist/esm/forfeit.js +4 -1
  33. package/dist/esm/identity/singleKey.js +7 -6
  34. package/dist/esm/index.js +7 -6
  35. package/dist/esm/{bip322 → intent}/index.js +31 -48
  36. package/dist/esm/providers/ark.js +62 -23
  37. package/dist/esm/providers/expoArk.js +78 -0
  38. package/dist/esm/providers/expoIndexer.js +101 -0
  39. package/dist/esm/providers/indexer.js +3 -1
  40. package/dist/esm/providers/utils.js +87 -0
  41. package/dist/esm/script/base.js +1 -2
  42. package/dist/esm/script/tapscript.js +1 -2
  43. package/dist/esm/script/vhtlc.js +1 -1
  44. package/dist/esm/tree/signingSession.js +8 -9
  45. package/dist/esm/tree/txTree.js +3 -4
  46. package/dist/esm/tree/validation.js +2 -3
  47. package/dist/esm/utils/arkTransaction.js +108 -5
  48. package/dist/esm/utils/unknownFields.js +1 -1
  49. package/dist/esm/wallet/index.js +1 -1
  50. package/dist/esm/wallet/onchain.js +1 -2
  51. package/dist/esm/wallet/serviceWorker/utils.js +1 -8
  52. package/dist/esm/wallet/serviceWorker/wallet.js +5 -9
  53. package/dist/esm/wallet/serviceWorker/worker.js +26 -24
  54. package/dist/esm/wallet/unroll.js +2 -3
  55. package/dist/esm/wallet/utils.js +8 -0
  56. package/dist/esm/wallet/vtxo-manager.js +372 -0
  57. package/dist/esm/wallet/wallet.js +124 -137
  58. package/dist/types/adapters/expo.d.ts +4 -0
  59. package/dist/types/arknote/index.d.ts +1 -1
  60. package/dist/types/forfeit.d.ts +2 -2
  61. package/dist/types/identity/index.d.ts +1 -1
  62. package/dist/types/identity/singleKey.d.ts +1 -1
  63. package/dist/types/index.d.ts +8 -7
  64. package/dist/types/intent/index.d.ts +41 -0
  65. package/dist/types/providers/ark.d.ts +190 -22
  66. package/dist/types/providers/expoArk.d.ts +22 -0
  67. package/dist/types/providers/expoIndexer.d.ts +18 -0
  68. package/dist/types/providers/indexer.d.ts +8 -8
  69. package/dist/types/providers/utils.d.ts +18 -0
  70. package/dist/types/script/base.d.ts +3 -2
  71. package/dist/types/tree/signingSession.d.ts +10 -10
  72. package/dist/types/utils/anchor.d.ts +2 -2
  73. package/dist/types/utils/arkTransaction.d.ts +16 -4
  74. package/dist/types/utils/unknownFields.d.ts +2 -2
  75. package/dist/types/wallet/index.d.ts +47 -7
  76. package/dist/types/wallet/onchain.d.ts +1 -1
  77. package/dist/types/wallet/serviceWorker/utils.d.ts +1 -2
  78. package/dist/types/wallet/serviceWorker/wallet.d.ts +2 -2
  79. package/dist/types/wallet/serviceWorker/worker.d.ts +3 -1
  80. package/dist/types/wallet/unroll.d.ts +1 -1
  81. package/dist/types/wallet/utils.d.ts +2 -0
  82. package/dist/types/wallet/vtxo-manager.d.ts +207 -0
  83. package/dist/types/wallet/wallet.d.ts +16 -4
  84. package/package.json +11 -3
  85. package/dist/cjs/bip322/errors.js +0 -13
  86. package/dist/esm/bip322/errors.js +0 -9
  87. package/dist/types/bip322/errors.d.ts +0 -6
  88. package/dist/types/bip322/index.d.ts +0 -57
@@ -63,31 +63,56 @@ export type TreeSignatureEvent = {
63
63
  signature: string;
64
64
  };
65
65
  export type SettlementEvent = BatchFinalizationEvent | BatchFinalizedEvent | BatchFailedEvent | TreeSigningStartedEvent | TreeNoncesAggregatedEvent | BatchStartedEvent | TreeTxEvent | TreeSignatureEvent;
66
- export interface MarketHour {
67
- nextStartTime: bigint;
66
+ export interface ScheduledSession {
67
+ duration: bigint;
68
+ fees: FeeInfo;
68
69
  nextEndTime: bigint;
70
+ nextStartTime: bigint;
69
71
  period: bigint;
70
- roundInterval: bigint;
71
72
  }
73
+ export interface IntentFeeInfo {
74
+ offchainInput: string;
75
+ offchainOutput: string;
76
+ onchainInput: string;
77
+ onchainOutput: string;
78
+ }
79
+ export interface FeeInfo {
80
+ intentFee: IntentFeeInfo;
81
+ txFeeRate: string;
82
+ }
83
+ export interface PendingTx {
84
+ arkTxid: string;
85
+ finalArkTx: string;
86
+ signedCheckpointTxs: string[];
87
+ }
88
+ export interface DeprecatedSigner {
89
+ cutoffDate: bigint;
90
+ pubkey: string;
91
+ }
92
+ export type ServiceStatus = Record<string, string>;
72
93
  export interface ArkInfo {
73
- signerPubkey: string;
74
- vtxoTreeExpiry: bigint;
75
- unilateralExitDelay: bigint;
76
- roundInterval: bigint;
77
- network: string;
94
+ boardingExitDelay: bigint;
95
+ checkpointTapscript: string;
96
+ deprecatedSigners: DeprecatedSigner[];
97
+ digest: string;
78
98
  dust: bigint;
99
+ fees: FeeInfo;
79
100
  forfeitAddress: string;
80
- marketHour?: MarketHour;
81
- version: string;
82
- utxoMinAmount: bigint;
101
+ forfeitPubkey: string;
102
+ network: string;
103
+ scheduledSession: ScheduledSession;
104
+ serviceStatus: ServiceStatus;
105
+ sessionDuration: bigint;
106
+ signerPubkey: string;
107
+ unilateralExitDelay: bigint;
83
108
  utxoMaxAmount: bigint;
84
- vtxoMinAmount: bigint;
109
+ utxoMinAmount: bigint;
110
+ version: string;
85
111
  vtxoMaxAmount: bigint;
86
- boardingExitDelay: bigint;
87
- checkpointExitClosure: string;
112
+ vtxoMinAmount: bigint;
88
113
  }
89
- export interface Intent {
90
- signature: string;
114
+ export interface SignedIntent {
115
+ proof: string;
91
116
  message: string;
92
117
  }
93
118
  export interface TxNotification {
@@ -108,8 +133,8 @@ export interface ArkProvider {
108
133
  signedCheckpointTxs: string[];
109
134
  }>;
110
135
  finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
111
- registerIntent(intent: Intent): Promise<string>;
112
- deleteIntent(intent: Intent): Promise<void>;
136
+ registerIntent(intent: SignedIntent): Promise<string>;
137
+ deleteIntent(intent: SignedIntent): Promise<void>;
113
138
  confirmRegistration(intentId: string): Promise<void>;
114
139
  submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
115
140
  submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
@@ -119,6 +144,7 @@ export interface ArkProvider {
119
144
  commitmentTx?: TxNotification;
120
145
  arkTx?: TxNotification;
121
146
  }>;
147
+ getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
122
148
  }
123
149
  /**
124
150
  * REST-based Ark provider implementation.
@@ -139,8 +165,8 @@ export declare class RestArkProvider implements ArkProvider {
139
165
  signedCheckpointTxs: string[];
140
166
  }>;
141
167
  finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
142
- registerIntent(intent: Intent): Promise<string>;
143
- deleteIntent(intent: Intent): Promise<void>;
168
+ registerIntent(intent: SignedIntent): Promise<string>;
169
+ deleteIntent(intent: SignedIntent): Promise<void>;
144
170
  confirmRegistration(intentId: string): Promise<void>;
145
171
  submitTreeNonces(batchId: string, pubkey: string, nonces: TreeNonces): Promise<void>;
146
172
  submitTreeSignatures(batchId: string, pubkey: string, signatures: TreePartialSigs): Promise<void>;
@@ -150,7 +176,149 @@ export declare class RestArkProvider implements ArkProvider {
150
176
  commitmentTx?: TxNotification;
151
177
  arkTx?: TxNotification;
152
178
  }>;
153
- private parseSettlementEvent;
154
- private parseTransactionNotification;
179
+ getPendingTxs(intent: SignedIntent): Promise<PendingTx[]>;
180
+ protected parseSettlementEvent(data: ProtoTypes.GetEventStreamResponse): SettlementEvent | null;
181
+ protected parseTransactionNotification(data: ProtoTypes.GetTransactionsStreamResponse): {
182
+ commitmentTx?: TxNotification;
183
+ arkTx?: TxNotification;
184
+ } | null;
185
+ }
186
+ declare namespace ProtoTypes {
187
+ interface BatchStartedEvent {
188
+ id: string;
189
+ intentIdHashes: string[];
190
+ batchExpiry: number;
191
+ }
192
+ interface BatchFailed {
193
+ id: string;
194
+ reason: string;
195
+ }
196
+ export interface BatchFinalizationEvent {
197
+ id: string;
198
+ commitmentTx: string;
199
+ }
200
+ interface BatchFinalizedEvent {
201
+ id: string;
202
+ commitmentTxid: string;
203
+ }
204
+ interface TreeSigningStartedEvent {
205
+ id: string;
206
+ cosignersPubkeys: string[];
207
+ unsignedCommitmentTx: string;
208
+ }
209
+ interface TreeNoncesAggregatedEvent {
210
+ id: string;
211
+ treeNonces: Record<string, string>;
212
+ }
213
+ interface TreeNoncesEvent {
214
+ id: string;
215
+ topic: string[];
216
+ txid: string;
217
+ nonces: Record<string, string>;
218
+ }
219
+ interface TreeTxEvent {
220
+ id: string;
221
+ topic: string[];
222
+ batchIndex: number;
223
+ txid: string;
224
+ tx: string;
225
+ children: Record<string, string>;
226
+ }
227
+ interface TreeSignatureEvent {
228
+ id: string;
229
+ topic: string[];
230
+ batchIndex: number;
231
+ txid: string;
232
+ signature: string;
233
+ }
234
+ interface Heartbeat {
235
+ }
236
+ export interface VtxoData {
237
+ outpoint: {
238
+ txid: string;
239
+ vout: number;
240
+ };
241
+ amount: string;
242
+ script: string;
243
+ createdAt: string;
244
+ expiresAt: string | null;
245
+ commitmentTxids: string[];
246
+ isPreconfirmed: boolean;
247
+ isSwept: boolean;
248
+ isUnrolled: boolean;
249
+ isSpent: boolean;
250
+ spentBy: string;
251
+ settledBy?: string;
252
+ arkTxid?: string;
253
+ }
254
+ export interface GetEventStreamResponse {
255
+ batchStarted?: BatchStartedEvent;
256
+ batchFailed?: BatchFailed;
257
+ batchFinalization?: BatchFinalizationEvent;
258
+ batchFinalized?: BatchFinalizedEvent;
259
+ treeSigningStarted?: TreeSigningStartedEvent;
260
+ treeNoncesAggregated?: TreeNoncesAggregatedEvent;
261
+ treeNonces?: TreeNoncesEvent;
262
+ treeTx?: TreeTxEvent;
263
+ treeSignature?: TreeSignatureEvent;
264
+ heartbeat?: Heartbeat;
265
+ }
266
+ export interface GetTransactionsStreamResponse {
267
+ commitmentTx?: {
268
+ txid: string;
269
+ tx: string;
270
+ spentVtxos: VtxoData[];
271
+ spendableVtxos: VtxoData[];
272
+ checkpointTxs?: Record<string, {
273
+ txid: string;
274
+ tx: string;
275
+ }>;
276
+ };
277
+ arkTx?: {
278
+ txid: string;
279
+ tx: string;
280
+ spentVtxos: VtxoData[];
281
+ spendableVtxos: VtxoData[];
282
+ checkpointTxs?: Record<string, {
283
+ txid: string;
284
+ tx: string;
285
+ }>;
286
+ };
287
+ heartbeat?: Heartbeat;
288
+ }
289
+ export interface EventData {
290
+ batchStarted?: BatchStartedEvent;
291
+ batchFailed?: BatchFailed;
292
+ batchFinalization?: BatchFinalizationEvent;
293
+ batchFinalized?: BatchFinalizedEvent;
294
+ treeSigningStarted?: TreeSigningStartedEvent;
295
+ treeNoncesAggregated?: TreeNoncesAggregatedEvent;
296
+ treeTx?: TreeTxEvent;
297
+ treeSignature?: TreeSignatureEvent;
298
+ }
299
+ export interface TransactionData {
300
+ commitmentTx?: {
301
+ txid: string;
302
+ tx: string;
303
+ spentVtxos: VtxoData[];
304
+ spendableVtxos: VtxoData[];
305
+ checkpointTxs?: Record<string, {
306
+ txid: string;
307
+ tx: string;
308
+ }>;
309
+ };
310
+ arkTx?: {
311
+ txid: string;
312
+ tx: string;
313
+ spentVtxos: VtxoData[];
314
+ spendableVtxos: VtxoData[];
315
+ checkpointTxs?: Record<string, {
316
+ txid: string;
317
+ tx: string;
318
+ }>;
319
+ };
320
+ }
321
+ export {};
155
322
  }
156
323
  export declare function isFetchTimeoutError(err: any): boolean;
324
+ export {};
@@ -0,0 +1,22 @@
1
+ import { RestArkProvider, SettlementEvent, TxNotification } from "./ark";
2
+ /**
3
+ * Expo-compatible Ark provider implementation using expo/fetch for SSE support.
4
+ * This provider works specifically in React Native/Expo environments where
5
+ * standard EventSource is not available but expo/fetch provides SSE capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ExpoArkProvider } from '@arkade-os/sdk/providers/expo';
10
+ *
11
+ * const provider = new ExpoArkProvider('https://ark.example.com');
12
+ * const info = await provider.getInfo();
13
+ * ```
14
+ */
15
+ export declare class ExpoArkProvider extends RestArkProvider {
16
+ constructor(serverUrl: string);
17
+ getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
18
+ getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<{
19
+ commitmentTx?: TxNotification;
20
+ arkTx?: TxNotification;
21
+ }>;
22
+ }
@@ -0,0 +1,18 @@
1
+ import { RestIndexerProvider, SubscriptionResponse } from "./indexer";
2
+ /**
3
+ * Expo-compatible Indexer provider implementation using expo/fetch for streaming support.
4
+ * This provider works specifically in React Native/Expo environments where
5
+ * standard fetch streaming may not work properly but expo/fetch provides streaming capabilities.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { ExpoIndexerProvider } from '@arkade-os/sdk/adapters/expo';
10
+ *
11
+ * const provider = new ExpoIndexerProvider('https://indexer.example.com');
12
+ * const vtxos = await provider.getVtxos({ scripts: ['script1'] });
13
+ * ```
14
+ */
15
+ export declare class ExpoIndexerProvider extends RestIndexerProvider {
16
+ constructor(serverUrl: string);
17
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
18
+ }
@@ -80,12 +80,19 @@ export interface SubscriptionResponse {
80
80
  scripts: string[];
81
81
  newVtxos: VirtualCoin[];
82
82
  spentVtxos: VirtualCoin[];
83
+ sweptVtxos: VirtualCoin[];
83
84
  tx?: string;
84
85
  checkpointTxs?: Record<string, {
85
86
  txid: string;
86
87
  tx: string;
87
88
  }>;
88
89
  }
90
+ export interface SubscriptionHeartbeat {
91
+ type: "heartbeat";
92
+ }
93
+ export interface SubscriptionEvent extends SubscriptionResponse {
94
+ type: "event";
95
+ }
89
96
  export interface IndexerProvider {
90
97
  getVtxoTree(batchOutpoint: Outpoint, opts?: PaginationOptions): Promise<{
91
98
  vtxoTree: Tx[];
@@ -158,14 +165,7 @@ export declare class RestIndexerProvider implements IndexerProvider {
158
165
  txids: string[];
159
166
  page?: PageResponse;
160
167
  }>;
161
- getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncGenerator<{
162
- txid: any;
163
- scripts: any;
164
- newVtxos: any;
165
- spentVtxos: any;
166
- tx: any;
167
- checkpointTxs: any;
168
- }, void, unknown>;
168
+ getSubscription(subscriptionId: string, abortSignal: AbortSignal): AsyncIterableIterator<SubscriptionResponse>;
169
169
  getVirtualTxs(txids: string[], opts?: PaginationOptions): Promise<{
170
170
  txs: string[];
171
171
  page?: PageResponse;
@@ -1 +1,19 @@
1
1
  export declare function eventSourceIterator(eventSource: EventSource): AsyncGenerator<MessageEvent, void, unknown>;
2
+ /**
3
+ * Dynamically imports expo/fetch with fallback to standard fetch.
4
+ * @returns A fetch function suitable for SSE streaming
5
+ */
6
+ export declare function getExpoFetch(options?: {
7
+ requireExpo?: boolean;
8
+ }): Promise<typeof fetch>;
9
+ /**
10
+ * Generic SSE stream processor using fetch API with ReadableStream.
11
+ * Handles SSE format parsing, buffer management, and abort signals.
12
+ *
13
+ * @param url - The SSE endpoint URL
14
+ * @param abortSignal - Signal to abort the stream
15
+ * @param fetchFn - Fetch function to use (defaults to standard fetch)
16
+ * @param headers - Additional headers to send
17
+ * @param parseData - Function to parse and yield data from SSE events
18
+ */
19
+ export declare function sseStreamIterator<T>(url: string, abortSignal: AbortSignal, fetchFn: typeof fetch, headers: Record<string, string>, parseData: (data: any) => T | null): AsyncGenerator<T, void, unknown>;
@@ -1,4 +1,5 @@
1
- import { BTC_NETWORK, Bytes } from "@scure/btc-signer/utils.js";
1
+ import { NETWORK } from "@scure/btc-signer";
2
+ import { Bytes } from "@scure/btc-signer/utils.js";
2
3
  import { ArkAddress } from "./address";
3
4
  import { ConditionCSVMultisigTapscript, CSVMultisigTapscript } from "./tapscript";
4
5
  export type TapLeafScript = [
@@ -27,7 +28,7 @@ export declare class VtxoScript {
27
28
  encode(): Bytes;
28
29
  address(prefix: string, serverPubKey: Bytes): ArkAddress;
29
30
  get pkScript(): Bytes;
30
- onchainAddress(network: BTC_NETWORK): string;
31
+ onchainAddress(network: typeof NETWORK): string;
31
32
  findLeaf(scriptHex: string): TapLeafScript;
32
33
  exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
33
34
  }
@@ -5,11 +5,11 @@ export declare const ErrMissingAggregateKey: Error;
5
5
  export type TreeNonces = Map<string, Pick<musig2.Nonces, "pubNonce">>;
6
6
  export type TreePartialSigs = Map<string, musig2.PartialSig>;
7
7
  export interface SignerSession {
8
- getPublicKey(): Uint8Array;
9
- init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): void;
10
- getNonces(): TreeNonces;
11
- setAggregatedNonces(nonces: TreeNonces): void;
12
- sign(): TreePartialSigs;
8
+ getPublicKey(): Promise<Uint8Array>;
9
+ init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
10
+ getNonces(): Promise<TreeNonces>;
11
+ setAggregatedNonces(nonces: TreeNonces): Promise<void>;
12
+ sign(): Promise<TreePartialSigs>;
13
13
  }
14
14
  export declare class TreeSignerSession implements SignerSession {
15
15
  private secretKey;
@@ -21,11 +21,11 @@ export declare class TreeSignerSession implements SignerSession {
21
21
  private rootSharedOutputAmount;
22
22
  constructor(secretKey: Uint8Array);
23
23
  static random(): TreeSignerSession;
24
- init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): void;
25
- getPublicKey(): Uint8Array;
26
- getNonces(): TreeNonces;
27
- setAggregatedNonces(nonces: TreeNonces): void;
28
- sign(): TreePartialSigs;
24
+ init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
25
+ getPublicKey(): Promise<Uint8Array>;
26
+ getNonces(): Promise<TreeNonces>;
27
+ setAggregatedNonces(nonces: TreeNonces): Promise<void>;
28
+ sign(): Promise<TreePartialSigs>;
29
29
  private generateNonces;
30
30
  private signPartial;
31
31
  }
@@ -1,5 +1,5 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
2
- import { TransactionInputUpdate } from "@scure/btc-signer/psbt";
1
+ import { Transaction } from "@scure/btc-signer";
2
+ import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
3
3
  export declare const ANCHOR_VALUE = 0n;
4
4
  export declare const ANCHOR_PKSCRIPT: Uint8Array<ArrayBuffer>;
5
5
  /**
@@ -1,9 +1,10 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
2
- import { VirtualCoin } from "../wallet";
1
+ import { Transaction } from "@scure/btc-signer";
2
+ import { Bytes } from "@scure/btc-signer/utils.js";
3
+ import { TransactionOutput } from "@scure/btc-signer/psbt.js";
4
+ import { ExtendedCoin, VirtualCoin } from "../wallet";
5
+ import { RelativeTimelock } from "../script/tapscript";
3
6
  import { EncodedVtxoScript, TapLeafScript } from "../script/base";
4
7
  import { CSVMultisigTapscript } from "../script/tapscript";
5
- import { TransactionOutput } from "@scure/btc-signer/psbt.js";
6
- import { Bytes } from "@scure/btc-signer/utils.js";
7
8
  export type ArkTxInput = {
8
9
  tapLeafScript: TapLeafScript;
9
10
  checkpointTapLeafScript?: Bytes;
@@ -25,3 +26,14 @@ export type OffchainTx = {
25
26
  * @returns Object containing the virtual transaction and checkpoint transactions
26
27
  */
27
28
  export declare function buildOffchainTx(inputs: ArkTxInput[], outputs: TransactionOutput[], serverUnrollScript: CSVMultisigTapscript.Type): OffchainTx;
29
+ export declare function hasBoardingTxExpired(coin: ExtendedCoin, boardingTimelock: RelativeTimelock): boolean;
30
+ /**
31
+ * Verify tapscript signatures on a transaction input
32
+ * @param tx Transaction to verify
33
+ * @param inputIndex Index of the input to verify
34
+ * @param requiredSigners List of required signer pubkeys (hex encoded)
35
+ * @param excludePubkeys List of pubkeys to exclude from verification (hex encoded, e.g., server key not yet signed)
36
+ * @param allowedSighashTypes List of allowed sighash types (defaults to [SigHash.DEFAULT])
37
+ * @throws Error if verification fails
38
+ */
39
+ export declare function verifyTapscriptSignatures(tx: Transaction, inputIndex: number, requiredSigners: string[], excludePubkeys?: string[], allowedSighashTypes?: number[]): void;
@@ -1,5 +1,5 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
2
- import { TransactionInputUpdate } from "@scure/btc-signer/psbt";
1
+ import { Transaction } from "@scure/btc-signer";
2
+ import { TransactionInputUpdate } from "@scure/btc-signer/psbt.js";
3
3
  /**
4
4
  * ArkPsbtFieldKey is the key values for ark psbt fields.
5
5
  */
@@ -1,25 +1,64 @@
1
- import { Output, SettlementEvent } from "../providers/ark";
1
+ import { Bytes } from "@scure/btc-signer/utils.js";
2
+ import { ArkProvider, Output, SettlementEvent } from "../providers/ark";
2
3
  import { Identity } from "../identity";
3
4
  import { RelativeTimelock } from "../script/tapscript";
4
5
  import { EncodedVtxoScript, TapLeafScript } from "../script/base";
5
- import { Bytes } from "@scure/btc-signer/utils.js";
6
6
  import { StorageAdapter } from "../storage";
7
+ import { RenewalConfig } from "./vtxo-manager";
8
+ import { IndexerProvider } from "../providers/indexer";
9
+ import { OnchainProvider } from "../providers/onchain";
7
10
  /**
8
11
  * Configuration options for wallet initialization.
9
12
  *
10
- * Defines the parameters required to create and configure a wallet instance,
11
- * including identity, server URLs, and optional timelock settings.
12
- * If optional parameters are not provided, the wallet will fetch them from the
13
- * Ark server.
13
+ * Supports two configuration modes:
14
+ * 1. URL-based: Provide arkServerUrl, indexerUrl (optional), and esploraUrl
15
+ * 2. Provider-based: Provide arkProvider, indexerProvider, and onchainProvider instances
16
+ *
17
+ * At least one of the following must be provided:
18
+ * - arkServerUrl OR arkProvider
19
+ *
20
+ * The wallet will use provided URLs to create default providers if custom provider
21
+ * instances are not supplied. If optional parameters are not provided, the wallet
22
+ * will fetch configuration from the Ark server.
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // URL-based configuration
27
+ * const wallet = await Wallet.create({
28
+ * identity: SingleKey.fromHex('...'),
29
+ * arkServerUrl: 'https://ark.example.com',
30
+ * esploraUrl: 'https://mempool.space/api'
31
+ * });
32
+ *
33
+ * // Provider-based configuration (e.g., for Expo/React Native)
34
+ * const wallet = await Wallet.create({
35
+ * identity: SingleKey.fromHex('...'),
36
+ * arkProvider: new ExpoArkProvider('https://ark.example.com'),
37
+ * indexerProvider: new ExpoIndexerProvider('https://ark.example.com'),
38
+ * onchainProvider: new EsploraProvider('https://mempool.space/api')
39
+ * });
40
+ * ```
14
41
  */
15
42
  export interface WalletConfig {
16
43
  identity: Identity;
17
- arkServerUrl: string;
44
+ arkServerUrl?: string;
45
+ indexerUrl?: string;
18
46
  esploraUrl?: string;
19
47
  arkServerPublicKey?: string;
20
48
  boardingTimelock?: RelativeTimelock;
21
49
  exitTimelock?: RelativeTimelock;
22
50
  storage?: StorageAdapter;
51
+ arkProvider?: ArkProvider;
52
+ indexerProvider?: IndexerProvider;
53
+ onchainProvider?: OnchainProvider;
54
+ renewalConfig?: RenewalConfig;
55
+ }
56
+ /**
57
+ * Provider class constructor interface for dependency injection.
58
+ * Ensures provider classes follow the consistent constructor pattern.
59
+ */
60
+ export interface ProviderClass<T> {
61
+ new (serverUrl: string): T;
23
62
  }
24
63
  export interface WalletBalance {
25
64
  boarding: {
@@ -73,6 +112,7 @@ export interface VirtualCoin extends Coin {
73
112
  arkTxId?: string;
74
113
  createdAt: Date;
75
114
  isUnrolled: boolean;
115
+ isSpent?: boolean;
76
116
  }
77
117
  export declare enum TxType {
78
118
  TxSent = "SENT",
@@ -1,9 +1,9 @@
1
+ import { Transaction } from "@scure/btc-signer";
1
2
  import { P2TR } from "@scure/btc-signer/payment.js";
2
3
  import { Coin, SendBitcoinParams } from ".";
3
4
  import { Identity } from "../identity";
4
5
  import { Network, NetworkName } from "../networks";
5
6
  import { OnchainProvider } from "../providers/onchain";
6
- import { Transaction } from "@scure/btc-signer/transaction.js";
7
7
  import { AnchorBumper } from "../utils/anchor";
8
8
  /**
9
9
  * Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
@@ -1,4 +1,4 @@
1
- import { ExtendedVirtualCoin, VirtualCoin, Wallet } from "../..";
1
+ export declare const DEFAULT_DB_NAME = "arkade-service-worker";
2
2
  /**
3
3
  * setupServiceWorker sets up the service worker.
4
4
  * @param path - the path to the service worker script
@@ -8,4 +8,3 @@ import { ExtendedVirtualCoin, VirtualCoin, Wallet } from "../..";
8
8
  * ```
9
9
  */
10
10
  export declare function setupServiceWorker(path: string): Promise<ServiceWorker>;
11
- export declare function extendVirtualCoin(wallet: Wallet, vtxo: VirtualCoin): ExtendedVirtualCoin;
@@ -2,7 +2,6 @@ import { IWallet, WalletBalance, SendBitcoinParams, SettleParams, ArkTransaction
2
2
  import { Response } from "./response";
3
3
  import { SettlementEvent } from "../../providers/ark";
4
4
  import { Identity } from "../../identity";
5
- import { StorageAdapter } from "../../storage";
6
5
  import { WalletRepository } from "../../repositories/walletRepository";
7
6
  import { ContractRepository } from "../../repositories/contractRepository";
8
7
  export type PrivateKeyIdentity = Identity & {
@@ -44,8 +43,9 @@ interface ServiceWorkerWalletOptions {
44
43
  arkServerPublicKey?: string;
45
44
  arkServerUrl: string;
46
45
  esploraUrl?: string;
46
+ dbName?: string;
47
+ dbVersion?: number;
47
48
  identity: PrivateKeyIdentity;
48
- storage?: StorageAdapter;
49
49
  }
50
50
  export type ServiceWorkerWalletCreateOptions = ServiceWorkerWalletOptions & {
51
51
  serviceWorker: ServiceWorker;
@@ -3,6 +3,8 @@
3
3
  * it aims to be run in a service worker context
4
4
  */
5
5
  export declare class Worker {
6
+ readonly dbName: string;
7
+ readonly dbVersion: number;
6
8
  private readonly messageCallback;
7
9
  private wallet;
8
10
  private arkProvider;
@@ -10,7 +12,7 @@ export declare class Worker {
10
12
  private incomingFundsSubscription;
11
13
  private walletRepository;
12
14
  private storage;
13
- constructor(messageCallback?: (message: ExtendableMessageEvent) => void);
15
+ constructor(dbName?: string, dbVersion?: number, messageCallback?: (message: ExtendableMessageEvent) => void);
14
16
  /**
15
17
  * Get spendable vtxos for the current wallet address
16
18
  */
@@ -1,4 +1,4 @@
1
- import { Transaction } from "@scure/btc-signer/transaction.js";
1
+ import { Transaction } from "@scure/btc-signer";
2
2
  import { ChainTx, IndexerProvider } from "../providers/indexer";
3
3
  import { AnchorBumper } from "../utils/anchor";
4
4
  import { OnchainProvider } from "../providers/onchain";
@@ -0,0 +1,2 @@
1
+ import type { ExtendedVirtualCoin, VirtualCoin, Wallet } from "..";
2
+ export declare function extendVirtualCoin(wallet: Wallet, vtxo: VirtualCoin): ExtendedVirtualCoin;