@arkade-os/sdk 0.5.8 → 0.5.10

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 (98) hide show
  1. package/README.md +22 -4
  2. package/dist/adapters/expo.cjs +7 -7
  3. package/dist/adapters/expo.d.cts +2 -2
  4. package/dist/adapters/expo.d.ts +2 -2
  5. package/dist/adapters/expo.js +4 -4
  6. package/dist/{asyncStorageTaskQueue-B5NPtkXo.d.cts → asyncStorageTaskQueue-BSUY0Lz8.d.cts} +1 -1
  7. package/dist/{asyncStorageTaskQueue-YPwiJyVA.d.ts → asyncStorageTaskQueue-CXKwLEgC.d.ts} +1 -1
  8. package/dist/{chunk-XXNPX4MK.js → chunk-4DUTRRXF.js} +3 -3
  9. package/dist/{chunk-XXNPX4MK.js.map → chunk-4DUTRRXF.js.map} +1 -1
  10. package/dist/{chunk-OLKZUJIN.js → chunk-4HCV67LR.js} +3915 -2997
  11. package/dist/chunk-4HCV67LR.js.map +1 -0
  12. package/dist/{chunk-E7LKKEVR.js → chunk-4MC7NHQT.js} +17 -12
  13. package/dist/chunk-4MC7NHQT.js.map +1 -0
  14. package/dist/{chunk-EQ3JVVUR.cjs → chunk-6GEVB7AN.cjs} +4499 -3578
  15. package/dist/chunk-6GEVB7AN.cjs.map +1 -0
  16. package/dist/{chunk-FDJ734CH.js → chunk-DPFD5KBK.js} +5 -2
  17. package/dist/chunk-DPFD5KBK.js.map +1 -0
  18. package/dist/{chunk-F5O6JI2H.js → chunk-FMX2FMYH.js} +5 -5
  19. package/dist/{chunk-F5O6JI2H.js.map → chunk-FMX2FMYH.js.map} +1 -1
  20. package/dist/{chunk-JYQXB7OH.cjs → chunk-KOXW2WGD.cjs} +55 -57
  21. package/dist/chunk-KOXW2WGD.cjs.map +1 -0
  22. package/dist/{chunk-YTOABP6J.js → chunk-MPE7FTKE.js} +21 -12
  23. package/dist/chunk-MPE7FTKE.js.map +1 -0
  24. package/dist/{chunk-L7OOPAUG.cjs → chunk-OMZZQTDM.cjs} +22 -17
  25. package/dist/chunk-OMZZQTDM.cjs.map +1 -0
  26. package/dist/{chunk-U34GU5RM.js → chunk-PXEFYEKL.js} +16 -11
  27. package/dist/chunk-PXEFYEKL.js.map +1 -0
  28. package/dist/{chunk-3F5AJ235.js → chunk-QEREPVKU.js} +10 -12
  29. package/dist/chunk-QEREPVKU.js.map +1 -0
  30. package/dist/{chunk-4IDCSOP2.cjs → chunk-SJBQW6P4.cjs} +33 -28
  31. package/dist/chunk-SJBQW6P4.cjs.map +1 -0
  32. package/dist/{chunk-5PWL7WOT.cjs → chunk-UPIQZRNJ.cjs} +11 -11
  33. package/dist/{chunk-5PWL7WOT.cjs.map → chunk-UPIQZRNJ.cjs.map} +1 -1
  34. package/dist/{chunk-JQSHFSME.cjs → chunk-UU6GNWEC.cjs} +20 -20
  35. package/dist/{chunk-JQSHFSME.cjs.map → chunk-UU6GNWEC.cjs.map} +1 -1
  36. package/dist/{chunk-SOJDUKY6.cjs → chunk-UWPYUDO4.cjs} +28 -18
  37. package/dist/chunk-UWPYUDO4.cjs.map +1 -0
  38. package/dist/{chunk-FLPWNMX3.cjs → chunk-WIZCF5IX.cjs} +5 -2
  39. package/dist/chunk-WIZCF5IX.cjs.map +1 -0
  40. package/dist/{chunk-KWR37J6L.cjs → chunk-XWKQEAZE.cjs} +14 -18
  41. package/dist/chunk-XWKQEAZE.cjs.map +1 -0
  42. package/dist/{chunk-H7GT3QC4.js → chunk-ZTZH4KEF.js} +9 -13
  43. package/dist/chunk-ZTZH4KEF.js.map +1 -0
  44. package/dist/compiler.cjs +4 -4
  45. package/dist/compiler.js +3 -3
  46. package/dist/contracts/handlers/index.cjs +11 -11
  47. package/dist/contracts/handlers/index.d.cts +2 -3
  48. package/dist/contracts/handlers/index.d.ts +2 -3
  49. package/dist/contracts/handlers/index.js +4 -4
  50. package/dist/{index-Pk3i_MMU.d.ts → index-Bq349_ly.d.cts} +2322 -99
  51. package/dist/{index-CKzBYoDa.d.cts → index-D4ahI0W6.d.cts} +1 -2
  52. package/dist/{index-czozpKPT.d.cts → index-Mn2POBPj.d.ts} +2322 -99
  53. package/dist/{index-COs69e8T.d.ts → index-Yh5y9G4E.d.ts} +1 -2
  54. package/dist/index.cjs +359 -347
  55. package/dist/index.d.cts +1459 -1357
  56. package/dist/index.d.ts +1459 -1357
  57. package/dist/index.js +7 -7
  58. package/dist/repositories/realm/index.cjs +40 -40
  59. package/dist/repositories/realm/index.d.cts +2 -2
  60. package/dist/repositories/realm/index.d.ts +2 -2
  61. package/dist/repositories/realm/index.js +8 -8
  62. package/dist/repositories/sqlite/index.cjs +38 -38
  63. package/dist/repositories/sqlite/index.d.cts +2 -2
  64. package/dist/repositories/sqlite/index.d.ts +2 -2
  65. package/dist/repositories/sqlite/index.js +8 -8
  66. package/dist/{taskRunner-DXivOJHc.d.cts → taskRunner-1wolHThW.d.cts} +1 -1
  67. package/dist/{taskRunner-DBOqvP33.d.ts → taskRunner-C1maPp-c.d.ts} +1 -1
  68. package/dist/wallet/expo/background.cjs +17 -17
  69. package/dist/wallet/expo/background.d.cts +3 -3
  70. package/dist/wallet/expo/background.d.ts +3 -3
  71. package/dist/wallet/expo/background.js +9 -9
  72. package/dist/wallet/expo/index.cjs +18 -18
  73. package/dist/wallet/expo/index.d.cts +3 -5
  74. package/dist/wallet/expo/index.d.ts +3 -5
  75. package/dist/wallet/expo/index.js +8 -8
  76. package/dist/worker/expo/index.cjs +12 -12
  77. package/dist/worker/expo/index.d.cts +4 -4
  78. package/dist/worker/expo/index.d.ts +4 -4
  79. package/dist/worker/expo/index.js +8 -8
  80. package/package.json +1 -1
  81. package/dist/chunk-3F5AJ235.js.map +0 -1
  82. package/dist/chunk-4IDCSOP2.cjs.map +0 -1
  83. package/dist/chunk-E7LKKEVR.js.map +0 -1
  84. package/dist/chunk-EQ3JVVUR.cjs.map +0 -1
  85. package/dist/chunk-FDJ734CH.js.map +0 -1
  86. package/dist/chunk-FLPWNMX3.cjs.map +0 -1
  87. package/dist/chunk-H7GT3QC4.js.map +0 -1
  88. package/dist/chunk-JYQXB7OH.cjs.map +0 -1
  89. package/dist/chunk-KWR37J6L.cjs.map +0 -1
  90. package/dist/chunk-L7OOPAUG.cjs.map +0 -1
  91. package/dist/chunk-OLKZUJIN.js.map +0 -1
  92. package/dist/chunk-SOJDUKY6.cjs.map +0 -1
  93. package/dist/chunk-U34GU5RM.js.map +0 -1
  94. package/dist/chunk-YTOABP6J.js.map +0 -1
  95. package/dist/delegate-gGkUnYpi.d.cts +0 -92
  96. package/dist/delegate-iyDum4fw.d.ts +0 -92
  97. package/dist/keyringDescriptorProvider-CbNzWwbS.d.ts +0 -2095
  98. package/dist/keyringDescriptorProvider-nC8fIjBN.d.cts +0 -2095
