@arkade-os/sdk 0.5.3 → 0.5.5

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 (114) hide show
  1. package/README.md +138 -50
  2. package/dist/adapters/expo.cjs +10 -5
  3. package/dist/adapters/expo.d.cts +13 -8
  4. package/dist/adapters/expo.d.ts +13 -8
  5. package/dist/adapters/expo.js +4 -3
  6. package/dist/{asyncStorageTaskQueue-C9PkPcW_.d.cts → asyncStorageTaskQueue-BbH-THYJ.d.cts} +2 -2
  7. package/dist/{asyncStorageTaskQueue-B3U5gQ-i.d.ts → asyncStorageTaskQueue-BlvkJyTa.d.ts} +2 -2
  8. package/dist/base-C-Y5t_0F.d.cts +359 -0
  9. package/dist/base-C-Y5t_0F.d.ts +359 -0
  10. package/dist/{chunk-OPX2HRWM.js → chunk-4I53THL6.js} +210 -937
  11. package/dist/chunk-4I53THL6.js.map +1 -0
  12. package/dist/{chunk-5WRA66RV.cjs → chunk-5SYUEVJH.cjs} +10 -10
  13. package/dist/chunk-5SYUEVJH.cjs.map +1 -0
  14. package/dist/{chunk-6FL4N4S2.js → chunk-7GIKLFHC.js} +83 -20
  15. package/dist/chunk-7GIKLFHC.js.map +1 -0
  16. package/dist/{chunk-BYPBVHVA.cjs → chunk-AMH7Q3DF.cjs} +61 -935
  17. package/dist/chunk-AMH7Q3DF.cjs.map +1 -0
  18. package/dist/{chunk-P7B4LQ3H.js → chunk-BCA6D255.js} +18 -842
  19. package/dist/chunk-BCA6D255.js.map +1 -0
  20. package/dist/{chunk-T7C3E2HL.js → chunk-CE46RS6L.js} +20 -39
  21. package/dist/chunk-CE46RS6L.js.map +1 -0
  22. package/dist/chunk-DNFTHG73.js +829 -0
  23. package/dist/chunk-DNFTHG73.js.map +1 -0
  24. package/dist/chunk-FDJ734CH.js +882 -0
  25. package/dist/chunk-FDJ734CH.js.map +1 -0
  26. package/dist/chunk-FLPWNMX3.cjs +930 -0
  27. package/dist/chunk-FLPWNMX3.cjs.map +1 -0
  28. package/dist/{chunk-Y4BL3YYX.js → chunk-FVVXCDNE.js} +4 -4
  29. package/dist/chunk-FVVXCDNE.js.map +1 -0
  30. package/dist/{chunk-ZPF4I3K2.cjs → chunk-HQQ4NRXI.cjs} +29 -47
  31. package/dist/chunk-HQQ4NRXI.cjs.map +1 -0
  32. package/dist/chunk-JFJNB7ZH.cjs +884 -0
  33. package/dist/chunk-JFJNB7ZH.cjs.map +1 -0
  34. package/dist/{chunk-KW7ZEWYS.cjs → chunk-KCL5AVML.cjs} +223 -985
  35. package/dist/chunk-KCL5AVML.cjs.map +1 -0
  36. package/dist/{chunk-HAQAWBYG.js → chunk-OO2KEK64.js} +2860 -1366
  37. package/dist/chunk-OO2KEK64.js.map +1 -0
  38. package/dist/{chunk-OUTWUYJ4.cjs → chunk-T254PXSN.cjs} +3337 -1824
  39. package/dist/chunk-T254PXSN.cjs.map +1 -0
  40. package/dist/chunk-V3ZLL5VY.js +380 -0
  41. package/dist/chunk-V3ZLL5VY.js.map +1 -0
  42. package/dist/chunk-X6ZI53DZ.cjs +383 -0
  43. package/dist/chunk-X6ZI53DZ.cjs.map +1 -0
  44. package/dist/{chunk-ZMSM3NOH.cjs → chunk-XWUCNMPN.cjs} +98 -34
  45. package/dist/chunk-XWUCNMPN.cjs.map +1 -0
  46. package/dist/compiler.cjs +50 -0
  47. package/dist/compiler.cjs.map +1 -0
  48. package/dist/compiler.d.cts +38 -0
  49. package/dist/compiler.d.ts +38 -0
  50. package/dist/compiler.js +47 -0
  51. package/dist/compiler.js.map +1 -0
  52. package/dist/contracts/handlers/index.cjs +11 -9
  53. package/dist/contracts/handlers/index.d.cts +6 -4
  54. package/dist/contracts/handlers/index.d.ts +6 -4
  55. package/dist/contracts/handlers/index.js +4 -2
  56. package/dist/{delegate-Cd28gxpM.d.ts → delegate-gGkUnYpi.d.cts} +1 -1
  57. package/dist/{delegate-ByfKszb6.d.cts → delegate-iyDum4fw.d.ts} +1 -1
  58. package/dist/{index-B6X2E7W_.d.ts → index-BWwVnJhU.d.cts} +7 -272
  59. package/dist/{index-DgH_0j14.d.cts → index-Bx-iArDs.d.ts} +7 -272
  60. package/dist/{index-BURzbRup.d.cts → index-DCml4QJn.d.ts} +1090 -1140
  61. package/dist/{index-BURzbRup.d.ts → index-DkyzIzKL.d.cts} +1090 -1140
  62. package/dist/index.cjs +470 -371
  63. package/dist/index.d.cts +687 -410
  64. package/dist/index.d.ts +687 -410
  65. package/dist/index.js +7 -4
  66. package/dist/{wallet-BnmhohgZ.d.ts → keyringDescriptorProvider-CS4w4PWd.d.ts} +427 -372
  67. package/dist/{wallet-BjQugVUt.d.cts → keyringDescriptorProvider-CmHXrIXd.d.cts} +427 -372
  68. package/dist/program-BARSNg3X.d.ts +286 -0
  69. package/dist/program-znrWkxE4.d.cts +286 -0
  70. package/dist/repositories/realm/index.cjs +100 -51
  71. package/dist/repositories/realm/index.cjs.map +1 -1
  72. package/dist/repositories/realm/index.d.cts +25 -10
  73. package/dist/repositories/realm/index.d.ts +25 -10
  74. package/dist/repositories/realm/index.js +72 -24
  75. package/dist/repositories/realm/index.js.map +1 -1
  76. package/dist/repositories/sqlite/index.cjs +222 -131
  77. package/dist/repositories/sqlite/index.cjs.map +1 -1
  78. package/dist/repositories/sqlite/index.d.cts +36 -17
  79. package/dist/repositories/sqlite/index.d.ts +36 -17
  80. package/dist/repositories/sqlite/index.js +196 -107
  81. package/dist/repositories/sqlite/index.js.map +1 -1
  82. package/dist/{taskRunner-BaNCSxqK.d.ts → taskRunner-DgMLSk_O.d.ts} +4 -4
  83. package/dist/{taskRunner-i56-drQV.d.cts → taskRunner-buh6aFpG.d.cts} +4 -4
  84. package/dist/wallet/expo/background.cjs +17 -14
  85. package/dist/wallet/expo/background.cjs.map +1 -1
  86. package/dist/wallet/expo/background.d.cts +5 -4
  87. package/dist/wallet/expo/background.d.ts +5 -4
  88. package/dist/wallet/expo/background.js +10 -7
  89. package/dist/wallet/expo/background.js.map +1 -1
  90. package/dist/wallet/expo/index.cjs +29 -16
  91. package/dist/wallet/expo/index.cjs.map +1 -1
  92. package/dist/wallet/expo/index.d.cts +12 -7
  93. package/dist/wallet/expo/index.d.ts +12 -7
  94. package/dist/wallet/expo/index.js +20 -7
  95. package/dist/wallet/expo/index.js.map +1 -1
  96. package/dist/worker/expo/index.cjs +12 -9
  97. package/dist/worker/expo/index.cjs.map +1 -1
  98. package/dist/worker/expo/index.d.cts +6 -5
  99. package/dist/worker/expo/index.d.ts +6 -5
  100. package/dist/worker/expo/index.js +8 -5
  101. package/dist/worker/expo/index.js.map +1 -1
  102. package/package.json +16 -1
  103. package/dist/chunk-5WRA66RV.cjs.map +0 -1
  104. package/dist/chunk-6FL4N4S2.js.map +0 -1
  105. package/dist/chunk-BYPBVHVA.cjs.map +0 -1
  106. package/dist/chunk-HAQAWBYG.js.map +0 -1
  107. package/dist/chunk-KW7ZEWYS.cjs.map +0 -1
  108. package/dist/chunk-OPX2HRWM.js.map +0 -1
  109. package/dist/chunk-OUTWUYJ4.cjs.map +0 -1
  110. package/dist/chunk-P7B4LQ3H.js.map +0 -1
  111. package/dist/chunk-T7C3E2HL.js.map +0 -1
  112. package/dist/chunk-Y4BL3YYX.js.map +0 -1
  113. package/dist/chunk-ZMSM3NOH.cjs.map +0 -1
  114. package/dist/chunk-ZPF4I3K2.cjs.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { Bytes } from '@scure/btc-signer/utils.js';
2
- import { TransactionInput, TransactionOutput, PSBTOutput } from '@scure/btc-signer/psbt.js';
3
- import { Transaction as Transaction$1, NETWORK } from '@scure/btc-signer';
2
+ import { Transaction as Transaction$1 } from '@scure/btc-signer';
3
+ import { TransactionInput, TransactionOutput } from '@scure/btc-signer/psbt.js';
4
+ import { A as ArkAddress, T as TapLeafScript, E as EncodedVtxoScript, R as RelativeTimelock, V as VtxoScript } from './base-C-Y5t_0F.js';
4
5
  import { TxOpts } from '@scure/btc-signer/transaction.js';
5
6
 
6
7
  /**
@@ -91,6 +92,31 @@ interface SignerSession {
91
92
  }>;
92
93
  sign(): Promise<TreePartialSigs>;
93
94
  }
95
+ /**
96
+ * Custom `Identity.signerSession()` methods can return `TreeSignerSession.random()`
97
+ * to keep the local ephemeral key separate from the wallet's signing key.
98
+ */
99
+ declare class TreeSignerSession implements SignerSession {
100
+ private secretKey;
101
+ static NOT_INITIALIZED: Error;
102
+ private myNonces;
103
+ private aggregateNonces;
104
+ private graph;
105
+ private scriptRoot;
106
+ private rootSharedOutputAmount;
107
+ constructor(secretKey: Uint8Array);
108
+ /** Use a fresh key/session per signing attempt; never reuse sessions or their nonces. */
109
+ static random(): TreeSignerSession;
110
+ init(tree: TxTree, scriptRoot: Uint8Array, rootInputAmount: bigint): Promise<void>;
111
+ getPublicKey(): Promise<Uint8Array>;
112
+ getNonces(): Promise<TreeNonces>;
113
+ aggregatedNonces(txid: string, noncesByPubkey: TreeNonces): Promise<{
114
+ hasAllNonces: boolean;
115
+ }>;
116
+ sign(): Promise<TreePartialSigs>;
117
+ private generateNonces;
118
+ private signPartial;
119
+ }
94
120
 
95
121
  /** A signing request that pairs a descriptor with a transaction. */
96
122
  interface DescriptorSigningRequest {
@@ -134,13 +160,256 @@ interface DescriptorProvider {
134
160
  signMessageWithDescriptor(descriptor: string, message: Uint8Array, type?: "schnorr" | "ecdsa"): Promise<Uint8Array>;
135
161
  }
136
162
 
163
+ /**
164
+ * Off-chain source of previous transactions: ark, tree and checkpoint txs, as
165
+ * base64 PSBTs keyed by txid. Structurally satisfied by `IndexerProvider`.
166
+ */
167
+ interface PrevTxSource {
168
+ getVirtualTxs(txids: string[]): Promise<{
169
+ txs: string[];
170
+ }>;
171
+ }
172
+ /**
173
+ * On-chain source of previous transactions — boarding and commitment txs, which
174
+ * `getVirtualTxs` does not serve. Structurally satisfied by `OnchainProvider`.
175
+ */
176
+ interface RawTxSource {
177
+ getRawTransaction(txid: string): Promise<Uint8Array>;
178
+ }
179
+ /**
180
+ * A previous transaction could not be resolved, so the emulator would reject the
181
+ * submission with `missing prevout tx for input N`. Distinguishes "no source is
182
+ * wired up" from "the source did not have it" — the remedies differ.
183
+ */
184
+ declare class PrevTxUnavailableError extends Error {
185
+ readonly txids: string[];
186
+ constructor(message: string, txids?: string[]);
187
+ }
188
+ /**
189
+ * Resolve raw wire-format bytes for each txid, batched and de-duplicated.
190
+ *
191
+ * Emulator v0.0.7+ requires the raw tx behind every input of a submitted ark tx
192
+ * or proof (`PrevArkTxField`) and of an onchain tx (`PrevoutTxField`).
193
+ * The value is a serialized `wire.MsgTx`, *not* a PSBT — `Transaction.toBytes()`
194
+ * with the default `(withScriptSig=false, withWitness=false)` is exactly the
195
+ * preimage the emulator hashes to check the tx against the outpoint.
196
+ *
197
+ * Off-chain txs are fetched in one batched call; anything the indexer does not
198
+ * serve (a commitment or boarding tx) falls through to `onchain` when supplied.
199
+ */
200
+ declare function resolvePrevTxs(txids: string[], source: PrevTxSource, onchain?: RawTxSource): Promise<Map<string, Uint8Array>>;
201
+ /**
202
+ * Attach `PrevArkTxField` to every input of `tx` that does not already carry
203
+ * one, resolving the bytes for `txids[i]` — the coin input `i` ultimately
204
+ * spends.
205
+ *
206
+ * Inputs already carrying the field are skipped rather than overwritten: the
207
+ * emulator rejects an input with more than one field of the same type, so a
208
+ * caller-supplied value (`Utxo.sourceTx`) must win outright. Nothing is fetched
209
+ * when every input is already covered.
210
+ */
211
+ declare function attachPrevArkTxs(tx: Transaction, txids: string[], source: PrevTxSource, onchain?: RawTxSource): Promise<void>;
212
+ /**
213
+ * Attach `PrevoutTxField` to every input of an onchain PSBT, reading each
214
+ * input's own outpoint — unlike an ark tx, an onchain tx spends its prevout
215
+ * directly, so the txid is in the PSBT already.
216
+ */
217
+ declare function attachPrevoutTxs(tx: Transaction, source: RawTxSource): Promise<void>;
218
+ /**
219
+ * A coin a proof spends, carrying the raw previous tx the emulator needs
220
+ * to resolve its prevout pkScript.
221
+ */
222
+ type WithPrevTx<T> = T & {
223
+ prevTx?: Uint8Array;
224
+ };
225
+ /**
226
+ * Fill in `prevTx` on every coin a proof will spend, in one batched
227
+ * lookup. The proof's synthetic input 0 needs nothing — the emulator synthesises
228
+ * a one-output tx for it — so this covers exactly the coins, which land on proof
229
+ * inputs `1..n`.
230
+ */
231
+ declare function withPrevTxs<T extends {
232
+ txid: string;
233
+ prevTx?: Uint8Array;
234
+ }>(coins: T[], source: PrevTxSource, onchain?: RawTxSource): Promise<T[]>;
235
+
236
+ /**
237
+ * An input of a {@link Proof}: an output it proves ownership of. `prevTx` carries the raw wire
238
+ * bytes of the transaction that created it — required by emulator v0.0.7+ on
239
+ * every real input of a submitted proof. {@link Proof.create} is synchronous,
240
+ * so the bytes are supplied rather than fetched; `withPrevTxs` fills them in.
241
+ */
242
+ type ProofInput = WithPrevTx<ExtendedCoin>;
243
+ /**
244
+ * A signed BIP322-style PSBT carrying a message. Its inputs are Bitcoin outputs,
245
+ * its signature proves the user controls them, and its message says what to do
246
+ * with them.
247
+ *
248
+ * A proof is a deliberately invalid PSBT, so it can never be broadcast. Signing
249
+ * a proof means signing the PSBT as a regular transaction.
250
+ */
251
+ type Proof = Transaction;
252
+ /**
253
+ * Utilities for creating and inspecting {@link Proof}s.
254
+ *
255
+ * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * // Create an unsigned proof
260
+ * const proof = Proof.create(
261
+ * "Hello Bitcoin!",
262
+ * [input],
263
+ * [output]
264
+ * );
265
+ *
266
+ * // Sign the proof
267
+ * const signedProof = await identity.sign(proof);
268
+ * ```
269
+ */
270
+ declare namespace Proof {
271
+ /**
272
+ * Creates an unsigned {@link Proof}.
273
+ *
274
+ * This function constructs a special transaction that can be signed to prove
275
+ * ownership of onchain and virtual outputs. The proof includes the message to be
276
+ * signed and the inputs/outputs that demonstrate ownership.
277
+ *
278
+ * @param message - The message to be signed, either a raw string or a Message object
279
+ * @param ins - Array of transaction inputs to prove ownership of
280
+ * @param outputs - Optional array of transaction outputs
281
+ * @returns An unsigned proof
282
+ */
283
+ function create(message: string | Message, ins: (TransactionInput | ProofInput)[], outputs?: TransactionOutput[]): Proof;
284
+ /**
285
+ * Compute the fee paid by a proof.
286
+ *
287
+ * @param proof - The proof
288
+ * @returns The fee in satoshis
289
+ */
290
+ function fee(proof: Proof): number;
291
+ type RegisterMessage = {
292
+ type: "register";
293
+ onchain_output_indexes: number[];
294
+ valid_at: number;
295
+ expire_at: number;
296
+ cosigners_public_keys: string[];
297
+ };
298
+ type DeleteMessage = {
299
+ type: "delete";
300
+ expire_at: number;
301
+ };
302
+ type GetPendingTxMessage = {
303
+ type: "get-pending-tx";
304
+ expire_at: number;
305
+ };
306
+ type Message = RegisterMessage | DeleteMessage | GetPendingTxMessage;
307
+ /**
308
+ * Serialize a proof message to the canonical JSON string used for signing.
309
+ *
310
+ * @param message - Proof message payload
311
+ * @returns Canonical string form of the message
312
+ */
313
+ function encodeMessage(message: Message): string;
314
+ }
315
+ /** @deprecated Use {@link ProofInput}. */
316
+ type IntentCoin = ProofInput;
317
+ /** @deprecated Use {@link Proof}. */
318
+ declare const Intent: typeof Proof;
319
+ /** @deprecated Use {@link Proof}. */
320
+ declare namespace Intent {
321
+ type Proof = Transaction;
322
+ type RegisterMessage = Proof.RegisterMessage;
323
+ type DeleteMessage = Proof.DeleteMessage;
324
+ type GetPendingTxMessage = Proof.GetPendingTxMessage;
325
+ type Message = Proof.Message;
326
+ }
327
+
328
+ /**
329
+ * Emulator REST client.
330
+ *
331
+ * The emulator is a signing service that executes Arkade scripts
332
+ * and co-signs transactions when the scripts pass validation.
333
+ *
334
+ * The read here goes through `baseFetch`, the SDK's shared fetch boundary, so
335
+ * it picks up whatever policy that boundary carries. The four submit calls
336
+ * deliberately do not: aborting a submit would not tell the caller whether the
337
+ * emulator signed, and none of them has a way to find out, so they stay on the
338
+ * global `fetch` with their transport-error type unchanged.
339
+ */
340
+
341
+ interface EmulatorInfo {
342
+ signerPubkey: string;
343
+ }
344
+ interface EmulatorProvider {
345
+ getInfo(): Promise<EmulatorInfo>;
346
+ submitTx(arkTx: string, checkpointTxs: string[]): Promise<{
347
+ signedArkTx: string;
348
+ signedCheckpointTxs: string[];
349
+ }>;
350
+ /** Signs an intent proof whose covenants pass: a registration, or the delete withdrawing it. */
351
+ submitIntent(intent: {
352
+ proof: string;
353
+ message: Intent.RegisterMessage | Intent.DeleteMessage;
354
+ }): Promise<string>;
355
+ submitFinalization(intent: {
356
+ proof: string;
357
+ message: Proof.RegisterMessage;
358
+ }, forfeits: string[], connectorTree: ConnectorTreeNode[] | null, commitmentTx: string): Promise<{
359
+ signedForfeits: string[];
360
+ signedCommitmentTx?: string;
361
+ }>;
362
+ submitOnchainTx(tx: string): Promise<{
363
+ signedTx: string;
364
+ }>;
365
+ }
366
+ interface ConnectorTreeNode {
367
+ txid: string;
368
+ tx: string;
369
+ children: Record<string, string>;
370
+ }
371
+ /**
372
+ * REST-based emulator client.
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * const client = new RestEmulatorProvider('http://localhost:7073');
377
+ * const info = await client.getInfo();
378
+ * console.log('Emulator pubkey:', info.signerPubkey);
379
+ * ```
380
+ */
381
+ declare class RestEmulatorProvider implements EmulatorProvider {
382
+ serverUrl: string;
383
+ constructor(serverUrl: string);
384
+ getInfo(): Promise<EmulatorInfo>;
385
+ submitTx(arkTx: string, checkpointTxs: string[]): Promise<{
386
+ signedArkTx: string;
387
+ signedCheckpointTxs: string[];
388
+ }>;
389
+ submitIntent(intent: {
390
+ proof: string;
391
+ message: Intent.RegisterMessage | Intent.DeleteMessage;
392
+ }): Promise<string>;
393
+ submitFinalization(intent: {
394
+ proof: string;
395
+ message: Proof.RegisterMessage;
396
+ }, forfeits: string[], connectorTree: ConnectorTreeNode[] | null, commitmentTx: string): Promise<{
397
+ signedForfeits: string[];
398
+ signedCommitmentTx?: string;
399
+ }>;
400
+ submitOnchainTx(tx: string): Promise<{
401
+ signedTx: string;
402
+ }>;
403
+ }
404
+
137
405
  /**
138
406
  * Where the SDK gets its `EventSource`. Node exposes the global only behind
139
407
  * `--experimental-eventsource` (24.x), so it must be injectable.
140
408
  *
141
- * Resolution order, per call: per-provider factory, then {@link configureEventSource}, then the
142
- * global. When none answers, {@link resolveEventSource} throws {@link EventSourceUnavailableError}
143
- * so callers can tell "no SSE in this environment" (don't reconnect) from "connection dropped".
409
+ * Resolution order, per call: per-provider factory, then {@link configureEventSource}, then
410
+ * {@link FetchEventSource} where `fetch` can stream, then the global. When none answers,
411
+ * {@link resolveEventSource} throws {@link EventSourceUnavailableError} so callers can tell
412
+ * "no SSE in this environment" (don't reconnect) from "connection dropped".
144
413
  */
145
414
  /**
146
415
  * The slice of `EventSource` this SDK actually uses. Structural rather than the DOM type because
@@ -152,7 +421,7 @@ interface EventSourceLike {
152
421
  close(): void;
153
422
  }
154
423
  /** Opens an SSE connection to `url`. `new EventSource(url)`, as a value. */
155
- type EventSourceFactory = (url: string) => EventSourceLike;
424
+ type EventSourceFactory = (url: string, headers?: Record<string, string>) => EventSourceLike;
156
425
  /** Options shared by every provider that opens an SSE stream. */
157
426
  interface EventSourceCapable {
158
427
  /**
@@ -175,7 +444,7 @@ declare class EventSourceUnavailableError extends Error {
175
444
  declare function isEventSourceUnavailableError(error: unknown): error is Error;
176
445
  /**
177
446
  * Set the `EventSource` every provider uses by default. Call once at startup,
178
- * before opening a wallet; pass `undefined` to go back to the global.
447
+ * before opening a wallet; pass `undefined` to go back to the default.
179
448
  *
180
449
  * @example
181
450
  * ```typescript
@@ -337,6 +606,30 @@ type GetVtxosOptions = PaginationOptions & {
337
606
  outpoints: Outpoint[];
338
607
  scripts?: never;
339
608
  });
609
+ /** Filters of {@link IndexerProvider.getUtxos}: scripts or outpoints, not both. */
610
+ type GetUtxosOptions = PaginationOptions & ({
611
+ scripts: string[];
612
+ outpoints?: never;
613
+ } | {
614
+ outpoints: Outpoint[];
615
+ scripts?: never;
616
+ });
617
+ /** An onchain coin whose spend the operator signed or watched, and that spend. */
618
+ interface IndexerUtxo extends Outpoint {
619
+ value: number;
620
+ script: string;
621
+ /** Txid of the spend: a batch commitment, a cosigned onchain tx or an unrolled VTXO's spend. */
622
+ spentBy: string;
623
+ /** Set once the spending tx confirms. */
624
+ spendConfirmation?: {
625
+ height: number;
626
+ time: number;
627
+ };
628
+ }
629
+ /** The Arkade server predates `GetUtxos` (arkd v0.9.22). */
630
+ declare class IndexerUtxosUnsupportedError extends Error {
631
+ constructor();
632
+ }
340
633
  interface IndexerProvider {
341
634
  /**
342
635
  * Fetch the virtual output tree for a batch outpoint.
@@ -448,6 +741,15 @@ interface IndexerProvider {
448
741
  vtxos: VirtualCoin[];
449
742
  page?: PageResponse;
450
743
  }>;
744
+ /**
745
+ * Fetch onchain coins whose spend the operator signed or watched: boarding inputs of a
746
+ * batch, inputs of a cosigned onchain tx, and spent unrolled VTXOs. Optional; a server
747
+ * without it throws {@link IndexerUtxosUnsupportedError}.
748
+ */
749
+ getUtxos?(opts: GetUtxosOptions): Promise<{
750
+ utxos: IndexerUtxo[];
751
+ page?: PageResponse;
752
+ }>;
451
753
  /**
452
754
  * Fetch metadata for a specific asset id.
453
755
  *
@@ -485,6 +787,8 @@ declare class RestIndexerProvider implements IndexerProvider {
485
787
  serverUrl: string;
486
788
  /** Overrides {@link configureEventSource} for this provider's subscription. */
487
789
  protected readonly eventSource?: EventSourceFactory;
790
+ /** Set by a 404 for this provider's lifetime: a server upgraded meanwhile needs a new one. */
791
+ private utxosUnsupported;
488
792
  /** @see fetchVtxosJson */
489
793
  private readonly inFlightVtxoReads;
490
794
  constructor(serverUrl?: string, options?: EventSourceCapable);
@@ -538,6 +842,10 @@ declare class RestIndexerProvider implements IndexerProvider {
538
842
  * delta-syncs that contract on both arms.
539
843
  */
540
844
  private fetchVtxosJson;
845
+ getUtxos(opts: GetUtxosOptions): Promise<{
846
+ utxos: IndexerUtxo[];
847
+ page?: PageResponse;
848
+ }>;
541
849
  getAssetDetails(assetId: string): Promise<AssetDetails>;
542
850
  subscribeForScripts(scripts: string[], subscriptionId?: string, signal?: AbortSignal): Promise<string>;
543
851
  unsubscribeForScripts(subscriptionId: string, scripts?: string[]): Promise<void>;
@@ -583,166 +891,31 @@ interface FeeOutput {
583
891
  }
584
892
 
585
893
  /**
586
- * Off-chain source of previous transactions: ark, tree and checkpoint txs, as
587
- * base64 PSBTs keyed by txid. Structurally satisfied by `IndexerProvider`.
894
+ * Thrown by {@link RestOperatorProvider} when arkd rejects a request with
895
+ * `DIGEST_MISMATCH` — the client's cached operator info was stale (e.g. an
896
+ * operator signer rotation). By the time this surfaces the provider has already
897
+ * refreshed its info and fired `onServerInfoChanged`; the caller should rebuild
898
+ * the request under the fresh operator info and retry. Mirrors NArk's
899
+ * `DigestMismatchException` (dotnet-sdk #131): the SDK never silently retries.
588
900
  */
589
- interface PrevTxSource {
590
- getVirtualTxs(txids: string[]): Promise<{
591
- txs: string[];
592
- }>;
901
+ declare class DigestMismatchError extends Error {
902
+ constructor(message: string);
593
903
  }
594
- /**
595
- * On-chain source of previous transactions — boarding and commitment txs, which
596
- * `getVirtualTxs` does not serve. Structurally satisfied by `OnchainProvider`.
597
- */
598
- interface RawTxSource {
599
- getRawTransaction(txid: string): Promise<Uint8Array>;
904
+ declare class OnchainCosignUnsupportedError extends Error {
905
+ constructor();
600
906
  }
601
- /**
602
- * A previous transaction could not be resolved, so the emulator would reject the
603
- * submission with `missing prevout tx for input N`. Distinguishes "no source is
604
- * wired up" from "the source did not have it" — the remedies differ.
605
- */
606
- declare class PrevTxUnavailableError extends Error {
607
- readonly txids: string[];
608
- constructor(message: string, txids?: string[]);
609
- }
610
- /**
611
- * Resolve raw wire-format bytes for each txid, batched and de-duplicated.
612
- *
613
- * Emulator v0.0.7+ requires the raw tx behind every input of a submitted ark tx
614
- * or intent proof (`PrevArkTxField`) and of an onchain tx (`PrevoutTxField`).
615
- * The value is a serialized `wire.MsgTx`, *not* a PSBT — `Transaction.toBytes()`
616
- * with the default `(withScriptSig=false, withWitness=false)` is exactly the
617
- * preimage the emulator hashes to check the tx against the outpoint.
618
- *
619
- * Off-chain txs are fetched in one batched call; anything the indexer does not
620
- * serve (a commitment or boarding tx) falls through to `onchain` when supplied.
621
- */
622
- declare function resolvePrevTxs(txids: string[], source: PrevTxSource, onchain?: RawTxSource): Promise<Map<string, Uint8Array>>;
623
- /**
624
- * Attach `PrevArkTxField` to every input of `tx` that does not already carry
625
- * one, resolving the bytes for `txids[i]` — the coin input `i` ultimately
626
- * spends.
627
- *
628
- * Inputs already carrying the field are skipped rather than overwritten: the
629
- * emulator rejects an input with more than one field of the same type, so a
630
- * caller-supplied value (`Utxo.sourceTx`) must win outright. Nothing is fetched
631
- * when every input is already covered.
632
- */
633
- declare function attachPrevArkTxs(tx: Transaction, txids: string[], source: PrevTxSource, onchain?: RawTxSource): Promise<void>;
634
- /**
635
- * Attach `PrevoutTxField` to every input of an onchain PSBT, reading each
636
- * input's own outpoint — unlike an ark tx, an onchain tx spends its prevout
637
- * directly, so the txid is in the PSBT already.
638
- */
639
- declare function attachPrevoutTxs(tx: Transaction, source: RawTxSource): Promise<void>;
640
- /**
641
- * A coin an intent proof spends, carrying the raw previous tx the emulator needs
642
- * to resolve its prevout pkScript.
643
- */
644
- type WithPrevTx<T> = T & {
645
- prevTx?: Uint8Array;
646
- };
647
- /**
648
- * Fill in `prevTx` on every coin an intent proof will spend, in one batched
649
- * lookup. The proof's synthetic input 0 needs nothing — the emulator synthesises
650
- * a one-output tx for it — so this covers exactly the coins, which land on proof
651
- * inputs `1..n`.
652
- */
653
- declare function withPrevTxs<T extends {
654
- txid: string;
655
- prevTx?: Uint8Array;
656
- }>(coins: T[], source: PrevTxSource, onchain?: RawTxSource): Promise<T[]>;
657
-
658
- /**
659
- * A coin an intent proof proves ownership of. `prevTx` carries the raw wire
660
- * bytes of the transaction that created it — required by emulator v0.0.7+ on
661
- * every real input of a submitted proof. {@link Intent.create} is synchronous,
662
- * so the bytes are supplied rather than fetched; `withPrevTxs` fills them in.
663
- */
664
- type IntentCoin = WithPrevTx<ExtendedCoin>;
665
- /**
666
- * Intent proof implementation for Bitcoin message signing.
667
- *
668
- * Intent proof defines a standard for signing Bitcoin messages as well as proving
669
- * ownership of outputs.
670
- *
671
- * This namespace provides utilities for creating and validating Intent proof.
672
- *
673
- * It is greatly inspired by BIP322.
674
- * @see https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
675
- *
676
- * @example
677
- * ```typescript
678
- * // Create a Intent proof
679
- * const proof = Intent.create(
680
- * "Hello Bitcoin!",
681
- * [input],
682
- * [output]
683
- * );
684
- *
685
- * // Sign the proof
686
- * const signedProof = await identity.sign(proof);
687
- *
688
- */
689
- declare namespace Intent {
690
- type Proof = Transaction;
691
- /**
692
- * Creates a new Intent proof unsigned transaction.
693
- *
694
- * This function constructs a special transaction that can be signed to prove
695
- * ownership of onchain and virtual outputs. The proof includes the message to be
696
- * signed and the inputs/outputs that demonstrate ownership.
697
- *
698
- * @param message - The Intent message to be signed, either raw string of Message object
699
- * @param ins - Array of transaction inputs to prove ownership of
700
- * @param outputs - Optional array of transaction outputs
701
- * @returns An unsigned Intent proof transaction
702
- */
703
- function create(message: string | Message, ins: (TransactionInput | IntentCoin)[], outputs?: TransactionOutput[]): Proof;
704
- /**
705
- * Compute the fee paid by an intent proof transaction.
706
- *
707
- * @param proof - Intent proof transaction
708
- * @returns The fee in satoshis
709
- */
710
- function fee(proof: Proof): number;
711
- type RegisterMessage = {
712
- type: "register";
713
- onchain_output_indexes: number[];
714
- valid_at: number;
715
- expire_at: number;
716
- cosigners_public_keys: string[];
717
- };
718
- type DeleteMessage = {
719
- type: "delete";
720
- expire_at: number;
721
- };
722
- type GetPendingTxMessage = {
723
- type: "get-pending-tx";
724
- expire_at: number;
725
- };
726
- type Message = RegisterMessage | DeleteMessage | GetPendingTxMessage;
727
- /**
728
- * Serialize an intent message to the canonical JSON string used for signing.
729
- *
730
- * @param message - Intent message payload
731
- * @returns Canonical string form of the message
732
- */
733
- function encodeMessage(message: Message): string;
734
- }
735
-
736
- /**
737
- * Thrown by {@link RestArkProvider} when arkd rejects a request with
738
- * `DIGEST_MISMATCH` — the client's cached server info was stale (e.g. an
739
- * operator signer rotation). By the time this surfaces the provider has already
740
- * refreshed its info and fired `onServerInfoChanged`; the caller should rebuild
741
- * the request under the fresh server info and retry. Mirrors NArk's
742
- * `DigestMismatchException` (dotnet-sdk #131): the SDK never silently retries.
743
- */
744
- declare class DigestMismatchError extends Error {
745
- constructor(message: string);
907
+ /** arkd's structured error name is carried in the message as `[NAME] ` so it survives structured clone. */
908
+ declare class OnchainCosignRejectedError extends Error {
909
+ readonly serverMessage: string;
910
+ readonly arkErrorName?: string | undefined;
911
+ constructor(serverMessage: string, arkErrorName?: string | undefined);
912
+ }
913
+ /** The cosign request may have broadcast the tx: never retry the payment with other coins. */
914
+ declare class OnchainCosignAmbiguousError extends Error {
915
+ readonly detail: string;
916
+ constructor(detail: string, options?: {
917
+ cause?: unknown;
918
+ });
746
919
  }
747
920
  /** Output requested during settlement or transaction submission. */
748
921
  type Output = {
@@ -835,7 +1008,7 @@ interface PendingTx {
835
1008
  }
836
1009
  interface DeprecatedSigner {
837
1010
  /**
838
- * Unix timestamp (seconds) after which the server no longer accepts this
1011
+ * Unix timestamp (seconds) after which the operator no longer accepts this
839
1012
  * signer's VTXOs as cooperative-migration inputs. arkd advertises this as a
840
1013
  * non-nullable field, so it is always present: `0n` is the sentinel for "no
841
1014
  * cutoff advertised" — the deprecated signer is due for migration
@@ -847,20 +1020,22 @@ interface DeprecatedSigner {
847
1020
  pubkey: string;
848
1021
  }
849
1022
  type ServiceStatus = Record<string, string>;
1023
+ /** @deprecated Use {@link OperatorInfo}. */
1024
+ type ArkadeInfo = OperatorInfo;
850
1025
  /**
851
- * The Arkade server's advertised configuration — the `/v1/info` response.
1026
+ * The operator's advertised configuration, the `/v1/info` response.
852
1027
  *
853
1028
  * Naming/placement vs the NArk reference (AGENTS.md asks divergences to be
854
1029
  * noted): NArk calls this `ArkServerInfo`, reads it via `GetServerInfoAsync`
855
1030
  * on the *transport*, and caches it in a dedicated `CachingClientTransport`.
856
- * This SDK names it for the product (`ArkadeInfo`, per #734) and hangs the
857
- * read off the wallet (`getArkadeInfo()`), because here the wallet is the one
1031
+ * This SDK names it for the operator and hangs the
1032
+ * read off the wallet, because here the wallet is the one
858
1033
  * object every consumer already holds and — in the service-worker model — the
859
1034
  * only side that has a transport at all; the page has no provider to hang it
860
1035
  * on. The `CachingClientTransport`-style memo lives at this layer instead, as
861
- * `CachingArkProvider`.
1036
+ * `CachingOperatorProvider`.
862
1037
  */
863
- interface ArkadeInfo {
1038
+ interface OperatorInfo {
864
1039
  boardingExitDelay: bigint;
865
1040
  checkpointTapscript: string;
866
1041
  deprecatedSigners: DeprecatedSigner[];
@@ -882,20 +1057,20 @@ interface ArkadeInfo {
882
1057
  */
883
1058
  vtxoTreeExpiry?: bigint;
884
1059
  /**
885
- * Weight budget an ark transaction must stay under; the server answers
1060
+ * Weight budget a transaction must stay under; the operator answers
886
1061
  * `TX_TOO_LARGE` past it.
887
1062
  *
888
- * `undefined` when not advertised — a server that omits the field and one
889
- * that sends `0` both mean "no limit stated". Never `0n`, which would read
890
- * as a server that accepts no transaction at all.
1063
+ * `undefined` when not advertised. Omitting the field and sending `0` both
1064
+ * mean "no limit stated". Never `0n`, which would say the operator accepts
1065
+ * no transaction at all.
891
1066
  */
892
1067
  maxTxWeight?: bigint;
893
1068
  /**
894
- * Maximum OP_RETURN outputs the server accepts per transaction.
1069
+ * Maximum OP_RETURN outputs the operator accepts per transaction.
895
1070
  *
896
- * `undefined` when not advertised — a server that omits the field and one
897
- * that sends `0` both mean "no limit stated". Never `0n`, which would read
898
- * as a server that forbids them outright.
1071
+ * `undefined` when not advertised. Omitting the field and sending `0` both
1072
+ * mean "no limit stated". Never `0n`, which would say the operator forbids
1073
+ * them outright.
899
1074
  */
900
1075
  maxOpReturnOutputs?: bigint;
901
1076
  /**
@@ -916,14 +1091,16 @@ interface ArkadeInfo {
916
1091
  vtxoMaxAmount: bigint;
917
1092
  vtxoMinAmount: bigint;
918
1093
  }
919
- /** Signed intent payload sent to the Arkade server. */
920
- interface SignedIntent<T extends Intent.Message> {
1094
+ /** A signed {@link Proof} and its message, as sent to the operator. */
1095
+ interface SignedProof<T extends Proof.Message> {
921
1096
  /** Base64-encoded signed proof transaction. */
922
1097
  proof: string;
923
- /** Intent message payload associated with the proof. */
1098
+ /** Message the proof commits to. */
924
1099
  message: T;
925
1100
  }
926
- /** Transaction notification emitted by the Arkade server stream. */
1101
+ /** @deprecated Use {@link SignedProof}. */
1102
+ type SignedIntent<T extends Proof.Message> = SignedProof<T>;
1103
+ /** Transaction notification emitted by the operator's stream. */
927
1104
  interface TxNotification {
928
1105
  /** Transaction id. */
929
1106
  txid: string;
@@ -947,13 +1124,13 @@ interface TxNotification {
947
1124
  interface SweepTxNotification extends TxNotification {
948
1125
  /**
949
1126
  * Outpoints the transaction swept — outpoints rather than virtual outputs,
950
- * because a swept output is gone: the server has nothing left to describe
1127
+ * because a swept output is gone: the operator has nothing left to describe
951
1128
  * beyond where it was. Empty when the sweep touched none of them.
952
1129
  */
953
1130
  sweptVtxos: Outpoint[];
954
1131
  }
955
1132
  /**
956
- * One frame of {@link ArkProvider.getTransactionsStream}. Exactly one arm is
1133
+ * One frame of {@link OperatorProvider.getTransactionsStream}. Exactly one arm is
957
1134
  * set; an unrecognized frame is dropped rather than yielded.
958
1135
  */
959
1136
  interface TxNotificationEvent {
@@ -961,9 +1138,11 @@ interface TxNotificationEvent {
961
1138
  arkTx?: TxNotification;
962
1139
  sweepTx?: SweepTxNotification;
963
1140
  }
964
- interface ArkProvider {
965
- /** Fetch Arkade server configuration and fee settings. */
966
- getInfo(): Promise<ArkadeInfo>;
1141
+ interface OperatorProvider {
1142
+ /** Fetch the operator's configuration and fee settings. */
1143
+ getInfo(): Promise<OperatorInfo>;
1144
+ /** Cosign and broadcast an onchain tx spending server-cosigned UTXOs; returns the txid. */
1145
+ cosignOnchainTx?(psbtB64: string): Promise<string>;
967
1146
  /** Submit a signed Arkade transaction and its checkpoint transactions. */
968
1147
  submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
969
1148
  arkTxid: string;
@@ -972,7 +1151,7 @@ interface ArkProvider {
972
1151
  }>;
973
1152
  /** Finalize a previously submitted Arkade transaction. */
974
1153
  finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
975
- /** Register a signed intent with the Arkade server. */
1154
+ /** Register a signed intent with the operator. */
976
1155
  registerIntent(intent: SignedIntent<Intent.RegisterMessage>): Promise<string>;
977
1156
  /** Delete a previously registered intent. */
978
1157
  deleteIntent(intent: SignedIntent<Intent.DeleteMessage>): Promise<void>;
@@ -986,44 +1165,45 @@ interface ArkProvider {
986
1165
  submitSignedForfeitTxs(signedForfeitTxs: string[], signedCommitmentTx?: string): Promise<void>;
987
1166
  /** Open the settlement event stream for the given topics. */
988
1167
  getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
989
- /** Stream transaction notifications emitted by the Arkade server. */
1168
+ /** Stream transaction notifications emitted by the operator. */
990
1169
  getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<TxNotificationEvent>;
991
1170
  /** Fetch pending transactions for a signed get-pending-tx intent. */
992
- getPendingTxs(intent: SignedIntent<Intent.GetPendingTxMessage>): Promise<PendingTx[]>;
1171
+ getPendingTxs(intent: SignedProof<Proof.GetPendingTxMessage>): Promise<PendingTx[]>;
993
1172
  }
994
1173
  /**
995
- * REST-based Arkade provider implementation.
1174
+ * REST-based operator provider implementation.
996
1175
  *
997
1176
  * @see https://buf.build/arkade-os/arkd/docs/main:ark.v1#ark.v1.ArkService
998
1177
  * @example
999
1178
  * ```typescript
1000
- * const provider = new RestArkProvider('https://arkade.computer');
1179
+ * const provider = new RestOperatorProvider('https://arkade.computer');
1001
1180
  * const info = await provider.getInfo();
1002
1181
  * ```
1003
1182
  */
1004
- declare class RestArkProvider implements ArkProvider {
1183
+ declare class RestOperatorProvider implements OperatorProvider {
1005
1184
  serverUrl: string;
1006
1185
  /** Overrides {@link configureEventSource} for this provider's streams. */
1007
1186
  protected readonly eventSource?: EventSourceFactory;
1008
1187
  constructor(serverUrl?: string, options?: EventSourceCapable);
1009
1188
  /**
1010
- * Last server-info digest seen (from {@link getInfo}). Sent as `X-Digest`
1189
+ * Last operator info digest seen (from {@link getInfo}). Sent as `X-Digest`
1011
1190
  * on outgoing requests so arkd can reject a client whose cached info is
1012
1191
  * stale. Empty until the first {@link getInfo}.
1013
1192
  */
1014
1193
  private _digest;
1194
+ private _onchainCosignUnsupported;
1015
1195
  private _hasServerInfo;
1016
1196
  private _suppressNextGetInfoChangeEmit;
1017
1197
  private _serverInfoListeners;
1018
1198
  /**
1019
- * Subscribe to server-info changes. Fired after a stale-info
1199
+ * Subscribe to operator info changes. Fired after a stale-info
1020
1200
  * `DIGEST_MISMATCH` refresh or when {@link getInfo} observes a changed digest.
1021
1201
  * Returns an unsubscribe function.
1022
1202
  */
1023
1203
  onServerInfoChanged(listener: (info: ArkadeInfo) => void): () => void;
1024
1204
  private emitServerInfoChanged;
1025
1205
  /**
1026
- * `fetch` wrapper for arkd requests that participates in server-info digest
1206
+ * `fetch` wrapper for arkd requests that participates in operator info digest
1027
1207
  * negotiation. Sends the cached `X-Digest`; when arkd rejects a request with
1028
1208
  * `DIGEST_MISMATCH`, refreshes {@link getInfo} (updating the digest), fires
1029
1209
  * {@link onServerInfoChanged}, and THROWS {@link DigestMismatchError} — it
@@ -1034,12 +1214,13 @@ declare class RestArkProvider implements ArkProvider {
1034
1214
  */
1035
1215
  private authedFetch;
1036
1216
  private postJson;
1037
- getInfo(): Promise<ArkadeInfo>;
1217
+ getInfo(): Promise<OperatorInfo>;
1038
1218
  submitTx(signedArkTx: string, checkpointTxs: string[]): Promise<{
1039
1219
  arkTxid: string;
1040
1220
  finalArkTx: string;
1041
1221
  signedCheckpointTxs: string[];
1042
1222
  }>;
1223
+ cosignOnchainTx(psbtB64: string): Promise<string>;
1043
1224
  finalizeTx(arkTxid: string, finalCheckpointTxs: string[]): Promise<void>;
1044
1225
  registerIntent(intent: SignedIntent<Intent.RegisterMessage>): Promise<string>;
1045
1226
  deleteIntent(intent: SignedIntent<Intent.DeleteMessage>): Promise<void>;
@@ -1049,7 +1230,7 @@ declare class RestArkProvider implements ArkProvider {
1049
1230
  submitSignedForfeitTxs(signedForfeitTxs: string[], signedCommitmentTx?: string): Promise<void>;
1050
1231
  getEventStream(signal: AbortSignal, topics: string[]): AsyncIterableIterator<SettlementEvent>;
1051
1232
  getTransactionsStream(signal: AbortSignal): AsyncIterableIterator<TxNotificationEvent>;
1052
- getPendingTxs(intent: SignedIntent<Intent.GetPendingTxMessage>): Promise<PendingTx[]>;
1233
+ getPendingTxs(intent: SignedProof<Proof.GetPendingTxMessage>): Promise<PendingTx[]>;
1053
1234
  protected parseSettlementEvent(data: ProtoTypes.GetEventStreamResponse): SettlementEvent | null;
1054
1235
  protected parseTransactionNotification(data: ProtoTypes.GetTransactionsStreamResponse): TxNotificationEvent | null;
1055
1236
  }
@@ -1159,360 +1340,12 @@ declare namespace ProtoTypes {
1159
1340
  }
1160
1341
  export { };
1161
1342
  }
1162
-
1163
- /**
1164
- * RelativeTimelock lets to create timelocked with CHECKSEQUENCEVERIFY script.
1165
- *
1166
- * @example
1167
- * ```typescript
1168
- * const timelock = { value: 144n, type: "blocks" }; // 1 day in blocks
1169
- * const timelock = { value: 512n, type: "seconds" }; // 8 minutes in seconds
1170
- * ```
1171
- */
1172
- type RelativeTimelock = {
1173
- value: bigint;
1174
- type: "seconds" | "blocks";
1175
- };
1176
- declare enum TapscriptType {
1177
- Multisig = "multisig",
1178
- CSVMultisig = "csv-multisig",
1179
- ConditionCSVMultisig = "condition-csv-multisig",
1180
- ConditionMultisig = "condition-multisig",
1181
- CLTVMultisig = "cltv-multisig"
1182
- }
1183
- /**
1184
- * ArkTapscript is the base element of vtxo scripts.
1185
- * It is used to encode and decode the different types of vtxo scripts.
1186
- */
1187
- interface ArkTapscript<T extends TapscriptType, Params> {
1188
- type: T;
1189
- params: Params;
1190
- script: Uint8Array;
1191
- }
1192
- /**
1193
- * decodeTapscript is a function that decodes an Arkade tapscript from a raw script.
1194
- *
1195
- * @throws {Error} if the script is not a valid Arkade tapscript
1196
- * @example
1197
- * ```typescript
1198
- * const arkTapscript = decodeTapscript(new Uint8Array(32));
1199
- * console.log("type:", arkTapscript.type);
1200
- * ```
1201
- */
1202
- declare function decodeTapscript(script: Uint8Array): ArkTapscript<TapscriptType, any>;
1203
- /**
1204
- * Implements a multi-signature tapscript.
1205
- *
1206
- * <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
1207
- *
1208
- * @example
1209
- * ```typescript
1210
- * const multisigTapscript = MultisigTapscript.encode({ pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
1211
- * ```
1212
- */
1213
- declare namespace MultisigTapscript {
1214
- type Type = ArkTapscript<TapscriptType.Multisig, Params>;
1215
- enum MultisigType {
1216
- CHECKSIG = 0,
1217
- CHECKSIGADD = 1
1218
- }
1219
- type Params = {
1220
- pubkeys: Bytes[];
1221
- type?: MultisigType;
1222
- };
1223
- /** Encode a plain multisig tapscript. */
1224
- function encode(params: Params): Type;
1225
- /** Decode a plain multisig tapscript from raw script bytes. */
1226
- function decode(script: Uint8Array): Type;
1227
- /** Return true when the tapscript is a plain multisig tapscript. */
1228
- function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
1229
- }
1230
- /**
1231
- * Implements a relative timelock script that requires all specified pubkeys to sign
1232
- * after the relative timelock has expired. The timelock can be specified in blocks or seconds.
1233
- *
1234
- * This is the standard exit closure and it is also used for the sweep closure in vtxo trees.
1235
- *
1236
- * <sequence> CHECKSEQUENCEVERIFY DROP <pubkey> CHECKSIG
1237
- *
1238
- * @example
1239
- * ```typescript
1240
- * const csvMultisigTapscript = CSVMultisigTapscript.encode({ timelock: { type: "blocks", value: 144 }, pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
1241
- * ```
1242
- */
1243
- declare namespace CSVMultisigTapscript {
1244
- type Type = ArkTapscript<TapscriptType.CSVMultisig, Params>;
1245
- type Params = {
1246
- timelock: RelativeTimelock;
1247
- } & MultisigTapscript.Params;
1248
- /** Encode a CSV multisig tapscript. */
1249
- function encode(params: Params): Type;
1250
- /** Decode a CSV multisig tapscript from raw script bytes. */
1251
- function decode(script: Uint8Array): Type;
1252
- /** Return true when the tapscript is a CSV multisig tapscript. */
1253
- function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
1254
- function isScriptValid(script: Uint8Array): true | Error;
1255
- }
1256
- /**
1257
- * Combines a condition script with an exit closure. The resulting script requires
1258
- * the condition to be met, followed by the standard exit closure requirements
1259
- * (timelock and signatures).
1260
- *
1261
- * <conditionScript> VERIFY <sequence> CHECKSEQUENCEVERIFY DROP <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
1262
- *
1263
- * @example
1264
- * ```typescript
1265
- * const conditionCSVMultisigTapscript = ConditionCSVMultisigTapscript.encode({ conditionScript: new Uint8Array(32), pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
1266
- * ```
1267
- */
1268
- declare namespace ConditionCSVMultisigTapscript {
1269
- type Type = ArkTapscript<TapscriptType.ConditionCSVMultisig, Params>;
1270
- type Params = {
1271
- conditionScript: Bytes;
1272
- } & CSVMultisigTapscript.Params;
1273
- /** Encode a condition + CSV multisig tapscript. */
1274
- function encode(params: Params): Type;
1275
- /** Decode a condition + CSV multisig tapscript from raw script bytes. */
1276
- function decode(script: Uint8Array): Type;
1277
- /** Return true when the tapscript is a condition + CSV multisig tapscript. */
1278
- function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
1279
- function isScriptValid(script: Uint8Array): true | Error;
1280
- }
1281
- /**
1282
- * Combines a condition script with a forfeit closure. The resulting script requires
1283
- * the condition to be met, followed by the standard forfeit closure requirements
1284
- * (multi-signature).
1285
- *
1286
- * <conditionScript> VERIFY <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
1287
- *
1288
- * @example
1289
- * ```typescript
1290
- * const conditionMultisigTapscript = ConditionMultisigTapscript.encode({ conditionScript: new Uint8Array(32), pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
1291
- * ```
1292
- */
1293
- declare namespace ConditionMultisigTapscript {
1294
- type Type = ArkTapscript<TapscriptType.ConditionMultisig, Params>;
1295
- type Params = {
1296
- conditionScript: Bytes;
1297
- } & MultisigTapscript.Params;
1298
- /** Encode a condition + multisig tapscript. */
1299
- function encode(params: Params): Type;
1300
- /** Decode a condition + multisig tapscript from raw script bytes. */
1301
- function decode(script: Uint8Array): Type;
1302
- /** Return true when the tapscript is a condition + multisig tapscript. */
1303
- function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
1304
- function isScriptValid(script: Uint8Array): true | Error;
1305
- }
1306
- /**
1307
- * Implements an absolute timelock (CLTV) script combined with a forfeit closure.
1308
- * The script requires waiting until a specific block height/timestamp before the
1309
- * forfeit closure conditions can be met.
1310
- *
1311
- * <locktime> CHECKLOCKTIMEVERIFY DROP <pubkey> CHECKSIGVERIFY <pubkey> CHECKSIG
1312
- *
1313
- * @example
1314
- * ```typescript
1315
- * const cltvMultisigTapscript = CLTVMultisigTapscript.encode({ absoluteTimelock: 144, pubkeys: [new Uint8Array(32), new Uint8Array(32)] });
1316
- * ```
1317
- */
1318
- declare namespace CLTVMultisigTapscript {
1319
- type Type = ArkTapscript<TapscriptType.CLTVMultisig, Params>;
1320
- type Params = {
1321
- absoluteTimelock: bigint;
1322
- } & MultisigTapscript.Params;
1323
- /** Encode a CLTV multisig tapscript. */
1324
- function encode(params: Params): Type;
1325
- /** Decode a CLTV multisig tapscript from raw script bytes. */
1326
- function decode(script: Uint8Array): Type;
1327
- /** Return true when the tapscript is a CLTV multisig tapscript. */
1328
- function is(tapscript: ArkTapscript<any, any>): tapscript is Type;
1329
- function isScriptValid(script: Uint8Array): true | Error;
1330
- }
1331
-
1332
- /**
1333
- * ArkAddress allows creating and decoding bech32m-encoded Arkade addresses: an hrp plus a
1334
- * 65-byte payload of version byte ‖ 32-byte server pubkey ‖ 32-byte VTXO taproot key.
1335
- *
1336
- * @remarks
1337
- * This is an Arkade-specific address format.
1338
- * It is distinct from the Taproot onchain address returned by `VtxoScript.onchainAddress`.
1339
- *
1340
- * @see VtxoScript
1341
- *
1342
- * @example
1343
- * ```typescript
1344
- * const address = new ArkAddress(
1345
- * new Uint8Array(32), // server public key
1346
- * new Uint8Array(32), // vtxo taproot public key
1347
- * "ark"
1348
- * );
1349
- *
1350
- * const encoded = address.encode();
1351
- * console.log("address: ", encoded);
1352
- *
1353
- * const decoded = ArkAddress.decode(encoded);
1354
- * ```
1355
- */
1356
- declare class ArkAddress {
1357
- readonly serverPubKey: Bytes;
1358
- readonly vtxoTaprootKey: Bytes;
1359
- readonly hrp: string;
1360
- readonly version: number;
1361
- /**
1362
- * Create an Arkade address from its server public key, Taproot output key, and prefix.
1363
- *
1364
- * @param serverPubKey - 32-byte Arkade server public key
1365
- * @param vtxoTaprootKey - 32-byte Taproot output key (a.k.a. tweaked public key)
1366
- * @param hrp - Bech32 human-readable prefix
1367
- * @param version - Address version byte
1368
- * @defaultValue `version = 0`
1369
- * @throws Error if either public key is not 32 bytes long
1370
- */
1371
- constructor(serverPubKey: Bytes, vtxoTaprootKey: Bytes, hrp?: string, version?: number);
1372
- /**
1373
- * Decode an Arkade address from its bech32m string form.
1374
- *
1375
- * @param address - Bech32m-encoded Arkade address
1376
- * @returns Decoded Arkade address
1377
- * @throws Error if the address is malformed or has an invalid payload length
1378
- * @see encode
1379
- */
1380
- static decode(address: string): ArkAddress;
1381
- /**
1382
- * Encode the address to its bech32m string form.
1383
- *
1384
- * @returns Bech32m-encoded Arkade address
1385
- * @see decode
1386
- */
1387
- encode(): string;
1388
- /** ScriptPubKey used to send non-dust funds to the address. */
1389
- get pkScript(): Bytes;
1390
- /** ScriptPubKey used to send sub-dust funds to the address. */
1391
- get subdustPkScript(): Bytes;
1392
- }
1393
-
1394
- type TapLeafScript = [
1395
- {
1396
- version: number;
1397
- internalKey: Bytes;
1398
- merklePath: Bytes[];
1399
- },
1400
- Bytes
1401
- ];
1402
- declare const TapTreeCoder: (typeof PSBTOutput.tapTree)[2];
1403
- declare function scriptFromTapLeafScript(leaf: TapLeafScript): Bytes;
1404
- /**
1405
- * VtxoScript is a script that contains a list of tapleaf scripts.
1406
- * It is used to create virtual output scripts.
1407
- *
1408
- * @see ArkAddress
1409
- *
1410
- * @example
1411
- * ```typescript
1412
- * const vtxoScript = new VtxoScript([new Uint8Array(32), new Uint8Array(32)]);
1413
- * ```
1414
- */
1415
- declare class VtxoScript {
1416
- readonly scripts: Bytes[];
1417
- readonly leaves: TapLeafScript[];
1418
- readonly tweakedPublicKey: Bytes;
1419
- readonly pkScript: Bytes;
1420
- /**
1421
- * Decode a virtual output script from an encoded TapTree.
1422
- *
1423
- * Leaves are normally read in construction order and their depths
1424
- * ignored: that covers the {@link encode} form (every depth 1) and the
1425
- * placeholder depths other writers use, such as arkd's. The exception is
1426
- * the BIP-371 form {@link toBIP371TapTree} writes, whose leaves are in the
1427
- * tree's DFS order: for some leaf counts (6, 7, 10, ...) that differs from
1428
- * construction order. A tree whose depths are exactly the shape
1429
- * `assembleBtcdTaprootTree` builds is that form, so its leaves are mapped
1430
- * back to construction order first. No construction-order writer produces
1431
- * that depth sequence when the two orders differ, so this never reorders
1432
- * a tree that decoded correctly before.
1433
- *
1434
- * Every leaf must carry the base tapscript version: the tree is rebuilt
1435
- * with {@link TAP_LEAF_VERSION} leaves, so any other version would
1436
- * silently derive a different taproot key.
1437
- *
1438
- * @param tapTree - Encoded TapTree bytes
1439
- * @returns Decoded virtual output script
1440
- * @throws Error if the TapTree cannot be decoded into a valid script set
1441
- * or a leaf carries a version other than {@link TAP_LEAF_VERSION}
1442
- * @see encode
1443
- */
1444
- static decode(tapTree: Bytes): VtxoScript;
1445
- /**
1446
- * Create a virtual output script from its tapleaf scripts.
1447
- *
1448
- * The Taproot script tree is assembled using btcd's algorithm
1449
- * (`txscript.AssembleTaprootScriptTree`) so the derived taproot output
1450
- * key agrees with arkd for any leaf count. `@scure/btc-signer`'s
1451
- * default `taprootListToTree` is a Huffman builder that only agrees
1452
- * with arkd for power-of-2 leaf counts.
1453
- *
1454
- * @param scripts - Raw tapscript bytes for each leaf
1455
- * @throws Error if the provided leaves cannot produce a valid Taproot tree
1456
- */
1457
- constructor(scripts: Bytes[]);
1458
- /**
1459
- * Encode the virtual output script to a TapTree byte representation.
1460
- *
1461
- * @returns Encoded TapTree bytes
1462
- * @see decode
1463
- */
1464
- encode(): Bytes;
1465
- /**
1466
- * Build the Arkade address corresponding to this virtual output script.
1467
- *
1468
- * @param prefix - Bech32 human-readable prefix
1469
- * @param serverPubKey - 32-byte Arkade server public key
1470
- * @returns Arkade address for this script
1471
- * @see ArkAddress
1472
- */
1473
- address(prefix: string | undefined, serverPubKey: Bytes): ArkAddress;
1474
- /**
1475
- * Build the Taproot onchain address corresponding to this virtual output script.
1476
- *
1477
- * @param network - Bitcoin network descriptor
1478
- * @returns Taproot onchain address
1479
- * @see address
1480
- */
1481
- onchainAddress(network?: typeof NETWORK): string;
1482
- /**
1483
- * Look up a tapleaf script by its hex-encoded tapscript body.
1484
- *
1485
- * @param scriptHex - Hex-encoded tapscript body without the leaf version byte
1486
- * @returns Matching tapleaf script
1487
- * @throws Error if no matching leaf exists
1488
- */
1489
- findLeaf(scriptHex: string): TapLeafScript;
1490
- /**
1491
- * Return all unilateral exit paths embedded in the virtual output script.
1492
- *
1493
- * @returns CSV-based exit paths found in the leaves
1494
- * @see getSequence
1495
- */
1496
- exitPaths(): Array<CSVMultisigTapscript.Type | ConditionCSVMultisigTapscript.Type>;
1497
- }
1498
- type EncodedVtxoScript = {
1499
- tapTree: Bytes;
1500
- };
1501
- /**
1502
- * Extract the timelock value encoded in a timelocked tapleaf, if any.
1503
- *
1504
- * The return value is unit-ambiguous: for a CSV leaf it is a BIP-68
1505
- * nSequence (relative timelock); for a CLTV leaf it is an absolute
1506
- * nLockTime. Callers must know which leaf shape they are inspecting to
1507
- * interpret the number correctly, and must not copy a CSV result into
1508
- * `Transaction.lockTime` (or vice versa).
1509
- *
1510
- * @param tapLeafScript - Tapleaf script to inspect
1511
- * @returns The encoded timelock value, or `undefined` when neither a CSV
1512
- * nor CLTV path is present
1513
- * @see VtxoScript.exitPaths
1514
- */
1515
- declare function getSequence(tapLeafScript: TapLeafScript): number | undefined;
1343
+ /** @deprecated Use {@link OperatorProvider}. */
1344
+ type ArkProvider = OperatorProvider;
1345
+ /** @deprecated Use {@link RestOperatorProvider}. */
1346
+ declare const RestArkProvider: typeof RestOperatorProvider;
1347
+ /** @deprecated Use {@link RestOperatorProvider}. */
1348
+ type RestArkProvider = RestOperatorProvider;
1516
1349
 
1517
1350
  type NetworkName = "bitcoin" | "testnet" | "signet" | "mutinynet" | "regtest";
1518
1351
  interface Network {
@@ -1530,10 +1363,14 @@ interface Network {
1530
1363
  }
1531
1364
  declare const getNetwork: (network: NetworkName) => Network;
1532
1365
  /**
1533
- * The {@link Network} an Arkade server's info names. {@link getNetwork} fails closed, so an
1534
- * unrecognized server network throws here rather than resolving to mainnet parameters downstream.
1366
+ * The {@link Network} the operator's info names. {@link getNetwork} fails closed, so an
1367
+ * unrecognized network throws here rather than resolving to mainnet parameters downstream.
1535
1368
  * Structurally typed so the network table doesn't depend on the provider layer.
1536
1369
  */
1370
+ declare const networkFromOperatorInfo: (info: {
1371
+ network: string;
1372
+ }) => Network;
1373
+ /** @deprecated Use {@link networkFromOperatorInfo}. */
1537
1374
  declare const networkFromArkadeInfo: (info: {
1538
1375
  network: string;
1539
1376
  }) => Network;
@@ -1545,17 +1382,17 @@ declare const networks: {
1545
1382
  regtest: Network;
1546
1383
  };
1547
1384
  /**
1548
- * Covenant co-signer ("emulator") of the mainnet Arkade deployment, resolved by the
1385
+ * The operator's cosigner that emulates Arkade Script on mainnet, resolved by the
1549
1386
  * `{ network: "bitcoin" }` service. No trailing slash: `RestEmulatorProvider` appends its paths
1550
1387
  * verbatim. The URL only selects where to ask for a signature; the key covenants commit to is
1551
1388
  * {@link BITCOIN_EMULATOR_PUBKEY}.
1552
1389
  */
1553
1390
  declare const DEFAULT_ARKADE_EMULATOR_URL: "https://emulator.arkade.computer";
1554
- /** Covenant co-signer ("emulator") for the mainnet Arkade deployment. */
1391
+ /** Key of the operator's cosigner that emulates Arkade Script on mainnet. */
1555
1392
  declare const BITCOIN_EMULATOR_PUBKEY: "0239c196415da47b26456a101daaa12ba9e445bfe153197f1e2b750bf40e52092e";
1556
- /** Covenant co-signer ("emulator") for the hosted mutinynet Arkade deployment. */
1393
+ /** Key of the operator's cosigner that emulates Arkade Script on mutinynet. */
1557
1394
  declare const MUTINYNET_EMULATOR_PUBKEY: "03f823b9b2febc81f4af967e77aed2f541cbd3397c6d8f5a72e32eb7b471af889a";
1558
- /** Covenant co-signer ("emulator") shipped with the `arkade-regtest` stack. */
1395
+ /** Key of the operator's cosigner that emulates Arkade Script in the `arkade-regtest` stack. */
1559
1396
  declare const REGTEST_EMULATOR_PUBKEY: "02999413c46fa10ada5cbc4bcc79a1d09160c2ba3cfc812705d7a13e5e545fb2a9";
1560
1397
  /**
1561
1398
  * The pinned co-signer key for `network`, as 33-byte compressed lowercase hex.
@@ -1592,16 +1429,24 @@ declare const ESPLORA_URL: Record<NetworkName, string>;
1592
1429
  type ExplorerTransaction = {
1593
1430
  txid: string;
1594
1431
  /**
1595
- * Spent outpoints, as returned by Esplora's `/address/:addr/txs`; the electrum provider omits
1596
- * them. Used to recover a boarding output's commitment tx when `/outspends` omits the spender.
1432
+ * Spent outpoints, as returned by Esplora's `/address/:addr/txs` and built from the raw tx by
1433
+ * the electrum provider. `getBoardingTxs` reads a boarding output's spender (commitment tx)
1434
+ * from them and asks `getTxOutspend(s)` only when no listed tx spends it, so a provider that
1435
+ * sets this saves one outspend request per settled boarding output. Leave it unset when
1436
+ * unknown: the outspend request then runs as before.
1597
1437
  */
1598
1438
  vin?: {
1599
1439
  txid: string;
1600
1440
  vout: number;
1441
+ /** Set by Esplora; the electrum provider omits it. */
1442
+ prevout?: {
1443
+ scriptpubkey_address?: string;
1444
+ };
1601
1445
  }[];
1602
1446
  vout: {
1603
1447
  scriptpubkey_address: string;
1604
- value: string;
1448
+ /** Output amount in satoshis, matching Esplora's numeric JSON field. */
1449
+ value: number;
1605
1450
  }[];
1606
1451
  status: {
1607
1452
  confirmed: boolean;
@@ -1704,6 +1549,11 @@ interface OnchainProvider {
1704
1549
  time: number;
1705
1550
  hash: string;
1706
1551
  }>;
1552
+ /**
1553
+ * Fetch consensus median-time-past for a block at the given height. Providers that do not
1554
+ * implement this cannot determine seconds-based relative-lock expiry from chain data.
1555
+ */
1556
+ getMedianTimePast?(height: number): Promise<number>;
1707
1557
  /**
1708
1558
  * Watch a set of addresses and invoke the callback when transactions are observed.
1709
1559
  *
@@ -1783,6 +1633,7 @@ declare class EsploraProvider implements OnchainProvider {
1783
1633
  time: number;
1784
1634
  hash: string;
1785
1635
  }>;
1636
+ getMedianTimePast(height: number): Promise<number>;
1786
1637
  private broadcastPackage;
1787
1638
  private broadcastTx;
1788
1639
  }
@@ -1905,7 +1756,7 @@ declare function toOffchainInputFeeParams(vtxo: NormalizedVirtualCoin): {
1905
1756
  declare function isVirtualCoin<T>(input: T): input is T & VirtualCoin;
1906
1757
 
1907
1758
  /**
1908
- * Classification of a contract's server signer against a fresh {@link ArkadeInfo} snapshot.
1759
+ * Classification of a contract's operator signer against a fresh {@link OperatorInfo} snapshot.
1909
1760
  * Always derived at read time from `params.serverPubKey` and the advertised signer set; no
1910
1761
  * stale-key metadata is persisted.
1911
1762
  *
@@ -1913,15 +1764,15 @@ declare function isVirtualCoin<T>(input: T): input is T & VirtualCoin;
1913
1764
  * - `MIGRATABLE`: signer deprecated, cutoff not passed; cooperative migration still possible.
1914
1765
  * - `DUE_NOW`: signer deprecated with no cutoff (arkd advertises `0n`); migrate immediately.
1915
1766
  * - `EXPIRED`: signer deprecated, cutoff passed; cooperative migration closed. NOT stranded:
1916
- * the server sweeps the batch at expiry and the swept VTXO recovers into the active signer via
1917
- * the normal recovery settle. Unilateral exit stays an opt-in escape hatch.
1767
+ * the operator sweeps the batch at expiry and the swept output recovers into the active
1768
+ * signer via the normal recovery settle. Unilateral exit stays an opt-in escape hatch.
1918
1769
  * - `UNKNOWN_SIGNER`: neither active nor advertised deprecated; the SDK does not migrate these.
1919
1770
  */
1920
1771
  type SignerStatus = "CURRENT" | "MIGRATABLE" | "DUE_NOW" | "EXPIRED" | "UNKNOWN_SIGNER";
1921
- /** Result of classifying one contract's server signer. */
1772
+ /** Result of classifying one contract's operator signer. */
1922
1773
  interface SignerClassification {
1923
1774
  status: SignerStatus;
1924
- /** The contract's server signer, normalized to x-only (32-byte) hex. */
1775
+ /** The contract's operator signer, normalized to x-only (32-byte) hex. */
1925
1776
  signerPubKey: string;
1926
1777
  /** Absolute cutoff (Unix seconds), present only when advertised for this deprecated signer. */
1927
1778
  cutoffDate?: bigint;
@@ -1932,7 +1783,7 @@ interface SignerClassification {
1932
1783
  secondsUntilCutoff?: number;
1933
1784
  }
1934
1785
  /**
1935
- * The server's signer set, pre-normalized to x-only hex, built once per pass via
1786
+ * The operator's signer set, pre-normalized to x-only hex, built once per pass via
1936
1787
  * {@link signerSetFromInfo}.
1937
1788
  */
1938
1789
  interface SignerSet {
@@ -1947,24 +1798,24 @@ interface SignerSet {
1947
1798
  deprecated: ReadonlyMap<string, bigint>;
1948
1799
  }
1949
1800
  /**
1950
- * Normalize a server signer pubkey hex to the lowercase x-only (32-byte) form of
1801
+ * Normalize a signer pubkey hex to the lowercase x-only (32-byte) form of
1951
1802
  * `params.serverPubKey`; arkd may advertise signers compressed (33 bytes).
1952
1803
  */
1953
1804
  declare function toXOnlySignerHex(pubkeyHex: string): string;
1954
- /** Build the {@link SignerSet} from a server-info snapshot, skipping empty deprecated pubkeys. */
1955
- declare function signerSetFromInfo(info: ArkadeInfo): SignerSet;
1805
+ /** Build the {@link SignerSet} from the operator's info, skipping empty deprecated pubkeys. */
1806
+ declare function signerSetFromInfo(info: OperatorInfo): SignerSet;
1956
1807
  /**
1957
- * Classify a contract's server signer against a pre-built {@link SignerSet}.
1808
+ * Classify a contract's operator signer against a pre-built {@link SignerSet}.
1958
1809
  *
1959
1810
  * @param contractServerPubKeyHex - the contract's `params.serverPubKey`
1960
1811
  * @param nowSeconds - current Unix time in seconds, compared against the cutoff
1961
1812
  */
1962
1813
  declare function classifyAgainstSignerSet(contractServerPubKeyHex: string, signerSet: SignerSet, nowSeconds?: number): SignerClassification;
1963
1814
  /**
1964
- * Classify one contract signer against {@link ArkadeInfo}. For many contracts, prefer
1815
+ * Classify one contract signer against {@link OperatorInfo}. For many contracts, prefer
1965
1816
  * {@link classifyAgainstSignerSet} with a shared signer set.
1966
1817
  */
1967
- declare function classifyContractSigner(contractServerPubKeyHex: string, info: ArkadeInfo, nowSeconds?: number): SignerClassification;
1818
+ declare function classifyContractSigner(contractServerPubKeyHex: string, info: OperatorInfo, nowSeconds?: number): SignerClassification;
1968
1819
  /** Whether a `settle()` migration intent should be built for VTXOs under this signer status. */
1969
1820
  declare function isCooperativelyMigratable(status: SignerStatus): boolean;
1970
1821
 
@@ -1999,13 +1850,13 @@ declare function selectPendingRecoveryOutpoints(contractsWithVtxos: ReadonlyArra
1999
1850
  * // Default behavior: virtual output renewal at 3 days, boarding sweep enabled, polling every minute
2000
1851
  * const wallet = await Wallet.create({
2001
1852
  * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
2002
- * arkProvider: new RestArkProvider(),
1853
+ * operatorProvider: new RestOperatorProvider(),
2003
1854
  * });
2004
1855
  *
2005
1856
  * // Custom expiry threshold of 24 hours
2006
1857
  * const wallet = await Wallet.create({
2007
1858
  * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
2008
- * arkProvider: new RestArkProvider(),
1859
+ * operatorProvider: new RestOperatorProvider(),
2009
1860
  * settlementConfig: {
2010
1861
  * vtxoThreshold: 60 * 60 * 24, // 24 hours in seconds
2011
1862
  * },
@@ -2014,7 +1865,7 @@ declare function selectPendingRecoveryOutpoints(contractsWithVtxos: ReadonlyArra
2014
1865
  * // Explicitly disable
2015
1866
  * const wallet = await Wallet.create({
2016
1867
  * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
2017
- * arkProvider: new RestArkProvider(),
1868
+ * operatorProvider: new RestOperatorProvider(),
2018
1869
  * settlementConfig: false,
2019
1870
  * });
2020
1871
  * ```
@@ -2256,7 +2107,7 @@ interface DeprecatedSignerMigrationReport {
2256
2107
  * ```typescript
2257
2108
  * const wallet = await Wallet.create({
2258
2109
  * identity,
2259
- * arkProvider: new RestArkProvider(),
2110
+ * operatorProvider: new RestOperatorProvider(),
2260
2111
  * settlementConfig: {
2261
2112
  * // Seconds before virtual output expiry to trigger renewal
2262
2113
  * vtxoThreshold: 259_200, // 3 days
@@ -2293,7 +2144,17 @@ interface IVtxoManager {
2293
2144
  }>;
2294
2145
  getExpiringVtxos(thresholdMs?: number): Promise<ExtendedVirtualCoin[]>;
2295
2146
  renewVtxos(eventCallback?: (event: SettlementEvent) => void, options?: RenewVtxosOptions): Promise<string>;
2147
+ /**
2148
+ * Boarding inputs whose own timelock has elapsed, at every boarding address the wallet shows,
2149
+ * including those under a deprecated signer.
2150
+ */
2296
2151
  getExpiredBoardingUtxos(): Promise<ExtendedCoin[]>;
2152
+ /**
2153
+ * Sweep the expired boarding inputs from {@link getExpiredBoardingUtxos} back to the current
2154
+ * boarding address via the unilateral exit path, which needs no operator.
2155
+ *
2156
+ * @returns The broadcast transaction ID
2157
+ */
2297
2158
  sweepExpiredBoardingUtxos(): Promise<string>;
2298
2159
  /**
2299
2160
  * Cooperatively migrate VTXOs minted under a now-deprecated server signer to the wallet's
@@ -2455,7 +2316,7 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
2455
2316
  * ```typescript
2456
2317
  * const wallet = await Wallet.create({
2457
2318
  * identity,
2458
- * arkProvider: new RestArkProvider(),
2319
+ * operatorProvider: new RestOperatorProvider(),
2459
2320
  * settlementConfig: {
2460
2321
  * vtxoThreshold: 86_400 // 24 hours
2461
2322
  * },
@@ -2513,6 +2374,8 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
2513
2374
  /**
2514
2375
  * Get boarding inputs whose timelock has expired: they can no longer be onboarded via
2515
2376
  * `settle()` and must be swept back to a fresh boarding address via the unilateral exit path.
2377
+ * Covers every boarding address the wallet shows, including those under a deprecated signer,
2378
+ * and judges each input by the timelock of its own address.
2516
2379
  *
2517
2380
  * @returns Array of expired boarding inputs
2518
2381
  *
@@ -2526,11 +2389,18 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
2526
2389
  * ```
2527
2390
  */
2528
2391
  getExpiredBoardingUtxos(prefetchedUtxos?: ExtendedCoin[]): Promise<ExtendedCoin[]>;
2392
+ /**
2393
+ * Renew the boarding coins nearing cosign cut-off through an arkd
2394
+ * cosignature; unrolled outputs are never swept here. Returns the txid, or
2395
+ * undefined when nothing qualified or the cosign path is unavailable.
2396
+ */
2397
+ sweepOnchainCoins(): Promise<string | undefined>;
2529
2398
  /**
2530
2399
  * Sweep expired boarding inputs back to a fresh boarding address via the unilateral exit path:
2531
2400
  * one pure onchain tx (no Arkade server) spending every expired input via the CSV exit script
2532
2401
  * into a single boarding-address output, which restarts the timelock. Skipped if the output
2533
- * after fees would be below dust.
2402
+ * after fees would be below dust. Covers boarding inputs under a deprecated signer too: the
2403
+ * exit leaf is the user's key plus a CSV, so it never needs the operator.
2534
2404
  *
2535
2405
  * @returns The broadcast transaction ID
2536
2406
  * @throws Error if no expired boarding inputs are found
@@ -2541,7 +2411,7 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
2541
2411
  * ```typescript
2542
2412
  * const wallet = await Wallet.create({
2543
2413
  * identity,
2544
- * arkProvider: new RestArkProvider(),
2414
+ * operatorProvider: new RestOperatorProvider(),
2545
2415
  * settlementConfig: {
2546
2416
  * boardingUtxoSweep: true,
2547
2417
  * },
@@ -2566,8 +2436,9 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
2566
2436
  * Status of every deprecated server signer the wallet holds funds under (VTXO and boarding,
2567
2437
  * merged per signer), without migrating.
2568
2438
  *
2569
- * @remarks Not a pure repository/info read: boarding holdings fan out per boarding address
2570
- * (`getCoins` round trips) and refresh the UTXO cache via `saveUtxos`.
2439
+ * @remarks This is no longer a pure repository/info read: surfacing boarding
2440
+ * holdings fans out per boarding address (`getCoins` round trips) and
2441
+ * syncs those coins into the contract manager's store.
2571
2442
  */
2572
2443
  getDeprecatedSignerStatus(): Promise<DeprecatedSignerReport[]>;
2573
2444
  /**
@@ -2626,11 +2497,13 @@ declare class VtxoManager implements AsyncDisposable, IVtxoManager {
2626
2497
  */
2627
2498
  private anyInputUnderDeprecatedSigner;
2628
2499
  private getSweepWallet;
2629
- private getBoardingTimelock;
2500
+ /** The signer `settle` can cooperate with: the one the wallet's boarding address is built on. */
2501
+ private getCurrentSigner;
2502
+ private boardingExpiry;
2630
2503
  private getOnchainProvider;
2631
- private getArkProvider;
2504
+ private getOperatorProvider;
2632
2505
  /**
2633
- * Unlike {@link getArkProvider}, doesn't require boarding-sweep capability. Undefined when no
2506
+ * Unlike {@link getOperatorProvider}, doesn't require boarding-sweep capability. Undefined when no
2634
2507
  * provider is wired, which callers treat as "no limit".
2635
2508
  */
2636
2509
  private getInfoProvider;
@@ -2704,14 +2577,20 @@ interface ContractFilter {
2704
2577
  * @see ContractWatchState
2705
2578
  */
2706
2579
  watch?: ContractWatchState | ContractWatchState[];
2580
+ /**
2581
+ * Filter by scope(s). Rows without a stored scope resolve via
2582
+ * `scopeOf`.
2583
+ */
2584
+ scope?: ContractScope | ContractScope[];
2707
2585
  }
2708
2586
  interface ContractRepository extends AsyncDisposable {
2709
2587
  /**
2710
2588
  * 2 — {@link Contract.watch}. An implementation must persist and
2711
2589
  * round-trip it, and treat a row without one as `"watched"`.
2712
2590
  * 3 — the unpaged `getContracts` is gone; implement `getContractsPage`.
2591
+ * 4 — persist contract scope; absent scope resolves via its handler.
2713
2592
  */
2714
- readonly version: 3;
2593
+ readonly version: 4;
2715
2594
  /**
2716
2595
  * Clear all data from storage.
2717
2596
  */
@@ -2729,18 +2608,23 @@ interface ContractRepository extends AsyncDisposable {
2729
2608
  }
2730
2609
  declare const collectContracts: (repository: Pick<ContractRepository, "getContractsPage">, filter?: ContractFilter) => Promise<Contract[]>;
2731
2610
 
2732
- type ArkIntentState = "waiting_to_submit" | "waiting_for_batch" | "batch_in_progress" | "batch_failed" | "batch_succeeded" | "cancelled";
2733
- declare const INTENT_TERMINAL_STATES: ReadonlySet<ArkIntentState>;
2734
- declare function isTerminalIntentState(s: ArkIntentState): boolean;
2735
- interface ArkIntent {
2736
- /** Intent proof tx id. Primary key. */
2737
- intentTxId: string;
2738
- /**
2739
- * Server-assigned batch intent id. Unique when present: saving a *different*
2740
- * intentTxId that reuses a live intentId is rejected (NArk parity). Absent
2741
- * until the intent is registered with arkd.
2742
- */
2743
- intentId?: string;
2611
+ type BatchRegistrationState = "waiting_to_submit" | "waiting_for_batch" | "batch_in_progress" | "batch_failed" | "batch_succeeded" | "cancelled";
2612
+ declare const BATCH_REGISTRATION_TERMINAL_STATES: ReadonlySet<BatchRegistrationState>;
2613
+ declare function isTerminalBatchRegistrationState(s: BatchRegistrationState): boolean;
2614
+ /**
2615
+ * A wallet's request to join a batch, tracked from signing to its terminal state.
2616
+ * Backends keep their older column and key names on disk and map them here. No data
2617
+ * migration runs, so an in-flight lock survives an upgrade or a rollback.
2618
+ */
2619
+ interface BatchRegistration {
2620
+ /** Register proof tx id. Primary key. */
2621
+ proofTxId: string;
2622
+ /**
2623
+ * Operator-assigned registration id. Unique when present: saving a *different*
2624
+ * proofTxId that reuses a live registrationId is rejected (NArk parity). Absent
2625
+ * until the proof is registered with the operator.
2626
+ */
2627
+ registrationId?: string;
2744
2628
  state: ArkIntentState;
2745
2629
  validFrom?: number;
2746
2630
  validUntil?: number;
@@ -2758,30 +2642,40 @@ interface ArkIntent {
2758
2642
  cancellationReason?: string;
2759
2643
  partialForfeits: string[];
2760
2644
  signerDescriptor?: string;
2761
- /** Input VTXOs locked by this intent. */
2762
- intentVtxos: Outpoint[];
2645
+ /** Inputs locked by this registration. */
2646
+ proofInputs: Outpoint[];
2763
2647
  }
2764
- interface IntentFilter {
2765
- intentTxIds?: string[];
2766
- intentIds?: string[];
2767
- /** Intents whose `intentVtxos` intersect any of these outpoints. */
2648
+ interface BatchRegistrationFilter {
2649
+ proofTxIds?: string[];
2650
+ registrationIds?: string[];
2651
+ /** Registrations whose `proofInputs` intersect any of these outpoints. */
2768
2652
  containingInputs?: Outpoint[];
2769
- states?: ArkIntentState[];
2653
+ states?: BatchRegistrationState[];
2770
2654
  /** Intents valid at this ms-epoch instant (null bounds = open). */
2771
2655
  validAt?: number;
2772
- /** Substring match over intentId, batchId, commitmentTransactionId. */
2656
+ /** Substring match over registrationId, batchId, commitmentTransactionId. */
2773
2657
  searchText?: string;
2774
2658
  }
2775
- type IntentPageFilter = IntentFilter;
2776
- interface IntentRepository extends AsyncDisposable {
2659
+ type BatchRegistrationPageFilter = BatchRegistrationFilter;
2660
+ /** @deprecated Use {@link BatchRegistration}. */
2661
+ type ArkIntent = BatchRegistration;
2662
+ /** @deprecated Use {@link BatchRegistrationFilter}. */
2663
+ type IntentFilter = BatchRegistrationFilter;
2664
+ /** @deprecated Use {@link BatchRegistrationPageFilter}. */
2665
+ type IntentPageFilter = BatchRegistrationPageFilter;
2666
+ interface BatchRegistrationRepository extends AsyncDisposable {
2777
2667
  readonly version: 1;
2778
2668
  clear(): Promise<void>;
2779
- /** Upsert by `intentTxId`; implementation sets `updatedAt = Date.now()`. */
2780
- saveIntent(intent: ArkIntent): Promise<void>;
2781
- /** Bounded intents in `intentTxId` order, not chronological order; `after` is exclusive. */
2782
- getIntentsPage(filter: IntentPageFilter | undefined, page: PageRequest): Promise<PageResult<ArkIntent>>;
2783
- /**
2784
- * Outpoints held by NON-terminal intents — `waiting_to_submit`,
2669
+ /** Upsert by primary key; implementation sets `updatedAt = Date.now()`. */
2670
+ saveBatchRegistration(intent: ArkIntent): Promise<void>;
2671
+ /** @deprecated Use {@link saveBatchRegistration}. */
2672
+ saveIntent: IntentRepository["saveBatchRegistration"];
2673
+ /** Bounded registrations in primary key order, not chronological order; `after` is exclusive. */
2674
+ getBatchRegistrationsPage(filter: IntentPageFilter | undefined, page: PageRequest): Promise<PageResult<ArkIntent>>;
2675
+ /** @deprecated Use {@link getBatchRegistrationsPage}. */
2676
+ getIntentsPage: IntentRepository["getBatchRegistrationsPage"];
2677
+ /**
2678
+ * Outpoints held by NON-terminal registrations — `waiting_to_submit`,
2785
2679
  * `waiting_for_batch`, and `batch_in_progress` — to exclude from spendable
2786
2680
  * balance. Terminal states never lock.
2787
2681
  *
@@ -2790,12 +2684,22 @@ interface IntentRepository extends AsyncDisposable {
2790
2684
  * offline-first and reads this set as its single source of coin locking, so
2791
2685
  * it must also hold inputs already committed to an in-progress batch. NArk
2792
2686
  * excludes `BatchInProgress` here but protects those inputs through its
2793
- * active-intent services instead.
2687
+ * own services instead.
2794
2688
  */
2795
2689
  getLockedVtxoOutpoints(): Promise<Outpoint[]>;
2796
2690
  }
2797
- /** Collects in `intentTxId` order; sort by `createdAt` for chronological display. */
2798
- declare const collectIntents: (repository: Pick<IntentRepository, "getIntentsPage">, filter?: IntentPageFilter) => Promise<ArkIntent[]>;
2691
+ /** @deprecated Use {@link collectBatchRegistrations}. */
2692
+ declare const collectIntents: (repository: Pick<IntentRepository, "getBatchRegistrationsPage">, filter?: IntentPageFilter) => Promise<BatchRegistration[]>;
2693
+ /** @deprecated Use {@link BatchRegistrationState}. */
2694
+ type ArkIntentState = BatchRegistrationState;
2695
+ /** @deprecated Use {@link BatchRegistrationRepository}. */
2696
+ type IntentRepository = BatchRegistrationRepository;
2697
+ /** @deprecated Use {@link isTerminalBatchRegistrationState}. */
2698
+ declare const isTerminalIntentState: typeof isTerminalBatchRegistrationState;
2699
+ /** @deprecated Use {@link BATCH_REGISTRATION_TERMINAL_STATES}. */
2700
+ declare const INTENT_TERMINAL_STATES: ReadonlySet<BatchRegistrationState>;
2701
+ /** Collects in primary key order; sort by `createdAt` for chronological display. */
2702
+ declare const collectBatchRegistrations: (repository: Pick<IntentRepository, "getBatchRegistrationsPage">, filter?: IntentPageFilter) => Promise<BatchRegistration[]>;
2799
2703
 
2800
2704
  /**
2801
2705
  * Type of a tx inside a VTXO's chain (commitment → leaf), as reported by
@@ -2845,12 +2749,253 @@ interface VirtualTxRepository extends AsyncDisposable {
2845
2749
  pruneForSpentVtxo(vtxo: Outpoint): Promise<void>;
2846
2750
  }
2847
2751
 
2848
- /**
2752
+ /** One transaction's participation in one logical action. */
2753
+ interface GroupMembership {
2754
+ /**
2755
+ * Stable id of the action; txs sharing it group together. Third-party
2756
+ * resolvers should namespace it (`"vendor:thing"`) to avoid colliding with
2757
+ * other resolvers' groups. SDK built-ins use namespaced ids such as `boarding:`.
2758
+ * A membership with an empty groupId is dropped.
2759
+ */
2760
+ groupId: string;
2761
+ /** Human label for the action, e.g. "Dice game". */
2762
+ label?: string;
2763
+ /** App category for icon/filtering, e.g. "game". */
2764
+ kind?: string;
2765
+ /**
2766
+ * Outcome of the action this membership belongs to, e.g. "failed",
2767
+ * "refunded" — an opaque machine token for the app to map to its own
2768
+ * copy or icon, not display text. Merged first-writer-wins across
2769
+ * resolvers sharing a `groupId`, like `label` and `kind`.
2770
+ */
2771
+ outcome?: string;
2772
+ /**
2773
+ * Free-form row data. Same-group metadata is shallow-merged with
2774
+ * earlier-resolver keys winning.
2775
+ */
2776
+ metadata?: Record<string, unknown>;
2777
+ /**
2778
+ * This tx's unsigned sat contribution to this group. Defaults to the tx's
2779
+ * full amount; the builder applies direction. Use it to split a batched tx
2780
+ * across groups. Same-key receive rows paired with a sent row are treated
2781
+ * as change and excluded from `Activity.amount`. A membership with a
2782
+ * non-finite amount (NaN/Infinity) is dropped.
2783
+ */
2784
+ amount?: number;
2785
+ }
2786
+ /** A pluggable resolver keyed by `id`. */
2787
+ interface ActivityResolver {
2788
+ /**
2789
+ * Registry key — override or remove by it. Namespace it (`"vendor:games"`)
2790
+ * so independent libraries don't clobber each other; `use()` overwrites
2791
+ * silently on a duplicate id.
2792
+ */
2793
+ id: string;
2794
+ /**
2795
+ * Load correlation data before `resolve` runs. If it rejects, this resolver
2796
+ * contributes no memberships.
2797
+ */
2798
+ prepare?(): Promise<void>;
2799
+ /** Pure and synchronous. The groups this tx belongs to, or undefined to leave it plain. */
2800
+ resolve(tx: ArkTransaction): GroupMembership[] | undefined;
2801
+ }
2802
+ /** The non-id, non-amount part of a {@link GroupMembership}. */
2803
+ interface ActivityIntent {
2804
+ /** Human label for the action, e.g. "Dice game". */
2805
+ label?: string;
2806
+ /** App category for icon/filtering, e.g. "game". */
2807
+ kind?: string;
2808
+ /**
2809
+ * Resolver-declared outcome for the group, e.g. "failed", "refunded" — an
2810
+ * opaque machine token for the app to map to its own copy or icon, not
2811
+ * display text.
2812
+ */
2813
+ outcome?: string;
2814
+ /** Free-form row data, shallow-merged across the group's resolvers (first-writer-wins). */
2815
+ metadata?: Record<string, unknown>;
2816
+ }
2817
+ /** One logical activity. */
2818
+ interface Activity {
2819
+ /** The groupId, or the natural tx key for untagged rows. */
2820
+ id: string;
2821
+ /** Merged intent for the group, if any resolver tagged it. */
2822
+ intent?: ActivityIntent;
2823
+ /** Member txs, oldest-first. */
2824
+ txs: ArkTransaction[];
2825
+ /** Signed net sats: positive received, negative sent; same-key change rows are excluded. */
2826
+ amount: number;
2827
+ /** Earliest member createdAt (ms since epoch). */
2828
+ createdAt: number;
2829
+ /** True once every member tx is settled. */
2830
+ settled: boolean;
2831
+ }
2832
+ /** Resolver registry keyed by id. */
2833
+ declare class ActivityRegistry {
2834
+ private readonly resolvers;
2835
+ /** Add a resolver, or override an existing one with the same id (kept in place). */
2836
+ use(resolver: ActivityResolver): void;
2837
+ /** Remove a resolver (built-in or custom) by id. */
2838
+ remove(id: string): void;
2839
+ /** The registered resolver ids, in registration order. */
2840
+ list(): string[];
2841
+ /** All registered resolvers, in registration (priority) order. */
2842
+ all(): ActivityResolver[];
2843
+ }
2844
+ /** Built-in resolver: labels on-chain boarding (deposit) transactions. */
2845
+ declare function boardingResolver(): ActivityResolver;
2846
+ /** Built-in resolver: labels collaborative exits (VTXOs forfeited to chain in a batch). */
2847
+ declare function collabExitResolver(): ActivityResolver;
2848
+ /**
2849
+ * Built-in resolver: labels the genesis transaction of a minted asset — "Asset
2850
+ * mint" on the issuer's sent tx, "Asset receive" when the fresh supply arrives
2851
+ * in the genesis tx itself. An asset id encodes its genesis txid; reissues and
2852
+ * transfers carry the asset under a different `arkTxid`, so they are left plain.
2853
+ *
2854
+ * `metadata.amount` is the decimal string of the asset's `bigint` amount, kept
2855
+ * as a string so large supplies survive JSON round-trips without truncation.
2856
+ * Recover the value with `BigInt(metadata.amount as string)` — using it
2857
+ * directly in arithmetic coerces (`"10" + 1` is `"101"`, not `11`) and loses
2858
+ * precision past `Number.MAX_SAFE_INTEGER`.
2859
+ */
2860
+ declare function assetMintResolver(): ActivityResolver;
2861
+ /**
2862
+ * A registry pre-populated with the SDK's built-in resolvers: `boarding`,
2863
+ * `collab-exit`, and `asset-mint`.
2864
+ */
2865
+ declare function createDefaultActivityRegistry(): ActivityRegistry;
2866
+
2867
+ /**
2868
+ * A source of unilateral-exit chain data for a set of VTXOs. Sources are tried
2869
+ * in order by the resolver; a source returns `null` (chain) or omits keys (psbts)
2870
+ * for data it cannot supply — a "miss" — and the resolver falls through.
2871
+ */
2872
+ interface ExitDataSource {
2873
+ readonly name: string;
2874
+ /** Full ancestry chain for a vtxo (all pages merged), or null on a miss. */
2875
+ getVtxoChain(vtxo: Outpoint): Promise<ChainTx[] | null>;
2876
+ /** Base64 PSBTs this source has, keyed by (unsigned) txid. Absent key = miss. */
2877
+ getVirtualTxs(txids: string[]): Promise<Map<string, string>>;
2878
+ }
2879
+ /** Reads exit chain data through an ordered chain of sources. */
2880
+ interface ExitChainResolver {
2881
+ getVtxoChain(vtxo: Outpoint): Promise<ChainTx[]>;
2882
+ getVirtualTxs(txids: string[]): Promise<string[]>;
2883
+ }
2884
+ /**
2885
+ * Assemble the standard exit-data resolver: local repo (if configured) → any
2886
+ * extra sources (e.g. a future provider) → indexer. Read-through persists to the
2887
+ * repository. With no repository this is exactly the indexer path (a no-op seam).
2888
+ */
2889
+ declare function createExitChainResolver(params: {
2890
+ indexer: IndexerProvider;
2891
+ repository?: VirtualTxRepository;
2892
+ extraSources?: ExitDataSource[];
2893
+ }): ExitChainResolver;
2894
+
2895
+ type ExitCaptureMode = "lite" | "full";
2896
+
2897
+ /** Delegate identity and fee information returned by `getDelegateInfo`. */
2898
+ interface DelegateInfo {
2899
+ /** Delegate public key. */
2900
+ pubkey: string;
2901
+ /** Delegate fee amount or expression returned by the delegate. */
2902
+ fee: string;
2903
+ /** Address for delegate fee collection. */
2904
+ delegateAddress: string;
2905
+ }
2906
+ /** Optional delegate behavior flags. */
2907
+ interface DelegateOptions {
2908
+ /**
2909
+ * Tell the delegate not to replace an existing delegation (signed register intent + its
2910
+ * forfeits) that already includes at least one virtual output from this request.
2911
+ *
2912
+ * @defaultValue `false`
2913
+ */
2914
+ rejectReplace?: boolean;
2915
+ }
2916
+ /** Provider interface for a remote delegation service. */
2917
+ interface DelegateProvider {
2918
+ /**
2919
+ * Request delegation for a signed register intent and its forfeit transactions.
2920
+ *
2921
+ * @param forfeitTxs - Forfeit transactions associated with the delegation request
2922
+ */
2923
+ delegate(intent: SignedProof<Proof.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
2924
+ /** Fetch delegate metadata: pubkey, fee, and delegate address. */
2925
+ getDelegateInfo(): Promise<DelegateInfo>;
2926
+ }
2927
+ /**
2928
+ * REST-based delegate provider implementation.
2929
+ * @example
2930
+ * ```typescript
2931
+ * const provider = new RestDelegateProvider('https://delegate.example.com');
2932
+ * const info = await provider.getDelegateInfo();
2933
+ * await provider.delegate(intent, forfeitTxs);
2934
+ * ```
2935
+ */
2936
+ declare class RestDelegateProvider implements DelegateProvider {
2937
+ url: string;
2938
+ /** @param url - Base URL of the remote delegation service. */
2939
+ constructor(url: string);
2940
+ /**
2941
+ * Submit a delegation request to the remote delegation service.
2942
+ *
2943
+ * @throws Error if the remote service rejects the request
2944
+ */
2945
+ delegate(intent: SignedProof<Proof.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
2946
+ /**
2947
+ * Fetch delegate metadata exposed by the remote delegation service.
2948
+ *
2949
+ * @throws Error if the remote service returns invalid data
2950
+ */
2951
+ getDelegateInfo(): Promise<DelegateInfo>;
2952
+ }
2953
+
2954
+ interface IDelegateManager {
2955
+ /**
2956
+ * Delegate virtual outputs to the remote delegation service.
2957
+ *
2958
+ * Vtxos that are not locked to a delegate-type contract (no tap leaf
2959
+ * matches the delegate's pubkey) are filtered out silently, since they
2960
+ * cannot be co-signed by the delegate.
2961
+ *
2962
+ * @param vtxos - Virtual outputs to delegate
2963
+ * @param destination - Arkade address that should receive renewed funds
2964
+ * @param delegateAt - Optional timestamp to force a specific delegation time
2965
+ * @returns Successfully delegated and failed outpoint groups
2966
+ */
2967
+ delegate(vtxos: ContractVtxo[], destination: string, delegateAt?: Date): Promise<{
2968
+ delegated: Outpoint[];
2969
+ failed: {
2970
+ outpoints: Outpoint[];
2971
+ error: unknown;
2972
+ }[];
2973
+ }>;
2974
+ /** Fetch delegate metadata such as pubkey, fee, and delegate address. */
2975
+ getDelegateInfo(): Promise<DelegateInfo>;
2976
+ }
2977
+ declare class DelegateManagerImpl implements IDelegateManager {
2978
+ readonly delegateProvider: DelegateProvider;
2979
+ readonly arkInfoProvider: Pick<OperatorProvider, "getInfo">;
2980
+ readonly identity: Identity;
2981
+ /** Create a delegate manager from the configured provider, Arkade info source, and wallet identity. */
2982
+ constructor(delegateProvider: DelegateProvider, arkInfoProvider: Pick<OperatorProvider, "getInfo">, identity: Identity);
2983
+ getDelegateInfo(): Promise<DelegateInfo>;
2984
+ delegate(vtxos: ContractVtxo[], destination: string, delegateAt?: Date): Promise<{
2985
+ delegated: Outpoint[];
2986
+ failed: {
2987
+ outpoints: Outpoint[];
2988
+ error: unknown;
2989
+ }[];
2990
+ }>;
2991
+ }
2992
+
2993
+ /**
2849
2994
  * Tapscript fields derived purely from a contract's params. They are identical
2850
2995
  * for every VTXO locked to the same contract, so they can be memoized per
2851
2996
  * contract (see {@link ContractTapscriptCache}).
2852
2997
  */
2853
- type ContractTapscripts = Pick<ExtendedVirtualCoin, "forfeitTapLeafScript" | "intentTapLeafScript" | "tapTree">;
2998
+ type ContractTapscripts = Pick<ExtendedVirtualCoin, "forfeitTapLeafScript" | "proofTapLeafScript" | "tapTree">;
2854
2999
  /**
2855
3000
  * Cache of per-contract tapscript data, keyed by `contract.script`. Building
2856
3001
  * the taproot tree via `handler.createScript(contract.params)` is the dominant
@@ -3125,9 +3270,30 @@ interface IContractManager extends Disposable {
3125
3270
  */
3126
3271
  refreshOutpoints(outpoints: Outpoint[]): Promise<void>;
3127
3272
  /**
3128
- * Rebuild the HD look-ahead watch window around the current allocation watermark. No-op
3129
- * without `lookAhead`. Call after anything that moves the watermark (restore, boarding
3130
- * allocation, receive rotation, server-signer rotation); concurrent calls coalesce.
3273
+ * Fetch onchain coins for onchain-scoped contracts (and contracts holding
3274
+ * unspent unrolled outputs), upsert them, and mark vanished ones spent.
3275
+ * No-op without `onchainProvider` and `network`. Narrowed by `scripts`; `fetched` holds coins
3276
+ * the caller already fetched, by script, so they are not fetched again.
3277
+ * Optional (like {@link watchScript}): the service-worker proxy does not forward it yet.
3278
+ */
3279
+ syncOnchain?(scripts?: string[], fetched?: ReadonlyMap<string, Coin[]>): Promise<void>;
3280
+ /**
3281
+ * Record `txid` as the pending spender of stored onchain coins. A sync confirms it once the
3282
+ * coin is spent, or releases it if still unspent `ONCHAIN_PENDING_RELEASE_BLOCKS` later.
3283
+ * `skipUnknown` marks the stored coins and logs the rest instead of rejecting them all.
3284
+ * `height` starts the release countdown; without it the chain tip is fetched.
3285
+ */
3286
+ markOnchainSpendPending?(outpoints: Outpoint[], txid: string, options?: {
3287
+ skipUnknown?: boolean;
3288
+ height?: number;
3289
+ }): Promise<void>;
3290
+ /**
3291
+ * Rebuild the HD look-ahead watch window around the current allocation
3292
+ * watermark. No-op when the manager was configured without `lookAhead`.
3293
+ *
3294
+ * Call after anything that moves the watermark (restore, boarding
3295
+ * allocation, receive rotation, server-signer rotation). Concurrent calls
3296
+ * coalesce into a single drain.
3131
3297
  */
3132
3298
  refillLookAhead(): Promise<void>;
3133
3299
  /**
@@ -3204,7 +3370,6 @@ type GetAllSpendingPathsOptions = {
3204
3370
  /** Wallet descriptor to determine role */
3205
3371
  walletDescriptor?: string;
3206
3372
  };
3207
- /** Configuration for the ContractManager. */
3208
3373
  interface ContractManagerConfig {
3209
3374
  /** Opt in to background boot; inspect getSyncState() before using cached data. */
3210
3375
  lazyInitialization?: boolean;
@@ -3256,6 +3421,9 @@ interface ContractManagerConfig {
3256
3421
  * on arkd's clock, so this must cover how far this host's clock can run ahead of it.
3257
3422
  */
3258
3423
  vtxoSyncOverlapMs?: number;
3424
+ /** Enables onchain coin discovery and watching; needs `network` too. */
3425
+ onchainProvider?: OnchainProvider;
3426
+ network?: Network;
3259
3427
  }
3260
3428
  /**
3261
3429
  * Wallet-injected surface backing the HD look-ahead window; a callback bundle so the contracts
@@ -3359,6 +3527,9 @@ declare class ContractManager implements IContractManager {
3359
3527
  /** Set by {@link dispose}, cleared by a re-`initialize`. A drain outlives the synchronous
3360
3528
  * `dispose()`, so it re-checks this at every await rather than run on a torn-down watcher. */
3361
3529
  private disposed;
3530
+ private onchainWatcher?;
3531
+ /** Serializes onchain read-modify-writes so a pending spender is never overwritten. */
3532
+ private onchainChain;
3362
3533
  private constructor();
3363
3534
  /**
3364
3535
  * Create a ContractManager, load persisted contracts and start watching all of them. Use
@@ -3609,6 +3780,29 @@ declare class ContractManager implements IContractManager {
3609
3780
  unwatchScript(script: string | string[]): Promise<void>;
3610
3781
  /** @see IContractManager.getWatchedScripts */
3611
3782
  getWatchedScripts(): Promise<WatchedScript[]>;
3783
+ /** @see IContractManager.syncOnchain */
3784
+ syncOnchain(scripts?: string[], fetched?: ReadonlyMap<string, Coin[]>): Promise<void>;
3785
+ /**
3786
+ * @see IContractManager.markOnchainSpendPending
3787
+ * @throws naming every outpoint that is not a stored, unconfirmed onchain coin; nothing is written then.
3788
+ */
3789
+ markOnchainSpendPending(outpoints: Outpoint[], txid: string, options?: {
3790
+ skipUnknown?: boolean;
3791
+ height?: number;
3792
+ }): Promise<void>;
3793
+ private readPendingSpends;
3794
+ private updatePendingSpends;
3795
+ private inOnchainOrder;
3796
+ private runOnchainSync;
3797
+ private syncOnchainContract;
3798
+ /**
3799
+ * arkd's record of how these onchain coins were spent, by outpoint: empty if it keeps none,
3800
+ * undefined if the lookup failed.
3801
+ */
3802
+ private serverSpends;
3803
+ /**
3804
+ * Emit an event to all registered callbacks.
3805
+ */
3612
3806
  private emitEvent;
3613
3807
  /** Resolves `false` when the event's sync failed, so the watcher keeps its poll off. */
3614
3808
  private handleContractEvent;
@@ -3637,8 +3831,8 @@ declare class ContractManager implements IContractManager {
3637
3831
  * Stop the watcher, clear callbacks, and mark the manager uninitialized.
3638
3832
  *
3639
3833
  * Teardown is synchronous. The returned promise settles once watcher events already being
3640
- * handled, any look-ahead drain, and any lazy boot sequence finish; after that nothing more is written to the
3641
- * repositories.
3834
+ * handled, any look-ahead drain, any onchain sync and any lazy boot sequence finish; after that
3835
+ * nothing more is written to the repositories.
3642
3836
  */
3643
3837
  dispose(): Promise<void>;
3644
3838
  /**
@@ -3686,6 +3880,8 @@ type ContractWatchState =
3686
3880
  * feeds transaction history.
3687
3881
  */
3688
3882
  | "retained";
3883
+ /** Which layer(s) a contract's coins live on. */
3884
+ type ContractScope = "offchain" | "onchain" | "both";
3689
3885
  /**
3690
3886
  * A contract that can receive and manage virtual outputs. Its type and parameters determine the
3691
3887
  * VtxoScript (spending paths); the wallet's default receiving address is a `"default"` contract,
@@ -3731,6 +3927,8 @@ interface Contract {
3731
3927
  * @see ContractWatchState
3732
3928
  */
3733
3929
  watch?: ContractWatchState;
3930
+ /** Layers this contract's coins live on. Absent ⇒ the handler's `defaultScope`, else `"offchain"`. */
3931
+ scope?: ContractScope;
3734
3932
  /** Unix timestamp in milliseconds when this contract was created. */
3735
3933
  createdAt: number;
3736
3934
  /** Optional metadata for external integrations. */
@@ -3819,6 +4017,8 @@ interface PathContext {
3819
4017
  interface ContractHandler<P = Record<string, unknown>, S extends VtxoScript = VtxoScript> {
3820
4018
  /** Contract type managed by this handler. */
3821
4019
  readonly type: string;
4020
+ /** Scope of contracts of this type that don't set {@link Contract.scope}. */
4021
+ readonly defaultScope?: ContractScope;
3822
4022
  /** Create the VtxoScript from serialized parameters. */
3823
4023
  createScript(params: Record<string, string>): S;
3824
4024
  /** Serialize typed parameters to string key-value pairs. */
@@ -3949,15 +4149,17 @@ declare function isDiscoverable(handler: ContractHandler<unknown> | undefined):
3949
4149
  /**
3950
4150
  * The per-contract tapscript annotation stamped onto every VTXO locked to a
3951
4151
  * contract (see `extendVirtualCoinForContract`): the leaf used to co-sign
3952
- * forfeits, the leaf committed in intent proofs, and the encoded taproot tree.
4152
+ * forfeits, the leaf committed in proofs, and the encoded taproot tree.
3953
4153
  */
3954
4154
  interface DerivedContractTapscripts {
3955
4155
  forfeitTapLeafScript: TapLeafScript;
3956
- intentTapLeafScript: TapLeafScript;
4156
+ proofTapLeafScript: TapLeafScript;
4157
+ /** @deprecated Use {@link proofTapLeafScript}. */
4158
+ intentTapLeafScript?: TapLeafScript;
3957
4159
  tapTree: Bytes;
3958
4160
  }
3959
4161
  /**
3960
- * Optional {@link ContractHandler} capability providing the forfeit/intent tapscripts for VTXO
4162
+ * Optional {@link ContractHandler} capability providing the forfeit/proof tapscripts for VTXO
3961
4163
  * annotation, for scripts without the legacy `forfeit()` (e.g. program-compiled arkade contracts).
3962
4164
  * Must be pure in `(contract.type, contract.script, contract.params)`: `ContractManager` memoizes
3963
4165
  * the result for its lifetime.
@@ -4063,497 +4265,180 @@ interface ContractWatcherConfig {
4063
4265
  /**
4064
4266
  * Maximum delay for reconnection and subscription update retries (ms).
4065
4267
  *
4066
- * @defaultValue `5_000` (5 seconds)
4067
- */
4068
- maxReconnectDelayMs?: number;
4069
- /**
4070
- * Maximum retry attempts per reconnection or subscription update failure; 0 for unlimited.
4071
- *
4072
- * @defaultValue `0` (unlimited)
4073
- */
4074
- maxReconnectAttempts?: number;
4075
- /**
4076
- * Deadline for each subscription POST, including its response body (ms).
4077
- * Timeouts use the subscription retry policy without interrupting the event stream.
4078
- *
4079
- * @defaultValue `30_000` (30 seconds)
4080
- * @remarks Must be greater than zero; a subscription request needs a finite deadline.
4081
- */
4082
- subscriptionRequestTimeoutMs?: number;
4083
- }
4084
- /**
4085
- * A returned promise holds off the poll until the event's handling settles; resolving `false` or
4086
- * rejecting keeps it off until a later handling succeeds.
4087
- */
4088
- type ContractWatcherEventCallback = (event: ContractEvent) => unknown;
4089
- type ConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting";
4090
- /**
4091
- * Watches contracts for virtual output changes: subscription with exponential-backoff reconnect,
4092
- * a poll after every (re)connect, and failsafe polling for missed events.
4093
- *
4094
- * Event-only: it reads the wallet repository for baselines but never writes it;
4095
- * `ContractManager` owns persistence.
4096
- *
4097
- * @example
4098
- * ```typescript
4099
- * const watcher = new ContractWatcher({
4100
- * indexerProvider: wallet.indexerProvider,
4101
- * });
4102
- *
4103
- * // Add the wallet's default contract
4104
- * await watcher.addContract(defaultContract);
4105
- *
4106
- * // Add additional contracts (swaps, etc.)
4107
- * await watcher.addContract(swapContract);
4108
- *
4109
- * // Start watching for events
4110
- * const stop = await watcher.startWatching((event) => {
4111
- * console.log(`${event.type} on contract ${event.contractScript}`);
4112
- * });
4113
- *
4114
- * // Later: stop watching
4115
- * stop();
4116
- * ```
4117
- */
4118
- declare class ContractWatcher {
4119
- private config;
4120
- private contracts;
4121
- /** In-memory and process-lifetime; never persisted. */
4122
- private watchedScripts;
4123
- private subscriptionId?;
4124
- private abortController?;
4125
- private isWatching;
4126
- private eventCallback?;
4127
- private connectionState;
4128
- private reconnectAttempts;
4129
- private reconnectTimeoutId?;
4130
- private failsafePollIntervalId?;
4131
- /** See {@link withCoalescedSubscription}. */
4132
- private subscriptionBatchDepth;
4133
- private subscriptionUpdateDeferred;
4134
- /** Subscription POSTs can fail while the event stream remains healthy. */
4135
- private subscriptionRetryTimeoutId?;
4136
- private subscriptionRetryAttempts;
4137
- /** A failed update needs catch-up even when reconnect owns the next attempt. */
4138
- private subscriptionNeedsCatchUp;
4139
- /** Serialize subscription creation and updates against the latest desired scripts. */
4140
- private subscriptionUpdate;
4141
- /** See {@link reportEventSourceUnavailable} — said once, not per attempt. */
4142
- private eventSourceReported;
4143
- /** @see ContractWatcherConfig */
4144
- constructor(config: ContractWatcherConfig);
4145
- /**
4146
- * Add a contract to be watched. Every contract is subscribed and polled whatever its
4147
- * {@link ContractState}, except a `retained` one, which is held for reads only.
4148
- *
4149
- * @see getWatchedContracts
4150
- */
4151
- addContract(contract: Contract): Promise<void>;
4152
- /** Pre-populate `lastKnownVtxos` from the wallet repository so polls emit only real deltas. */
4153
- private seedLastKnownVtxos;
4154
- updateContract(contract: Contract): Promise<void>;
4155
- removeContract(contractScript: string): Promise<void>;
4156
- /** All in-memory contracts. */
4157
- getAllContracts(): Contract[];
4158
- /**
4159
- * Every registered contract except `retained` ones, retired (`inactive`) addresses included.
4160
- *
4161
- * Feeds both the subscription and the sweep scope. `state` must never narrow it: an Ark
4162
- * receive address can be paid again after the wallet rotated past it, and such a payment
4163
- * would stay invisible. Only an owner's explicit {@link ContractWatchState} narrows it; the
4164
- * row stays in the repository for reads, annotation and history.
4165
- */
4166
- getWatchedContracts(): Contract[];
4167
- /** Scripts the subscription carries; wider than the sync scope {@link getWatchedContracts}. */
4168
- private getSubscribedScripts;
4169
- /** @see IContractManager.watchScript for the delivery and filter contract. */
4170
- addWatchedScript(script: string | string[], options?: {
4171
- label?: string;
4172
- }): Promise<void>;
4173
- /** Stop watching a script added by {@link addWatchedScript}. */
4174
- removeWatchedScript(script: string | string[]): Promise<void>;
4175
- /** Every script registered via {@link addWatchedScript}. */
4176
- getWatchedScripts(): WatchedScript[];
4177
- /** Repository virtual outputs for contracts, grouped by contract script. */
4178
- private getContractVtxos;
4179
- /** Start watching for virtual output events across all watched contracts. */
4180
- startWatching(callback: ContractWatcherEventCallback): Promise<() => void>;
4181
- stopWatching(): Promise<void>;
4182
- isCurrentlyWatching(): boolean;
4183
- getConnectionState(): ConnectionState;
4184
- /** Force a poll of all watched contracts (manual refresh, app resume). */
4185
- forcePoll(): Promise<void>;
4186
- /** @param skipUpdate - The caller already established `subscriptionId`. */
4187
- private connect;
4188
- /**
4189
- * Handle "this environment has no `EventSource`": warn once and return true so the caller
4190
- * skips reconnecting. A missing global is not a dropped connection; unlimited backoff would
4191
- * retry forever and fire a `connection_reset` (read as "resync, stream coming back") every
4192
- * few seconds.
4193
- */
4194
- private reportEventSourceUnavailable;
4195
- private scheduleReconnect;
4196
- /** Replays repository state — only what a sync stored; watch-only scripts poll the indexer. */
4197
- private startFailsafePolling;
4198
- private pollAllContracts;
4199
- /**
4200
- * Poll watch-only scripts against the indexer and emit the delta. Not {@link pollContracts}:
4201
- * that diffs the wallet repository, permanently empty for a script the wallet doesn't own, so
4202
- * every live output would read as spent.
4203
- */
4204
- private pollWatchedScripts;
4205
- /** Poll specific contracts' repository state and emit events for changes. */
4206
- private pollContracts;
4207
- /**
4208
- * Run `fn` with subscription updates coalesced into one `subscribeForScripts` on the way out
4209
- * (success or error). Each subscribe posts the *whole* script list, so N eager updates would
4210
- * be quadratic.
4211
- *
4212
- * A contract added inside the scope isn't streaming until the flush, and the failsafe poll
4213
- * only replays repository state. Callers must supply their own catch-up (`Wallet.restore`
4214
- * follows `scanContracts` with a bulk `refreshVtxos`) or keep the scope short.
4215
- */
4216
- withCoalescedSubscription<T>(fn: () => Promise<T>): Promise<T>;
4217
- private tryUpdateSubscription;
4218
- private cancelSubscriptionRetry;
4219
- private scheduleSubscriptionRetry;
4220
- /** @see getSubscribedScripts */
4221
- private updateSubscription;
4222
- private sendSubscriptionUpdate;
4223
- private subscribeWithTimeout;
4224
- private listenLoop;
4225
- /**
4226
- * Normalization boundary: a consumer `IndexerProvider` may yield legacy-shaped VTXOs, and the
4227
- * normalized shape is what external event consumers receive.
4228
- */
4229
- private handleSubscriptionUpdate;
4230
- /**
4231
- * Route each subscription VTXO to the single contract locking it via `vtxo.script`, skipping
4232
- * unknown scripts: fan-out produced phantom state in non-owning contracts.
4233
- */
4234
- private processSubscriptionVtxos;
4235
- /** As {@link emitVtxoEvent}, less the `contract` and the annotation. */
4236
- private emitWatchedScriptEvent;
4237
- private emitVtxoEvent;
4238
- /** A successful reset reconciles every watched contract, so it clears {@link ContractState.stale}. */
4239
- private emitConnectionReset;
4240
- }
4241
-
4242
- /** Delegate identity and fee information returned by `getDelegateInfo`. */
4243
- interface DelegateInfo {
4244
- /** Delegate public key. */
4245
- pubkey: string;
4246
- /** Delegate fee amount or expression returned by the delegate. */
4247
- fee: string;
4248
- /** Address for delegate fee collection. */
4249
- delegateAddress: string;
4250
- }
4251
- /** Optional delegate behavior flags. */
4252
- interface DelegateOptions {
4253
- /**
4254
- * Tell the delegate not to replace an existing delegation (signed register intent + its
4255
- * forfeits) that already includes at least one virtual output from this request.
4256
- *
4257
- * @defaultValue `false`
4258
- */
4259
- rejectReplace?: boolean;
4260
- }
4261
- /** Provider interface for a remote delegation service. */
4262
- interface DelegateProvider {
4263
- /**
4264
- * Request delegation for a signed register intent and its forfeit transactions.
4265
- *
4266
- * @param forfeitTxs - Forfeit transactions associated with the delegation request
4267
- */
4268
- delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
4269
- /** Fetch delegate metadata: pubkey, fee, and delegate address. */
4270
- getDelegateInfo(): Promise<DelegateInfo>;
4271
- }
4272
- /**
4273
- * REST-based delegate provider implementation.
4274
- * @example
4275
- * ```typescript
4276
- * const provider = new RestDelegateProvider('https://delegate.example.com');
4277
- * const info = await provider.getDelegateInfo();
4278
- * await provider.delegate(intent, forfeitTxs);
4279
- * ```
4280
- */
4281
- declare class RestDelegateProvider implements DelegateProvider {
4282
- url: string;
4283
- /** @param url - Base URL of the remote delegation service. */
4284
- constructor(url: string);
4285
- /**
4286
- * Submit a delegation request to the remote delegation service.
4287
- *
4288
- * @throws Error if the remote service rejects the request
4289
- */
4290
- delegate(intent: SignedIntent<Intent.RegisterMessage>, forfeitTxs: string[], options?: DelegateOptions): Promise<void>;
4291
- /**
4292
- * Fetch delegate metadata exposed by the remote delegation service.
4293
- *
4294
- * @throws Error if the remote service returns invalid data
4295
- */
4296
- getDelegateInfo(): Promise<DelegateInfo>;
4297
- }
4298
-
4299
- interface IDelegateManager {
4300
- /**
4301
- * Delegate virtual outputs to the remote delegation service.
4302
- *
4303
- * Vtxos that are not locked to a delegate-type contract (no tap leaf
4304
- * matches the delegate's pubkey) are filtered out silently, since they
4305
- * cannot be co-signed by the delegate.
4306
- *
4307
- * @param vtxos - Virtual outputs to delegate
4308
- * @param destination - Arkade address that should receive renewed funds
4309
- * @param delegateAt - Optional timestamp to force a specific delegation time
4310
- * @returns Successfully delegated and failed outpoint groups
4311
- */
4312
- delegate(vtxos: ContractVtxo[], destination: string, delegateAt?: Date): Promise<{
4313
- delegated: Outpoint[];
4314
- failed: {
4315
- outpoints: Outpoint[];
4316
- error: unknown;
4317
- }[];
4318
- }>;
4319
- /** Fetch delegate metadata such as pubkey, fee, and delegate address. */
4320
- getDelegateInfo(): Promise<DelegateInfo>;
4321
- }
4322
- declare class DelegateManagerImpl implements IDelegateManager {
4323
- readonly delegateProvider: DelegateProvider;
4324
- readonly arkInfoProvider: Pick<ArkProvider, "getInfo">;
4325
- readonly identity: Identity;
4326
- /** Create a delegate manager from the configured provider, Arkade info source, and wallet identity. */
4327
- constructor(delegateProvider: DelegateProvider, arkInfoProvider: Pick<ArkProvider, "getInfo">, identity: Identity);
4328
- getDelegateInfo(): Promise<DelegateInfo>;
4329
- delegate(vtxos: ContractVtxo[], destination: string, delegateAt?: Date): Promise<{
4330
- delegated: Outpoint[];
4331
- failed: {
4332
- outpoints: Outpoint[];
4333
- error: unknown;
4334
- }[];
4335
- }>;
4336
- }
4337
-
4338
- /** One transaction's participation in one logical action. */
4339
- interface GroupMembership {
4340
- /**
4341
- * Stable id of the action; txs sharing it group together. Third-party
4342
- * resolvers should namespace it (`"vendor:thing"`) to avoid colliding with
4343
- * other resolvers' groups. SDK built-ins use namespaced ids such as `boarding:`.
4344
- * A membership with an empty groupId is dropped.
4345
- */
4346
- groupId: string;
4347
- /** Human label for the action, e.g. "Dice game". */
4348
- label?: string;
4349
- /** App category for icon/filtering, e.g. "game". */
4350
- kind?: string;
4351
- /**
4352
- * Outcome of the action this membership belongs to, e.g. "failed",
4353
- * "refunded" — an opaque machine token for the app to map to its own
4354
- * copy or icon, not display text. Merged first-writer-wins across
4355
- * resolvers sharing a `groupId`, like `label` and `kind`.
4356
- */
4357
- outcome?: string;
4358
- /**
4359
- * Free-form row data. Same-group metadata is shallow-merged with
4360
- * earlier-resolver keys winning.
4361
- */
4362
- metadata?: Record<string, unknown>;
4363
- /**
4364
- * This tx's unsigned sat contribution to this group. Defaults to the tx's
4365
- * full amount; the builder applies direction. Use it to split a batched tx
4366
- * across groups. Same-key receive rows paired with a sent row are treated
4367
- * as change and excluded from `Activity.amount`. A membership with a
4368
- * non-finite amount (NaN/Infinity) is dropped.
4369
- */
4370
- amount?: number;
4371
- }
4372
- /** A pluggable resolver keyed by `id`. */
4373
- interface ActivityResolver {
4374
- /**
4375
- * Registry key — override or remove by it. Namespace it (`"vendor:games"`)
4376
- * so independent libraries don't clobber each other; `use()` overwrites
4377
- * silently on a duplicate id.
4378
- */
4379
- id: string;
4380
- /**
4381
- * Load correlation data before `resolve` runs. If it rejects, this resolver
4382
- * contributes no memberships.
4383
- */
4384
- prepare?(): Promise<void>;
4385
- /** Pure and synchronous. The groups this tx belongs to, or undefined to leave it plain. */
4386
- resolve(tx: ArkTransaction): GroupMembership[] | undefined;
4387
- }
4388
- /** The non-id, non-amount part of a {@link GroupMembership}. */
4389
- interface ActivityIntent {
4390
- /** Human label for the action, e.g. "Dice game". */
4391
- label?: string;
4392
- /** App category for icon/filtering, e.g. "game". */
4393
- kind?: string;
4394
- /**
4395
- * Resolver-declared outcome for the group, e.g. "failed", "refunded" — an
4396
- * opaque machine token for the app to map to its own copy or icon, not
4397
- * display text.
4398
- */
4399
- outcome?: string;
4400
- /** Free-form row data, shallow-merged across the group's resolvers (first-writer-wins). */
4401
- metadata?: Record<string, unknown>;
4402
- }
4403
- /** One logical activity. */
4404
- interface Activity {
4405
- /** The groupId, or the natural tx key for untagged rows. */
4406
- id: string;
4407
- /** Merged intent for the group, if any resolver tagged it. */
4408
- intent?: ActivityIntent;
4409
- /** Member txs, oldest-first. */
4410
- txs: ArkTransaction[];
4411
- /** Signed net sats: positive received, negative sent; same-key change rows are excluded. */
4412
- amount: number;
4413
- /** Earliest member createdAt (ms since epoch). */
4414
- createdAt: number;
4415
- /** True once every member tx is settled. */
4416
- settled: boolean;
4417
- }
4418
- /** Resolver registry keyed by id. */
4419
- declare class ActivityRegistry {
4420
- private readonly resolvers;
4421
- /** Add a resolver, or override an existing one with the same id (kept in place). */
4422
- use(resolver: ActivityResolver): void;
4423
- /** Remove a resolver (built-in or custom) by id. */
4424
- remove(id: string): void;
4425
- /** The registered resolver ids, in registration order. */
4426
- list(): string[];
4427
- /** All registered resolvers, in registration (priority) order. */
4428
- all(): ActivityResolver[];
4429
- }
4430
- /** Built-in resolver: labels on-chain boarding (deposit) transactions. */
4431
- declare function boardingResolver(): ActivityResolver;
4432
- /** Built-in resolver: labels collaborative exits (VTXOs forfeited to chain in a batch). */
4433
- declare function collabExitResolver(): ActivityResolver;
4434
- /**
4435
- * Built-in resolver: labels the genesis transaction of a minted asset — "Asset
4436
- * mint" on the issuer's sent tx, "Asset receive" when the fresh supply arrives
4437
- * in the genesis tx itself. An asset id encodes its genesis txid; reissues and
4438
- * transfers carry the asset under a different `arkTxid`, so they are left plain.
4439
- *
4440
- * `metadata.amount` is the decimal string of the asset's `bigint` amount, kept
4441
- * as a string so large supplies survive JSON round-trips without truncation.
4442
- * Recover the value with `BigInt(metadata.amount as string)` — using it
4443
- * directly in arithmetic coerces (`"10" + 1` is `"101"`, not `11`) and loses
4444
- * precision past `Number.MAX_SAFE_INTEGER`.
4445
- */
4446
- declare function assetMintResolver(): ActivityResolver;
4447
- /**
4448
- * A registry pre-populated with the SDK's built-in resolvers: `boarding`,
4449
- * `collab-exit`, and `asset-mint`.
4450
- */
4451
- declare function createDefaultActivityRegistry(): ActivityRegistry;
4452
-
4453
- /**
4454
- * A source of unilateral-exit chain data for a set of VTXOs. Sources are tried
4455
- * in order by the resolver; a source returns `null` (chain) or omits keys (psbts)
4456
- * for data it cannot supply — a "miss" — and the resolver falls through.
4457
- */
4458
- interface ExitDataSource {
4459
- readonly name: string;
4460
- /** Full ancestry chain for a vtxo (all pages merged), or null on a miss. */
4461
- getVtxoChain(vtxo: Outpoint): Promise<ChainTx[] | null>;
4462
- /** Base64 PSBTs this source has, keyed by (unsigned) txid. Absent key = miss. */
4463
- getVirtualTxs(txids: string[]): Promise<Map<string, string>>;
4464
- }
4465
- /** Reads exit chain data through an ordered chain of sources. */
4466
- interface ExitChainResolver {
4467
- getVtxoChain(vtxo: Outpoint): Promise<ChainTx[]>;
4468
- getVirtualTxs(txids: string[]): Promise<string[]>;
4268
+ * @defaultValue `5_000` (5 seconds)
4269
+ */
4270
+ maxReconnectDelayMs?: number;
4271
+ /**
4272
+ * Maximum retry attempts per reconnection or subscription update failure; 0 for unlimited.
4273
+ *
4274
+ * @defaultValue `0` (unlimited)
4275
+ */
4276
+ maxReconnectAttempts?: number;
4277
+ /**
4278
+ * Deadline for each subscription POST, including its response body (ms).
4279
+ * Timeouts use the subscription retry policy without interrupting the event stream.
4280
+ *
4281
+ * @defaultValue `30_000` (30 seconds)
4282
+ * @remarks Must be greater than zero; a subscription request needs a finite deadline.
4283
+ */
4284
+ subscriptionRequestTimeoutMs?: number;
4469
4285
  }
4470
4286
  /**
4471
- * Assemble the standard exit-data resolver: local repo (if configured) → any
4472
- * extra sources (e.g. a future provider) → indexer. Read-through persists to the
4473
- * repository. With no repository this is exactly the indexer path (a no-op seam).
4287
+ * A returned promise holds off the poll until the event's handling settles; resolving `false` or
4288
+ * rejecting keeps it off until a later handling succeeds.
4474
4289
  */
4475
- declare function createExitChainResolver(params: {
4476
- indexer: IndexerProvider;
4477
- repository?: VirtualTxRepository;
4478
- extraSources?: ExitDataSource[];
4479
- }): ExitChainResolver;
4480
-
4481
- type ExitCaptureMode = "lite" | "full";
4482
-
4290
+ type ContractWatcherEventCallback = (event: ContractEvent) => unknown;
4291
+ type ConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting";
4483
4292
  /**
4484
- * Emulator REST client.
4485
- *
4486
- * The emulator is a signing service that executes Arkade scripts
4487
- * and co-signs transactions when the scripts pass validation.
4293
+ * Watches contracts for virtual output changes: subscription with exponential-backoff reconnect,
4294
+ * a poll after every (re)connect, and failsafe polling for missed events.
4488
4295
  *
4489
- * The read here goes through `baseFetch`, the SDK's shared fetch boundary, so
4490
- * it picks up whatever policy that boundary carries. The four submit calls
4491
- * deliberately do not: aborting a submit would not tell the caller whether the
4492
- * emulator signed, and none of them has a way to find out, so they stay on the
4493
- * global `fetch` with their transport-error type unchanged.
4494
- */
4495
-
4496
- interface EmulatorInfo {
4497
- signerPubkey: string;
4498
- }
4499
- interface EmulatorProvider {
4500
- getInfo(): Promise<EmulatorInfo>;
4501
- submitTx(arkTx: string, checkpointTxs: string[]): Promise<{
4502
- signedArkTx: string;
4503
- signedCheckpointTxs: string[];
4504
- }>;
4505
- submitIntent(intent: {
4506
- proof: string;
4507
- message: Intent.RegisterMessage;
4508
- }): Promise<string>;
4509
- submitFinalization(intent: {
4510
- proof: string;
4511
- message: Intent.RegisterMessage;
4512
- }, forfeits: string[], connectorTree: ConnectorTreeNode[] | null, commitmentTx: string): Promise<{
4513
- signedForfeits: string[];
4514
- signedCommitmentTx?: string;
4515
- }>;
4516
- submitOnchainTx(tx: string): Promise<{
4517
- signedTx: string;
4518
- }>;
4519
- }
4520
- interface ConnectorTreeNode {
4521
- txid: string;
4522
- tx: string;
4523
- children: Record<string, string>;
4524
- }
4525
- /**
4526
- * REST-based emulator client.
4296
+ * Event-only: it reads the wallet repository for baselines but never writes it;
4297
+ * `ContractManager` owns persistence.
4527
4298
  *
4528
4299
  * @example
4529
4300
  * ```typescript
4530
- * const client = new RestEmulatorProvider('http://localhost:7073');
4531
- * const info = await client.getInfo();
4532
- * console.log('Emulator pubkey:', info.signerPubkey);
4301
+ * const watcher = new ContractWatcher({
4302
+ * indexerProvider: wallet.indexerProvider,
4303
+ * });
4304
+ *
4305
+ * // Add the wallet's default contract
4306
+ * await watcher.addContract(defaultContract);
4307
+ *
4308
+ * // Add additional contracts (swaps, etc.)
4309
+ * await watcher.addContract(swapContract);
4310
+ *
4311
+ * // Start watching for events
4312
+ * const stop = await watcher.startWatching((event) => {
4313
+ * console.log(`${event.type} on contract ${event.contractScript}`);
4314
+ * });
4315
+ *
4316
+ * // Later: stop watching
4317
+ * stop();
4533
4318
  * ```
4534
4319
  */
4535
- declare class RestEmulatorProvider implements EmulatorProvider {
4536
- serverUrl: string;
4537
- constructor(serverUrl: string);
4538
- getInfo(): Promise<EmulatorInfo>;
4539
- submitTx(arkTx: string, checkpointTxs: string[]): Promise<{
4540
- signedArkTx: string;
4541
- signedCheckpointTxs: string[];
4542
- }>;
4543
- submitIntent(intent: {
4544
- proof: string;
4545
- message: Intent.RegisterMessage;
4546
- }): Promise<string>;
4547
- submitFinalization(intent: {
4548
- proof: string;
4549
- message: Intent.RegisterMessage;
4550
- }, forfeits: string[], connectorTree: ConnectorTreeNode[] | null, commitmentTx: string): Promise<{
4551
- signedForfeits: string[];
4552
- signedCommitmentTx?: string;
4553
- }>;
4554
- submitOnchainTx(tx: string): Promise<{
4555
- signedTx: string;
4556
- }>;
4320
+ declare class ContractWatcher {
4321
+ private config;
4322
+ private contracts;
4323
+ /** In-memory and process-lifetime; never persisted. */
4324
+ private watchedScripts;
4325
+ private subscriptionId?;
4326
+ private abortController?;
4327
+ private isWatching;
4328
+ private eventCallback?;
4329
+ private connectionState;
4330
+ private reconnectAttempts;
4331
+ private reconnectTimeoutId?;
4332
+ private failsafePollIntervalId?;
4333
+ /** See {@link withCoalescedSubscription}. */
4334
+ private subscriptionBatchDepth;
4335
+ private subscriptionUpdateDeferred;
4336
+ /** Subscription POSTs can fail while the event stream remains healthy. */
4337
+ private subscriptionRetryTimeoutId?;
4338
+ private subscriptionRetryAttempts;
4339
+ /** A failed update needs catch-up even when reconnect owns the next attempt. */
4340
+ private subscriptionNeedsCatchUp;
4341
+ /** Serialize subscription creation and updates against the latest desired scripts. */
4342
+ private subscriptionUpdate;
4343
+ /** See {@link reportEventSourceUnavailable} — said once, not per attempt. */
4344
+ private eventSourceReported;
4345
+ /** @see ContractWatcherConfig */
4346
+ constructor(config: ContractWatcherConfig);
4347
+ /**
4348
+ * Add a contract to be watched. Every contract is subscribed and polled whatever its
4349
+ * {@link ContractState}, except a `retained` one, which is held for reads only.
4350
+ *
4351
+ * @see getWatchedContracts
4352
+ */
4353
+ addContract(contract: Contract): Promise<void>;
4354
+ /** Pre-populate `lastKnownVtxos` from the wallet repository so polls emit only real deltas. */
4355
+ private seedLastKnownVtxos;
4356
+ updateContract(contract: Contract): Promise<void>;
4357
+ removeContract(contractScript: string): Promise<void>;
4358
+ /** All in-memory contracts. */
4359
+ getAllContracts(): Contract[];
4360
+ /**
4361
+ * Every registered contract except `retained` ones, retired (`inactive`) addresses included.
4362
+ *
4363
+ * Feeds both the subscription and the sweep scope. `state` must never narrow it: an Ark
4364
+ * receive address can be paid again after the wallet rotated past it, and such a payment
4365
+ * would stay invisible. Only an owner's explicit {@link ContractWatchState} narrows it; the
4366
+ * row stays in the repository for reads, annotation and history.
4367
+ */
4368
+ getWatchedContracts(): Contract[];
4369
+ /** Scripts the subscription carries; wider than the sync scope {@link getWatchedContracts}. */
4370
+ private getSubscribedScripts;
4371
+ /** @see IContractManager.watchScript for the delivery and filter contract. */
4372
+ addWatchedScript(script: string | string[], options?: {
4373
+ label?: string;
4374
+ }): Promise<void>;
4375
+ /** Stop watching a script added by {@link addWatchedScript}. */
4376
+ removeWatchedScript(script: string | string[]): Promise<void>;
4377
+ /** Every script registered via {@link addWatchedScript}. */
4378
+ getWatchedScripts(): WatchedScript[];
4379
+ /** Repository virtual outputs for contracts, grouped by contract script. */
4380
+ private getContractVtxos;
4381
+ /** Start watching for virtual output events across all watched contracts. */
4382
+ startWatching(callback: ContractWatcherEventCallback): Promise<() => void>;
4383
+ stopWatching(): Promise<void>;
4384
+ isCurrentlyWatching(): boolean;
4385
+ getConnectionState(): ConnectionState;
4386
+ /** Force a poll of all watched contracts (manual refresh, app resume). */
4387
+ forcePoll(): Promise<void>;
4388
+ /** @param skipUpdate - The caller already established `subscriptionId`. */
4389
+ private connect;
4390
+ /**
4391
+ * Handle "this environment has no `EventSource`": warn once and return true so the caller
4392
+ * skips reconnecting. A missing global is not a dropped connection; unlimited backoff would
4393
+ * retry forever and fire a `connection_reset` (read as "resync, stream coming back") every
4394
+ * few seconds.
4395
+ */
4396
+ private reportEventSourceUnavailable;
4397
+ private scheduleReconnect;
4398
+ /** Replays repository state — only what a sync stored; watch-only scripts poll the indexer. */
4399
+ private startFailsafePolling;
4400
+ private pollAllContracts;
4401
+ /**
4402
+ * Poll watch-only scripts against the indexer and emit the delta. Not {@link pollContracts}:
4403
+ * that diffs the wallet repository, permanently empty for a script the wallet doesn't own, so
4404
+ * every live output would read as spent.
4405
+ */
4406
+ private pollWatchedScripts;
4407
+ /** Poll specific contracts' repository state and emit events for changes. */
4408
+ private pollContracts;
4409
+ /**
4410
+ * Run `fn` with subscription updates coalesced into one `subscribeForScripts` on the way out
4411
+ * (success or error). Each subscribe posts the *whole* script list, so N eager updates would
4412
+ * be quadratic.
4413
+ *
4414
+ * A contract added inside the scope isn't streaming until the flush, and the failsafe poll
4415
+ * only replays repository state. Callers must supply their own catch-up (`Wallet.restore`
4416
+ * follows `scanContracts` with a bulk `refreshVtxos`) or keep the scope short.
4417
+ */
4418
+ withCoalescedSubscription<T>(fn: () => Promise<T>): Promise<T>;
4419
+ private tryUpdateSubscription;
4420
+ private cancelSubscriptionRetry;
4421
+ private scheduleSubscriptionRetry;
4422
+ /** @see getSubscribedScripts */
4423
+ private updateSubscription;
4424
+ private sendSubscriptionUpdate;
4425
+ private subscribeWithTimeout;
4426
+ private listenLoop;
4427
+ /**
4428
+ * Normalization boundary: a consumer `IndexerProvider` may yield legacy-shaped VTXOs, and the
4429
+ * normalized shape is what external event consumers receive.
4430
+ */
4431
+ private handleSubscriptionUpdate;
4432
+ /**
4433
+ * Route each subscription VTXO to the single contract locking it via `vtxo.script`, skipping
4434
+ * unknown scripts: fan-out produced phantom state in non-owning contracts.
4435
+ */
4436
+ private processSubscriptionVtxos;
4437
+ /** As {@link emitVtxoEvent}, less the `contract` and the annotation. */
4438
+ private emitWatchedScriptEvent;
4439
+ private emitVtxoEvent;
4440
+ /** A successful reset reconciles every watched contract, so it clears {@link ContractState.stale}. */
4441
+ private emitConnectionReset;
4557
4442
  }
4558
4443
 
4559
4444
  /**
@@ -4566,9 +4451,10 @@ declare class RestEmulatorProvider implements EmulatorProvider {
4566
4451
  /**
4567
4452
  * The Arkade deployment to talk to.
4568
4453
  *
4569
- * - `{ network: "bitcoin" }` — the hosted mainnet deployment, including its covenant co-signer
4570
- * ({@link DEFAULT_ARKADE_EMULATOR_URL}). Mainnet is the only network with a one-liner.
4571
- * - `{ operatorUrl, emulatorUrl? }` — a specific operator. A custom operator does not imply the default
4454
+ * - `{ network: "bitcoin" }`: the hosted mainnet deployment, including the operator's cosigner
4455
+ * that emulates Arkade Script ({@link DEFAULT_ARKADE_EMULATOR_URL}). Mainnet is the only network
4456
+ * with a one-liner.
4457
+ * - `{ operatorUrl, emulatorUrl? }`: a specific operator. A custom operator does not imply the default
4572
4458
  * emulator: without `emulatorUrl`, covenant (`arkadeScript`) paths stay disabled.
4573
4459
  */
4574
4460
  type ArkadeService = {
@@ -4579,10 +4465,11 @@ type ArkadeService = {
4579
4465
  };
4580
4466
  /** The providers and operator info an {@link ArkadeService} resolves to. */
4581
4467
  interface ResolvedArkadeService {
4582
- arkProvider: ArkProvider;
4468
+ arkProvider: OperatorProvider;
4583
4469
  indexerProvider: IndexerProvider;
4584
4470
  onchainProvider: OnchainProvider;
4585
- /** The covenant co-signer; absent for an `operatorUrl` service without `emulatorUrl`. */
4471
+ /** The operator's cosigner that emulates Arkade Script; absent for an `operatorUrl` service
4472
+ * without `emulatorUrl`. */
4586
4473
  emulator?: EmulatorProvider;
4587
4474
  info: ArkadeInfo;
4588
4475
  }
@@ -4594,7 +4481,7 @@ interface ResolvedArkadeService {
4594
4481
  * the deployment, and silently using another one is the expensive failure.
4595
4482
  */
4596
4483
  declare function resolveArkadeService(service: ArkadeService, opts?: {
4597
- arkProvider?: ArkProvider;
4484
+ arkProvider?: OperatorProvider;
4598
4485
  info?: ArkadeInfo;
4599
4486
  }): Promise<ResolvedArkadeService>;
4600
4487
 
@@ -4660,7 +4547,7 @@ interface NewAddress {
4660
4547
  * @see StorageConfig
4661
4548
  */
4662
4549
  interface BaseWalletConfig {
4663
- /** Optional Arkade server public key used to construct and validate Arkade addresses. */
4550
+ /** Optional operator public key used to construct and validate Arkade addresses. */
4664
4551
  arkServerPublicKey?: string;
4665
4552
  /** Relative timelock applied to boarding scripts. */
4666
4553
  boardingTimelock?: RelativeTimelock;
@@ -4675,15 +4562,17 @@ interface BaseWalletConfig {
4675
4562
  /** Repository-backed storage configuration overrides. Defaults to IndexedDB if unset. */
4676
4563
  storage?: StorageConfig;
4677
4564
  /**
4678
- * The Arkade deployment, in place of `arkProvider`/`indexerProvider`/`onchainProvider`
4565
+ * The Arkade deployment, in place of `operatorProvider`/`indexerProvider`/`onchainProvider`
4679
4566
  * (combining them throws): `{ network: "bitcoin" }` or `{ operatorUrl }`. With
4680
4567
  * `{ network }`, an operator reporting another network throws.
4681
4568
  *
4682
4569
  * @see ArkadeService
4683
4570
  */
4684
4571
  service?: ArkadeService;
4685
- /** Optional Arkade provider instance. */
4686
- arkProvider?: ArkProvider;
4572
+ /** Optional operator provider instance. */
4573
+ operatorProvider?: OperatorProvider;
4574
+ /** @deprecated Use {@link operatorProvider}. */
4575
+ arkProvider?: OperatorProvider;
4687
4576
  /** Optional indexer provider instance. */
4688
4577
  indexerProvider?: IndexerProvider;
4689
4578
  /** Optional onchain provider, or a factory given the operator's network once it is known. */
@@ -4703,7 +4592,7 @@ interface BaseWalletConfig {
4703
4592
  * // Provider-based configuration (e.g., for Expo/React Native)
4704
4593
  * const wallet = await ReadonlyWallet.create({
4705
4594
  * identity: ReadonlySingleKey.fromPublicKey(pubkey),
4706
- * arkProvider: new ExpoArkProvider(),
4595
+ * operatorProvider: new ExpoOperatorProvider(),
4707
4596
  * indexerProvider: new ExpoIndexerProvider(),
4708
4597
  * onchainProvider: new EsploraProvider()
4709
4598
  * });
@@ -4734,7 +4623,7 @@ interface ReadonlyWalletConfig extends BaseWalletConfig {
4734
4623
  * // Provider-based configuration
4735
4624
  * const wallet = await Wallet.create({
4736
4625
  * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
4737
- * arkProvider: new ExpoArkProvider(),
4626
+ * operatorProvider: new ExpoOperatorProvider(),
4738
4627
  * indexerProvider: new ExpoIndexerProvider(),
4739
4628
  * onchainProvider: new EsploraProvider()
4740
4629
  * });
@@ -4742,7 +4631,7 @@ interface ReadonlyWalletConfig extends BaseWalletConfig {
4742
4631
  * // With settlement configuration
4743
4632
  * const wallet = await Wallet.create({
4744
4633
  * identity: MnemonicIdentity.fromMnemonic('abandon abandon...'),
4745
- * arkProvider: new RestArkProvider(),
4634
+ * operatorProvider: new RestOperatorProvider(),
4746
4635
  * settlementConfig: {
4747
4636
  * vtxoThreshold: 60 * 60 * 24, // 24 hours in seconds
4748
4637
  * boardingUtxoSweep: true,
@@ -4800,6 +4689,15 @@ interface WalletConfig extends ReadonlyWalletConfig {
4800
4689
  * @defaultValue `false`
4801
4690
  */
4802
4691
  concurrentSpending?: boolean;
4692
+ /** Cosigns onchain inputs whose spend carries an emulator packet; no default. */
4693
+ emulator?: EmulatorProvider;
4694
+ /**
4695
+ * Minimum blocks that must remain before a coin's exit CSV matures for the
4696
+ * client to request an onchain cosign. Non-negative integer.
4697
+ *
4698
+ * @defaultValue 6
4699
+ */
4700
+ onchainCosignMarginBlocks?: number;
4803
4701
  }
4804
4702
  /**
4805
4703
  * Repository implementations used to store wallet and contract state.
@@ -4817,7 +4715,7 @@ type StorageConfig = {
4817
4715
  * Optional intent-lifecycle repository. Opt-in: when present, the wallet
4818
4716
  * persists settlement intents and excludes intent-locked VTXOs from
4819
4717
  * spendable balance. Absent ⇒ those code paths are no-ops. Only one wallet
4820
- * instance may settle against it: reconciliation deletes from the server any
4718
+ * instance may settle against it: reconciliation deletes from the operator any
4821
4719
  * pending intent that instance is not settling itself.
4822
4720
  */
4823
4721
  intentRepository?: IntentRepository;
@@ -4843,8 +4741,8 @@ type StorageConfig = {
4843
4741
  };
4844
4742
  /** Provider class constructor shape for dependency injection. */
4845
4743
  interface ProviderClass<T> {
4846
- /** @param serverUrl - Base server URL used by the provider */
4847
- new (serverUrl: string): T;
4744
+ /** @param operatorUrl - Base operator URL used by the provider */
4745
+ new (operatorUrl: string): T;
4848
4746
  }
4849
4747
  /**
4850
4748
  * Balance summary returned by `IWallet.getBalance`.
@@ -5024,6 +4922,17 @@ interface SendParams {
5024
4922
  /** Maximum sats of unavoidable change this send may pay as an offchain fee. Defaults to any change below the operator's VTXO minimum; 0 disables it. */
5025
4923
  maxChangeFee?: number;
5026
4924
  }
4925
+ /** Arguments of {@link IWallet.sendOnchain}. */
4926
+ type SendOnchainParams = {
4927
+ outputs: {
4928
+ address: string;
4929
+ amount: number;
4930
+ }[];
4931
+ /** Spend only these onchain coins; defaults to every cosignable generically spendable coin. */
4932
+ inputs?: Outpoint[];
4933
+ /** Spend every selected cosignable coin to this address (Σin − fee); `outputs` must be empty. */
4934
+ sweepTo?: string;
4935
+ };
5027
4936
  /**
5028
4937
  * Known asset metadata fields.
5029
4938
  *
@@ -5156,6 +5065,8 @@ interface Status {
5156
5065
  block_hash?: string;
5157
5066
  /** Block time where the output was confirmed, when known. */
5158
5067
  block_time?: number;
5068
+ /** Set on an onchain coin the contract manager stored from the onchain provider. */
5069
+ fromExplorer?: boolean;
5159
5070
  }
5160
5071
  /** Onchain output location data. */
5161
5072
  interface Outpoint {
@@ -5196,7 +5107,7 @@ interface VirtualCoin extends Coin {
5196
5107
  isUnrolled: boolean;
5197
5108
  /** Whether this output was spent offchain (`spentBy` helper); not set for unrolled or swept. */
5198
5109
  isSpent?: boolean;
5199
- /** Whether the server has swept the batch this virtual output belongs to. */
5110
+ /** Whether the operator has swept the batch this virtual output belongs to. */
5200
5111
  isSwept?: boolean;
5201
5112
  /** Whether this virtual output is not yet finalized in a batch. */
5202
5113
  isPreconfirmed?: boolean;
@@ -5214,14 +5125,14 @@ interface VirtualCoin extends Coin {
5214
5125
  /** Batch commitment transaction(s) this virtual output depends on. */
5215
5126
  commitmentTxIds?: string[];
5216
5127
  /**
5217
- * Wall-clock batch expiry, when the server expressed expiry as a timestamp.
5128
+ * Wall-clock batch expiry, when the operator expressed expiry as a timestamp.
5218
5129
  *
5219
5130
  * @remarks
5220
5131
  * Mutually exclusive with `expiresAtHeight`; both are absent when there is no expiry.
5221
5132
  */
5222
5133
  expiresAt?: Date;
5223
5134
  /**
5224
- * Block-height batch expiry, when the server expressed expiry as a height (regtest-like
5135
+ * Block-height batch expiry, when the operator expressed expiry as a height (regtest-like
5225
5136
  * deployments). Evaluating it needs a chain tip — see {@link isPastExpiry}.
5226
5137
  */
5227
5138
  expiresAtHeight?: number;
@@ -5292,8 +5203,13 @@ interface ArkTransaction {
5292
5203
  type TapLeaves = {
5293
5204
  /** Tapleaf script used for the forfeit path. */
5294
5205
  forfeitTapLeafScript: TapLeafScript;
5295
- /** Tapleaf script used for the intent path. */
5296
- intentTapLeafScript: TapLeafScript;
5206
+ /** Tapleaf script a proof signs for this coin. */
5207
+ proofTapLeafScript: TapLeafScript;
5208
+ /**
5209
+ * @deprecated Use {@link proofTapLeafScript}. SDK coins never set this key.
5210
+ * A coin that sets it signs proofs with this leaf.
5211
+ */
5212
+ intentTapLeafScript?: TapLeafScript;
5297
5213
  };
5298
5214
  /**
5299
5215
  * Onchain output data enriched with tapscript and witness data.
@@ -5395,12 +5311,14 @@ interface IAssetManager extends IReadonlyAssetManager {
5395
5311
  */
5396
5312
  burn(params: BurnParams): Promise<string>;
5397
5313
  }
5398
- /** Options for {@link IReadonlyWallet.getArkadeInfo}. */
5399
- type GetArkadeInfoOptions = {
5314
+ /** Options for {@link IReadonlyWallet.getOperatorInfo}. */
5315
+ type GetOperatorInfoOptions = {
5400
5316
  /** Throw when the operator is unreachable instead of answering from the
5401
5317
  * persisted snapshot — for callers binding the answer into a covenant. */
5402
5318
  requireLive?: boolean;
5403
5319
  };
5320
+ /** @deprecated Use {@link GetOperatorInfoOptions}. */
5321
+ type GetArkadeInfoOptions = GetOperatorInfoOptions;
5404
5322
  /**
5405
5323
  * Chain reads beyond the wallet's own VTXOs: an arbitrary script's virtual outputs and the
5406
5324
  * transactions that spent them.
@@ -5426,7 +5344,7 @@ type ArkadeReader = Pick<IndexerProvider, "getVirtualTxs"> & {
5426
5344
  * Submit and finalize a signed Arkade transaction. Only on {@link IWallet}: broadcasting is the
5427
5345
  * one thing a readonly wallet must not do (hence `ReadonlyWallet.arkProvider` is protected).
5428
5346
  */
5429
- type ArkadeBroadcaster = Pick<ArkProvider, "submitTx" | "finalizeTx">;
5347
+ type ArkadeBroadcaster = Pick<OperatorProvider, "submitTx" | "finalizeTx">;
5430
5348
  /**
5431
5349
  * Signing wallet interface: {@link IReadonlyWallet} plus sending, settling and asset operations.
5432
5350
  *
@@ -5434,9 +5352,9 @@ type ArkadeBroadcaster = Pick<ArkProvider, "submitTx" | "finalizeTx">;
5434
5352
  */
5435
5353
  interface IWallet extends IReadonlyWallet {
5436
5354
  /**
5437
- * Broadcast access to this wallet's Arkade server, so a plugin needs no server URL of its own.
5355
+ * Broadcast access to this wallet's operator, so a plugin needs no operator URL of its own.
5438
5356
  *
5439
- * @returns A submit/finalize pair bound to this wallet's server
5357
+ * @returns A submit/finalize pair bound to this wallet's operator
5440
5358
  * @see ArkadeBroadcaster
5441
5359
  */
5442
5360
  getArkadeBroadcaster(): Promise<ArkadeBroadcaster>;
@@ -5456,7 +5374,9 @@ interface IWallet extends IReadonlyWallet {
5456
5374
  * @returns Arkade transaction id
5457
5375
  * @see SettleParams
5458
5376
  */
5459
- settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void): Promise<string>;
5377
+ settle(params?: SettleParams, eventCallback?: (event: SettlementEvent) => void, hooks?: {
5378
+ onPhase?: (phase: "preparing" | "registration_attempt") => void;
5379
+ }): Promise<string>;
5460
5380
  /**
5461
5381
  * Send bitcoin and/or assets to one or more Arkade recipients, as variadic `Recipient`s or a
5462
5382
  * `SendParams` object (which can also name the inputs).
@@ -5475,6 +5395,24 @@ interface IWallet extends IReadonlyWallet {
5475
5395
  * ```
5476
5396
  */
5477
5397
  send(...args: [SendParams] | [Recipient, ...Recipient[]]): Promise<string>;
5398
+ /**
5399
+ * Fill, sign and cosign the wallet-owned onchain inputs of a PSBT through
5400
+ * the collaborative leaf, then broadcast it. Foreign inputs are left as given:
5401
+ * sign them but do not finalize them, since arkd refuses a finalized input and
5402
+ * finalizes the transaction itself.
5403
+ *
5404
+ * @param psbt - Base64 PSBT or transaction
5405
+ * @returns Onchain transaction id
5406
+ */
5407
+ cosignOnchainTx(psbt: string | Transaction$1): Promise<string>;
5408
+ /**
5409
+ * Spend onchain contract coins (boarding, unrolled) immediately via
5410
+ * {@link cosignOnchainTx}, selecting inputs and adding change.
5411
+ *
5412
+ * @returns Onchain transaction id
5413
+ * @see SendOnchainParams
5414
+ */
5415
+ sendOnchain(params: SendOnchainParams): Promise<string>;
5478
5416
  /** Asset manager bound to this wallet instance. */
5479
5417
  assetManager: IAssetManager;
5480
5418
  /** @returns Delegation manager, when configured. */
@@ -5493,7 +5431,7 @@ interface IReadonlyWallet {
5493
5431
  /** @returns Onchain boarding address used to move funds into Arkade. */
5494
5432
  getBoardingAddress(): Promise<string>;
5495
5433
  /**
5496
- * Info (network, signer key, delays, dust, fees, limits) for this wallet's Arkade server.
5434
+ * Info (network, signer key, delays, dust, fees, limits) for this wallet's operator.
5497
5435
  * Live when reachable, else the snapshot persisted at construction.
5498
5436
  *
5499
5437
  * With `requireLive` it throws instead of using the cache — for callers binding
@@ -5502,9 +5440,11 @@ interface IReadonlyWallet {
5502
5440
  *
5503
5441
  * @see ArkadeInfo
5504
5442
  */
5505
- getArkadeInfo(opts?: GetArkadeInfoOptions): Promise<ArkadeInfo>;
5443
+ getOperatorInfo(opts?: GetOperatorInfoOptions): Promise<ArkadeInfo>;
5444
+ /** @deprecated Use {@link getOperatorInfo}. */
5445
+ getArkadeInfo(opts?: GetOperatorInfoOptions): Promise<ArkadeInfo>;
5506
5446
  /**
5507
- * Server-side chain reads for scripts the wallet does not own (e.g. a plugin's covenant);
5447
+ * Operator-side chain reads for scripts the wallet does not own (e.g. a plugin's covenant);
5508
5448
  * {@link getVtxos} reads the wallet's own outputs from repositories.
5509
5449
  *
5510
5450
  * @see ArkadeReader
@@ -5578,6 +5518,15 @@ interface WalletState {
5578
5518
  */
5579
5519
  lastSyncTime?: number;
5580
5520
  }
5521
+ /** Backend transaction over fresh state. Updaters run once, synchronously, with no I/O,
5522
+ * re-entry or external side effects. Failures are propagated without automatic retries.
5523
+ */
5524
+ interface AtomicWalletState {
5525
+ readonly version: 1;
5526
+ /** Caller assertion of persistence beyond this process, not physical storage detection. */
5527
+ readonly persistent?: true;
5528
+ update(updater: (state: WalletState) => WalletState): Promise<void>;
5529
+ }
5581
5530
  interface VtxoRepositoryKey {
5582
5531
  /** Authoritative ownership key. */
5583
5532
  script: string;
@@ -5602,6 +5551,7 @@ interface WalletRepository extends AsyncDisposable {
5602
5551
  * `getVtxosForScript(s)`) are gone; implement the `*Page` reads instead.
5603
5552
  */
5604
5553
  readonly version: 2;
5554
+ readonly atomicWalletState?: AtomicWalletState;
5605
5555
  /**
5606
5556
  * Clear all data from storage.
5607
5557
  */
@@ -5704,4 +5654,4 @@ declare function isBatchSignable(identity: Identity): identity is BatchSignableI
5704
5654
  */
5705
5655
  declare function isSigningIdentity(value: unknown): value is Identity;
5706
5656
 
5707
- export { type VirtualTxRepository as $, type ArkadeInfo as A, type Contract as B, type ContractRepository as C, type ExtendedVirtualCoin as D, type ExtendedCoin as E, type PageResult as F, type GetArkadeInfoOptions as G, type ScriptVtxoCursor as H, type IWallet as I, type ScriptVtxoPageOptions as J, type StoredVtxo as K, type VtxoRepositoryKey as L, type TransactionHistoryPageFilter as M, type NormalizedExtendedVirtualCoin as N, type Outpoint as O, type PageRequest as P, type TransactionHistoryPageCursor as Q, type Recipient as R, type SettleParams as S, type TxNotificationEvent as T, type WalletState as U, VtxoScript as V, type WalletRepository as W, type ContractFilter as X, type IntentRepository as Y, type ArkIntent as Z, type IntentPageFilter as _, type Identity as a, type ContractEvent as a$, type VirtualTx as a0, type VtxoBranch as a1, ChainedTxType as a2, type DescriptorProvider as a3, type DescriptorSigningRequest as a4, Transaction as a5, type Network as a6, type BatchStartedEvent as a7, type TreeSigningStartedEvent as a8, TxTree as a9, VtxoManager as aA, type SignerSession as aB, type SignedIntent as aC, Intent as aD, type TimeHeight as aE, type IntentFeeConfig as aF, type OffchainInput as aG, FeeAmount as aH, type OnchainInput as aI, type FeeOutput as aJ, type ContractWatcherConfig as aK, type Asset as aL, type FeeInfo as aM, type GetVtxosOptions as aN, type PaginationOptions as aO, type CreateContractParams as aP, type GetContractsFilter as aQ, type GetSpendablePathsOptions as aR, type GetAllSpendingPathsOptions as aS, type InputExpiryFloor as aT, type IssuanceParams as aU, type ReissuanceParams as aV, type BurnParams as aW, type RenewVtxosOptions as aX, type NormalizedVtxoPage as aY, type WatchedScript as aZ, type PathSelection as a_, type TreeNoncesEvent as aa, type BatchFinalizationEvent as ab, type BatchFinalizedEvent as ac, type BatchFailedEvent as ad, type TreeTxEvent as ae, type TreeSignatureEvent as af, type IReadonlyWallet as ag, type ReadonlyIdentity as ah, type OnchainProvider as ai, type DelegateProvider as aj, type ReadonlyWalletConfig as ak, type ExitCaptureMode as al, type ExitDataSource as am, type IReadonlyAssetManager as an, type ContractSyncState as ao, type RecipientArkadeAddressContext as ap, EsploraProvider as aq, type NetworkName as ar, ArkAddress as as, type ContractWithVtxos as at, selectPendingRecoveryOutpoints as au, type Coin as av, ContractManager as aw, type ContractManagerConfig as ax, CSVMultisigTapscript as ay, type SettlementConfig as az, type WalletConfig as b, type GroupMembership as b$, type AssetDetails as b0, type IssuanceResult as b1, type DelegateInfo as b2, type MigrationGlobalSkipReason as b3, type MigrationLegSkipReason as b4, type SignerStatus as b5, type StorageConfig as b6, type IVtxoManager as b7, type SendBitcoinParams as b8, type ExplorerTransaction as b9, ConditionCSVMultisigTapscript as bA, ConditionMultisigTapscript as bB, type ConnectorTreeNode as bC, type ContractBalance as bD, type ContractEventCallback as bE, type ContractHandler as bF, type ContractState as bG, type ContractVtxo as bH, ContractWatcher as bI, type ContractWatcherEventCallback as bJ, DEFAULT_ARKADE_EMULATOR_URL as bK, DEFAULT_VTXO_PAGE_SIZE as bL, DelegateManagerImpl as bM, type DelegateOptions as bN, type DeprecatedSignerMigrationReport as bO, type DeprecatedSignerReport as bP, DigestMismatchError as bQ, type Discoverable as bR, type DiscoveredContract as bS, type DiscoveryDeps as bT, ESPLORA_URL as bU, type EmulatorInfo as bV, type EventSourceCapable as bW, type EventSourceFactory as bX, type EventSourceLike as bY, EventSourceUnavailableError as bZ, type ExitChainResolver as b_, type TreeNonces as ba, type TreePartialSigs as bb, type PendingTx as bc, type EncodedVtxoScript as bd, type EmulatorProvider as be, type Status as bf, type ChainTx as bg, type ArkadeService as bh, type ContractVtxoEvent as bi, type ExtendedContractVtxo as bj, type ResolvedArkadeService as bk, resolveArkadeService as bl, type PathContext as bm, type ActivityIntent as bn, type ActivityResolver as bo, type ArkIntentState as bp, type ArkTapscript as bq, type AssetMetadata as br, BITCOIN_EMULATOR_PUBKEY as bs, type BaseWalletConfig as bt, type BatchInfo as bu, type BatchSignableIdentity as bv, CLTVMultisigTapscript as bw, type CandidateDeps as bx, ChainTxType as by, type CommitmentTx as bz, type ArkadeReader as c, collabExitResolver as c$, type HandlerError as c0, INTENT_TERMINAL_STATES as c1, IndexerTxType as c2, type IntentCoin as c3, type IntentFilter as c4, type KnownMetadata as c5, MAX_PAGE_SIZE as c6, MUTINYNET_EMULATOR_PUBKEY as c7, type MigrateDeprecatedSignerOptions as c8, type MigrationLegReport as c9, type TapLeaves as cA, TapTreeCoder as cB, TapscriptType as cC, type Tx as cD, type TxHistoryRecord as cE, type TxKey as cF, type TxNotification as cG, type TxTag as cH, type TxTreeNode as cI, TxType as cJ, type Vtxo as cK, type VtxoChain as cL, type VtxoType as cM, type WalletMode as cN, type WithPrevTx as cO, assertAllowedSighashTypes as cP, assertPageRequest as cQ, assertRecipientArkadeAddress as cR, assetMintResolver as cS, attachPrevArkTxs as cT, attachPrevoutTxs as cU, boardingResolver as cV, canRecoverOnchain as cW, canSpendOffchain as cX, canSweepOnchain as cY, classifyAgainstSignerSet as cZ, classifyContractSigner as c_, type MigrationVtxoRef as ca, MultisigTapscript as cb, type NewAddressType as cc, type Nonces as cd, type Output as ce, type PageResponse as cf, PartialSig as cg, type PrevTxSource as ch, PrevTxUnavailableError as ci, type ProviderClass as cj, REGTEST_EMULATOR_PUBKEY as ck, type RawTxSource as cl, type RenewalSplit as cm, type RenewalSplitContext as cn, RestDelegateProvider as co, RestEmulatorProvider as cp, type ScanContractsOptions as cq, type ScanResult as cr, type ScheduledSession as cs, SettlementEventType as ct, type SignRequest as cu, type SignerClassification as cv, type SignerSet as cw, type SubscriptionFilter as cx, type SubscriptionResponse as cy, type SweepTxNotification as cz, type ArkadeBroadcaster as d, collectContracts as d0, collectIntents as d1, collectPages as d2, collectScriptVtxos as d3, collectTransactionHistory as d4, collectUtxos as d5, collectVtxos as d6, configureEventSource as d7, createDefaultActivityRegistry as d8, createExitChainResolver as d9, resolveEmulatorPubkey as dA, resolveEventSource as dB, resolvePrevTxs as dC, scriptFromTapLeafScript as dD, signerSetFromInfo as dE, toOffchainInputFeeParams as dF, toXOnlySignerHex as dG, withPrevTxs as dH, type TapscriptDeriving as dI, decodeTapscript as da, defaultEmulatorPubkey as db, getAllNormalizedVtxos as dc, getConfiguredEventSource as dd, getNetwork as de, getNormalizedVtxos as df, getRandomId as dg, getSequence as dh, hasCandidates as di, isBatchSignable as dj, isContractVtxoEvent as dk, isCooperativelyMigratable as dl, isDiscoverable as dm, isEventSourceUnavailableError as dn, isPastExpiry as dp, isSigningIdentity as dq, isSubdust as dr, isTerminalIntentState as ds, isVirtualCoin as dt, isVtxoExpiringSoon as du, isVtxoSpent as dv, iteratePages as dw, networkFromArkadeInfo as dx, networks as dy, pageResult as dz, type WalletBalance as e, type GetVtxosFilter as f, type GetSpendableVtxosFilter as g, type ArkTransaction as h, ActivityRegistry as i, type Activity as j, type IContractManager as k, type GetNewAddressesOptions as l, type NewAddress as m, type IDelegateManager as n, type SettlementEvent as o, type SendParams as p, type IAssetManager as q, RestArkProvider as r, RestIndexerProvider as s, type SubscriptionEvent as t, type SubscriptionHeartbeat as u, type ArkProvider as v, type IndexerProvider as w, type RelativeTimelock as x, type TapLeafScript as y, type VirtualCoin as z };
5657
+ export { type BatchRegistration as $, type ArkadeInfo as A, type Outpoint as B, type ContractRepository as C, type PageResult as D, type ExtendedCoin as E, type ScriptVtxoCursor as F, type GetOperatorInfoOptions as G, type ScriptVtxoPageOptions as H, type IWallet as I, type StoredVtxo as J, type VtxoRepositoryKey as K, type TransactionHistoryPageFilter as L, type TransactionHistoryPageCursor as M, type NormalizedExtendedVirtualCoin as N, type OperatorProvider as O, type PageRequest as P, type AtomicWalletState as Q, type Recipient as R, type SettleParams as S, type TxNotificationEvent as T, type WalletState as U, type VirtualCoin as V, type WalletRepository as W, type ContractFilter as X, type BatchRegistrationRepository as Y, type ArkIntent as Z, type IntentPageFilter as _, type Identity as a, type NormalizedVtxoPage as a$, type VirtualTxRepository as a0, type VirtualTx as a1, type VtxoBranch as a2, ChainedTxType as a3, type Network as a4, type BatchStartedEvent as a5, type TreeSigningStartedEvent as a6, TxTree as a7, type TreeNoncesEvent as a8, type BatchFinalizationEvent as a9, type SignerSession as aA, Transaction as aB, type SignedIntent as aC, Intent as aD, type SignedProof as aE, Proof as aF, type TimeHeight as aG, type DescriptorSigningRequest as aH, type IntentFeeConfig as aI, type OffchainInput as aJ, FeeAmount as aK, type OnchainInput as aL, type FeeOutput as aM, type ContractWatcherConfig as aN, type Asset as aO, type FeeInfo as aP, type GetVtxosOptions as aQ, type PaginationOptions as aR, type CreateContractParams as aS, type GetContractsFilter as aT, type GetSpendablePathsOptions as aU, type GetAllSpendingPathsOptions as aV, type InputExpiryFloor as aW, type IssuanceParams as aX, type ReissuanceParams as aY, type BurnParams as aZ, type RenewVtxosOptions as a_, type BatchFinalizedEvent as aa, type BatchFailedEvent as ab, type TreeTxEvent as ac, type TreeSignatureEvent as ad, type DescriptorProvider as ae, type IReadonlyWallet as af, type ReadonlyIdentity as ag, type OnchainProvider as ah, type DelegateProvider as ai, type ReadonlyWalletConfig as aj, type IntentRepository as ak, type ExitCaptureMode as al, type ExitDataSource as am, type IReadonlyAssetManager as an, type ContractSyncState as ao, type RecipientArkadeAddressContext as ap, EsploraProvider as aq, type NetworkName as ar, type OperatorInfo as as, type ContractWithVtxos as at, selectPendingRecoveryOutpoints as au, type Coin as av, ContractManager as aw, type ContractManagerConfig as ax, type SettlementConfig as ay, VtxoManager as az, type WalletConfig as b, type EventSourceLike as b$, type WatchedScript as b0, type PathSelection as b1, type ContractEvent as b2, type AssetDetails as b3, type IssuanceResult as b4, type DelegateInfo as b5, type MigrationGlobalSkipReason as b6, type MigrationLegSkipReason as b7, type SignerStatus as b8, type StorageConfig as b9, type BatchSignableIdentity as bA, type CandidateDeps as bB, ChainTxType as bC, type CommitmentTx as bD, type ConnectorTreeNode as bE, type ContractBalance as bF, type ContractEventCallback as bG, type ContractHandler as bH, type ContractScope as bI, type ContractState as bJ, type ContractVtxo as bK, ContractWatcher as bL, type ContractWatcherEventCallback as bM, DEFAULT_ARKADE_EMULATOR_URL as bN, DEFAULT_VTXO_PAGE_SIZE as bO, DelegateManagerImpl as bP, type DelegateOptions as bQ, type DeprecatedSignerMigrationReport as bR, type DeprecatedSignerReport as bS, DigestMismatchError as bT, type Discoverable as bU, type DiscoveredContract as bV, type DiscoveryDeps as bW, ESPLORA_URL as bX, type EmulatorInfo as bY, type EventSourceCapable as bZ, type EventSourceFactory as b_, type IVtxoManager as ba, type SendBitcoinParams as bb, type ExplorerTransaction as bc, type TreeNonces as bd, type TreePartialSigs as be, type PendingTx as bf, type EmulatorProvider as bg, type Status as bh, type ChainTx as bi, type ArkadeService as bj, type ContractVtxoEvent as bk, type ExtendedContractVtxo as bl, type ResolvedArkadeService as bm, resolveArkadeService as bn, type PathContext as bo, type ActivityIntent as bp, type ActivityResolver as bq, type ArkIntentState as br, type AssetMetadata as bs, BATCH_REGISTRATION_TERMINAL_STATES as bt, BITCOIN_EMULATOR_PUBKEY as bu, type BaseWalletConfig as bv, type BatchInfo as bw, type BatchRegistrationFilter as bx, type BatchRegistrationPageFilter as by, type BatchRegistrationState as bz, type ArkadeReader as c, assertRecipientArkadeAddress as c$, EventSourceUnavailableError as c0, type ExitChainResolver as c1, type GetArkadeInfoOptions as c2, type GetUtxosOptions as c3, type GroupMembership as c4, type HandlerError as c5, INTENT_TERMINAL_STATES as c6, IndexerTxType as c7, type IndexerUtxo as c8, IndexerUtxosUnsupportedError as c9, RestEmulatorProvider as cA, type ScanContractsOptions as cB, type ScanResult as cC, type ScheduledSession as cD, SettlementEventType as cE, type SignRequest as cF, type SignerClassification as cG, type SignerSet as cH, type SubscriptionFilter as cI, type SubscriptionResponse as cJ, type SweepTxNotification as cK, type TapLeaves as cL, TreeSignerSession as cM, type Tx as cN, type TxHistoryRecord as cO, type TxKey as cP, type TxNotification as cQ, type TxTag as cR, type TxTreeNode as cS, TxType as cT, type Vtxo as cU, type VtxoChain as cV, type VtxoType as cW, type WalletMode as cX, type WithPrevTx as cY, assertAllowedSighashTypes as cZ, assertPageRequest as c_, type IntentCoin as ca, type IntentFilter as cb, type KnownMetadata as cc, MAX_PAGE_SIZE as cd, MUTINYNET_EMULATOR_PUBKEY as ce, type MigrateDeprecatedSignerOptions as cf, type MigrationLegReport as cg, type MigrationVtxoRef as ch, type NewAddressType as ci, type Nonces as cj, OnchainCosignAmbiguousError as ck, OnchainCosignRejectedError as cl, OnchainCosignUnsupportedError as cm, type Output as cn, type PageResponse as co, PartialSig as cp, type PrevTxSource as cq, PrevTxUnavailableError as cr, type ProofInput as cs, type ProviderClass as ct, REGTEST_EMULATOR_PUBKEY as cu, type RawTxSource as cv, type RenewalSplit as cw, type RenewalSplitContext as cx, RestArkProvider as cy, RestDelegateProvider as cz, type ArkadeBroadcaster as d, assetMintResolver as d0, attachPrevArkTxs as d1, attachPrevoutTxs as d2, boardingResolver as d3, canRecoverOnchain as d4, canSpendOffchain as d5, canSweepOnchain as d6, classifyAgainstSignerSet as d7, classifyContractSigner as d8, collabExitResolver as d9, isSubdust as dA, isTerminalBatchRegistrationState as dB, isTerminalIntentState as dC, isVirtualCoin as dD, isVtxoExpiringSoon as dE, isVtxoSpent as dF, iteratePages as dG, networkFromArkadeInfo as dH, networkFromOperatorInfo as dI, networks as dJ, pageResult as dK, resolveEmulatorPubkey as dL, resolveEventSource as dM, resolvePrevTxs as dN, signerSetFromInfo as dO, toOffchainInputFeeParams as dP, toXOnlySignerHex as dQ, withPrevTxs as dR, type TapscriptDeriving as dS, collectBatchRegistrations as da, collectContracts as db, collectIntents as dc, collectPages as dd, collectScriptVtxos as de, collectTransactionHistory as df, collectUtxos as dg, collectVtxos as dh, configureEventSource as di, createDefaultActivityRegistry as dj, createExitChainResolver as dk, defaultEmulatorPubkey as dl, getAllNormalizedVtxos as dm, getConfiguredEventSource as dn, getNetwork as dp, getNormalizedVtxos as dq, getRandomId as dr, hasCandidates as ds, isBatchSignable as dt, isContractVtxoEvent as du, isCooperativelyMigratable as dv, isDiscoverable as dw, isEventSourceUnavailableError as dx, isPastExpiry as dy, isSigningIdentity as dz, type WalletBalance as e, type GetVtxosFilter as f, type GetSpendableVtxosFilter as g, type ArkTransaction as h, ActivityRegistry as i, type Activity as j, type IContractManager as k, type GetNewAddressesOptions as l, type NewAddress as m, type IDelegateManager as n, type SettlementEvent as o, type SendParams as p, type SendOnchainParams as q, type IAssetManager as r, RestOperatorProvider as s, RestIndexerProvider as t, type SubscriptionEvent as u, type SubscriptionHeartbeat as v, type ArkProvider as w, type IndexerProvider as x, type Contract as y, type ExtendedVirtualCoin as z };