@@ -1,2095 +0,0 @@
1
- import { a as Identity, a3 as Transaction, a4 as SignerSession, a5 as ReadonlyIdentity, a6 as Network, a7 as ActivityResolver, a8 as BatchStartedEvent, a9 as TreeSigningStartedEvent, aa as TxTree, ab as TreeNoncesEvent, ac as BatchFinalizationEvent, ad as BatchFinalizedEvent, ae as BatchFailedEvent, af as TreeTxEvent, ag as TreeSignatureEvent, n as SettlementEvent, b as WalletConfig, W as WalletRepository, C as ContractRepository, ah as DescriptorProvider, j as IContractManager, k as GetNewAddressesOptions, l as NewAddress, ai as IReadonlyWallet, aj as OnchainProvider, x as OperatorProvider, w as IndexerProvider, ak as DelegateProvider, al as ReadonlyWalletConfig, Y as BatchRegistrationRepository, $ as VirtualTxRepository, am as ExitCaptureMode, an as ExitDataSource, h as ActivityRegistry, ao as IReadonlyAssetManager, ap as ContractSyncState, aq as RecipientArkadeAddressContext, G as GetOperatorInfoOptions, O as OperatorInfo, A as ArkadeReader, ar as EsploraProvider, as as NetworkName, d as WalletBalance, e as GetVtxosFilter, N as NormalizedExtendedVirtualCoin, f as GetSpendableVtxosFilter, at as ContractWithVtxos, au as selectPendingRecoveryOutpoints, g as ArkTransaction, i as Activity, E as ExtendedCoin, av as Coin, z as ExtendedVirtualCoin, aw as ContractManager, ax as ContractManagerConfig, I as IWallet, B as Outpoint, ay as SettlementConfig, c as ArkadeBroadcaster, q as IAssetManager, az as VtxoManager, m as IDelegateManager, S as SettleParams, R as Recipient, p as SendOnchainParams, aA as SignedIntent, aB as Intent, aC as SignedProof, aD as Proof, o as SendParams, aE as TimeHeight, P as PageRequest, D as PageResult, F as ScriptVtxoCursor, H as ScriptVtxoPageOptions, J as StoredVtxo, K as VtxoRepositoryKey, L as TransactionHistoryPageFilter, M as TransactionHistoryPageCursor, Q as AtomicWalletState, U as WalletState, aF as DescriptorSigningRequest } from './index-czozpKPT.cjs';
2
- import { TransactionOutput } from '@scure/btc-signer/psbt.js';
3
- import { Bytes } from '@scure/btc-signer/utils.js';
4
- import { R as RelativeTimelock, A as ArkAddress, C as CSVMultisigTapscript } from './base-C-Y5t_0F.cjs';
5
- import { D as DefaultVtxo, a as DelegateVtxo } from './delegate-gGkUnYpi.cjs';
6
-
7
- /**
8
- * In-memory single key implementation for Bitcoin transaction signing.
9
- *
10
- * @example
11
- * ```typescript
12
- * // Create from hex string
13
- * const key = SingleKey.fromHex('your_private_key_hex');
14
- *
15
- * // Create from raw bytes
16
- * const key = SingleKey.fromPrivateKey(privateKeyBytes);
17
- *
18
- * // Create random key
19
- * const randomKey = SingleKey.fromRandomBytes();
20
- *
21
- * // Sign a transaction
22
- * const signedTx = await key.sign(transaction);
23
- * ```
24
- */
25
- declare class SingleKey implements Identity {
26
- private key;
27
- private constructor();
28
- /** Create a signing identity from raw private key bytes. */
29
- static fromPrivateKey(privateKey: Uint8Array): SingleKey;
30
- /** Create a signing identity from a hex-encoded private key. */
31
- static fromHex(privateKeyHex: string): SingleKey;
32
- /** Create a signing identity with a freshly generated random private key. */
33
- static fromRandomBytes(): SingleKey;
34
- /**
35
- * Export the private key as a hex string.
36
- *
37
- * @returns The private key as a hex string
38
- */
39
- toHex(): string;
40
- sign(tx: Transaction, inputIndexes?: number[]): Promise<Transaction>;
41
- compressedPublicKey(): Promise<Uint8Array>;
42
- xOnlyPublicKey(): Promise<Uint8Array>;
43
- signerSession(): SignerSession;
44
- signMessage(message: Uint8Array, signatureType?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
45
- /**
46
- * BIP-340 sign `messageHash` with aux_rand = 0, so the signature — and
47
- * anything derived from it — is reproducible from the key alone.
48
- *
49
- * What lets a static wallet derive a swap preimage instead of storing one
50
- * (see `wallet/contractSecrets.ts`). Deliberately NOT `signMessage`, whose
51
- * schnorr branch draws a random aux_rand: a preimage derived from that is
52
- * unrecoverable, and the loss would only surface at claim time.
53
- */
54
- signSchnorrDeterministic(messageHash: Uint8Array): Promise<Uint8Array>;
55
- toReadonly(): Promise<ReadonlySingleKey>;
56
- }
57
- declare class ReadonlySingleKey implements ReadonlyIdentity {
58
- private readonly publicKey;
59
- /** Create a readonly identity from a compressed public key. */
60
- constructor(publicKey: Uint8Array);
61
- /**
62
- * Create a ReadonlySingleKey from a compressed public key.
63
- *
64
- * @param publicKey - 33-byte compressed public key (02/03 prefix + 32-byte x coordinate)
65
- * @returns A new ReadonlySingleKey instance
66
- * @example
67
- * ```typescript
68
- * const pubkey = new Uint8Array(33); // your compressed public key
69
- * const readonlyKey = ReadonlySingleKey.fromPublicKey(pubkey);
70
- * ```
71
- */
72
- static fromPublicKey(publicKey: Uint8Array): ReadonlySingleKey;
73
- xOnlyPublicKey(): Promise<Uint8Array>;
74
- compressedPublicKey(): Promise<Uint8Array>;
75
- }
76
-
77
- /** Wall-clock floor for `batchExpiry` outside regtest. */
78
- declare const DEFAULT_MIN_BATCH_EXPIRY_SECONDS = 86400n;
79
- /** Wall-clock floor for `batchExpiry` on regtest (~10 blocks). */
80
- declare const REGTEST_MIN_BATCH_EXPIRY_SECONDS = 6000n;
81
- /** Bounds applied to a server-supplied `BatchStartedEvent.batchExpiry`. */
82
- type BatchExpiryPolicy = {
83
- /** Minimum wall-clock delay in seconds, after normalization. */
84
- minSeconds: bigint;
85
- /**
86
- * Reject block-typed timelocks. Mirrors arkd, which allows a block-typed
87
- * vtxo tree expiry only on regtest.
88
- */
89
- requireSeconds: boolean;
90
- /** When advertised by the operator, `batchExpiry` must equal it exactly. */
91
- advertisedVtxoTreeExpiry?: bigint;
92
- };
93
- /**
94
- * Default policy for a network.
95
- *
96
- * Derive it from the locally held {@link Network} — pinned at wallet setup —
97
- * rather than from a per-round server field, so the permissive regtest branch
98
- * can't be selected by the operator at event time.
99
- */
100
- declare function defaultBatchExpiryPolicy(network: Network): BatchExpiryPolicy;
101
- /** Resolve a policy for `network`, applying any caller overrides on top. */
102
- declare function resolveBatchExpiryPolicy(network: Network, overrides?: Partial<BatchExpiryPolicy>): BatchExpiryPolicy;
103
- /**
104
- * Check a server-supplied batch expiry against `policy` and return the timelock
105
- * to commit to.
106
- *
107
- * The sweep leaf of the shared batch output is derived from this value, so it
108
- * is never reconstructible from anything else the server sends: validating the
109
- * tree only proves it is consistent with whatever value was chosen. Callers
110
- * must encode the returned timelock rather than re-deriving their own.
111
- *
112
- * @throws {ServerResponseMismatchError} if the value is out of policy.
113
- */
114
- declare function assertValidBatchExpiry(batchExpiry: bigint, policy: BatchExpiryPolicy): RelativeTimelock;
115
-
116
- /**
117
- * ArkadeCash is a bearer instrument for the Arkade.
118
- * It encodes a private key and contract parameters as a bech32m string,
119
- * enabling wallet-to-wallet transfers without address exchange.
120
- *
121
- * Format: arkadecash1... / tarkadecash1... (bech32m encoded)
122
- * Payload: version (1 byte) + private key (32 bytes) + server pubkey (32 bytes) + csv timelock sequence (4 bytes)
123
- */
124
- declare class ArkadeCash {
125
- readonly csvTimelock: RelativeTimelock;
126
- readonly hrp: string;
127
- static readonly DefaultHRP = "arkadecash";
128
- /** The only prefixes minted or accepted: mainnet and test networks. */
129
- static readonly HRPs: readonly string[];
130
- static readonly Version = 0;
131
- static readonly PayloadLength: number;
132
- private readonly _privateKey;
133
- private readonly _serverPubKey;
134
- private readonly _publicKey;
135
- constructor(privateKey: Uint8Array, serverPubKey: Uint8Array, csvTimelock: RelativeTimelock, hrp?: string);
136
- /** The note's private key. Returns a fresh copy; mutating it is a no-op. */
137
- get privateKey(): Uint8Array;
138
- /** The server's public key. Returns a fresh copy; mutating it is a no-op. */
139
- get serverPubKey(): Uint8Array;
140
- /** The note's public key. Returns a fresh copy; mutating it is a no-op. */
141
- get publicKey(): Uint8Array;
142
- static generate(serverPubKey: Uint8Array, csvTimelock: RelativeTimelock, hrp?: string): ArkadeCash;
143
- static fromString(encoded: string): ArkadeCash;
144
- toString(): string;
145
- get identity(): SingleKey;
146
- get vtxoScript(): DefaultVtxo.Script;
147
- address(addressHrp: string): ArkAddress;
148
- }
149
-
150
- type ArkadeCashAction = "issued" | "claimed";
151
- /** One transaction of a voucher and the voucher's share of it, in sats. */
152
- interface ArkadeCashTx {
153
- txid: string;
154
- amount: number;
155
- }
156
- interface ArkadeCashRecord {
157
- id: string;
158
- action: ArkadeCashAction;
159
- createdAt: number;
160
- outcome: string;
161
- issues: ArkadeCashTx[];
162
- claims: ArkadeCashTx[];
163
- }
164
- declare class ArkadeCashTracker {
165
- readonly records: Map<string, ArkadeCashRecord>;
166
- get(id: string): ArkadeCashRecord | undefined;
167
- list(): ArkadeCashRecord[];
168
- }
169
- declare function createArkadeCashTracker(): ArkadeCashTracker;
170
- /**
171
- * Combine two records of one voucher. Transactions are unioned by txid and the earliest
172
- * `createdAt` is kept. A claim outranks an issue for `action` and `outcome`; between records
173
- * with the same action, `next` wins.
174
- */
175
- declare function mergeArkadeCashRecord(prev: ArkadeCashRecord | undefined, next: ArkadeCashRecord): ArkadeCashRecord;
176
- /** Inject a public record, merging it into any record already held for the voucher. */
177
- declare function addArkadeCashRecord(records: ArkadeCashTracker, record: ArkadeCashRecord): void;
178
- declare function arkadeCashId(cash: ArkadeCash): string;
179
- declare function arkadeCashResolver(records: ArkadeCashTracker): ActivityResolver;
180
-
181
- declare class ArkError extends Error {
182
- readonly code: number;
183
- readonly message: string;
184
- readonly name: string;
185
- readonly metadata?: Record<string, string> | undefined;
186
- constructor(code: number, message: string, name: string, metadata?: Record<string, string> | undefined);
187
- }
188
- /**
189
- * Structured arkd error `name`s the SDK branches on, centralized so call sites don't
190
- * hardcode string literals. Not an exhaustive mirror of the server's codes — only the
191
- * ones the SDK acts on.
192
- */
193
- declare const ArkErrorName: {
194
- readonly DIGEST_MISMATCH: "DIGEST_MISMATCH";
195
- readonly VTXO_ALREADY_SPENT: "VTXO_ALREADY_SPENT";
196
- readonly INVALID_TX_FILTER: "INVALID_TX_FILTER";
197
- readonly TX_FILTERS_LIMIT_EXCEEDED: "TX_FILTERS_LIMIT_EXCEEDED";
198
- /**
199
- * A CLTV closure was spent before its absolute locktime matured. `submitTx` only, with
200
- * metadata `{ locktime, current_locktime, type: "height" | "time" }`. Self-healing, so defer
201
- * and retry: the server matures a seconds-locktime against the **chain tip block's
202
- * timestamp**, not wall clock, so a prompt spend is rejected until a later block lands.
203
- */
204
- readonly FORFEIT_CLOSURE_LOCKED: "FORFEIT_CLOSURE_LOCKED";
205
- readonly INVALID_INTENT_PROOF: "INVALID_INTENT_PROOF";
206
- readonly INTERNAL_ERROR: "INTERNAL_ERROR";
207
- };
208
- type ArkErrorName = (typeof ArkErrorName)[keyof typeof ArkErrorName];
209
- /**
210
- * Type guard for a structured {@link ArkError}, optionally narrowing to a cataloged
211
- * {@link ArkErrorName}; for an uncataloged name, add it there or compare `err.name` after the
212
- * one-argument form.
213
- *
214
- * @example
215
- * if (isArkError(maybeArkError(err), ArkErrorName.DIGEST_MISMATCH)) { ... }
216
- */
217
- declare function isArkError(error: unknown, name?: ArkErrorName): error is ArkError;
218
- /**
219
- * Which remote dependency an availability failure refers to; labels the
220
- * {@link ProviderUnavailableError} message and `ProviderConnectionState`. Deliberately *not* a
221
- * field on the error: structured clone across the service-worker `postMessage` boundary keeps
222
- * `message`, `stack` and `cause` but drops own-properties and normalizes a custom `name` to
223
- * `"Error"`.
224
- */
225
- type ProviderKind = "arkade" | "indexer";
226
- /**
227
- * A remote provider (Arkade operator or its indexer) is temporarily unreachable: transport
228
- * failure, timeout, or a 5xx/429. Retryable, unlike terminal config/auth/schema errors, which
229
- * stay a plain `Error`/{@link ArkError}. The low-level error is kept as {@link Error.cause}.
230
- */
231
- declare class ProviderUnavailableError extends Error {
232
- /** Always `true`: this error type only ever wraps retryable conditions. */
233
- readonly retryable = true;
234
- constructor(message: string, options?: {
235
- cause?: unknown;
236
- });
237
- }
238
- /**
239
- * A non-2xx response from a plain HTTP provider (Esplora, an SSE stream), carrying what a caller
240
- * needs to back off: the numeric `status` and any `Retry-After` in milliseconds. The status is in
241
- * the message too — `statusText` is empty over HTTP/2, and own-properties do not survive the
242
- * service-worker boundary (see {@link ProviderKind}) — as `<prefix>: <detail> (<status>)`, so a
243
- * caller matching on the prefix still matches.
244
- */
245
- declare class HttpResponseError extends Error {
246
- readonly status: number;
247
- readonly retryAfterMs?: number;
248
- /** @param detail - Replaces `statusText`, for a route that reads the body instead. */
249
- constructor(prefix: string, response: Response, detail?: string);
250
- }
251
- /**
252
- * A response doesn't reconcile with what the SDK submitted or validated (a checkpoint txid not
253
- * among those submitted, a commitment tx differing from the one validated at tree signing).
254
- * Terminal: the two are equal by construction in a well-formed exchange. `retryable` and `name`
255
- * don't cross the SW boundary (see {@link ProviderKind}), so every distinguishing detail belongs
256
- * in `message`.
257
- */
258
- declare class ServerResponseMismatchError extends Error {
259
- readonly retryable = false;
260
- constructor(message: string, options?: {
261
- cause?: unknown;
262
- });
263
- }
264
- /**
265
- * Try to convert an error to an ArkError class, returning undefined if the error is not an ArkError
266
- * @param error - The error to parse
267
- * @returns The parsed ArkError, or undefined if the error is not an ArkError
268
- */
269
- declare function maybeArkError(error: any): ArkError | undefined;
270
-
271
- /** Where the {@link OperatorInfo} used to construct a wallet came from. */
272
- type ServerInfoSource = "live" | "cache";
273
-
274
- /**
275
- * Batch namespace provides utilities for joining and processing batch session.
276
- * The batch settlement process involves multiple events, this namespace provides abstractions and types to handle them.
277
- * @see https://docs.arkadeos.com/learn/pillars/batch-swaps
278
- * @example
279
- * ```typescript
280
- * // use wallet handler or create a custom one
281
- * const handler = wallet.createBatchHandler(intentId, inputs, expectedRecipients, musig2session);
282
- *
283
- * const abortController = new AbortController();
284
- * // Get event stream from the operator provider
285
- * const eventStream = arkProvider.getEventStream(
286
- * abortController.signal,
287
- * ['your-topic-1', 'your-topic-2']
288
- * );
289
- *
290
- * // Join the batch and process events
291
- * try {
292
- * const commitmentTxid = await Batch.join(eventStream, handler);
293
- * console.log('Batch completed with commitment:', commitmentTxid);
294
- * } catch (error) {
295
- * console.error('Batch processing failed:', error);
296
- * } finally {
297
- * abortController.abort();
298
- * }
299
- * ```
300
- */
301
- declare namespace Batch {
302
- interface Handler {
303
- /**
304
- * Called on BatchStarted event.
305
- * @returns { skip: boolean } indicating whether the batch should be skipped or not.
306
- */
307
- onBatchStarted(event: BatchStartedEvent): Promise<{
308
- skip: boolean;
309
- }>;
310
- /**
311
- * Called when tree signing starts.
312
- * @param event The tree signing started event.
313
- * @param vtxoTree The unsigned virtual output tree, reconstructed from the TreeTxEvent events.
314
- * @returns Promise resolving to a boolean indicating whether to continue processing.
315
- */
316
- onTreeSigningStarted(event: TreeSigningStartedEvent, vtxoTree: TxTree): Promise<{
317
- skip: boolean;
318
- }>;
319
- /**
320
- * Called when tree nonces are received.
321
- * @param event The tree nonces event.
322
- * @returns Promise resolving to a boolean indicating whether signing is complete.
323
- */
324
- onTreeNonces(event: TreeNoncesEvent): Promise<{
325
- fullySigned: boolean;
326
- }>;
327
- /**
328
- * Called during batch finalization.
329
- * @param event The batch finalization event.
330
- * @param vtxoTree The signed virtual output tree, reconstructed from the TreeTxEvent events.
331
- * @param connectorTree The connector transaction tree, reconstructed from the TreeTxEvent events.
332
- */
333
- onBatchFinalization(event: BatchFinalizationEvent, vtxoTree?: TxTree, connectorTree?: TxTree): Promise<void>;
334
- /**
335
- * Called when batch finalization completes successfully.
336
- *
337
- * @param event - Batch finalized event
338
- */
339
- onBatchFinalized?(event: BatchFinalizedEvent): Promise<void>;
340
- /**
341
- * Called when batch processing fails.
342
- *
343
- * @param event - Batch failed event
344
- */
345
- onBatchFailed?(event: BatchFailedEvent): Promise<void>;
346
- /**
347
- * Called for each virtual output tree transaction chunk received during batch processing.
348
- *
349
- * @param event - Tree transaction event
350
- */
351
- onTreeTxEvent?(event: TreeTxEvent): Promise<void>;
352
- /**
353
- * Called for each tree signature event received during batch processing.
354
- *
355
- * @param event - Tree signature event
356
- */
357
- onTreeSignatureEvent?(event: TreeSignatureEvent): Promise<void>;
358
- }
359
- /**
360
- * Options for the join function.
361
- *
362
- * @property abortController - Abort controller used to cancel batch processing.
363
- * @property skipVtxoTreeSigning - Ignore events related to the virtual output tree musig2 signing session.
364
- * @property eventCallback - Callback invoked for each settlement event received while joining the batch.
365
- */
366
- type JoinOptions = Partial<{
367
- abortController: AbortController;
368
- skipVtxoTreeSigning: boolean;
369
- eventCallback: (event: SettlementEvent) => Promise<void>;
370
- }>;
371
- /**
372
- * Starts `stream` so the provider subscribes now, before the caller registers an intent whose
373
- * batch could otherwise start unseen. The returned iterator replays the first event; pass it
374
- * to {@link join}.
375
- */
376
- function prime(stream: AsyncIterableIterator<SettlementEvent>): AsyncIterableIterator<SettlementEvent>;
377
- /**
378
- * Start the state machine that will process the batch events and join a batch.
379
- * @param eventIterator - The events stream to process.
380
- * @param handler - How to react to events.
381
- * @param options - Options.
382
- */
383
- function join(eventIterator: AsyncIterableIterator<SettlementEvent>, handler: Handler, options?: JoinOptions): Promise<string>;
384
- }
385
-
386
- /**
387
- * Inputs a {@link ReceiveRotatorFactory} gets at boot to find the current display contract or
388
- * allocate a fresh descriptor. Allocation only: `resolveBoot` rebuilds the tapscript afterwards.
389
- */
390
- interface ReceiveRotatorBootOpts {
391
- walletRepository: WalletRepository;
392
- contractRepository: ContractRepository;
393
- serverPubKey: Uint8Array;
394
- /** When set, only this contract family is considered for the current display contract. */
395
- expectedContractType?: "default" | "delegate";
396
- /**
397
- * The wallet's baseline (index-0) x-only receive pubkey, used by {@link
398
- * WalletReceiveRotator.defaultBoot} when no tagged receive row exists. Such a wallet never
399
- * rotated L2, and the raw watermark can't be used: boarding shares the HD index stream, so a
400
- * boarding-only allocation may have advanced it.
401
- */
402
- baselineReceivePubKey?: Uint8Array;
403
- /** Receives rotation-failure and backoff diagnostics. Defaults to `console`. */
404
- logger?: Logger;
405
- }
406
- /**
407
- * Output of {@link ReceiveRotatorFactory.createReceiveRotator}: the rotator plus the receive
408
- * pubkey resolved at boot (existing tagged display contract's, or freshly allocated).
409
- */
410
- interface ReceiveRotatorBoot {
411
- rotator: WalletReceiveRotator;
412
- receivePubkey: Uint8Array;
413
- }
414
- /**
415
- * What {@link WalletReceiveRotator.resolveBoot} returns: the rotator, the offchain tapscript to
416
- * use (rebuilt to the boot pubkey if it differs), and the provider, which the wallet keeps so
417
- * spends route per-input signing through {@link DescriptorProvider.signWithDescriptor}.
418
- */
419
- interface ReceiveRotatorBootResult {
420
- rotator: WalletReceiveRotator;
421
- offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
422
- provider: DescriptorProvider;
423
- }
424
- /**
425
- * Opt-in {@link DescriptorProvider} extension for providers driving HD receive rotation
426
- * (implemented by {@link HDDescriptorProvider}). Kept out of the core interface so
427
- * allocate-and-sign providers needn't know the receive lifecycle; without it the wallet uses
428
- * {@link WalletReceiveRotator.defaultBoot}.
429
- */
430
- interface ReceiveRotatorFactory {
431
- createReceiveRotator(opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot | undefined>;
432
- }
433
- /**
434
- * Parse the trailing HD child index from a materialized signing descriptor
435
- * (`tr(...xpub.../0/<index>)`). Returns 0 when absent or unparseable: restore registers the
436
- * index-0 baseline untagged, so a missing descriptor legitimately means 0.
437
- */
438
- declare function signingDescriptorIndex(descriptor: unknown): number;
439
- /**
440
- * Strict {@link signingDescriptorIndex}: `undefined` instead of the 0 fallback, for callers
441
- * (e.g. watermark moves) where mapping "unparseable" to 0 would silently do nothing.
442
- */
443
- declare function strictSigningDescriptorIndex(descriptor: string): number | undefined;
444
- /** Minimal logging surface the rotator needs; `console` or any structured logger satisfies it. */
445
- interface Logger {
446
- error(message: string, ...args: unknown[]): void;
447
- }
448
- /**
449
- * The wallet surface the rotator needs at runtime. An interface to avoid a circular dependency on
450
- * `wallet.ts`; `Wallet` satisfies it structurally.
451
- */
452
- interface RotatableWallet {
453
- readonly defaultContractScript: string;
454
- readonly network: {
455
- hrp: string;
456
- };
457
- readonly arkServerPublicKey: Uint8Array;
458
- readonly offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
459
- /**
460
- * @internal Sole sanctioned write path for `offchainTapscript` after construction; called
461
- * once per rotation after the new display contract is persisted.
462
- */
463
- setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
464
- getContractManager(): Promise<IContractManager>;
465
- getAddress(): Promise<string>;
466
- }
467
- /**
468
- * Owns the wallet's HD receive-rotation lifecycle; exists only when `walletMode` resolves to a
469
- * {@link DescriptorProvider}.
470
- *
471
- * 1. `resolveBoot()` (before Wallet construction): reuse the display contract's pubkey or
472
- * allocate the first descriptor.
473
- * 2. `install(wallet)`: subscribe to `vtxo_received` and rotate on matching events.
474
- * 3. `dispose()`: unsubscribe and drain any in-flight rotation.
475
- *
476
- * NArk parity: the provider is a pure allocator; the current address comes from the contract
477
- * repository, not the provider.
478
- */
479
- declare class WalletReceiveRotator {
480
- private readonly provider;
481
- private unsubscribe?;
482
- private chain;
483
- /**
484
- * Script of the latest tagged display contract, retired by the next `rotate()`. `undefined`
485
- * means the untagged index-0 baseline is displayed, which must NOT be deactivated.
486
- */
487
- private currentTaggedScript;
488
- /** Drives exponential backoff so a broken provider isn't hammered on every inbound VTXO. */
489
- private consecutiveFailures;
490
- /** Unix ms before which `vtxo_received` events skip rotation; 0 = no backoff. */
491
- private nextRotationAllowedAt;
492
- private readonly logger;
493
- private constructor();
494
- /**
495
- * Resolve `walletMode` to a provider and build the rotator (via its
496
- * {@link ReceiveRotatorFactory}, else {@link defaultBoot}). Returns `undefined` for the
497
- * static path.
498
- *
499
- * Resolution errors propagate for `'hd'` and explicit providers (degrading would hide
500
- * misconfig); a {@link NonRangeableDescriptorError} is swallowed only under `'auto'`, for
501
- * back-compat with identities whose descriptor isn't rangeable.
502
- */
503
- static resolveBoot(config: WalletConfig, setup: ReceiveRotatorBootOpts & {
504
- offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
505
- }): Promise<ReceiveRotatorBootResult | undefined>;
506
- /**
507
- * Default boot any {@link ReceiveRotatorFactory.createReceiveRotator} can delegate to: take
508
- * the current display contract from the repository, else allocate/derive the receive pubkey.
509
- * Tapscript construction is deliberately left to `resolveBoot`.
510
- */
511
- static defaultBoot(provider: DescriptorProvider, opts: ReceiveRotatorBootOpts): Promise<ReceiveRotatorBoot>;
512
- /**
513
- * Subscribe to `vtxo_received` and rotate whenever the current display contract receives
514
- * funds. Old display contracts stay watched, so earlier shared addresses keep crediting.
515
- */
516
- install(wallet: RotatableWallet): Promise<void>;
517
- /**
518
- * One rotation attempt with exponential backoff. Errors are logged, not rethrown, so `chain`
519
- * never rejects and the next `vtxo_received` still runs.
520
- */
521
- private runRotateWithBackoff;
522
- /** Wait for any in-flight rotation to complete (mainly for tests). */
523
- drain(): Promise<void>;
524
- /**
525
- * Run `fn` on the rotation chain. {@link Wallet.rotateServerSigner} uses it because both it
526
- * and `rotate()` swap `offchainTapscript`; interleaving could tear the visible receive state.
527
- * The chain advances even if `fn` rejects (the caller still sees the rejection).
528
- */
529
- runExclusive<T>(fn: () => Promise<T>): Promise<T>;
530
- /**
531
- * Unsubscribe first so no late event queues work, then drain so an in-flight
532
- * `createContract` finishes before the contract manager disposes.
533
- */
534
- dispose(): Promise<void>;
535
- /**
536
- * Allocate the next descriptor, register it as the new tagged display contract (same
537
- * default/delegate shape), swap it in, and mark the previous tagged one `inactive` (still
538
- * watched; it just stops being advertised). The untagged index-0 baseline is never retired.
539
- */
540
- private rotate;
541
- }
542
-
543
- /**
544
- * Capability a wallet exposes so descriptor-blind consumers (Boltz swaps, other plugins) can bind
545
- * artifacts to the wallet's current HD index and later enumerate every used index. Probed
546
- * structurally ({@link isHDWalletCapable}) rather than widening `IWallet`, so plugins keep working
547
- * against older wallets; a static wallet answers "no HD state" through the same methods.
548
- */
549
- interface HDWalletCapable {
550
- /**
551
- * The descriptor at the wallet's current receive index, or `undefined` for
552
- * static / `auto` wallets and HD wallets that have never rotated. Callers
553
- * fall back to the identity key.
554
- */
555
- getCurrentSigningDescriptor(): Promise<string | undefined>;
556
- /**
557
- * Every descriptor the wallet may hold keys under, ascending by index: the allocation
558
- * watermark's band plus any descriptor persisted on a contract. Empty for static wallets.
559
- * `lookAhead` appends that many past the watermark without advancing it, for restore probing.
560
- */
561
- getUsedSigningDescriptors(opts?: {
562
- lookAhead?: number;
563
- }): Promise<string[]>;
564
- /**
565
- * An {@link Identity} whose keys and signatures are those of `descriptor`; the wallet
566
- * identity itself when `descriptor` is the identity's own key.
567
- *
568
- * Throws {@link ForeignDescriptorError} for a descriptor this wallet cannot sign for — never
569
- * substitutes another key, which would sign happily and surface only as a rejected tx or a
570
- * dead script. The returned identity must actually sign (`sign`, `signMessage`,
571
- * `signerSession`): `contractSigner` refuses a watch-only one as `WalletCannotSignError`,
572
- * which would otherwise pass every check and throw after the contract is funded.
573
- */
574
- signerForDescriptor(descriptor: string): Promise<Identity>;
575
- }
576
- /**
577
- * Thrown by {@link HDWalletCapable.signerForDescriptor} when the wallet holds no key for the
578
- * descriptor, so callers can tell "not my key" from transient signing failures.
579
- */
580
- declare class ForeignDescriptorError extends Error {
581
- readonly descriptor: string;
582
- readonly name = "ForeignDescriptorError";
583
- constructor(descriptor: string, options?: {
584
- cause?: unknown;
585
- });
586
- }
587
- /**
588
- * Thrown by `Wallet.getNewAddresses({ forceNew: true })` when there is no HD stream to advance
589
- * (`walletMode: 'static'` / `'auto'`, or a {@link DescriptorProvider} that declined). Typed
590
- * rather than a silent repeat, which would surface only as two payers sharing a script.
591
- */
592
- declare class WalletCannotAllocateAddressError extends Error {
593
- readonly name = "WalletCannotAllocateAddressError";
594
- constructor(reason: string, options?: {
595
- cause?: unknown;
596
- });
597
- }
598
- /** Anything that can derive and sign for a descriptor it claims. */
599
- type DescriptorOwner = Pick<DescriptorProvider, "isOurs" | "signWithDescriptor" | "signMessageWithDescriptor">;
600
- /**
601
- * The identity that signs `descriptor`, or {@link ForeignDescriptorError}. Shared by every
602
- * {@link HDWalletCapable.signerForDescriptor} so page- and worker-side wallets cannot drift into
603
- * a signer that passes a pubkey check and then throws on every signature, after funding.
604
- */
605
- declare function resolveDescriptorSigner(descriptor: string, identity: Identity, provider?: DescriptorOwner): Promise<Identity>;
606
- /** Structural type guard for {@link HDWalletCapable}. */
607
- declare function isHDWalletCapable(value: unknown): value is HDWalletCapable;
608
- /**
609
- * Allocating a *fresh* index — strictly more than {@link HDWalletCapable}'s descriptor awareness.
610
- * A separate probe because widening that guard would silently demote every wallet implementing
611
- * only its original surface (including older SDKs') from HD-capable to static.
612
- */
613
- interface HDAllocationCapable {
614
- /**
615
- * The signing descriptor a new artifact (swap, invoice, contract) should bind to. **The
616
- * wallet decides**: an HD wallet allocates a fresh index, advancing the watermark; a static
617
- * wallet answers with its one `tr(pubkey)` every time. Consumers must not probe the wallet's
618
- * shape or mint key material; they use the answer with
619
- * {@link HDWalletCapable.signerForDescriptor}.
620
- *
621
- * `undefined` only for implementations that genuinely cannot answer (`Wallet` always
622
- * answers); callers then fall back to the identity key — never a random one.
623
- *
624
- * Unlike {@link HDWalletCapable.getCurrentSigningDescriptor}, which peeks (two artifacts bound
625
- * to a peek share a key). Per-call uniqueness is a wallet property, so anything deriving
626
- * per-artifact secrets must check the descriptor's shape, not the wallet's.
627
- */
628
- getNextSigningDescriptor(): Promise<string | undefined>;
629
- /**
630
- * Move the allocation watermark to `descriptor`'s index so later allocations cannot reissue
631
- * it. Monotonic; a static wallet accepts its own descriptor as a no-op.
632
- *
633
- * Throws on a descriptor this wallet cannot derive, or an HD descriptor with no parseable
634
- * trailing index: mapping those to index 0 would let a restored artifact's index be reissued.
635
- */
636
- advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
637
- }
638
- /** Structural type guard for {@link HDAllocationCapable}. */
639
- declare function isHDAllocationCapable(value: unknown): value is HDAllocationCapable;
640
- /**
641
- * Minting addresses to hand out: beyond {@link HDAllocationCapable}'s bare index, the wallet
642
- * builds the scripts, persists them as watched contracts, and reports the rows. A third probe
643
- * for the same no-silent-demotion reason.
644
- */
645
- interface AddressAllocationCapable {
646
- /**
647
- * Fresh addresses of each requested type from one newly allocated HD index, persisted and
648
- * watched. An HD wallet burns an index; a wallet with no stream answers with its existing
649
- * display addresses or, under `forceNew`, throws {@link WalletCannotAllocateAddressError}.
650
- *
651
- * Unlike {@link HDAllocationCapable.getNextSigningDescriptor}, allocation and script
652
- * registration happen together: split across a process boundary, a failed registration
653
- * leaves a burnt index and an unwatched address.
654
- */
655
- getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
656
- }
657
- /** Structural type guard for {@link AddressAllocationCapable}. */
658
- declare function isAddressAllocationCapable(value: unknown): value is AddressAllocationCapable;
659
-
660
- /**
661
- * Cap on HD descriptors getUsedSigningDescriptors() materializes past the watermark (bounds
662
- * plugin/restore probes; the watermark itself is not moved).
663
- */
664
- declare const MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD = 1000;
665
- type IncomingFunds = {
666
- type: "utxo";
667
- coins: Coin[];
668
- } | {
669
- type: "vtxo";
670
- newVtxos: ExtendedVirtualCoin[];
671
- spentVtxos: ExtendedVirtualCoin[];
672
- };
673
- /**
674
- * Capability contract for a wallet that can report newly received funds.
675
- *
676
- * Kept as its own interface rather than on the wallet interfaces because not every wallet
677
- * implements it (the service-worker and Expo wallets do not), matching the repo's
678
- * capability-interface pattern. Lets helpers depend on just this one method instead of the
679
- * whole Wallet class.
680
- */
681
- interface NotifiesIncomingFunds {
682
- notifyIncomingFunds(eventCallback: (coins: IncomingFunds) => void): Promise<() => void>;
683
- }
684
-
685
- /**
686
- * Structural rather than {@link ContractWithVtxos} so the worker's repository-built snapshot
687
- * (VTXOs without `contractScript`) classifies without a parallel array.
688
- */
689
- type PendingRecoverySnapshot = Parameters<typeof selectPendingRecoveryOutpoints>[0];
690
- /**
691
- * Boarding UTXOs grouped by boarding address, with that address's signer. A flat
692
- * {@link ExtendedCoin} can't carry it: it keeps only the encoded leaves, not the owning script's
693
- * `serverPubKey` or CSV delay, which deprecated-signer classification needs.
694
- */
695
- interface BoardingUtxoGroup {
696
- /** Tapscript of the boarding address the coins sit on. */
697
- tapscript: DefaultVtxo.Script;
698
- /** Operator key of that address, normalized x-only hex. */
699
- serverPubKey: string;
700
- /** CSV exit timelock decoded from THIS tapscript's exit leaf. */
701
- csvTimelock: RelativeTimelock;
702
- coins: ExtendedCoin[];
703
- }
704
- /**
705
- * Why a VTXO at an arkadeCash address could neither be swept nor imported for
706
- * recovery by {@link Wallet.claimCash}.
707
- *
708
- * - `subdust` — below dust, so it sits at an OP_RETURN script with no spendable
709
- * leaf. Unspendable as cash; `createCash` prevents minting these.
710
- * - `already-spent` — someone else claimed it first.
711
- * - `exited` — unilaterally exited onchain, so the offchain sweep cannot reach it;
712
- * `Unroll.completeUnroll` is the remedy.
713
- * - `has-assets` — asset-bearing; the BTC-only sweep would burn the assets.
714
- * - `sweep-failed` — spendable, but its own sweep was rejected.
715
- * - `recovery-failed` — operator-swept and recoverable in principle, but the
716
- * import that hands it to the wallet's recovery machinery failed.
717
- *
718
- * An output the operator swept whose import *succeeds* is not reported here — it lands
719
- * in {@link ArkadeCashClaimResult.recovering} instead.
720
- */
721
- type ArkadeCashUnclaimedReason = "subdust" | "already-spent" | "exited" | "has-assets" | "sweep-failed" | "recovery-failed";
722
- /** Minimal outpoint + value identifying a VTXO in a claim report. */
723
- interface ArkadeCashVtxoRef {
724
- txid: string;
725
- vout: number;
726
- /** Value in satoshis. */
727
- value: number;
728
- }
729
- /** A VTXO {@link Wallet.claimCash} left behind, with the reason why. */
730
- interface ArkadeCashUnclaimedVtxo extends ArkadeCashVtxoRef {
731
- reason: ArkadeCashUnclaimedReason;
732
- }
733
- /**
734
- * Outcome of {@link Wallet.claimCash}: what was swept instantly, what was
735
- * imported for background recovery, and what was left behind.
736
- *
737
- * The shape is open — further buckets may be added as more of the
738
- * non-sweepable states become claimable.
739
- */
740
- interface ArkadeCashClaimResult {
741
- /**
742
- * The Arkade transactions registered by successful sweeps, each with the sats it paid this
743
- * wallet.
744
- */
745
- claims?: ArkadeCashTx[];
746
- /** Satoshis swept to this wallet instantly (the thin single-key sweep). */
747
- swept: number;
748
- /**
749
- * Operator-swept outputs imported for recovery. These funds are not in the
750
- * wallet yet: a swept VTXO can only move through a settlement, so
751
- * `claimCash` imports it as a signable contract and hands it to the
752
- * wallet's own recovery machinery, which settles it back (rotation-aware)
753
- * on the normal retry cadence. The amount arrives as a fresh VTXO once
754
- * that settlement finalizes.
755
- */
756
- recovering: {
757
- /** Satoshis imported for recovery. */
758
- amount: number;
759
- vtxos: ArkadeCashVtxoRef[];
760
- };
761
- unclaimed: {
762
- /** Satoshis left behind. */
763
- amount: number;
764
- vtxos: ArkadeCashUnclaimedVtxo[];
765
- };
766
- }
767
- /**
768
- * Thrown when {@link Wallet.createCash}'s `send` fails after the transaction may already have been
769
- * submitted. `cash` carries the private key of the funded output: discard it and the sats may be
770
- * stranded. Persist it; {@link Wallet.claimCash} recovers the funds whether or not the send landed.
771
- */
772
- declare class ArkadeCashCreateError extends Error {
773
- /** The encoded arkadeCash token controlling the funded output. */
774
- readonly cash: string;
775
- /** The original failure from `send`. */
776
- readonly cause: unknown;
777
- constructor(
778
- /** The encoded arkadeCash token controlling the funded output. */
779
- cash: string,
780
- /** The original failure from `send`. */
781
- cause: unknown);
782
- }
783
- /**
784
- * Thrown by {@link Wallet.claimCash} when the arkadeCash comes from another operator. Its signer
785
- * is not the connected operator's active signer, and it is not in the operator's list of
786
- * deprecated signers either. Nothing is queried or signed. To claim it, connect to the operator
787
- * that issued it.
788
- */
789
- declare class ArkadeCashOperatorMismatchError extends Error {
790
- /** The signer in the arkadeCash script, x-only hex. */
791
- readonly cashSignerPubKey: string;
792
- /** The active signer of the connected operator, x-only hex. */
793
- readonly activeSignerPubKey: string;
794
- constructor(
795
- /** The signer in the arkadeCash script, x-only hex. */
796
- cashSignerPubKey: string,
797
- /** The active signer of the connected operator, x-only hex. */
798
- activeSignerPubKey: string);
799
- }
800
- /**
801
- * Freshness of provider-backed sync (operator info source + indexer-sync health). Balances/VTXOs
802
- * are always served from the repository regardless. `syncing` says a provider sync is in flight
803
- * right now; optional so adding it breaks no implementer, {@link ReadonlyWallet} always sets it.
804
- */
805
- type ProviderConnectionState = {
806
- mode: "online";
807
- syncing?: boolean;
808
- source: "live";
809
- lastOnlineAt: number;
810
- } | {
811
- mode: "degraded";
812
- syncing?: boolean;
813
- source: "cache" | "repository";
814
- provider: ProviderKind;
815
- reason: string;
816
- lastOnlineAt?: number;
817
- };
818
- declare class ReadonlyWallet implements IReadonlyWallet {
819
- readonly identity: ReadonlyIdentity;
820
- readonly network: Network;
821
- readonly onchainProvider: OnchainProvider;
822
- /** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
823
- protected readonly arkProvider: Pick<OperatorProvider, "getInfo">;
824
- readonly indexerProvider: IndexerProvider;
825
- readonly dustAmount: bigint;
826
- readonly walletRepository: WalletRepository;
827
- readonly contractRepository: ContractRepository;
828
- readonly delegateProvider?: DelegateProvider | undefined;
829
- protected lazyInitialization: boolean;
830
- private boardingLoaded;
831
- private _contractManager?;
832
- private _contractManagerInitializing?;
833
- protected readonly watcherConfig?: ReadonlyWalletConfig["watcherConfig"];
834
- protected vtxoSyncOverlapMs?: number;
835
- protected copySyncOverlapTo(wallet: ReadonlyWallet): void;
836
- /** Opt-in intent-lifecycle repository; `undefined` ⇒ intent persistence is a no-op. */
837
- intentRepository?: BatchRegistrationRepository;
838
- /**
839
- * **Experimental / inert.** Opt-in virtual-tx repository, exposed so callers can pass it to
840
- * {@link Unroll.Session.create} as a best-effort raw-tx cache. Normal sync never writes it.
841
- */
842
- virtualTxRepository?: VirtualTxRepository;
843
- /** Opt-in exit-data capture settings; see {@link StorageConfig.exitDataCapture}. */
844
- exitDataCapture?: {
845
- mode?: ExitCaptureMode;
846
- minExitWorthSats?: number;
847
- sources?: ExitDataSource[];
848
- };
849
- private readonly _assetManager;
850
- readonly walletContractTimelocks: RelativeTimelock[];
851
- protected _pendingSpendOutpoints: Set<string>;
852
- protected _heldOutpoints: Set<string>;
853
- /** Activity resolvers consumed by {@link getActivityHistory}. */
854
- readonly activity: ActivityRegistry;
855
- get assetManager(): IReadonlyAssetManager;
856
- /**
857
- * Active receive tapscript; written only by {@link Wallet.setOffchainTapscriptForRotation}
858
- * (sole intended caller: {@link WalletReceiveRotator.rotate}).
859
- */
860
- protected _offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
861
- /**
862
- * Current boarding tapscript (QR / onboarding target); written only by
863
- * {@link Wallet.setBoardingTapscriptForRotation}. Static / `auto` wallets never rotate it.
864
- */
865
- protected _boardingTapscript: DefaultVtxo.Script;
866
- /**
867
- * Active operator signer (x-only); written only by
868
- * {@link Wallet.setArkServerPublicKeyForRotation} when arkd rotates its signer mid-session.
869
- */
870
- protected _arkServerPublicKey: Bytes;
871
- /**
872
- * Whether the LATEST operator info resolution was live or fell back to the cached snapshot.
873
- * Updated on every {@link getOperatorInfo} read so recovery (or a fresh fallback) is reflected.
874
- */
875
- protected _serverInfoSource: ServerInfoSource;
876
- /**
877
- * Epoch-ms of the last live operator contact, or the cached snapshot's `savedAt` when the
878
- * latest resolution fell back.
879
- */
880
- protected _serverInfoLastOnlineAt?: number;
881
- /** @see {@link _serverInfoSource} */
882
- get serverInfoSource(): ServerInfoSource;
883
- /**
884
- * Composed provider-connection freshness: degraded on `arkade` (`cache`) when the latest
885
- * operator info resolution fell back, else degraded on `indexer` (`repository`) when an
886
- * initialized contract manager has, else online. Never forces a `ContractManager` to
887
- * construct, so it is safe for readonly callers.
888
- */
889
- getProviderConnectionState(): ProviderConnectionState;
890
- /**
891
- * The contract manager's sync health **without initializing it** (`online` if none exists),
892
- * so unlike {@link getContractManager} it never triggers a remote sync.
893
- */
894
- getContractSyncState(): ContractSyncState;
895
- protected constructor(identity: ReadonlyIdentity, network: Network, onchainProvider: OnchainProvider,
896
- /** Narrowed so a readonly wallet can't grow a `submitTx` use; `Wallet` re-widens it. */
897
- arkProvider: Pick<OperatorProvider, "getInfo">, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider | undefined, watcherConfig?: ReadonlyWalletConfig["watcherConfig"], walletContractTimelocks?: RelativeTimelock[]);
898
- /**
899
- * x-only hex → cutoff of the operator's deprecated signers, cached for OFFLINE read/watch.
900
- * Boarding watch/history fan out over {current} ∪ this set so deposits at addresses minted
901
- * under a rotated signer stay watched. Deliberately NOT used by the spend path:
902
- * {@link getBoardingUtxos} stays current-signer-only (a deprecated-signer input in a plain
903
- * settle() is rejected; recovery goes through the migration API).
904
- */
905
- protected _deprecatedSigners: Map<string, bigint>;
906
- /**
907
- * Refresh the cached deprecated-signer set from operator info; feeds
908
- * {@link pendingRecoveryOutpoints}. Lenient: a malformed entry is skipped, never fatal.
909
- */
910
- refreshDeprecatedSigners(info: {
911
- deprecatedSigners?: readonly {
912
- pubkey?: string;
913
- cutoffDate?: bigint;
914
- }[];
915
- }): void;
916
- /** Boarding WATCH/HISTORY signer set: current ∪ deprecated (spend stays current-only). */
917
- protected watchedBoardingSigners(): Set<string>;
918
- /**
919
- * `serverPubKey` defaults to the live key; spend paths that snapshot it
920
- * against mid-flight rotation pass their snapshot, so the check reads from
921
- * one rotation epoch.
922
- */
923
- protected recipientAddressContext(serverPubKey?: Bytes): RecipientArkadeAddressContext;
924
- /** Currently-active receive tapscript; changes only on receive rotation. */
925
- get offchainTapscript(): DefaultVtxo.Script | DelegateVtxo.Script;
926
- /** Current active server signer (x-only, 32 bytes); changes only on server-signer rotation. */
927
- get arkServerPublicKey(): Bytes;
928
- /**
929
- * Info for the connected operator: live wins, a retryable failure falls back to
930
- * the boot snapshot, a terminal one propagates. Live because `signerPubkey`,
931
- * `checkpointTapscript` and `fees` move on rotation, and a covenant built against a
932
- * superseded signer is unspendable.
933
- *
934
- * @remarks Reading does NOT re-pin the wallet ({@link arkServerPublicKey}, {@link dustAmount},
935
- * tapscripts), so inside a rotation window this can report epoch N+1 while the wallet spends
936
- * on N; the provider's `onServerInfoChanged` closes the window. Pass `{ requireLive: true }`
937
- * before binding the answer into a covenant to fail closed instead of getting the snapshot.
938
- *
939
- * @returns The operator's info
940
- * @see OperatorInfo
941
- */
942
- getOperatorInfo(opts?: GetOperatorInfoOptions): Promise<OperatorInfo>;
943
- /** @deprecated Use {@link getOperatorInfo}. */
944
- getArkadeInfo(opts?: GetOperatorInfoOptions): Promise<OperatorInfo>;
945
- /**
946
- * Chain reads against this wallet's operator for scripts it does not own, bound to the wallet's
947
- * own (possibly Expo/injected) `indexerProvider`. `getVtxos` normalizes via
948
- * {@link getNormalizedVtxos}. A bound object, not the provider, so an `IReadonlyWallet`
949
- * holder gets these two reads and nothing else.
950
- */
951
- getArkadeReader(): Promise<ArkadeReader>;
952
- /**
953
- * Current boarding tapscript (on-chain onboarding target); changes only when a fresh boarding
954
- * address is explicitly allocated.
955
- */
956
- get boardingTapscript(): DefaultVtxo.Script;
957
- /**
958
- * Fired after boarding rotation so a live {@link notifyIncomingFunds} watcher re-subscribes
959
- * to the fresh address in-session instead of missing deposits until its next re-init.
960
- */
961
- private readonly _boardingRotationListeners;
962
- /** Register a listener invoked synchronously after each boarding rotation. */
963
- protected onBoardingRotation(listener: () => void): () => void;
964
- /** A throwing listener is isolated: it can't break the rotation or starve siblings. */
965
- protected notifyBoardingRotation(): void;
966
- /** Shared setup for ReadonlyWallet.create() and Wallet.create(). */
967
- protected static setupWalletConfig(config: ReadonlyWalletConfig, pubKey: Uint8Array): Promise<{
968
- arkProvider: OperatorProvider;
969
- indexerProvider: IndexerProvider;
970
- onchainProvider: OnchainProvider | EsploraProvider;
971
- network: Network;
972
- networkName: NetworkName;
973
- serverPubKey: Uint8Array<ArrayBufferLike>;
974
- offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script;
975
- boardingTapscript: DefaultVtxo.Script;
976
- dustAmount: bigint;
977
- walletRepository: WalletRepository | IndexedDBWalletRepository;
978
- contractRepository: ContractRepository;
979
- info: OperatorInfo;
980
- serverInfoSource: ServerInfoSource;
981
- serverInfoLastOnlineAt: number | undefined;
982
- delegateProvider: DelegateProvider | undefined;
983
- walletContractTimelocks: RelativeTimelock[];
984
- }>;
985
- /**
986
- * Create a readonly wallet for querying balances, addresses, and history.
987
- *
988
- * @param config - Readonly wallet configuration
989
- * @returns A readonly wallet instance
990
- */
991
- static create<T extends ReadonlyWallet>(this: {
992
- prototype: T;
993
- }, config: ReadonlyWalletConfig): Promise<T>;
994
- static create(config: ReadonlyWalletConfig): Promise<ReadonlyWallet>;
995
- get arkAddress(): ArkAddress;
996
- /**
997
- * Get the pkScript hex for the wallet's primary offchain address.
998
- * For the full wallet-owned script set registered in ContractManager, use getWalletScripts().
999
- */
1000
- get defaultContractScript(): string;
1001
- /** Returns the wallet's Arkade address. */
1002
- getAddress(): Promise<string>;
1003
- /** Returns the onchain boarding address used to move funds into Arkade. */
1004
- getBoardingAddress(): Promise<string>;
1005
- /**
1006
- * Return the wallet's combined onchain and offchain balances.
1007
- */
1008
- getBalance(): Promise<WalletBalance>;
1009
- /** Cached balance; inspect connection state and boarding.loaded before displaying zeros. */
1010
- getStoredBalance(): Promise<WalletBalance>;
1011
- private balanceFromSnapshot;
1012
- /**
1013
- * Return virtual outputs tracked by the wallet, including escrowed, locked and
1014
- * awaiting-recovery funds. Coin selection must use {@link getSpendableVtxos}: feeding this
1015
- * into `settle({ inputs })` or `send({ selectedVtxos })` bypasses the generic-spending gate.
1016
- *
1017
- * @param filter - Optional flags controlling whether recoverable or unrolled VTXOs are included
1018
- */
1019
- getVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
1020
- /** Cached VTXOs; may be empty before the first sync. Never use for coin selection. */
1021
- getStoredVtxos(filter?: GetVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
1022
- /**
1023
- * @internal The stored VTXOs {@link reserveVtxos} holds, minus any being spent: for renewal,
1024
- * which skips them, to report the ones it would have renewed. No sync.
1025
- */
1026
- getHeldVtxos(): Promise<NormalizedExtendedVirtualCoin[]>;
1027
- /** @inheritdoc */
1028
- getSpendableVtxos(filter?: GetSpendableVtxosFilter): Promise<NormalizedExtendedVirtualCoin[]>;
1029
- /**
1030
- * Debug-log any explicit input generic selection would have excluded. Explicit-input APIs stay
1031
- * ungated on purpose (naming an outpoint *is* the intent, and is how an escrowed deposit is
1032
- * recovered), so this only makes the crossing visible — notably
1033
- * `settle({ inputs: await wallet.getVtxos() })`. Never throws. Public for worker and plugins.
1034
- */
1035
- logUngatedInputs(source: string, inputs: readonly {
1036
- txid: string;
1037
- vout: number;
1038
- script?: string;
1039
- }[]): Promise<void>;
1040
- /**
1041
- * Past-cutoff-signer contracts as a script-level exclusion: the `pendingRecovery` answer for a
1042
- * caller-supplied input without a synced snapshot (a swept outpoint is unspendable anyway).
1043
- */
1044
- private expiredSignerExclusion;
1045
- /** The intent store's lock set. Fails open, like every other read of it. */
1046
- protected lockedOutpoints(): Promise<Set<string>>;
1047
- /**
1048
- * One contract+VTXO read (which may sync against the indexer). Callers needing several views
1049
- * derive them all from one snapshot so they answer about the same instant.
1050
- */
1051
- protected contractSnapshot(filter?: GetSpendableVtxosFilter, options?: {
1052
- unspentOnly?: boolean;
1053
- }): Promise<ContractWithVtxos[]>;
1054
- protected contractSnapshotStored(): Promise<ContractWithVtxos[]>;
1055
- /**
1056
- * The two exclusion sets the gate is made of, derived from one snapshot so
1057
- * {@link getSpendableVtxos} and the balance answer about the same instant.
1058
- */
1059
- private spendabilityView;
1060
- /** The capability probes {@link computeOffchainBalance} needs, over one snapshot. */
1061
- private balanceCapabilities;
1062
- /**
1063
- * Outpoints of not-yet-swept VTXOs whose deprecated signer is past its cutoff (EXPIRED) —
1064
- * unspendable until they recover; excluded by {@link getBalance} and {@link getSpendableVtxos}.
1065
- * Takes a fresh (syncing) snapshot; callers that hold one or must not sync use
1066
- * {@link pendingRecoveryOutpointsIn}.
1067
- */
1068
- pendingRecoveryOutpoints(): Promise<Set<string>>;
1069
- /** {@link pendingRecoveryOutpoints} over a caller-held snapshot; no I/O of its own. */
1070
- pendingRecoveryOutpointsIn(snapshot: PendingRecoverySnapshot): Set<string>;
1071
- private selectPendingRecovery;
1072
- /**
1073
- * Return wallet transaction history derived from Arkade state and boarding transactions.
1074
- */
1075
- getTransactionHistory(): Promise<ArkTransaction[]>;
1076
- /**
1077
- * Wallet history grouped by registered activity resolvers. With no resolver match,
1078
- * rows bucket by transaction key so send/change pairs stay together.
1079
- */
1080
- getActivityHistory(): Promise<Activity[]>;
1081
- /**
1082
- * Clear the global VTXO sync cursor, forcing a full re-bootstrap on next sync.
1083
- * Useful for recovery after indexer reprocessing or debugging.
1084
- */
1085
- clearSyncCursor(): Promise<void>;
1086
- /**
1087
- * Wipe all locally persisted wallet data (VTXOs, UTXOs, history, sync
1088
- * cursor, contracts, intents). Create a fresh wallet instance afterward.
1089
- * Intents are kept while any may still be held by arkd, so a later
1090
- * reconciliation can release them with their stored proofs.
1091
- */
1092
- clear(): Promise<void>;
1093
- private clearIntents;
1094
- /**
1095
- * On-chain (P2TR) addresses of every boarding tapscript this wallet uses, current plus
1096
- * historical rotated, so deposits at old addresses still surface; {@link getBoardingAddress}
1097
- * stays single-valued.
1098
- */
1099
- getBoardingAddresses(): Promise<string[]>;
1100
- /** Transaction history across the wallet's boarding addresses (current + historical). */
1101
- getBoardingTxs(): Promise<{
1102
- boardingTxs: ArkTransaction[];
1103
- commitmentsToIgnore: Set<string>;
1104
- }>;
1105
- /**
1106
- * Every boarding tapscript whose UTXOs belong to this wallet (rotation spreads them over
1107
- * several addresses), deduplicated by scriptPubKey. Includes index-0 `default` rows when a
1108
- * baseline boarding script coalesced with one.
1109
- *
1110
- * @param allowedSigners - x-only operator keys whose persisted boarding rows are included;
1111
- * defaults to the current signer (the foreign-ASP guard). Migration widens it to old signers.
1112
- * The baseline and current display tapscript are included regardless.
1113
- */
1114
- protected getBoardingTapscripts(allowedSigners?: Set<string>): Promise<DefaultVtxo.Script[]>;
1115
- /**
1116
- * Fetch and cache onchain inputs (UTXOs) received at the boarding addresses
1117
- * of the given signer set, grouped per boarding address so the caller keeps
1118
- * the address↔signer association that {@link ExtendedCoin} cannot carry
1119
- * (it retains only the encoded leaves/tapTree the spend needs, not the
1120
- * `DefaultVtxo.Script` and its `serverPubKey`/CSV delay).
1121
- *
1122
- * Per group: `getCoins` (a failure throws), then `ContractManager.syncOnchain`,
1123
- * then the fetched coins minus stored-spent outpoints → {@link extendCoinWithTapscript}.
1124
- * It does not call `getInfo()`; the caller supplies the allowed signer set.
1125
- *
1126
- * @param allowedSigners - x-only-hex operator keys whose boarding addresses to
1127
- * fetch (passed through to {@link getBoardingTapscripts}).
1128
- * @param skipFailedSigners - x-only-hex server keys whose address lookups may fail: that
1129
- * address is left out of the result and its cache untouched, instead of failing the whole
1130
- * fetch. A lookup under any other signer still rejects.
1131
- */
1132
- getBoardingUtxosForSigners(allowedSigners: Set<string>, skipFailedSigners?: ReadonlySet<string>): Promise<BoardingUtxoGroup[]>;
1133
- /** `undefined` when a lookup under one of `skipFailedSigners` failed or timed out. */
1134
- private fetchBoardingCoins;
1135
- /**
1136
- * Fetch and cache boarding UTXOs at current and historical boarding addresses, each annotated
1137
- * with its own address's tapscript so spends use the right per-index leaves. Current-signer
1138
- * only: old-signer inputs would make a plain `settle()` the operator must reject, so their
1139
- * recovery goes through the deprecated-signer migration API.
1140
- */
1141
- getBoardingUtxos(): Promise<ExtendedCoin[]>;
1142
- /**
1143
- * @internal {@link getBoardingUtxos} minus those an in-flight settle is spending or an
1144
- * unresolved intent locks, for SDK picks. The getter itself lists them: callers that mirror it
1145
- * (the worker's cache and broadcasts, balances) must not see a settle's inputs vanish, and then
1146
- * stay gone if it fails.
1147
- */
1148
- getSelectableBoardingUtxos(): Promise<ExtendedCoin[]>;
1149
- /**
1150
- * @internal {@link getSelectableBoardingUtxos} for every boarding address history shows,
1151
- * current and deprecated signers, grouped by signer. Only the boarding sweep reads it: a
1152
- * unilateral exit needs no operator, so it recovers coins that `settle` must not take.
1153
- */
1154
- getSelectableBoardingUtxoGroups(): Promise<BoardingUtxoGroup[]>;
1155
- /** Boarding coins from the store, no network call; pending and confirmed spends excluded. */
1156
- getStoredBoardingUtxos(): Promise<ExtendedCoin[]>;
1157
- /**
1158
- * Subscribe to onchain and offchain notifications for newly received funds.
1159
- *
1160
- * The onchain watcher tracks every boarding address (current + historical) and re-subscribes
1161
- * automatically when boarding rotates after subscribing, so deposits to a fresh address fire
1162
- * within the same session.
1163
- *
1164
- * @param eventCallback - Callback invoked when matching funds are detected
1165
- * @returns A function that stops the subscriptions
1166
- */
1167
- notifyIncomingFunds(eventCallback: (coins: IncomingFunds) => void): Promise<() => void>;
1168
- /** Fetch Arkade transaction ids that are still pending final settlement. */
1169
- fetchPendingTxs(): Promise<string[]>;
1170
- /**
1171
- * Get all pkScript hex strings for the wallet's own addresses
1172
- * (both delegate and non-delegate, current and historical).
1173
- */
1174
- getWalletScripts(): Promise<string[]>;
1175
- /**
1176
- * Build a map of scriptHex → VtxoScript for all wallet contracts,
1177
- * so virtual outputs can be extended with the correct tapscript per contract.
1178
- */
1179
- getScriptMap(): Promise<Map<string, DefaultVtxo.Script | DelegateVtxo.Script>>;
1180
- /**
1181
- * Get the ContractManager, which manages the wallet's own receive contracts and external ones
1182
- * (Boltz swaps, HTLCs, …) with resilient multi-contract watching.
1183
- *
1184
- * @example
1185
- * ```typescript
1186
- * const manager = await wallet.getContractManager();
1187
- *
1188
- * // Create a contract for a Boltz swap
1189
- * const contract = await manager.createContract({
1190
- * label: "Boltz Swap",
1191
- * type: "vhtlc",
1192
- * params: { ... },
1193
- * script: swapScript,
1194
- * address: swapAddress,
1195
- * });
1196
- *
1197
- * // Start watching for events (includes wallet's default address)
1198
- * const stop = await manager.onContractEvent((event) => {
1199
- * console.log(`${event.type} on ${event.contractScript}`);
1200
- * });
1201
- * ```
1202
- */
1203
- getContractManager(): Promise<ContractManager>;
1204
- /**
1205
- * HD look-ahead configuration for the contract manager. Readonly wallets
1206
- * have no descriptor provider, hence no watermark to look ahead of.
1207
- * @see Wallet.lookAheadConfig
1208
- */
1209
- protected lookAheadConfig(): ContractManagerConfig["lookAhead"];
1210
- /** Readonly wallets never settle, so they neither release nor own batch registrations. */
1211
- protected intentReconciliationConfig(): ContractManagerConfig["intentReconciliation"];
1212
- private initializeContractManager;
1213
- /** Dispose wallet-owned managers and release background resources. */
1214
- dispose(): Promise<void>;
1215
- /** Async-dispose hook that forwards to `dispose()`. */
1216
- [Symbol.asyncDispose](): Promise<void>;
1217
- }
1218
- /**
1219
- * Main wallet implementation for Bitcoin transactions with Arkade protocol support.
1220
- *
1221
- * @example
1222
- * ```typescript
1223
- * // Create a wallet with providers
1224
- * const wallet = await Wallet.create({
1225
- * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
1226
- * operatorProvider: new RestOperatorProvider(),
1227
- * onchainProvider: new EsploraProvider()
1228
- * });
1229
- *
1230
- * // Use custom providers and/or URLs (e.g., for Expo/React Native)
1231
- * const wallet = await Wallet.create({
1232
- * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
1233
- * operatorProvider: new ExpoOperatorProvider('https://arkade.computer'),
1234
- * indexerProvider: new ExpoIndexerProvider('https://arkade.computer'),
1235
- * onchainProvider: new EsploraProvider('https://mempool.space/api')
1236
- * });
1237
- *
1238
- * // Get addresses
1239
- * const arkAddress = await wallet.getAddress();
1240
- * const boardingAddress = await wallet.getBoardingAddress();
1241
- *
1242
- * // Send bitcoin
1243
- * const txid = await wallet.send({
1244
- * address: 'ark1q...',
1245
- * amount: 50000,
1246
- * });
1247
- * ```
1248
- */
1249
- declare class Wallet extends ReadonlyWallet implements IWallet, HDWalletCapable, AddressAllocationCapable {
1250
- readonly forfeitOutputScript: Bytes;
1251
- readonly forfeitPubkey: Bytes;
1252
- /** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
1253
- protected readonly batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined;
1254
- /** @see WalletConfig.oneShotSubmit */
1255
- readonly oneShotSubmit: boolean;
1256
- static MIN_FEE_RATE: number;
1257
- readonly identity: Identity;
1258
- private readonly _delegateManager?;
1259
- private _vtxoManager?;
1260
- private _vtxoManagerInitializing?;
1261
- private _walletAssetManager?;
1262
- /**
1263
- * HD receive rotator; absent for `static` and SingleKey-under-`auto` wallets. Its subscription
1264
- * installs lazily on first `getVtxoManager()` so the contract manager is up first.
1265
- */
1266
- private _receiveRotator?;
1267
- /** Unsubscribe for `onServerInfoChanged` (mid-session signer rotation). */
1268
- private _serverInfoUnsub?;
1269
- /**
1270
- * Tail of the serialized {@link handleServerInfoChanged} chain; {@link dispose} awaits it so an
1271
- * in-flight rotation settles before the contract manager is torn down.
1272
- */
1273
- private _serverInfoInFlight;
1274
- /**
1275
- * React to a mid-session operator info change (`DIGEST_MISMATCH`): refresh deprecated signers
1276
- * first so boarding watch widens immediately, then rotate via {@link rotateServerSigner} only
1277
- * if the active signer changed. Old-signer rows stay active. Never throws into the emit loop.
1278
- */
1279
- private handleServerInfoChanged;
1280
- /**
1281
- * Await an `onServerInfoChanged` handler still applying a rotation. {@link rotateServerSigner}
1282
- * persists the new signer's rows *before* committing the tapscripts, so a path that refreshes
1283
- * operator info then reads signer-derived state must drain first or it reads torn state and
1284
- * races the handler. Resolves once idle; handler rejections are swallowed (already logged).
1285
- *
1286
- * @internal Invoked by {@link dispose} and the {@link VtxoManager} migration
1287
- * pass; not part of the stable public API.
1288
- */
1289
- settleServerInfoChanges(): Promise<void>;
1290
- private _receiveRotatorInstalled;
1291
- /**
1292
- * Descriptor-aware signer for inputs locked by rotated pubkeys (the rotator's instance).
1293
- * Undefined for static / non-HD wallets, which only sign with the identity.
1294
- */
1295
- private readonly _descriptorProvider?;
1296
- /**
1297
- * Keyring holding foreign private keys imported outside the wallet's
1298
- * derivation tree (see {@link KeyringDescriptorProvider}). Wraps
1299
- * {@link _descriptorProvider} (or a {@link StaticDescriptorProvider}
1300
- * over the wallet identity when there is no HD provider) and is the
1301
- * descriptor provider {@link _signerRouter} actually signs through, so
1302
- * a contract carrying `metadata.signingDescriptor` for an imported key
1303
- * is signable by construction.
1304
- *
1305
- * Kept separate from {@link _descriptorProvider} on purpose: the latter
1306
- * still gates HD boarding/receive rotation (a `!provider` check means
1307
- * "static wallet, no rotation"), and wrapping it with a keyring for
1308
- * every wallet would break that gate. The keyring is orthogonal — it
1309
- * only ever adds foreign signable keys, never receive addresses.
1310
- *
1311
- * Populated for every {@link Wallet.create}d wallet; the constructor's
1312
- * param is optional so the router degrades to {@link _descriptorProvider}
1313
- * if a caller ever omits it.
1314
- */
1315
- private readonly _keyring?;
1316
- /**
1317
- * The built-in HD provider behind any keyring wrapping, or `undefined` when there is none.
1318
- * Every HD-specific branch goes through this: a wrapped HD provider (a public `walletMode`
1319
- * shape) fails `instanceof HDDescriptorProvider` and would silently take the non-HD path.
1320
- */
1321
- private get _hdProvider();
1322
- /** Per-side width of the HD look-ahead band. @see WalletConfig.lookAheadWindow */
1323
- private readonly _lookAheadWindow;
1324
- protected intentReconciliationConfig(): ContractManagerConfig["intentReconciliation"];
1325
- /**
1326
- * Watch a band of receive scripts around the HD watermark so payments to an externally-issued
1327
- * address land without a `restore()`. HD only. `candidateDeps` is read at refill time, so a
1328
- * band rebuilt after {@link rotateServerSigner} fans the new signer set.
1329
- */
1330
- protected lookAheadConfig(): ContractManagerConfig["lookAhead"];
1331
- /**
1332
- * Every axis an externally issued receive script could use: an issuer sharing the seed (NArk,
1333
- * a merchant backend) picks its own contract type. From cached state (no `getInfo`) to stay
1334
- * synchronous and offline-safe.
1335
- */
1336
- private receiveCandidateDeps;
1337
- private readonly _signerRouter;
1338
- private _emulator?;
1339
- private _cosignMarginBlocks;
1340
- /**
1341
- * @internal Sole write path for `offchainTapscript`; called by
1342
- * {@link WalletReceiveRotator.rotate} after the rotated contract is persisted.
1343
- */
1344
- setOffchainTapscriptForRotation(tapscript: DefaultVtxo.Script | DelegateVtxo.Script): void;
1345
- /**
1346
- * @internal Sole write path for `boardingTapscript`; called by
1347
- * {@link Wallet.getNewBoardingAddress} after the rotated contract is persisted.
1348
- */
1349
- setBoardingTapscriptForRotation(tapscript: DefaultVtxo.Script): void;
1350
- /**
1351
- * @internal Sole write path for `arkServerPublicKey`; called by
1352
- * {@link Wallet.rotateServerSigner} after the rotated rows are persisted.
1353
- */
1354
- setArkServerPublicKeyForRotation(serverPubKey: Bytes): void;
1355
- /**
1356
- * Checkpoint output script from the operator's `checkpointTapscript`; pinned at construction,
1357
- * re-sourced only via {@link setServerUnrollScriptForRotation}.
1358
- */
1359
- protected _serverUnrollScript: CSVMultisigTapscript.Type;
1360
- get serverUnrollScript(): CSVMultisigTapscript.Type;
1361
- /**
1362
- * @internal Sole write path for `serverUnrollScript`; called by
1363
- * {@link Wallet._doRotateServerSigner} with the rotating `OperatorInfo`'s checkpoint script.
1364
- */
1365
- setServerUnrollScriptForRotation(script: CSVMultisigTapscript.Type): void;
1366
- /**
1367
- * Serializes {@link rotateServerSigner} for static / non-HD wallets so two callers can't both
1368
- * swap the tapscripts; HD wallets use {@link WalletReceiveRotator.runExclusive} instead.
1369
- */
1370
- private _serverRotationChain;
1371
- /**
1372
- * Allocate a *fresh* on-chain boarding address at the next index of the shared HD stream and
1373
- * make it the displayed one (NArk: `GetNextContract(NextContractPurpose.Boarding)`).
1374
- * Persists an `active` `boarding` contract tagged {@link WALLET_RECEIVE_SOURCE} so it is
1375
- * watched, restored at boot and signable per index.
1376
- *
1377
- * A static / `auto` wallet returns {@link getBoardingAddress} unchanged (no index burned). A
1378
- * custom {@link DescriptorProvider} wallet burns an index per call, including via
1379
- * {@link maybeRotateBoardingAfterBoard} on every settle consuming a boarding UTXO; retired
1380
- * addresses stay reachable through {@link getBoardingUtxos}.
1381
- *
1382
- * @deprecated Use {@link getNewAddresses} — it mints any combination of
1383
- * address types at one shared index, and reports the contract row behind
1384
- * each. Note the difference in display behaviour: this method *swaps* the
1385
- * advertised boarding address, where `getNewAddresses` mints side
1386
- * addresses and leaves {@link getBoardingAddress} alone. To keep this
1387
- * method's behaviour, keep calling this method.
1388
- */
1389
- getNewBoardingAddress(): Promise<string>;
1390
- /**
1391
- * Allocate a *fresh* address of each requested type, all at **one** new HD index. The way to
1392
- * issue a second address before the first is paid ({@link getAddress} only advances on
1393
- * receipt). Each is persisted `active` with its `signingDescriptor`, so it is watched,
1394
- * counted, and signable via {@link signerForDescriptor}; the look-ahead band slides.
1395
- *
1396
- * Rows are deliberately **untagged**: boot adopts the newest {@link WALLET_RECEIVE_SOURCE} row
1397
- * as the display address, and a side address must not become what the wallet advertises.
1398
- * {@link getAddress} and {@link getBoardingAddress} are unchanged.
1399
- *
1400
- * A wallet with no HD stream (`static` / `auto`) returns its persisted display rows, or with
1401
- * `forceNew` throws {@link WalletCannotAllocateAddressError} rather than return a stale one.
1402
- *
1403
- * @example
1404
- * ```typescript
1405
- * const [invoice] = await wallet.getNewAddresses({ forceNew: true });
1406
- * // hand `invoice.address` to Alice, keep the descriptor with the invoice
1407
- * const signer = await wallet.signerForDescriptor(invoice.signingDescriptor);
1408
- * ```
1409
- */
1410
- getNewAddresses(opts?: GetNewAddressesOptions): Promise<NewAddress[]>;
1411
- /**
1412
- * Shared core of {@link getNewAddresses} and {@link getNewBoardingAddress}.
1413
- *
1414
- * @param tagSource - Tag rows {@link WALLET_RECEIVE_SOURCE} so boot adopts them as the display
1415
- * address; only the deprecated boarding allocator passes `true`.
1416
- */
1417
- private allocateAddresses;
1418
- /**
1419
- * The wallet's existing display addresses as persisted rows, each minted from the descriptor
1420
- * that owns its display script ({@link displayDescriptor}) so it signs for `address`.
1421
- */
1422
- private currentAddresses;
1423
- /**
1424
- * The descriptor owning the current display script for `type`, from its persisted row. Not
1425
- * derived from the identity: on a rotated wallet that would pair the address with a signer
1426
- * holding the wrong key. Falls back to the identity's `tr(pubkey)` when no row carries one
1427
- * (static / `auto`; index-0 baselines have no `signingDescriptor`).
1428
- */
1429
- private displayDescriptor;
1430
- /**
1431
- * Build, persist and shape one address of `type` owned by `descriptor`. The descriptor is the
1432
- * sole source of the owner key in both branches, so `address` and `signingDescriptor` can't
1433
- * drift apart.
1434
- */
1435
- private mintAddress;
1436
- /**
1437
- * Boarding contract owned by `pubKey`, keeping the current tapscript's other options
1438
- * (offchain analogue: {@link buildReceiveContract}).
1439
- */
1440
- private buildBoardingContract;
1441
- /**
1442
- * @see HDWalletCapable.getCurrentSigningDescriptor
1443
- */
1444
- getCurrentSigningDescriptor(): Promise<string | undefined>;
1445
- /**
1446
- * @see HDAllocationCapable.getNextSigningDescriptor
1447
- *
1448
- * Every `Wallet` answers, so consumers never branch on wallet shape: HD allocates through the
1449
- * contract manager; otherwise the identity key as `tr(pubkey)`, the same every call.
1450
- */
1451
- getNextSigningDescriptor(): Promise<string | undefined>;
1452
- /**
1453
- * @see HDAllocationCapable.advanceSigningDescriptorWatermark
1454
- */
1455
- advanceSigningDescriptorWatermark(descriptor: string): Promise<void>;
1456
- /**
1457
- * @see HDWalletCapable.getUsedSigningDescriptors
1458
- *
1459
- * Union of the watermark band (covers indices allocated for unpersisted things, e.g. swaps)
1460
- * and descriptors persisted on contracts (covers rows a restore scan wrote).
1461
- */
1462
- getUsedSigningDescriptors(opts?: {
1463
- lookAhead?: number;
1464
- }): Promise<string[]>;
1465
- /**
1466
- * @see HDWalletCapable.signerForDescriptor
1467
- *
1468
- * Fail-loud: a descriptor this wallet can't sign for throws {@link ForeignDescriptorError}
1469
- * rather than substituting the baseline identity, which would sign with the wrong key.
1470
- */
1471
- signerForDescriptor(descriptor: string): Promise<Identity>;
1472
- /**
1473
- * Mid-session operator signer rotation. A wallet built before the rotation keeps deriving
1474
- * old-signer receive addresses, and a migration output to one yields an output the operator must
1475
- * reject, so receive state is re-derived under the new signer first.
1476
- *
1477
- * Same write-path as {@link WalletReceiveRotator.rotate} with the operator key swapped: build the
1478
- * new tapscripts, register their rows (carrying signing metadata so a descriptor-backed
1479
- * pubkey still signs), and only then commit visible state. Old-signer rows stay `active` for
1480
- * the migration pass to drain. Idempotent; serialized against HD receive rotation.
1481
- *
1482
- * @internal Invoked by the {@link VtxoManager} migration pass; not part of
1483
- * the stable public API.
1484
- */
1485
- rotateServerSigner(newServerPubKey: Bytes, checkpointTapscript: string): Promise<void>;
1486
- private _doRotateServerSigner;
1487
- /**
1488
- * Serializes `settle`/`send` so VtxoManager's background renewal can't race user
1489
- * transactions for the same inputs; with `concurrentSpending`, only until inputs are reserved.
1490
- */
1491
- private _txLock;
1492
- private readonly _settlingOutpoints;
1493
- /** Coalesces concurrent {@link restore} calls into one scan; cleared on settle. */
1494
- private _restoreInFlight?;
1495
- private _addPendingSpends;
1496
- private _removePendingSpends;
1497
- /**
1498
- * Hold VTXOs so no SDK-chosen spend picks them; the holder still spends them by naming them.
1499
- * All-or-nothing: throws {@link VtxoReservedError} if any is held or already being spent.
1500
- * In-memory, for this `Wallet` instance only.
1501
- */
1502
- reserveVtxos(outpoints: readonly Outpoint[]): VtxoReservation;
1503
- /**
1504
- * @internal For `AssetManager`: reserves what `fn` submits, hiding it from other picks until
1505
- * the submit ends. With `concurrentSpending`, `fn` runs under the wallet lock, released once
1506
- * the inputs are reserved; otherwise `fn` runs unlocked and only the submit takes the lock.
1507
- */
1508
- withSpendLock<T>(fn: (submit: OffchainSubmit) => Promise<T>): Promise<T>;
1509
- private _withTxLock;
1510
- private _assertNotInFlight;
1511
- private _assertNotHeld;
1512
- /**
1513
- * Explicitly recover this wallet's contracts and balance on a fresh repo: a gap-limit scan
1514
- * for HD wallets, the single default pubkey otherwise. Throws on operational failure (a
1515
- * truncated restore is loud), never because of identity/mode. Idempotent.
1516
- *
1517
- * Ordering: scan → advance the HD watermark → inline VTXO pull → only THEN surface handler
1518
- * errors, so safely-discovered funds are recovered even when one handler failed.
1519
- *
1520
- * @param opts.gapLimit - Consecutive-unused-index window. Default 20. A non-positive /
1521
- * non-integer value throws synchronously.
1522
- *
1523
- * @note Concurrent calls coalesce onto the running scan; their `gapLimit` is ignored.
1524
- */
1525
- restore(opts?: {
1526
- gapLimit?: number;
1527
- }): Promise<void>;
1528
- private _runRestore;
1529
- readonly settlementConfig: SettlementConfig | false;
1530
- private _concurrentSpending;
1531
- private _submitsAwaitingFinalize;
1532
- /** @see WalletConfig.concurrentSpending */
1533
- get concurrentSpending(): boolean;
1534
- /** Public here; `ReadonlyWallet` keeps it protected so a readonly view can't submit. */
1535
- readonly arkProvider: OperatorProvider;
1536
- /**
1537
- * Broadcast access bound to this wallet's operator, so a plugin needs only the wallet. Not on
1538
- * {@link ReadonlyWallet}: a readonly wallet or `toReadonly()` view must not be able to submit.
1539
- */
1540
- getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
1541
- protected constructor(identity: Identity, network: Network, onchainProvider: OnchainProvider, arkProvider: OperatorProvider, indexerProvider: IndexerProvider, arkServerPublicKey: Bytes, offchainTapscript: DefaultVtxo.Script | DelegateVtxo.Script, boardingTapscript: DefaultVtxo.Script, serverUnrollScript: CSVMultisigTapscript.Type, forfeitOutputScript: Bytes, forfeitPubkey: Bytes, dustAmount: bigint, walletRepository: WalletRepository, contractRepository: ContractRepository, delegateProvider?: DelegateProvider, watcherConfig?: WalletConfig["watcherConfig"], settlementConfig?: WalletConfig["settlementConfig"], walletContractTimelocks?: RelativeTimelock[], receiveRotator?: WalletReceiveRotator, descriptorProvider?: DescriptorProvider, keyring?: KeyringDescriptorProvider, lookAheadWindow?: number,
1542
- /** Overrides for the `batchExpiry` bounds; defaults derive from `network`. */
1543
- batchExpiryPolicy?: Partial<BatchExpiryPolicy> | undefined,
1544
- /** @see WalletConfig.oneShotSubmit */
1545
- oneShotSubmit?: boolean);
1546
- get assetManager(): IAssetManager;
1547
- getVtxoManager(): Promise<VtxoManager>;
1548
- dispose(): Promise<void>;
1549
- /**
1550
- * Create a full wallet and initialize its background managers.
1551
- *
1552
- * @param config - Wallet configuration
1553
- * @returns A wallet ready to query balances and send transactions
1554
- * @example
1555
- * ```typescript
1556
- * const wallet = await Wallet.create({
1557
- * identity,
1558
- * operatorProvider: new RestOperatorProvider(),
1559
- * });
1560
- * ```
1561
- */
1562
- static create<T extends Wallet>(this: {
1563
- prototype: T;
1564
- }, config: WalletConfig): Promise<T>;
1565
- static create(config: WalletConfig): Promise<Wallet>;
1566
- /**
1567
- * Convert this wallet to a readonly wallet.
1568
- *
1569
- * @returns A readonly wallet with the same configuration but readonly identity
1570
- * @example
1571
- * ```typescript
1572
- * const wallet = await Wallet.create({ identity: MnemonicIdentity.fromMnemonic('abandon abandon...'), ... });
1573
- * const readonlyWallet = await wallet.toReadonly();
1574
- *
1575
- * // Can query balance and addresses
1576
- * const balance = await readonlyWallet.getBalance();
1577
- * const address = await readonlyWallet.getAddress();
1578
- *
1579
- * // But cannot send transactions (type error)
1580
- * // readonlyWallet.send(...); // TypeScript error
1581
- * ```
1582
- */
1583
- toReadonly(): Promise<ReadonlyWallet>;
1584
- /** Returns the delegate manager when delegation support is configured. */
1585
- getDelegateManager(): Promise<IDelegateManager | undefined>;
1586
- /**
1587
- * Settle boarding inputs and/or virtual outputs into a finalized mainnet transaction.
1588
- *
1589
- * `params.inputs` is **ungated** (how an escrowed deposit is recovered by hand), so
1590
- * `settle({ inputs: await wallet.getVtxos() })` bypasses the gate; pass
1591
- * {@link getSpendableVtxos} to settle "whatever is spendable".
1592
- *
1593
- * @param params - Optional settlement inputs and outputs. When omitted, the wallet settles all eligible funds.
1594
- * @param eventCallback - Optional callback invoked for settlement stream events.
1595
- * @param hooks - Optional phases for preparation and intent registration.
1596
- * @returns The finalized Arkade transaction id
1597
- */
1598
- settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void, hooks?: {
1599
- onPhase?: (phase: "preparing" | "registration_attempt") => void;
1600
- }): Promise<string>;
1601
- private _settleImpl;
1602
- /**
1603
- * Rotate-on-board: the boarding analogue of {@link WalletReceiveRotator}'s L2 rotation.
1604
- * Boarding has no on-chain receive event (the watcher sees only the L2 indexer), so a settle
1605
- * consuming a boarding UTXO (a non-VTXO, non-arknote input) is the trigger. No-op without a
1606
- * descriptor provider. Best-effort: the settle has committed, so failures are only logged.
1607
- */
1608
- private maybeRotateBoardingAfterBoard;
1609
- private handleSettlementFinalizationEvent;
1610
- private unsignableBoardingInputError;
1611
- /**
1612
- * Create a batch event handler for settlement flows.
1613
- *
1614
- * @param intentId - The intent ID.
1615
- * @param inputs - Inputs used by the intent.
1616
- * @param expectedRecipients - Expected recipients to validate in the virtual output tree.
1617
- * @param session - Optional musig2 signing session. When omitted, signing steps are skipped.
1618
- */
1619
- createBatchHandler(intentId: string, inputs: ExtendedCoin[], expectedRecipients: Recipient[], session?: SignerSession): Batch.Handler;
1620
- /**
1621
- * Signing jobs keyed by each input's own `witnessUtxo.script`; inputs without one
1622
- * (cosigner/connector) are silently omitted.
1623
- */
1624
- private inputSigningJobsFromWitnessUtxos;
1625
- /**
1626
- * Best-effort upsert into {@link intentRepository}; never throws into the settle path.
1627
- * Preserves fields the event reducer already wrote.
1628
- */
1629
- private persistIntentSnapshot;
1630
- signInputsByWitnessScript(tx: Transaction): Promise<Transaction>;
1631
- signOnchainBoardingTx(tx: Transaction): Promise<Transaction>;
1632
- /** @see IWallet.cosignOnchainTx */
1633
- cosignOnchainTx(psbt: string | Transaction): Promise<string>;
1634
- /** @see IWallet.sendOnchain */
1635
- sendOnchain(params: SendOnchainParams): Promise<string>;
1636
- private _buildOnchainSpend;
1637
- private _cosignOnchainTxImpl;
1638
- /** Boarding outpoints the automatic cosign sweep should renew now (never unrolled exits); excludes coins an intent has locked. */
1639
- getOnchainSweepInputs(): Promise<Outpoint[]>;
1640
- /** Unspent onchain coins from the store; the onchain rows are kept fresh by syncOnchain, not the indexer. */
1641
- private onchainCoins;
1642
- safeRegisterIntent(intent: SignedIntent<Intent.RegisterMessage>, inputs: ExtendedCoin[]): Promise<string>;
1643
- makeRegisterIntentSignature(coins: ExtendedCoin[], outputs: TransactionOutput[], onchainOutputsIndexes: number[], cosignerPubKeys: string[], validAt?: number): Promise<SignedProof<Proof.RegisterMessage>>;
1644
- makeDeleteIntentSignature(coins: ExtendedCoin[]): Promise<SignedProof<Proof.DeleteMessage>>;
1645
- makeGetPendingTxIntentSignature(coins: ExtendedVirtualCoin[]): Promise<SignedProof<Proof.GetPendingTxMessage>>;
1646
- /**
1647
- * Finalizes pending transactions by retrieving them from the operator and finalizing each one.
1648
- * Skips the operator check entirely when no send was interrupted (no pending tx flag set).
1649
- * @param vtxos - Optional list of virtual outputs to use instead of retrieving them from the operator
1650
- * @returns Array of transaction IDs that were finalized
1651
- */
1652
- finalizePendingTxs(vtxos?: ExtendedVirtualCoin[]): Promise<{
1653
- finalized: string[];
1654
- pending: string[];
1655
- }>;
1656
- /**
1657
- * Operator unroll scripts a pending checkpoint may have been built under: configured, current,
1658
- * and one per deprecated signer — else a pre-rotation tx would stay pending forever.
1659
- */
1660
- private checkpointUnrollCandidates;
1661
- private hasPendingTxFlag;
1662
- private setPendingTxFlag;
1663
- /**
1664
- * Create an ArkadeCash bearer instrument: sends `amount` to a DefaultVtxo controlled by a fresh
1665
- * key and returns the encoded token, claimable via `claimCash()` without sharing an address.
1666
- *
1667
- * Short-lived: it carries a private key, so hand it over and claim it promptly. Unclaimed past
1668
- * its batch expiry it is swept, and `claimCash` can only report it.
1669
- *
1670
- * @param amount - Whole sats at or above dust (below dust mints an unspendable OP_RETURN).
1671
- * @returns The encoded arkadeCash string (e.g., "arkadecash1...")
1672
- */
1673
- createCash(amount: number): Promise<string>;
1674
- /**
1675
- * Claim an ArkadeCash bearer instrument: sweep what can be swept, recover what
1676
- * was swept by the operator, report the rest.
1677
- *
1678
- * Every spendable VTXO at the arkadeCash address is swept to this wallet in
1679
- * its own offchain transaction, signed with the key carried by the arkadeCash
1680
- * string. An output the operator already swept at batch expiry cannot move
1681
- * through the thin sweep — only a settlement can lift it — so it is
1682
- * **imported** as a signable `default` contract (the arkadeCash key is filed
1683
- * in the keyring) and handed to the wallet's own recovery machinery, which
1684
- * settles it back on the normal retry cadence. That import is the only
1685
- * thing `claimCash` persists, and the key is purged once recovery
1686
- * completes. Anything neither sweepable nor recoverable — subdust, already
1687
- * claimed, or asset-bearing — is returned in `unclaimed` with a per-VTXO
1688
- * reason and otherwise ignored.
1689
- *
1690
- * The arkadeCash string is the recovery token: a claim interrupted between
1691
- * submit and finalize is completed by simply re-running `claimCash`, which
1692
- * drains any pending arkadeCash transaction at the operator before sweeping.
1693
- * The import is idempotent, so re-running is always safe.
1694
- *
1695
- * @param cashStr - The encoded arkadeCash string (e.g., "arkadecash1...")
1696
- * @returns What was swept instantly, what was imported for recovery, and
1697
- * what was left behind. The shape is open: further buckets may be added.
1698
- */
1699
- claimCash(cashStr: string): Promise<ArkadeCashClaimResult>;
1700
- /**
1701
- * Import an arkadeCash instrument as a signable, recovery-only contract so the
1702
- * wallet's own recovery machinery can settle its operator-swept outputs back.
1703
- *
1704
- * Two writes, both idempotent so a re-run (or a resumed claim) is safe:
1705
- * - the arkadeCash private key is filed in the keyring, returning its
1706
- * `tr(<pubkey>)` descriptor;
1707
- * - a `default` contract for the arkadeCash script is registered carrying that
1708
- * descriptor as `metadata.signingDescriptor` (so the signer router can
1709
- * sign the swept inputs) and `metadata.recoveryOnly` (so the contract is
1710
- * settled in its own isolated intent, never bundled into the wallet's own
1711
- * renewal/recovery — a persistently rejected input then dents only its
1712
- * own recovery, never the wallet's funds).
1713
- *
1714
- * A row may already exist at the script WITHOUT the recovery flags — the
1715
- * public `createContract` surface lets a consumer register the cash
1716
- * address (e.g. to watch a note it issued) — and `createContract`'s
1717
- * same-type idempotency keeps such a row as-is. It is then promoted:
1718
- * presenting the bearer key IS the authorization to claim, and left
1719
- * unflagged the row would feed unsignable swept VTXOs into the wallet's
1720
- * own settles while being invisible to both the isolated recovery pass
1721
- * and `removeRecoveryContract`'s purge.
1722
- */
1723
- private importArkadeCashForRecovery;
1724
- /** Best-effort, non-blocking trigger of the isolated imported-recovery pass. */
1725
- private kickImportedRecovery;
1726
- /**
1727
- * Retire a contract imported for recovery once its funds have been settled
1728
- * back: purge the keyring key that backed it, then delete the contract row.
1729
- * Ends the key-at-rest window opened by {@link importArkadeCashForRecovery}.
1730
- *
1731
- * Scoped to recovery-only contracts as a safety guard — it will not touch a
1732
- * regular wallet contract — and idempotent: a second call (the contract
1733
- * already gone) is a no-op. Invoked by the isolated recovery pass in
1734
- * `VtxoManager` (see its `RecoveryContractCapableWallet` capability).
1735
- *
1736
- * The write order is load-bearing; do not swap it. The two repositories
1737
- * cannot be written atomically, so one of them leaks on a partial failure.
1738
- * Purging the key first leaves a contract row with a dangling descriptor:
1739
- * visible, harmless, and retried to completion by the next recovery pass
1740
- * (its VTXOs read back spent, so nothing is signed). The reverse leaves an
1741
- * unencrypted key that nothing references — the descriptor lived only in
1742
- * the row just deleted — so no retry can ever find it, breaking the
1743
- * purge-on-completion bound that justifies storing it in the clear.
1744
- */
1745
- removeRecoveryContract(script: string): Promise<void>;
1746
- /**
1747
- * Correlate an imported voucher's settlement with the voucher record. This
1748
- * is deliberately kept on wallet state rather than being inferred from the
1749
- * generic recovery row, which has no safe public correlation key. The
1750
- * imported contract carries no cash id, so its script is the join key:
1751
- * the script is the voucher id.
1752
- */
1753
- correlateArkadeCashRecovery(cashId: string, txid: string, amount: number, outcome?: string): Promise<void>;
1754
- /**
1755
- * Split the VTXOs at an arkadeCash address into three buckets: the ones the
1756
- * thin sweep can move (`spendable`), the operator-swept ones that must go
1757
- * through a recovery settlement (`recoverable`), and the ones that can
1758
- * only be reported (`unclaimed`).
1759
- */
1760
- private classifyCashVtxos;
1761
- /** Read every page of an unfiltered VTXO query for the given scripts. */
1762
- private fetchAllVtxos;
1763
- /**
1764
- * Complete sweeps a previous `claimCash` registered but never finalized: a thin
1765
- * {@link finalizePendingTxs} signed with the arkadeCash key. A drained tx pays whoever
1766
- * registered it, so finalizing is still right, but only value paid to `myPkScript` counts.
1767
- *
1768
- * @param vtxos - VTXOs at the cash contract's own pkScript, spent included; any other
1769
- * outpoint (subdust above all) would invalidate the proof.
1770
- * @returns Txs finalized, sats paid to this wallet, and the outpoints consumed to pay it.
1771
- */
1772
- private finalizePendingCashTxs;
1773
- /** Sum the outputs of an ark tx PSBT that pay the given scriptPubKey. */
1774
- private arkTxAmountPaidTo;
1775
- /**
1776
- * Send BTC and/or assets to one or more recipients, passed either as
1777
- * variadic `Recipient`s or as a single `SendParams` object — the latter
1778
- * also carries the virtual outputs to spend.
1779
- *
1780
- * @param args - Recipients, or a `SendParams` object
1781
- * @returns Promise resolving to the Arkade transaction ID
1782
- * @see SendParams
1783
- *
1784
- * @example
1785
- * ```typescript
1786
- * const txid = await wallet.send({
1787
- * address: 'ark1q...',
1788
- * amount: 1000, // (optional, default to dust) btc amount to send to the output
1789
- * assets: [{ assetId: 'abc123...', amount: 50n }] // (optional) list of assets to send
1790
- * });
1791
- *
1792
- * // choosing the inputs as well as the outputs
1793
- * const txid = await wallet.send({
1794
- * recipients: [{ address: 'ark1q...', amount: 1000 }],
1795
- * selectedVtxos: mine, // spent as given, nothing added
1796
- * });
1797
- * ```
1798
- */
1799
- send(...args: [SendParams] | [Recipient, ...Recipient[]]): Promise<string>;
1800
- private _sendImpl;
1801
- /**
1802
- * Shared submit/persist tail of `send` and {@link sendSelectedVtxosToSelf}; callers own coin
1803
- * selection, outputs and the synchronous epoch snapshot.
1804
- */
1805
- private _submitOffchainSpend;
1806
- /**
1807
- * @internal Migration primitive for {@link VtxoManager}: spend the wallet's own
1808
- * deprecated-signer VTXOs into one full-value output on the *active* signer, via the Ark send
1809
- * path (not `settle`) so arkd builds checkpoints against the active epoch. No boarding inputs.
1810
- * The caller must already be on the active signer and have sized the batch. Preserves all
1811
- * input assets; records no `TxSent` history.
1812
- */
1813
- sendSelectedVtxosToSelf(inputs: ExtendedVirtualCoin[], now?: TimeHeight): Promise<string>;
1814
- /**
1815
- * Build an offchain transaction from the given inputs and outputs,
1816
- * sign it, submit to the operator provider, and finalize.
1817
- *
1818
- * Signs whatever it is handed, ungated — see {@link settle} for the trade.
1819
- *
1820
- * @returns The Arkade transaction id and operator-signed checkpoint PSBTs (for bookkeeping)
1821
- */
1822
- buildAndSubmitOffchainTx(inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[], serverUnrollScript?: CSVMultisigTapscript.Type, options?: {
1823
- validUntil?: number;
1824
- }): Promise<{
1825
- arkTxid: string;
1826
- signedCheckpointTxs: string[];
1827
- }>;
1828
- private _buildAndSubmitOffchainTx;
1829
- private updateDbAfterOffchainTx;
1830
- private updateDbAfterSettle;
1831
- }
1832
- /**
1833
- * Select virtual outputs to reach a target amount, prioritizing those closer to expiry
1834
- * @param coins List of virtual outputs to select from
1835
- * @param targetAmount Target amount to reach in satoshis
1836
- * @returns Selected virtual outputs and change amount
1837
- */
1838
- declare function selectVirtualCoins(coins: ExtendedVirtualCoin[], targetAmount: number): {
1839
- inputs: ExtendedVirtualCoin[];
1840
- changeAmount: bigint;
1841
- };
1842
- /**
1843
- * Raised when a wait is cancelled through its `AbortSignal` or `timeoutMs`. `name` is
1844
- * `"AbortError"`, so DOM and SDK aborts can be handled identically.
1845
- */
1846
- declare class AbortError extends Error {
1847
- constructor(message?: string);
1848
- }
1849
- /**
1850
- * A VTXO named for a spend or a hold is held, or already being spent by another operation.
1851
- * Match on `name`, not `instanceof`: only the name survives the service-worker boundary.
1852
- */
1853
- declare class VtxoReservedError extends Error {
1854
- readonly outpoints: readonly string[];
1855
- readonly holder: "in-flight" | "held";
1856
- readonly name = "VtxoReservedError";
1857
- constructor(outpoints: readonly string[], holder: "in-flight" | "held");
1858
- }
1859
- /** A hold placed by {@link Wallet.reserveVtxos}. */
1860
- interface VtxoReservation {
1861
- readonly outpoints: readonly Outpoint[];
1862
- /** Idempotent. */
1863
- release(): void;
1864
- }
1865
- /** @internal Submits an Arkade transaction for {@link Wallet.withSpendLock}'s caller. */
1866
- type OffchainSubmit = (inputs: ExtendedVirtualCoin[], outputs: TransactionOutput[]) => Promise<{
1867
- arkTxid: string;
1868
- signedCheckpointTxs: string[];
1869
- }>;
1870
- /** Options for {@link waitForIncomingFunds}. */
1871
- interface WaitForIncomingFundsOptions {
1872
- /**
1873
- * Cancels the wait. On abort the underlying subscription is stopped and
1874
- * the returned promise rejects — with the signal's `reason` when the
1875
- * caller supplied an `Error`, otherwise an {@link AbortError}.
1876
- */
1877
- signal?: AbortSignal;
1878
- /**
1879
- * Cancels the wait after this many milliseconds, rejecting with an
1880
- * {@link AbortError}. Equivalent to passing an `AbortSignal.timeout`
1881
- * signal, without requiring that API on the target platform.
1882
- */
1883
- timeoutMs?: number;
1884
- }
1885
- /**
1886
- * Wait for incoming funds to the wallet.
1887
- *
1888
- * Keeps live network watchers open until it settles. **Cancel it if you won't await it to
1889
- * completion** (`signal` / `timeoutMs`): a `Promise.race` against a timer abandons the loser
1890
- * without stopping its watchers, and in a loop stacks subscriptions until the process exits.
1891
- *
1892
- * @param wallet - The wallet to wait for incoming funds
1893
- * @param options - Cancellation options; see {@link WaitForIncomingFundsOptions}
1894
- * @returns A promise that resolves the next new coins received by the wallet's address
1895
- * @throws {AbortError} If cancelled via `signal` or `timeoutMs`
1896
- * @example
1897
- * ```typescript
1898
- * // Wake early on a deposit, but give up after 30s and release the watchers.
1899
- * try {
1900
- * const funds = await waitForIncomingFunds(wallet, { timeoutMs: 30_000 })
1901
- * } catch (e) {
1902
- * if ((e as Error).name !== "AbortError") throw e
1903
- * }
1904
- * ```
1905
- */
1906
- declare function waitForIncomingFunds(wallet: NotifiesIncomingFunds, options?: WaitForIncomingFundsOptions): Promise<IncomingFunds>;
1907
-
1908
- /**
1909
- * IndexedDB-based implementation of WalletRepository.
1910
- */
1911
- declare class IndexedDBWalletRepository implements WalletRepository {
1912
- readonly version: 2;
1913
- private readonly connection;
1914
- /** persistentWalletState asserts persistence beyond this process; it cannot detect browser eviction. */
1915
- constructor(dbName?: string, options?: {
1916
- persistentWalletState?: boolean;
1917
- });
1918
- clear(): Promise<void>;
1919
- [Symbol.asyncDispose](): Promise<void>;
1920
- getVtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedVirtualCoin, Outpoint>>;
1921
- saveVtxos(address: string, vtxos: ExtendedVirtualCoin[]): Promise<void>;
1922
- deleteVtxos(address: string): Promise<void>;
1923
- getVtxosForScriptPage(script: string, page: PageRequest<ScriptVtxoCursor>, options?: ScriptVtxoPageOptions): Promise<PageResult<StoredVtxo, ScriptVtxoCursor>>;
1924
- saveVtxosForScript(key: VtxoRepositoryKey, vtxos: ExtendedVirtualCoin[]): Promise<void>;
1925
- deleteVtxosForScript(script: string): Promise<void>;
1926
- getUtxosPage(address: string, page: PageRequest<Outpoint>): Promise<PageResult<ExtendedCoin, Outpoint>>;
1927
- private pageByAddress;
1928
- saveUtxos(addressOrBatch: string | ReadonlyMap<string, ExtendedCoin[]>, utxos?: ExtendedCoin[]): Promise<void>;
1929
- deleteUtxos(address: string): Promise<void>;
1930
- getTransactionHistoryPage(filter: TransactionHistoryPageFilter, page: PageRequest<TransactionHistoryPageCursor>): Promise<PageResult<ArkTransaction, TransactionHistoryPageCursor>>;
1931
- saveTransactions(address: string, txs: ArkTransaction[]): Promise<void>;
1932
- deleteTransactions(address: string): Promise<void>;
1933
- readonly atomicWalletState: AtomicWalletState;
1934
- getWalletState(): Promise<WalletState | null>;
1935
- saveWalletState(state: WalletState): Promise<void>;
1936
- private getDB;
1937
- }
1938
-
1939
- /**
1940
- * A {@link DescriptorProvider} decorator that adds a **keyring**: raw
1941
- * private keys imported from outside the wallet's derivation tree, each
1942
- * addressed by a `tr(<pubkey>)` descriptor.
1943
- *
1944
- * Resolution is union-shaped — `signWithDescriptor` /
1945
- * `signMessageWithDescriptor` serve a descriptor from the wrapped
1946
- * provider's derivation tree *or* from the keyring, whichever owns it —
1947
- * so the wallet's existing descriptor routing
1948
- * (`InputSignerRouter`) signs foreign-key contracts with no changes: an
1949
- * imported contract carrying `metadata.signingDescriptor` is signable by
1950
- * construction rather than throwing `MissingSigningDescriptorError`.
1951
- *
1952
- * Allocation is *not* extended: `getNextSigningDescriptor` always
1953
- * delegates to the wrapped provider. The keyring holds foreign keys the
1954
- * wallet was handed; it never mints receive addresses.
1955
- *
1956
- * Lifecycle: entries persist under
1957
- * `WalletRepository.getWalletState().settings.keyring` (same
1958
- * no-migration pattern as `HDDescriptorProvider`), so an import survives
1959
- * the restarts a recovery spans, and {@link deleteKey} purges it when
1960
- * recovery completes. The repository is the source of truth: the async
1961
- * signing/purge APIs converge on sibling instances' imports and purges
1962
- * (see {@link refresh}), so any tab/worker sharing the repo can complete
1963
- * a recovery another one started.
1964
- *
1965
- * **Keys are stored unencrypted.** This is a deliberate, scoped
1966
- * decision: the intended use is a short-lived, purge-on-completion hold
1967
- * of a key that guards funds already destined for this wallet. At-rest
1968
- * encryption is a possible hardening follow-up. Do not use this to hold
1969
- * long-lived key material.
1970
- *
1971
- * @example
1972
- * ```ts
1973
- * const provider = await KeyringDescriptorProvider.create(hdProvider, walletRepo);
1974
- * const descriptor = await provider.importKey(foreignPrivKey);
1975
- * // descriptor: tr(<x-only pubkey hex>)
1976
- * // ... import a contract with metadata.signingDescriptor = descriptor,
1977
- * // let the wallet's recovery machinery settle it, then:
1978
- * await provider.deleteKey(descriptor);
1979
- * ```
1980
- */
1981
- declare class KeyringDescriptorProvider implements DescriptorProvider {
1982
- /**
1983
- * The wrapped provider. Exposed so callers that need to reach a
1984
- * concrete provider type behind the decorator (e.g. the wallet's
1985
- * restore path, which branches on `HDDescriptorProvider`) can
1986
- * unwrap it rather than mis-classify the decorator.
1987
- */
1988
- readonly base: DescriptorProvider;
1989
- private readonly walletRepository;
1990
- /**
1991
- * In-memory mirror of the persisted keyring, keyed by x-only pubkey
1992
- * hex. Required because {@link isOurs} is synchronous while
1993
- * persistence is not. The **repository is the source of truth**: the
1994
- * async APIs write through to it and {@link refresh} re-seeds this
1995
- * mirror from it when a signing request names a foreign key the
1996
- * mirror doesn't know — a sibling instance (another tab/worker on
1997
- * the same repo) may have imported it after this instance was
1998
- * constructed. The sync views ({@link isOurs}, {@link hasKey},
1999
- * {@link listKeyringDescriptors}) answer from the last-known
2000
- * snapshot.
2001
- */
2002
- private readonly keys;
2003
- private constructor();
2004
- /**
2005
- * Wrap `base` with a keyring, loading any previously imported keys
2006
- * from the repository. Unlike `HDDescriptorProvider.create`, this
2007
- * *does* read at construction: `isOurs` is synchronous and must be
2008
- * able to answer for persisted keys from the first call.
2009
- */
2010
- static create(base: DescriptorProvider, walletRepository: WalletRepository): Promise<KeyringDescriptorProvider>;
2011
- /**
2012
- * Import a raw private key into the keyring and return its
2013
- * `tr(<x-only pubkey>)` descriptor handle. Idempotent: re-importing
2014
- * the same key returns the same descriptor and leaves storage
2015
- * unchanged.
2016
- */
2017
- importKey(privateKey: Uint8Array): Promise<string>;
2018
- /**
2019
- * Purge a keyring entry. Returns `true` when an entry was removed,
2020
- * `false` when the descriptor was not in the keyring (already
2021
- * purged, or never ours) — so a repeated purge is a safe no-op.
2022
- *
2023
- * Always goes through storage, never trusting the in-memory mirror:
2024
- * the entry may have been imported by a sibling instance after this
2025
- * one was constructed, and skipping the persistent purge on a memory
2026
- * miss would leave that key at rest forever.
2027
- */
2028
- deleteKey(descriptor: string): Promise<boolean>;
2029
- /** True iff `descriptor` resolves to a key held in the keyring. */
2030
- hasKey(descriptor: string): boolean;
2031
- /** The `tr(<pubkey>)` descriptors of every key currently held. */
2032
- listKeyringDescriptors(): string[];
2033
- /** Allocation is the wrapped provider's job; the keyring never mints. */
2034
- getNextSigningDescriptor(): Promise<string>;
2035
- /** Ours iff the wrapped provider claims it, or the keyring holds it. */
2036
- isOurs(descriptor: string): boolean;
2037
- /**
2038
- * Signs each request with the key its descriptor resolves to.
2039
- * Keyring-owned requests are signed here; every other request is
2040
- * handed to the wrapped provider in a single batched call, so a
2041
- * batch-signing identity behind a `StaticDescriptorProvider` still
2042
- * sees one interaction.
2043
- *
2044
- * Results are returned in request order regardless of how the
2045
- * requests split across the two signers.
2046
- */
2047
- signWithDescriptor(requests: DescriptorSigningRequest[]): Promise<Transaction[]>;
2048
- /** Signs a message with the keyring key, or delegates to the base. */
2049
- signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
2050
- /**
2051
- * Split requests into keyring-owned and base-delegated buckets.
2052
- * `mayBeStale` is set when a delegated descriptor is foreign-shaped —
2053
- * a sibling instance may have imported its key after this instance
2054
- * seeded the mirror, so the caller should {@link refresh} once and
2055
- * re-split before trusting the delegation.
2056
- */
2057
- private splitRequests;
2058
- /**
2059
- * True when `descriptor` is a bare `tr(<pubkey>)` the base provider
2060
- * does not own — the only shape a keyring entry can have, so the only
2061
- * kind of miss a {@link refresh} could turn into a hit.
2062
- */
2063
- private isForeignShaped;
2064
- /**
2065
- * Re-seed the in-memory mirror from the repository, converging on
2066
- * imports and purges made by sibling instances on the same repo.
2067
- * Full replacement, not a merge, so sibling *deletions* propagate
2068
- * too. Corrupt persisted settings throw, same as {@link create}.
2069
- *
2070
- * Only a *miss* triggers a refresh, so that convergence is one-sided:
2071
- * an entry this instance still believes it holds is never
2072
- * revalidated, and a sibling's purge can linger in this mirror until
2073
- * some unrelated foreign-shaped miss re-seeds it. Harmless today —
2074
- * `deleteKey`'s caller also deletes the contract row carrying the
2075
- * descriptor, so no signing request can name the stale entry — but it
2076
- * means the at-rest purge is not a memory purge for siblings.
2077
- */
2078
- private refresh;
2079
- /**
2080
- * The keyring key for `descriptor`, or `undefined` when the request
2081
- * belongs to the base provider. Base ownership wins on collision:
2082
- * a key already in the derivation tree keeps its established signing
2083
- * path, so importing it cannot reroute existing contracts.
2084
- */
2085
- private resolveKey;
2086
- /**
2087
- * Read-modify-write the keyring settings through `updateWalletState`,
2088
- * whose in-process mutex plus cross-context Web Lock keep concurrent
2089
- * imports/purges — including ones driven from other tabs/workers
2090
- * sharing the store — from clobbering each other's entries.
2091
- */
2092
- private mutate;
2093
- }
2094
-
2095
- export { isHDWalletCapable as $, type AddressAllocationCapable as A, type BatchExpiryPolicy as B, SingleKey as C, DEFAULT_MIN_BATCH_EXPIRY_SECONDS as D, VtxoReservedError as E, ForeignDescriptorError as F, type WaitForIncomingFundsOptions as G, type HDWalletCapable as H, type IncomingFunds as I, WalletCannotAllocateAddressError as J, KeyringDescriptorProvider as K, addArkadeCashRecord as L, MAX_USED_SIGNING_DESCRIPTORS_LOOK_AHEAD as M, type NotifiesIncomingFunds as N, arkadeCashId as O, type ProviderConnectionState as P, arkadeCashResolver as Q, ReadonlyWallet as R, type ServerInfoSource as S, assertValidBatchExpiry as T, createArkadeCashTracker as U, type VtxoReservation as V, Wallet as W, defaultBatchExpiryPolicy as X, isAddressAllocationCapable as Y, isArkError as Z, isHDAllocationCapable as _, type HDAllocationCapable as a, maybeArkError as a0, mergeArkadeCashRecord as a1, resolveBatchExpiryPolicy as a2, resolveDescriptorSigner as a3, selectVirtualCoins as a4, signingDescriptorIndex as a5, strictSigningDescriptorIndex as a6, waitForIncomingFunds as a7, type ArkadeCashTx as b, type ArkadeCashRecord as c, type ArkadeCashClaimResult as d, type ReceiveRotatorFactory as e, type ReceiveRotatorBootOpts as f, type ReceiveRotatorBoot as g, Batch as h, AbortError as i, ArkError as j, ArkErrorName as k, ArkadeCash as l, type ArkadeCashAction as m, ArkadeCashCreateError as n, ArkadeCashOperatorMismatchError as o, type ArkadeCashUnclaimedReason as p, type ArkadeCashUnclaimedVtxo as q, type ArkadeCashVtxoRef as r, type BoardingUtxoGroup as s, HttpResponseError as t, IndexedDBWalletRepository as u, type ProviderKind as v, ProviderUnavailableError as w, REGTEST_MIN_BATCH_EXPIRY_SECONDS as x, ReadonlySingleKey as y, ServerResponseMismatchError as z };