@qntx/wallet-engine 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +1057 -20
  2. package/dist/apps-fiat24.d.mts +202 -0
  3. package/dist/apps-fiat24.mjs +1378 -0
  4. package/dist/apps-fiat24.mjs.map +1 -0
  5. package/dist/apps-hyperliquid.d.mts +549 -0
  6. package/dist/apps-hyperliquid.mjs +2742 -0
  7. package/dist/apps-hyperliquid.mjs.map +1 -0
  8. package/dist/apps-polymarket.d.mts +729 -0
  9. package/dist/apps-polymarket.mjs +3786 -0
  10. package/dist/apps-polymarket.mjs.map +1 -0
  11. package/dist/apps.d.mts +136 -0
  12. package/dist/apps.mjs +535 -0
  13. package/dist/apps.mjs.map +1 -0
  14. package/dist/connect-BY1C5ZRI.mjs +210 -0
  15. package/dist/connect-BY1C5ZRI.mjs.map +1 -0
  16. package/dist/connect.d.mts +17 -9
  17. package/dist/connect.mjs +3 -185
  18. package/dist/controller-DpNVHVsj.d.mts +2295 -0
  19. package/dist/controller-rMnaxKAH.mjs +46 -0
  20. package/dist/controller-rMnaxKAH.mjs.map +1 -0
  21. package/dist/decimal-COJ4g8qy.mjs +38 -0
  22. package/dist/decimal-COJ4g8qy.mjs.map +1 -0
  23. package/dist/eligibility-BfM9ybYZ.mjs +48 -0
  24. package/dist/eligibility-BfM9ybYZ.mjs.map +1 -0
  25. package/dist/engine-Dic_kkEr.d.mts +1829 -0
  26. package/dist/errors-B8W-hoYW.d.mts +7 -0
  27. package/dist/errors-horUy5k1.mjs +24 -0
  28. package/dist/errors-horUy5k1.mjs.map +1 -0
  29. package/dist/gateway-contract.d.mts +3 -362
  30. package/dist/gateway-contract.mjs +1531 -81
  31. package/dist/gateway-contract.mjs.map +1 -1
  32. package/dist/idb.d.mts +5 -0
  33. package/dist/idb.mjs +122 -46
  34. package/dist/idb.mjs.map +1 -1
  35. package/dist/index-vBgfOFIh.d.mts +2227 -0
  36. package/dist/index.d.mts +58 -515
  37. package/dist/index.mjs +22314 -4901
  38. package/dist/index.mjs.map +1 -1
  39. package/dist/json-BDwV38cj.mjs +15 -0
  40. package/dist/json-BDwV38cj.mjs.map +1 -0
  41. package/dist/link-Ceq8Dggp.mjs +139 -0
  42. package/dist/link-Ceq8Dggp.mjs.map +1 -0
  43. package/dist/primitives-DbSHLZKq.mjs +31 -0
  44. package/dist/primitives-DbSHLZKq.mjs.map +1 -0
  45. package/dist/push-message-AQuzoNFY.d.mts +84 -0
  46. package/dist/push-message-kbnH1A5w.mjs +142 -0
  47. package/dist/push-message-kbnH1A5w.mjs.map +1 -0
  48. package/dist/push.d.mts +13 -0
  49. package/dist/push.mjs +70 -0
  50. package/dist/push.mjs.map +1 -0
  51. package/dist/qr.d.mts +292 -0
  52. package/dist/qr.mjs +1725 -0
  53. package/dist/qr.mjs.map +1 -0
  54. package/dist/registry-CbtwcxkX.mjs +374 -0
  55. package/dist/registry-CbtwcxkX.mjs.map +1 -0
  56. package/dist/risk-DyABgg4W.mjs +757 -0
  57. package/dist/risk-DyABgg4W.mjs.map +1 -0
  58. package/dist/session-CNJFLarP.mjs +18 -0
  59. package/dist/session-CNJFLarP.mjs.map +1 -0
  60. package/dist/socket-ChG9JRT_.mjs +110 -0
  61. package/dist/socket-ChG9JRT_.mjs.map +1 -0
  62. package/dist/spi-BrTw5s98.d.mts +3 -0
  63. package/dist/timer-Cdk5rGM2.mjs +43 -0
  64. package/dist/timer-Cdk5rGM2.mjs.map +1 -0
  65. package/dist/types-BpvioFGo.d.mts +258 -0
  66. package/dist/types-DbftVZ3I.mjs +90 -0
  67. package/dist/types-DbftVZ3I.mjs.map +1 -0
  68. package/dist/walletconnect.d.mts +86 -0
  69. package/dist/walletconnect.mjs +1507 -0
  70. package/dist/walletconnect.mjs.map +1 -0
  71. package/dist/webln-BgrtPXpG.mjs +2593 -0
  72. package/dist/webln-BgrtPXpG.mjs.map +1 -0
  73. package/dist/webln-Bllk_xJ2.d.mts +666 -0
  74. package/package.json +94 -19
  75. package/dist/connect.mjs.map +0 -1
  76. package/dist/errors-DpkJneDe.d.mts +0 -1696
  77. package/dist/registry-Deo5WQe1.d.mts +0 -25
  78. package/dist/registry-wYrcuFNc.mjs +0 -99
  79. package/dist/registry-wYrcuFNc.mjs.map +0 -1
  80. package/dist/webln-DzsI7jVb.mjs +0 -3629
  81. package/dist/webln-DzsI7jVb.mjs.map +0 -1
@@ -0,0 +1,2295 @@
1
+ import { Gr as TronNodePath, Lr as TronIndexerPath, dr as NetworkInfo } from "./index-vBgfOFIh.mjs";
2
+ import { StoreApi } from "zustand/vanilla";
3
+ import { BitcoinTemplate, ChainError, DisplayIntent, MessageContent, SignRequest } from "@qntx/wallet-chains";
4
+ import { PublicClient } from "viem";
5
+ import "@solana/kit";
6
+ import { decodeEvm } from "@qntx/wallet-chains/evm";
7
+ import "@scure/btc-signer";
8
+ import { BitcoinAccountTemplate, BitcoinOwn } from "@qntx/wallet-chains/bitcoin";
9
+ import { CooperativeExitResult, LightningInvoice, LightningPayment, LightningSendStatus, SparkClient, SparkNetwork, SparkPayment, SparkStore, SparkTransfer } from "@qntx/spark";
10
+ import { NostrKeyRef, VerifyFactor, Wallet } from "@qntx/wallet";
11
+ import { LnurlPayRequest, LnurlWithdrawRequest } from "@qntx/spark/lnurl";
12
+ import { Event, NostrSigner, UnsignedEvent } from "@qntx/nostr";
13
+ import { SparkSigner } from "@qntx/wallet/spark";
14
+ import { ChainsApi, chains } from "@qntx/wallet/chains";
15
+ import "@scure/btc-signer/psbt.js";
16
+ import { SparkAccountRef, SparkApproveIntent } from "@qntx/wallet/protocol";
17
+ /** Log port: listener failures are reported here and never reach the emitter or peers. */
18
+ type EngineLogger = {
19
+ readonly warn: (message: string, error?: unknown) => void;
20
+ };
21
+ type EventBus<E> = {
22
+ /** Synchronous dispatch to every current listener in registration order. */
23
+ emit: <K extends keyof E>(type: K, payload: E[K]) => void;
24
+ on: <K extends keyof E>(type: K, listener: (payload: E[K]) => void) => () => void;
25
+ };
26
+ declare function createEventBus<E>(logger: EngineLogger): EventBus<E>;
27
+ /**
28
+ * A one-shot timer, `setTimeout` semantics: `fn` runs at most once, `ms` after the call, unless the
29
+ * returned function cancels it first. Every host passes exactly this; loops re-arm through
30
+ * {@link repeat}.
31
+ */
32
+ type SetTimer = (ms: number, fn: () => unknown) => () => void;
33
+ /**
34
+ * An `AbortSignal` that fires after `ms` on the injected timer — the platform timeout signal is not
35
+ * available in every runtime this package runs in. Call `cancel` once the work is done, or `abort`
36
+ * to stop it early.
37
+ */
38
+ declare function timeoutSignal(ms: number, setTimer: SetTimer): {
39
+ readonly signal: AbortSignal;
40
+ readonly cancel: () => void;
41
+ readonly abort: () => void;
42
+ };
43
+ type Esplora = {
44
+ readonly get: (path: string) => Promise<unknown>;
45
+ readonly post: (path: string, body: string) => Promise<unknown>;
46
+ };
47
+ /** TRON HTTP client: POSTs an allow-listed path to each endpoint in order. */
48
+ type TronApi = {
49
+ readonly post: (path: TronNodePath | TronIndexerPath, body: unknown) => Promise<unknown>;
50
+ };
51
+ /** A `pinnedTronCaller` client plus the endpoint it committed to after its first answer. */
52
+ type PinnedTronApi = TronApi & {
53
+ /** The URL every later read goes to; `undefined` until the first call answers. */
54
+ readonly pinnedUrl: () => string | undefined;
55
+ };
56
+ /**
57
+ * The TRON node API is throttling and the transaction's validity window does not leave time to wait
58
+ * the requested backoff out — retry the request later.
59
+ */
60
+ declare class TronThrottledError extends Error {
61
+ readonly retryAfterMs: number;
62
+ constructor(retryAfterMs: number);
63
+ }
64
+ type TronFeeQuote = {
65
+ /** Sun the transaction is expected to burn: bandwidth + activation + expected energy. */
66
+ readonly expected: string;
67
+ /** Sun the transaction could burn at most: bandwidth max + activation + `fee_limit`. */
68
+ readonly max: string;
69
+ readonly bandwidth: {
70
+ readonly bytes: number;
71
+ readonly source: "staked" | "free" | "burn" | "activation-staked" | "activation-fee";
72
+ readonly stakedAvailable: bigint;
73
+ readonly freeAvailable: bigint;
74
+ /** Sun the bandwidth is expected to burn. */
75
+ readonly burn: string;
76
+ };
77
+ /** Sun the system contract charges for activating the recipient (absent when not activating). */
78
+ readonly activation?: string;
79
+ readonly energy?: {
80
+ /** `energy_used` — the total estimate, penalty included. */
81
+ readonly used: number;
82
+ /** The dynamic-energy penalty inside `used`. */
83
+ readonly penalty: number;
84
+ /** Staked energy available to the caller. */
85
+ readonly available: bigint;
86
+ /** Sun the caller is expected to burn — the deployer's share only lowers it. */
87
+ readonly burn: string;
88
+ /** Sun the transaction's `fee_limit` is set to. */
89
+ readonly feeLimit: string;
90
+ };
91
+ /** Sun the memo costs (`getMemoFee`); present when `memo` was set. */
92
+ readonly memo?: string;
93
+ readonly warnings: ReadonlyArray<"recipient-not-activated" | "token-recipient-empty" | "fee-limit-below-estimate">;
94
+ };
95
+ type ControllerOptions<S> = {
96
+ readonly name: string;
97
+ readonly defaultState: () => S;
98
+ };
99
+ /**
100
+ * Controller base: a zustand vanilla store plus lifecycle. `update` applies a recipe that must
101
+ * return a NEW state object — it replaces the store's state wholesale — and every stored state is
102
+ * deeply frozen once, at this boundary: what `getState` hands a host can only be read. Returning
103
+ * the same reference is a no-op (no set, no notification). Persistence and migrations layer on
104
+ * later — this package carries only what its first user needs.
105
+ */
106
+ declare abstract class Controller<S extends Record<string, unknown>> {
107
+ readonly name: string;
108
+ readonly store: StoreApi<S>;
109
+ protected constructor(options: ControllerOptions<S>);
110
+ getState(): S;
111
+ protected update(recipe: (state: S) => S): void;
112
+ abstract init(): Promise<void>;
113
+ abstract destroy(): Promise<void>;
114
+ }
115
+ /**
116
+ * Per-session gateway client ids — a fresh unlinkable id per scope. Lives apart from client.ts so
117
+ * entries that need only session ids (the apps eligibility fetch) don't bundle the contract table
118
+ * that `gatewayScope` requires.
119
+ */
120
+ /** A gateway traffic class with its own client id: one per chain family plus the service routes. */
121
+ type GatewayScope = "evm" | "solana" | "bitcoin" | "tron" | "service";
122
+ type GatewayConfig = {
123
+ readonly url: string;
124
+ readonly clientIds: Readonly<Record<GatewayScope, string>>;
125
+ };
126
+ type EngineErrorCode = "closed" | "invalid-input";
127
+ /** Typed engine errors: store codes are `closed` and `invalid-input`. */
128
+ declare class EngineStoreError extends Error {
129
+ readonly code: EngineErrorCode;
130
+ constructor(code: EngineErrorCode, message: string);
131
+ }
132
+ /** Why an NFT transfer preparation refused, surfaced for callers that branch on it. */
133
+ type NftRefusal = "not-nft" | "not-owned" | "insufficient-balance" | "programmable" | "frozen" | "not-found";
134
+ /** An NFT send refusal: `code` stays `invalid-request`, `reason` names which guard fired. */
135
+ declare class NftTransferError extends ChainError {
136
+ readonly reason: NftRefusal;
137
+ constructor(reason: NftRefusal, message: string);
138
+ }
139
+ /**
140
+ * Engine storage port: named collections of byte values. `collection` is synchronous and cheap —
141
+ * the same collection object backs every call, so guards (closed) live on the store.
142
+ */
143
+ type EngineCollection = {
144
+ /**
145
+ * Resolves `undefined` for a missing record AND for one the store cannot authenticate — an
146
+ * unauthenticated record reads exactly like a deleted one.
147
+ */
148
+ readonly get: (key: string) => Promise<Uint8Array | undefined>;
149
+ readonly put: (key: string, bytes: Uint8Array) => Promise<void>;
150
+ readonly delete: (key: string) => Promise<void>;
151
+ /** Every key in the collection, in an unspecified order. */
152
+ readonly list: () => Promise<ReadonlyArray<string>>;
153
+ };
154
+ type EngineStore = {
155
+ readonly collection: (name: string) => EngineCollection;
156
+ readonly close: () => Promise<void>;
157
+ };
158
+ /**
159
+ * Non-secret device data (the phishing list, the origins the user trusts): available while the
160
+ * wallet is locked, and the host may keep it unencrypted. Never put anything secret in it.
161
+ */
162
+ type PublicStore = {
163
+ readonly get: (key: string) => Promise<Uint8Array | undefined>;
164
+ readonly put: (key: string, bytes: Uint8Array) => Promise<void>;
165
+ };
166
+ type SolanaRpc = {
167
+ readonly call: (method: string, params: unknown[]) => Promise<unknown>;
168
+ };
169
+ /** A `pinnedSolanaCaller` client plus the endpoint it committed to after its first answer. */
170
+ type PinnedSolanaRpc = SolanaRpc & {
171
+ /** The URL every later read goes to; `undefined` until the first call answers. */
172
+ readonly pinnedUrl: () => string | undefined;
173
+ };
174
+ /**
175
+ * A second-upstream client for cross-checking reads the primary endpoints answered. `not-needed`:
176
+ * the primary already comes from a host endpoint — trusted configuration — so no other upstream is
177
+ * involved. `unavailable`: a cross-check is needed but there is no second upstream to run it on.
178
+ * `available` carries the corroborating client and names which upstream it reads: a `host` endpoint
179
+ * is trusted configuration; `gateway` is the gateway a custom-endpoint list displaced — a different
180
+ * upstream than the primary, but not trusted configuration.
181
+ */
182
+ type Independent<T> = {
183
+ readonly kind: "not-needed";
184
+ } | {
185
+ readonly kind: "unavailable";
186
+ } | {
187
+ readonly kind: "available";
188
+ readonly source: "host" | "gateway";
189
+ readonly client: T;
190
+ };
191
+ type NetworkControllerState = {
192
+ readonly customRpc: Record<string, ReadonlyArray<string>>;
193
+ };
194
+ type Options$1 = {
195
+ readonly fetch: typeof globalThis.fetch;
196
+ readonly rpc: Readonly<Record<string, ReadonlyArray<string>>>;
197
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
198
+ readonly openStore: () => Promise<EngineStore>;
199
+ readonly logger: EngineLogger;
200
+ readonly gateway?: GatewayConfig | undefined;
201
+ readonly setTimer: SetTimer;
202
+ readonly random: (length: number) => Uint8Array;
203
+ readonly now: () => number;
204
+ };
205
+ declare class NetworkController extends Controller<NetworkControllerState> {
206
+ private readonly options;
207
+ private engineStore?;
208
+ private readonly clients;
209
+ private readonly ensClients;
210
+ private readonly gatewayBase;
211
+ private readonly gatewayFetch;
212
+ /** The persisted custom endpoints, verified or not — what `addRpc` writes back. */
213
+ private storedRpc;
214
+ /** Networks the gateway reported at unlock; empty while locked or when the read failed. */
215
+ private gatewayServed;
216
+ constructor(options: Options$1);
217
+ init(): Promise<void>;
218
+ /**
219
+ * Loads the persisted custom endpoints and re-verifies each against its network before use: an
220
+ * endpoint that no longer serves the chain (or does not answer) is skipped for this session and
221
+ * stays persisted, so a transient failure costs nothing at the next unlock.
222
+ */
223
+ private loadCustomRpc;
224
+ /** Reads the gateway's served networks; any failure leaves the gateway unused until next unlock. */
225
+ private loadGatewayNetworks;
226
+ destroy(): Promise<void>;
227
+ lock(): void;
228
+ /** The gateway URL serving `network`'s family RPC, or `undefined` when the gateway cannot. */
229
+ private gatewayUrl;
230
+ /**
231
+ * Ordered endpoints: a network with custom endpoints uses custom → host and never the gateway;
232
+ * otherwise a gateway-served network uses gateway → host; else host only.
233
+ */
234
+ endpoints(network: string): ReadonlyArray<string>;
235
+ info(network: string): NetworkInfo;
236
+ client(network: string): PublicClient;
237
+ /** True when the gateway heads this network's endpoint list (no custom endpoints, gateway-served). */
238
+ gatewayFirst(network: string): boolean;
239
+ /**
240
+ * The upstream a network's reads corroborate on. A custom-endpoint network is never its own
241
+ * proof: the host endpoints corroborate it when there are any, else the gateway it displaced when
242
+ * the gateway serves the network, else nothing can. A gateway-first network corroborates on the
243
+ * host endpoints as before; a host-only list needs nothing.
244
+ */
245
+ private independent;
246
+ /** Second-upstream EVM client for cross-checking reads; a host never gets the install id. */
247
+ independentClient(network: string): Independent<PublicClient>;
248
+ /**
249
+ * The client's sibling for ENS resolution: same ordered endpoints, CCIP-Read enabled over the
250
+ * plain injected fetch — gateway URLs come from contracts, not the host, so they never get the
251
+ * install id.
252
+ */
253
+ ensClient(network: string): PublicClient;
254
+ /** Second-upstream ENS client for cross-checking resolutions. */
255
+ independentEnsClient(network: string): Independent<PublicClient>;
256
+ independentSolanaRpc(network: string): Independent<SolanaRpc>;
257
+ /**
258
+ * Fresh pinned second-upstream Solana client — for proofs whose reads must all come from one
259
+ * upstream. Only a different upstream than `primaryUrl` corroborates: when the poll's pin already
260
+ * landed on a host endpoint, the host-only continuity rule applies instead of a second read of
261
+ * the same upstream.
262
+ */
263
+ independentPinnedSolanaRpc(network: string, primaryUrl: string | undefined): Independent<SolanaRpc>;
264
+ /** Second-upstream TRON client for cross-checking reads; a host never gets the install id. */
265
+ independentTronApi(network: string): Independent<TronApi>;
266
+ /**
267
+ * Fresh pinned second-upstream TRON client — for proofs whose reads must all come from one
268
+ * upstream. Only a different upstream than `primaryUrl` corroborates: when the poll's pin already
269
+ * landed on a host endpoint, the host-only continuity rule applies instead of a second read of
270
+ * the same upstream.
271
+ */
272
+ independentPinnedTronApi(network: string, primaryUrl: string | undefined): Independent<TronApi>;
273
+ independentEsplora(network: string): Independent<Esplora>;
274
+ /** Networks with at least one configured endpoint or served by the gateway, by family. */
275
+ enabled(family: "evm" | "solana" | "bitcoin" | "tron"): ReadonlyArray<string>;
276
+ /** Solana JSON-RPC over the ordered endpoint list — kit's transport is single-endpoint. */
277
+ solanaRpc(network: string): SolanaRpc;
278
+ /**
279
+ * Fresh one-upstream Solana client: failover on the first call, then pinned — for a sequence of
280
+ * reads that must agree with each other.
281
+ */
282
+ pinnedSolanaRpc(network: string): PinnedSolanaRpc;
283
+ /** TRON node API over the ordered endpoint list — plain POSTs fail over like Solana's. */
284
+ tronApi(network: string): TronApi;
285
+ /**
286
+ * Fresh one-upstream TRON client: failover on the first call, then pinned — for a sequence of
287
+ * reads that must agree with each other. `until` bounds throttled-read retries to the
288
+ * transaction's validity window; absent, a 429/503 propagates like every other failure.
289
+ */
290
+ pinnedTronApi(network: string, until?: () => number): PinnedTronApi;
291
+ /** Bounded-concurrency + 429-aware ordered-failover Esplora client. */
292
+ esplora(network: string): Esplora;
293
+ /**
294
+ * Throws unless `url` serves `info`'s chain: the genesis hash for Bitcoin (Esplora) and Solana,
295
+ * `eth_chainId` for EVM. Bounded like the gateway probe, so a dead endpoint cannot stall unlock.
296
+ */
297
+ private probe;
298
+ /** Validates a custom endpoint against the network's chain, then persists it first in the list. */
299
+ addRpc(network: string, url: string): Promise<void>;
300
+ }
301
+ type AddressFamily = "evm" | "solana" | "bitcoin" | "tron" | "spark";
302
+ type AddressBookEntry = {
303
+ readonly id: string;
304
+ readonly name: string;
305
+ readonly family: AddressFamily;
306
+ readonly address: string;
307
+ readonly note?: string;
308
+ readonly createdAt: number;
309
+ readonly updatedAt: number;
310
+ };
311
+ type AddressBookTombstone = {
312
+ readonly id: string;
313
+ readonly deleted: true;
314
+ readonly updatedAt: number;
315
+ };
316
+ type AddressBookRecord = AddressBookEntry | AddressBookTombstone;
317
+ type AddressBookState = {
318
+ /** Live entries only; tombstones stay internal. */
319
+ readonly entries: Record<string, AddressBookEntry>;
320
+ };
321
+ type AddressBookOptions = {
322
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
323
+ readonly openStore: () => Promise<EngineStore>;
324
+ readonly random: (n: number) => Uint8Array;
325
+ readonly now: () => number;
326
+ readonly logger: EngineLogger;
327
+ };
328
+ declare class AddressBookController extends Controller<AddressBookState> {
329
+ private readonly options;
330
+ private engineStore;
331
+ /** Every record, tombstones included, by id. */
332
+ private records;
333
+ constructor(options: AddressBookOptions);
334
+ init(): Promise<void>;
335
+ destroy(): Promise<void>;
336
+ lock(): void;
337
+ /** Entries and tombstones, for the metadata document. */
338
+ syncEntries(): ReadonlyArray<AddressBookRecord>;
339
+ /**
340
+ * Merges records from another device (last writer wins among records with the same identity,
341
+ * tombstones are terminal, records stamped past the clock bound or rewriting a local identity are
342
+ * refused). Returns whether anything local changed and whether the merged set holds something
343
+ * `remote` lacks, i.e. whether the remote copy needs a newer publish.
344
+ */
345
+ merge(remote: ReadonlyArray<AddressBookRecord>): Promise<{
346
+ readonly changed: boolean;
347
+ readonly localNewer: boolean;
348
+ }>;
349
+ add(params: {
350
+ readonly name: string;
351
+ readonly family: AddressFamily;
352
+ readonly address: string;
353
+ readonly note?: string;
354
+ }): Promise<AddressBookEntry>;
355
+ rename(id: string, name: string): Promise<AddressBookEntry>;
356
+ /** Sets or clears (empty or `undefined`) the note. */
357
+ setNote(id: string, note: string | undefined): Promise<AddressBookEntry>;
358
+ /** Removes the entry, leaving a tombstone so other devices drop it too. */
359
+ remove(id: string): Promise<void>;
360
+ /** An edit always stamps above the record it replaces, so it outranks a newer remote copy. */
361
+ private editStamp;
362
+ private checkedNote;
363
+ private requireEntry;
364
+ private persist;
365
+ private requireStore;
366
+ }
367
+ /** A Sign In With Solana request after validation: `domain` and `address` are resolved. */
368
+ type SignInFields = {
369
+ readonly domain: string;
370
+ readonly address: string;
371
+ readonly statement?: string;
372
+ readonly uri?: string;
373
+ readonly version?: string;
374
+ readonly chainId?: string;
375
+ readonly nonce?: string;
376
+ readonly issuedAt?: string;
377
+ readonly expirationTime?: string;
378
+ readonly notBefore?: string;
379
+ readonly requestId?: string;
380
+ readonly resources?: ReadonlyArray<string>;
381
+ };
382
+ /** Simulation result shapes, in a leaf module so routes and the request controller share them. */
383
+ type AssetChange = {
384
+ /** Same ids as `DisplayIntent`: EVM `native` or a token address; Solana `lamports` or a mint. */
385
+ readonly asset: string;
386
+ /** Signed decimal in the smallest unit; negative is an outflow. */
387
+ readonly amount: string;
388
+ readonly decimals?: number;
389
+ readonly symbol?: string;
390
+ /** True only when `decimals` and `symbol` come from the built-in token table. */
391
+ readonly verified: boolean;
392
+ };
393
+ type SimulationOutcome = {
394
+ readonly status: "success";
395
+ readonly changes: ReadonlyArray<AssetChange>;
396
+ } | {
397
+ readonly status: "reverted";
398
+ readonly error: string;
399
+ } | {
400
+ readonly status: "unavailable";
401
+ readonly error: string;
402
+ };
403
+ type EvmFeeTier = "slow" | "normal" | "fast";
404
+ type SolanaFeeTier = "slow" | "normal" | "fast";
405
+ type RequestCheckCode = "decode-partial" | "nonce-mismatch" | "fee-mismatch" | "reads-unverified" | "fee-above-network" | "fee-exceeds-amount" | "simulation-unavailable";
406
+ /**
407
+ * Local, engine-side metadata pinned to a history entry by transfer id. Written after the payment
408
+ * it annotates has already succeeded — a missing or malformed note must never affect the payment
409
+ * itself.
410
+ */
411
+ type PaymentNote = {
412
+ readonly kind: "zap";
413
+ /** 64 lowercase hex. */
414
+ readonly recipientPubkey: string;
415
+ /** 64 lowercase hex — event zaps carry the zapped event's id. */
416
+ readonly eventId?: string;
417
+ /** At most 2000 characters. */
418
+ readonly comment?: string;
419
+ /** The lud16 or LNURL the zap resolved. */
420
+ readonly lightning: string;
421
+ };
422
+ type SparkActivity = SparkPayment & {
423
+ readonly note?: PaymentNote;
424
+ };
425
+ /** A Spark send or Spark invoice, a Lightning payment, a cooperative exit, or a token send. */
426
+ type SparkPaymentKind = "transfer" | "lightning" | "exit" | "token";
427
+ /**
428
+ * `submitted`: persisted before the commit call, and kept after it returned until the operator
429
+ * reports a final status. `unknown`: the commit response was lost — it may have committed.
430
+ * `settled` and `failed` are the operator's final answer. `archived`: the user gave up on an
431
+ * outcome the operator can never answer for — kept, never reconciled, never blocking.
432
+ */
433
+ type SparkPaymentState = "submitted" | "unknown" | "settled" | "failed" | "archived";
434
+ /** One wallet-initiated Spark payment, from just before its commit call to the operator's answer. */
435
+ type SparkPaymentRecord = {
436
+ /** The request's idempotent transfer id — for sats payments, the Spark transfer id. */
437
+ readonly id: string;
438
+ readonly kind: SparkPaymentKind;
439
+ readonly state: SparkPaymentState;
440
+ /** Spark address, Lightning payee public key (hex) or bitcoin address. */
441
+ readonly receiver: string;
442
+ /** Decimal base units: sats, or the token's base units. */
443
+ readonly amount: string;
444
+ /** Token payments: the bech32m token identifier. */
445
+ readonly tokenIdentifier?: string;
446
+ /** Token payments whose broadcast outcome was uncertain: the outputs it spends. */
447
+ readonly inputOutputIds?: ReadonlyArray<string>;
448
+ /** Settled token payments: the final transaction hash. */
449
+ readonly transactionHash?: string;
450
+ /** Milliseconds since the epoch, taken just before the commit call. */
451
+ readonly submittedAt: number;
452
+ /** Why the payment failed, or why its outcome is unknown. */
453
+ readonly error?: string;
454
+ };
455
+ /**
456
+ * SparkStore over one EngineCollection: chains keyed by leafId, enumerated by the port's `list()`.
457
+ * A record that fails to decode — or does not name its own key, like a leftover `__all__` index row
458
+ * from older data — is skipped, not fatal: the next leaves sync rewrites it.
459
+ */
460
+ declare function sparkStore(col: EngineCollection): SparkStore;
461
+ type SparkAccountState = {
462
+ readonly status: "locked" | "connecting" | "ready" | "error";
463
+ readonly balanceSats?: number;
464
+ readonly identityPublicKey?: string;
465
+ readonly sparkAddress?: string;
466
+ readonly errorCategory?: string;
467
+ /** First history page (20 entries, newest first), refreshed alongside the balance. */
468
+ readonly recent?: ReadonlyArray<SparkActivity>;
469
+ /** Token balances in base units, refreshed alongside `recent`; absent until the first read. */
470
+ readonly tokens?: ReadonlyArray<SparkTokenBalance>;
471
+ /**
472
+ * This session's payment records by id — every open one, plus those that settled or failed since
473
+ * unlock; absent until the account has one.
474
+ */
475
+ readonly payments?: Readonly<Record<string, SparkPaymentRecord>>;
476
+ };
477
+ type SparkTokenBalance = {
478
+ readonly tokenIdentifier: string;
479
+ readonly amount: string;
480
+ readonly outputCount: number;
481
+ };
482
+ type SparkControllerState = {
483
+ readonly accounts: Readonly<Record<string, SparkAccountState>>;
484
+ };
485
+ type SparkApis = {
486
+ readonly signer: (ref: SparkAccountRef) => SparkSigner;
487
+ readonly approve: (params: {
488
+ account: SparkAccountRef;
489
+ intent: SparkApproveIntent;
490
+ verify: VerifyFactor;
491
+ }) => Promise<unknown>;
492
+ };
493
+ type SparkClientFactory = (options: {
494
+ readonly ref: SparkAccountRef;
495
+ readonly store: ReturnType<typeof sparkStore>;
496
+ readonly signer: SparkSigner;
497
+ readonly fetch: typeof globalThis.fetch;
498
+ }) => SparkClient;
499
+ type SparkControllerOptions = {
500
+ readonly spark: SparkApis;
501
+ readonly fetch: typeof globalThis.fetch;
502
+ readonly now: () => number;
503
+ readonly logger: EngineLogger;
504
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
505
+ readonly createClient: SparkClientFactory;
506
+ };
507
+ declare class SparkController extends Controller<SparkControllerState> {
508
+ private readonly options;
509
+ private engineStore;
510
+ private readonly accounts;
511
+ private readonly clients;
512
+ private readonly ledgers;
513
+ private readonly recentSeq;
514
+ private readonly tokensSeq;
515
+ private readonly aborts;
516
+ constructor(options: SparkControllerOptions);
517
+ /** Engine calls this with the open store on unlock; `undefined` on lock. */
518
+ setStore(store: EngineStore | undefined): void;
519
+ /**
520
+ * Declarative account set: refs not yet tracked are patched `locked` and started when the store
521
+ * is open; tracked refs no longer listed are stopped and dropped; running refs stay untouched.
522
+ */
523
+ setAccounts(refs: ReadonlyArray<SparkAccountRef>): void;
524
+ init(): Promise<void>;
525
+ destroy(): Promise<void>;
526
+ private stopAccount;
527
+ /** Lock: abort every event loop, close every client, reset state. */
528
+ lockAll(): Promise<void>;
529
+ private startAccount;
530
+ private runEvents;
531
+ private handleTransfer;
532
+ private notesCollection;
533
+ /** Attach locally written notes to a history page; malformed records warn and drop. */
534
+ private withNotes;
535
+ /**
536
+ * Refill `recent` from the first history page. A failure keeps the previous page — it never
537
+ * touches `status`/`errorCategory`. A per-account sequence keeps a slower older refresh from
538
+ * overwriting a newer one.
539
+ */
540
+ private refreshRecent;
541
+ /**
542
+ * Refill `tokens` from the client's balance list. Like `refreshRecent`: a failure warns and keeps
543
+ * the previous list — it never touches `status`/`errorCategory` — and the sequence + client
544
+ * identity guard keeps a stale read from overwriting a newer one.
545
+ */
546
+ private refreshTokens;
547
+ private patch;
548
+ private clientFor;
549
+ /** A running account's client and payment ledger — they start and stop together. */
550
+ private connection;
551
+ /**
552
+ * Runs a committing call under a payment record persisted first — a failed write throws before
553
+ * anything is sent. An unknown outcome leaves the record open and throws `unknown` carrying it; a
554
+ * definite error fails it; a call that returns keeps it `submitted` until the operator's history
555
+ * settles it, unless `settled` reads the final state from the result itself.
556
+ */
557
+ private recorded;
558
+ /**
559
+ * A definite pre-commit refusal for sats payments: the operator's balance answers before any
560
+ * record exists — an unreadable balance is `network` (nothing is committed), a shortfall is
561
+ * `insufficient-funds`.
562
+ */
563
+ private requireSats;
564
+ private guarded;
565
+ /**
566
+ * Runs a committing client call with up to three idempotent retries (1 s, 2 s, 4 s backoff):
567
+ * `retryable` decides which error means the outcome is unknown and the same call may repeat,
568
+ * `call` receives the previous attempt's error so a retry can carry the handle it reported. A
569
+ * definite error on the first attempt propagates; after an uncertain attempt nothing is definite
570
+ * any more — the earlier attempt may have committed — so exhaustion and any later error throw
571
+ * {@link UnknownOutcomeError} with `message`.
572
+ */
573
+ private committing;
574
+ /**
575
+ * A sats payment commits under its transfer id: a network failure leaves the outcome unknown, so
576
+ * the same call retries under the same id — the SO/SSP deduplicates it.
577
+ */
578
+ private committed;
579
+ /**
580
+ * A token transfer commits under its spent output ids: only `SparkTokenBroadcastError` means the
581
+ * broadcast's outcome is uncertain — a plain network error happened before it — so the retry
582
+ * carries `error.inputOutputIds` and the same terms, per the library's contract.
583
+ */
584
+ private committedToken;
585
+ /**
586
+ * One-off balance + activity probe for an account that may not be running: builds a temporary
587
+ * client through the same factory on the account's own exit-chain collection (nothing diverges —
588
+ * `balance()`/`transfers.history` never write it), reads, and closes it in `finally`.
589
+ */
590
+ inspect(ref: SparkAccountRef): Promise<{
591
+ balanceSats: number;
592
+ used: boolean;
593
+ }>;
594
+ /** History for one account: a client page merged with locally written notes by id. */
595
+ history(ref: SparkAccountRef, options?: {
596
+ readonly limit?: number;
597
+ readonly offset?: number;
598
+ }): Promise<{
599
+ readonly items: ReadonlyArray<SparkActivity>;
600
+ readonly nextOffset: number | undefined;
601
+ }>;
602
+ send(ref: SparkAccountRef, params: {
603
+ receiver: string;
604
+ amountSats: number;
605
+ /** The request's idempotent transfer id — a retry resumes, never double-pays. */
606
+ transferId: string;
607
+ verify: VerifyFactor;
608
+ /** Called immediately before the send; a throw there means nothing may be sent. */
609
+ commit: () => void;
610
+ }): Promise<SparkTransfer>;
611
+ /**
612
+ * Sends a token amount to a Spark address. The approval intent is the kernel's `token` shape —
613
+ * the raw 32-byte identifier and the receiver's identity key with a canonical decimal amount —
614
+ * and the commit retries only on `SparkTokenBroadcastError`, under the spent output ids it
615
+ * reports; everything else propagates (a plain network failure happened before broadcast).
616
+ */
617
+ sendToken(ref: SparkAccountRef, params: {
618
+ /** Spark address of the receiver. */
619
+ receiver: string;
620
+ /** Bech32m token identifier (`btkn`/`btknrt`). */
621
+ tokenIdentifier: string;
622
+ /** Base units, 1…2^128−1. */
623
+ amount: bigint;
624
+ /** The request's idempotent transfer id — keys the payment record. */
625
+ transferId: string;
626
+ verify: VerifyFactor;
627
+ /** Called immediately before the transfer; a throw there means nothing may be sent. */
628
+ commit: () => void;
629
+ }): Promise<string>;
630
+ registerLightningAddress(ref: SparkAccountRef, params: {
631
+ serverUrl: string;
632
+ domain: string;
633
+ username: string;
634
+ description: string;
635
+ }): Promise<{
636
+ lnurl: string;
637
+ lightningAddress: string;
638
+ }>;
639
+ unregisterLightningAddress(ref: SparkAccountRef, params: {
640
+ serverUrl: string;
641
+ domain: string;
642
+ username: string;
643
+ }): Promise<void>;
644
+ payInvoice(ref: SparkAccountRef, params: {
645
+ invoice: string;
646
+ amountSats?: number;
647
+ maxFeeSats: number;
648
+ /** The request's idempotent transfer id — a retry resumes, never double-pays. */
649
+ transferId: string;
650
+ verify: VerifyFactor;
651
+ /** Called immediately before the send; a throw there means nothing may be sent. */
652
+ commit: () => void;
653
+ /** Local annotation written under the payment's transfer id after it succeeds. */
654
+ note?: PaymentNote;
655
+ }): Promise<LightningPayment>;
656
+ /**
657
+ * Pays a Spark invoice address. The approval intent mirrors `send`: receiver identity and amount
658
+ * come from the parsed invoice (the supplied `amountSats` fills an open invoice). Then
659
+ * `client.invoices.pay` executes it.
660
+ */
661
+ paySparkInvoice(ref: SparkAccountRef, params: {
662
+ invoice: string;
663
+ amountSats?: number;
664
+ /** The request's idempotent transfer id — a retry resumes, never double-pays. */
665
+ transferId: string;
666
+ verify: VerifyFactor;
667
+ /** Called immediately before the send; a throw there means nothing may be sent. */
668
+ commit: () => void;
669
+ }): Promise<SparkTransfer>;
670
+ createInvoice(ref: SparkAccountRef, params: {
671
+ amountSats: number;
672
+ memo?: string;
673
+ }): Promise<LightningInvoice>;
674
+ /** A fresh single-use L1 deposit address (with the SO's proof of possession). */
675
+ newDepositAddress(ref: SparkAccountRef): Promise<string>;
676
+ /** Claims a confirmed L1 deposit paying one of the account's unused deposit addresses. */
677
+ claimDeposit(ref: SparkAccountRef, transaction: Uint8Array): Promise<void>;
678
+ /**
679
+ * Archives an open payment record the operator can never answer for — a token send whose
680
+ * broadcast failed before its spent outputs were known. The archived outcome stays genuinely
681
+ * unknown forever: it stops blocking re-sends and `holdsToken`, and history flags it
682
+ * `unresolved`. The host must obtain the user's confirmation first.
683
+ */
684
+ archivePayment(ref: SparkAccountRef, id: string): void;
685
+ /** The account's last-synced balance — a cached snapshot, not a fresh query. */
686
+ accountBalance(ref: SparkAccountRef): number | undefined;
687
+ /** A payment's settle status — `payInvoice` resolves the send; `sendStatus` reports its preimage. */
688
+ paymentStatus(ref: SparkAccountRef, request: {
689
+ readonly requestId: string;
690
+ readonly paymentHash: Uint8Array;
691
+ }): Promise<LightningSendStatus>;
692
+ receiveAddress(ref: SparkAccountRef): Promise<string | undefined>;
693
+ /**
694
+ * The SSP's converged cooperative-exit quote for paying `amountSats` to an L1 address: the fee
695
+ * depends on the gross amount, so the quote is re-taken on `amountSats + fee` until it settles.
696
+ */
697
+ quoteExit(ref: SparkAccountRef, params: {
698
+ address: string;
699
+ /** Sats that arrive at the address — the exit debits amountSats + fee. */
700
+ amountSats: number;
701
+ speed: "FAST" | "MEDIUM" | "SLOW";
702
+ }): Promise<{
703
+ readonly feeSats: number;
704
+ readonly exitSats: number;
705
+ }>;
706
+ /**
707
+ * Cooperative exit to an L1 address: `amountSats` arrives at the address and the exit debits
708
+ * `amountSats + fee` of leaves, where `fee` is the SSP's converged quote for the speed —
709
+ * re-quoted here and bounded by `maxFeeSats` before any approval. The intent carries the payout
710
+ * (`amountSats`) and the fee (`maxFeeSats: fee`); the kernel matches the exit output against it.
711
+ */
712
+ withdraw(ref: SparkAccountRef, params: {
713
+ address: string;
714
+ /** Sats that arrive at the address — the exit debits amountSats + the quoted fee. */
715
+ amountSats: number;
716
+ speed: "FAST" | "MEDIUM" | "SLOW";
717
+ /** Caller cap on the converged exit fee, in sats. */
718
+ maxFeeSats: number;
719
+ /** The request's idempotent transfer id — a retry resumes, never double-pays. */
720
+ transferId: string;
721
+ verify: VerifyFactor;
722
+ /** Called immediately before the send; a throw there means nothing may be sent. */
723
+ commit: () => void;
724
+ }): Promise<CooperativeExitResult>;
725
+ /**
726
+ * Converges the SSP exit fee for a payout: the fee is quoted on the gross amount, so re-quote on
727
+ * `amountSats + fee` until the fee stops growing (three re-quotes at most).
728
+ */
729
+ private settleExitFee;
730
+ }
731
+ /**
732
+ * What the host shows for a Spark, Lightning or exit request; `family` tells it apart from a chain
733
+ * intent.
734
+ */
735
+ type SparkDisplay = {
736
+ readonly family: "spark";
737
+ readonly network: SparkNetwork;
738
+ readonly kind: "transfer" | "lightning" | "exit";
739
+ readonly amountSats: number;
740
+ readonly maxFeeSats?: number;
741
+ /** Exits only: the quoted fee; the debit is `amountSats + feeSats`. */
742
+ readonly feeSats?: number;
743
+ /** Spark address, Lightning payee public key (hex) or bitcoin address. */
744
+ readonly receiver: string;
745
+ /** Invoice description or the LNURL metadata text. */
746
+ readonly description?: string;
747
+ } | {
748
+ readonly family: "spark";
749
+ readonly network: SparkNetwork;
750
+ readonly kind: "token";
751
+ /** Bech32m token identifier (`btkn`/`btknrt`). */
752
+ readonly tokenIdentifier: string;
753
+ /** Decimal base units. */
754
+ readonly amount: string;
755
+ /** Spark address of the receiver. */
756
+ readonly receiver: string;
757
+ };
758
+ type SparkResult = {
759
+ readonly kind: "spark";
760
+ readonly transfer: SparkTransfer;
761
+ } | {
762
+ readonly kind: "lightning";
763
+ readonly payment: LightningPayment;
764
+ } | {
765
+ readonly kind: "withdraw";
766
+ readonly exit: CooperativeExitResult;
767
+ } | {
768
+ readonly kind: "token";
769
+ readonly transactionHash: string;
770
+ } |
771
+ /**
772
+ * The commit response was lost and the payment may have gone out: `payment` is its open record,
773
+ * which `SparkAccountState.payments` and `engine.history` keep following until the Spark operator
774
+ * settles or fails it.
775
+ */
776
+ {
777
+ readonly kind: "pending";
778
+ readonly payment: SparkPaymentRecord;
779
+ };
780
+ /**
781
+ * A validated, fixed Spark payment: everything that does not need the user's verification has
782
+ * happened (including any LNURL invoice fetch), so approval only re-checks expiry and executes.
783
+ */
784
+ type PreparedSparkAction = {
785
+ readonly display: SparkDisplay;
786
+ readonly checks: ReadonlyArray<RequestCheckCode>;
787
+ /** Why the action can no longer be paid at `now` (an expiring invoice), if so. */
788
+ readonly staleReason: (now: number) => string | undefined;
789
+ /**
790
+ * Runs the controller's approve-first payment call. `commit` is the request's point of no return
791
+ * — the controller calls it immediately before the client call that sends, and a throw there
792
+ * means nothing may be sent.
793
+ */
794
+ readonly execute: (spark: SparkController, verify: VerifyFactor, commit: () => void) => Promise<SparkResult>;
795
+ };
796
+ type PaymentOption = {
797
+ readonly kind: "spark";
798
+ readonly address: string;
799
+ } | {
800
+ readonly kind: "spark-invoice";
801
+ readonly invoice: string;
802
+ readonly amountSats?: number;
803
+ readonly memo?: string;
804
+ readonly expiresAt?: number;
805
+ } | {
806
+ readonly kind: "lightning";
807
+ readonly invoice: string;
808
+ readonly amountSats?: number;
809
+ readonly paymentHash: string;
810
+ readonly description?: string;
811
+ readonly expiresAt: number;
812
+ } | {
813
+ readonly kind: "lnurl-pay";
814
+ readonly request: LnurlPayRequest;
815
+ readonly address?: string;
816
+ } | {
817
+ readonly kind: "lnurl-withdraw";
818
+ readonly request: LnurlWithdrawRequest;
819
+ } | {
820
+ readonly kind: "bitcoin";
821
+ readonly address: string;
822
+ };
823
+ type PaymentRequest = {
824
+ readonly options: ReadonlyArray<PaymentOption>;
825
+ readonly amountSats?: number;
826
+ readonly label?: string;
827
+ readonly message?: string;
828
+ };
829
+ type PaymentParse = {
830
+ /** A WalletConnect pairing URI; the host passes it to the walletconnect entry's `pair`. */
831
+ readonly kind: "walletconnect";
832
+ readonly uri: string;
833
+ } | {
834
+ readonly kind: "request";
835
+ readonly request: PaymentRequest;
836
+ } | {
837
+ readonly kind: "lnurl";
838
+ readonly url: string;
839
+ readonly address?: string;
840
+ } | {
841
+ readonly kind: "unsupported";
842
+ readonly format: "bolt12" | "silent-payment" | "lnurl-auth" | "spark-token-invoice" | "nostr-wallet-connect";
843
+ } | {
844
+ readonly kind: "invalid";
845
+ readonly reason: "network" | "expired" | "amount-mismatch" | "malformed";
846
+ } | {
847
+ readonly kind: "unrecognized";
848
+ };
849
+ type ParseOptions = {
850
+ readonly network: SparkNetwork;
851
+ readonly now: number;
852
+ };
853
+ /** `input` → PaymentParse. Never throws: every failure is a structured result. */
854
+ declare function parsePayment(input: string, options: ParseOptions): PaymentParse;
855
+ type PayParams = {
856
+ readonly account: SparkAccountRef;
857
+ readonly option: PaymentOption;
858
+ /** Caller-supplied amount — required by open invoices, the `spark` option, and LNURL flows. */
859
+ readonly amountSats?: number;
860
+ readonly comment?: string;
861
+ readonly maxFeeSats?: number;
862
+ readonly speed?: "FAST" | "MEDIUM" | "SLOW";
863
+ /** `amountSats` came from the service's minimum (WebLN `lnurl`), not an explicit amount. */
864
+ readonly amountFromServiceMinimum?: boolean;
865
+ /** Token payment — valid only with the plain `spark` option, and never with `amountSats`. */
866
+ readonly token?: {
867
+ /** Bech32m token identifier (`btkn`/`btknrt`). */
868
+ readonly identifier: string;
869
+ /** Base units. */
870
+ readonly amount: bigint;
871
+ };
872
+ };
873
+ type WithdrawLnurlParams = {
874
+ readonly account: SparkAccountRef;
875
+ readonly option: Extract<PaymentOption, {
876
+ kind: "lnurl-withdraw";
877
+ }>;
878
+ readonly amountSats: number;
879
+ };
880
+ /** A profile zap names the recipient pubkey; an event zap carries the event it zaps. */
881
+ type ZapRecipient = {
882
+ readonly pubkey: string;
883
+ readonly lightning: string;
884
+ } | {
885
+ readonly event: Event;
886
+ readonly lightning: string;
887
+ };
888
+ type PrepareZapParams = {
889
+ /** Any `NostrSigner` — wallet key, external key, NIP-07/46 — signs the 9734. */
890
+ readonly signer: NostrSigner;
891
+ readonly recipient: ZapRecipient;
892
+ readonly amountSats: number;
893
+ readonly comment?: string | undefined;
894
+ readonly relays: ReadonlyArray<string>;
895
+ readonly network: SparkNetwork;
896
+ };
897
+ type PrepareZapContext = {
898
+ readonly verifyEvent: (event: Event) => boolean;
899
+ readonly fetch: typeof globalThis.fetch;
900
+ readonly now: () => number;
901
+ };
902
+ /** Everything a payer needs: the signed 9734, the invoice, and the note fields. */
903
+ type PreparedZap = {
904
+ readonly zapRequest: Event;
905
+ readonly invoice: string;
906
+ /** Hex payment hash decoded from the invoice. */
907
+ readonly paymentHash: string;
908
+ /** Millisecond expiry decoded from the invoice. */
909
+ readonly expiresAt: number;
910
+ readonly amountSats: number;
911
+ /** The LNURL service's 9735 signing pubkey. */
912
+ readonly receiptPubkey: string;
913
+ readonly recipientPubkey: string;
914
+ readonly eventId?: string;
915
+ readonly comment?: string;
916
+ /** The lud16 or LNURL as given. */
917
+ readonly lightning: string;
918
+ };
919
+ /** Everything up to payment: resolve LNURL, sign the 9734, request the invoice. */
920
+ declare function prepareZap(params: PrepareZapParams, context: PrepareZapContext): Promise<PreparedZap>;
921
+ /**
922
+ * `blocked`: on the list. `trusted`: on the list, but the user trusts that origin. `clear`: not on
923
+ * the list, or not a web page. `unchecked`: no list has been loaded yet.
924
+ */
925
+ type PhishingStatus = "blocked" | "trusted" | "clear" | "unchecked";
926
+ declare const PHISHING_REFRESH_MS = 3600000;
927
+ type PhishingState = {
928
+ readonly version: number | null;
929
+ /** Last successful sync in this process, or the stored list's time after a restart. */
930
+ readonly updatedAt: number | null;
931
+ readonly trusted: ReadonlyArray<string>;
932
+ };
933
+ type PhishingControllerOptions = {
934
+ readonly publicStore: PublicStore;
935
+ readonly gateway?: GatewayConfig | undefined;
936
+ readonly fetch: typeof globalThis.fetch;
937
+ readonly now: () => number;
938
+ readonly setTimer: (ms: number, fn: () => void) => () => void;
939
+ readonly logger: EngineLogger;
940
+ };
941
+ declare class PhishingController extends Controller<PhishingState> {
942
+ private readonly options;
943
+ private readonly fetchGateway;
944
+ private deny;
945
+ private allow;
946
+ private inflight;
947
+ private abort;
948
+ private cancelTimer;
949
+ private epoch;
950
+ private destroyed;
951
+ constructor(options: PhishingControllerOptions);
952
+ init(): Promise<void>;
953
+ destroy(): Promise<void>;
954
+ check(url: string): PhishingStatus;
955
+ /** Fetches a snapshot or diff from the gateway; one request at a time, never throws. */
956
+ sync(): Promise<void>;
957
+ trust(origin: string): Promise<void>;
958
+ untrust(origin: string): Promise<void>;
959
+ private assertOrigin;
960
+ private saveTrusted;
961
+ private arm;
962
+ private refresh;
963
+ private load;
964
+ private restoreList;
965
+ private fetchAndApply;
966
+ private apply;
967
+ private persist;
968
+ }
969
+ type ChainRequestMethod = "send" | "speed-up" | "cancel" | "cpfp" | "evm-delegation" | "evm-batch" | "evm-approve" | "evm-revoke" | "evm-cctp" | "evm-swap" | "evm-bridge" | "evm-nft-send" | "solana-nft-send" | "evm-lido" | "solana-stake" | "solana-revoke" | "solana-swap" | "tron-stake" | "tron-approve";
970
+ /** A web page; `origin` is `scheme://host[:port]`, computed by the host from the top-level URL. */
971
+ type BrowserOrigin = {
972
+ readonly kind: "browser";
973
+ readonly origin: string;
974
+ };
975
+ type WalletConnectVerify = {
976
+ readonly validation: "VALID" | "INVALID" | "UNKNOWN";
977
+ readonly isScam: boolean;
978
+ };
979
+ /** A WalletConnect peer. `origin` is the session key `walletconnect:<topic>` — never a URL. */
980
+ type WalletConnectOrigin = {
981
+ readonly kind: "walletconnect";
982
+ readonly origin: string;
983
+ readonly topic: string;
984
+ /** The peer's self-declared metadata URL reduced to its origin — display only, never verified. */
985
+ readonly url: string;
986
+ readonly name: string;
987
+ readonly verify: WalletConnectVerify;
988
+ };
989
+ type DappOrigin = BrowserOrigin | WalletConnectOrigin;
990
+ /** A request an in-engine application (Hyperliquid, …) opened — core never enumerates app ids. */
991
+ type AppOrigin = {
992
+ readonly kind: "app";
993
+ readonly id: string;
994
+ };
995
+ /**
996
+ * A scanned QR sign request. `declared` is the counterpart's self-declared origin text — display
997
+ * only, never verified; it is already sanitised and at most 64 characters.
998
+ */
999
+ type QrOrigin = {
1000
+ readonly kind: "qr";
1001
+ readonly declared?: string;
1002
+ };
1003
+ type RequestOrigin = {
1004
+ readonly kind: "internal";
1005
+ } | AppOrigin | DappOrigin | QrOrigin;
1006
+ /** The URL a dApp origin's phishing and sign-in checks run against. */
1007
+ declare const dappUrl: (origin: DappOrigin) => string;
1008
+ declare const walletConnectKey: (topic: string) => string;
1009
+ type RequestMethod = ChainRequestMethod | "pay" | "zap" | "evm-sign" | "tron-sign" | "evm-delegation" | "evm-batch" | "nostr-sign" | "webln-invoice" | "watch-asset" | "solana-sign" | "bitcoin-sign" | "spark-deposit" | "spark-exit";
1010
+ /** A Solana chain account the `solana-sign` request signs for. */
1011
+ type SolanaAccount = {
1012
+ readonly walletId: string;
1013
+ readonly groupIndex: number;
1014
+ readonly address: string;
1015
+ };
1016
+ /** A Bitcoin account the `bitcoin-sign` request signs for: the group's fixed dApp-facing address. */
1017
+ type BitcoinAccount = {
1018
+ readonly walletId: string;
1019
+ readonly groupIndex: number;
1020
+ readonly address: string;
1021
+ /** `btc.bip84` for the `payment` purpose, `btc.bip86` for `ordinals`. */
1022
+ readonly template: "btc.bip84" | "btc.bip86";
1023
+ };
1024
+ /**
1025
+ * The wallet group a `bitcoin-sign` PSBT request signs for: inputs of several dApp-facing templates
1026
+ * of the same group may mix in one PSBT — each sign entry names its own template.
1027
+ */
1028
+ type BitcoinGroup = {
1029
+ readonly walletId: string;
1030
+ readonly groupIndex: number;
1031
+ };
1032
+ /** The sighash a dApp asks for per input; anything else is refused before it reaches a request. */
1033
+ type BitcoinSigHash = "ALL" | "SINGLE|ANYONECANPAY";
1034
+ /**
1035
+ * One PSBT and the inputs it asks the wallet to sign — a QR counterpart may request any of the
1036
+ * group's four templates where a dApp only uses the two dApp-facing ones.
1037
+ */
1038
+ type BitcoinPsbtInput = {
1039
+ readonly psbt: Uint8Array;
1040
+ readonly sign: ReadonlyArray<{
1041
+ readonly index: number;
1042
+ readonly sigHash: BitcoinSigHash;
1043
+ readonly template: BitcoinTemplate;
1044
+ }>;
1045
+ };
1046
+ /**
1047
+ * A dApp PSBT after the engine enriched the requested inputs with this account's derivation data:
1048
+ * `request` is what the kernel signs, `own` the verified own-key outputs split into discoverable
1049
+ * change and unusual paths, `inputs` the signed inputs' prevout values and sighash (for risk).
1050
+ */
1051
+ type PreparedBitcoinPsbt = {
1052
+ readonly request: Extract<SignRequest, {
1053
+ kind: "bitcoin.psbt";
1054
+ }>;
1055
+ readonly own: BitcoinOwn;
1056
+ readonly inputs: ReadonlyArray<{
1057
+ readonly index: number;
1058
+ readonly value: number;
1059
+ readonly sigHash: BitcoinSigHash;
1060
+ readonly template: BitcoinTemplate;
1061
+ /** The user froze this outpoint — signing it is a danger finding. */
1062
+ readonly frozen: boolean;
1063
+ }>;
1064
+ };
1065
+ /** A token the page asked to watch whose on-chain metadata cannot be shown; the dApp's bad input. */
1066
+ declare class InvalidTokenError extends Error {
1067
+ constructor(message: string);
1068
+ }
1069
+ /** A Sign-In with X message for another domain than the page that asked for the signature. */
1070
+ declare class SignInOriginError extends Error {
1071
+ constructor(message: string);
1072
+ }
1073
+ /** A request that ended without a result: `stage` says how, `message` is the failure if any. */
1074
+ declare class RequestEndedError extends Error {
1075
+ readonly stage: "rejected" | "failed" | "expired" | "invalidated";
1076
+ /**
1077
+ * Whether the request had reached the `signed` stage when it ended — `false` proves nothing it
1078
+ * produced was broadcast, `true` means a signature may already be out.
1079
+ */
1080
+ readonly signed: boolean;
1081
+ constructor(stage: RequestEndedError["stage"], message: string | undefined, signed: boolean);
1082
+ }
1083
+ /**
1084
+ * An app pinned the nonce its transaction must carry but the sender's next free nonce differs — the
1085
+ * request is refused before anything is shown rather than signed at a nonce that would sit
1086
+ * `unknown` forever.
1087
+ */
1088
+ declare class NonceConflictError extends Error {
1089
+ /** The nonce the caller requires the transaction to carry. */
1090
+ readonly expected: number;
1091
+ /** The sender's next free nonce as the engine sees it. */
1092
+ readonly next: number;
1093
+ constructor(expected: number, next: number);
1094
+ }
1095
+ /** The origin already has a request in flight; a dApp gets one at a time. */
1096
+ declare class OriginBusyError extends Error {
1097
+ constructor(origin: string);
1098
+ }
1099
+ /**
1100
+ * Request risk, pure. A recipient the wallet has never paid or saved is a `warning`; one that looks
1101
+ * like a known address (same first and last four characters, different address) is a `danger` — the
1102
+ * shape of an address-poisoning lookalike. Both can apply to one recipient. A page the user trusts
1103
+ * despite the phishing list is a `danger`; one that could not be checked is a `warning`. A sign-in
1104
+ * over QR carries no verifiable domain at all — a `danger` the user must acknowledge, since a dApp
1105
+ * claiming a domain it does not own is refused outright.
1106
+ */
1107
+ type RiskFinding = {
1108
+ readonly code: "first-recipient" | "address-poisoning" | "phishing-origin" | "phishing-unchecked" | "token-impersonation" | "token-symbol-unicode" | "simulation-reverted" | "simulation-mismatch" | "collection-approval" | "unlimited-approval" | "sign-in-malformed" | "sign-in-domain-mismatch" | "sign-in-port-mismatch" | "sign-in-address-mismatch" | "sign-in-expired" | "sign-in-not-yet-valid" | "permit-approval" | "permit-unlimited" | "permit-long-lived" | "order-receives-nothing" | "order-offerer-mismatch" | "safe-delegatecall" | "safe-gas-refund" | "bitcoin-sighash-single" | "bitcoin-inscription-input" | "bitcoin-frozen-input" | "bitcoin-unusual-output" | "bitcoin-unconfirmed-output" | "stake-authority" | "blind-signing" | "contract-recipient" | "token-contract-recipient" | "token-recipient-empty" | "fee-limit-below-estimate" | "verify-mismatch" | "verify-threat" | "fiat24-internal-account" | "fiat24-card-pull" | "fiat24-unlimited-approval" | "fiat24-exact-out-unbounded" | "fiat24-payee-offchain" | "fiat24-account-move" | "fiat24-account-burn" | "qr-sign-in-unverified";
1109
+ readonly level: "warning" | "danger";
1110
+ };
1111
+ type AcrossBridgeQuote = {
1112
+ readonly provider: "across";
1113
+ readonly inputToken: string;
1114
+ readonly outputToken: string;
1115
+ readonly inputAmount: bigint;
1116
+ readonly outputAmount: bigint;
1117
+ readonly destinationNetwork: string;
1118
+ readonly quoteTimestamp: number;
1119
+ readonly fillDeadline: number;
1120
+ readonly exclusiveRelayer: string;
1121
+ readonly exclusivityParameter: number;
1122
+ readonly spokePool: string;
1123
+ readonly taker: string;
1124
+ readonly fetchedAt: number;
1125
+ };
1126
+ /** The deposit status Across reports for an origin transaction — display only. */
1127
+ type AcrossBridgeStatus = {
1128
+ readonly status: "pending" | "filled" | "expired" | "refunded" | "failed" | "unknown";
1129
+ readonly fillTxHash?: string;
1130
+ };
1131
+ /**
1132
+ * The terms a gateway swap quote commits to — `sell`/`buy` use the engine's own asset ids
1133
+ * (`native`, `erc20:<addr>`) rather than the 0x sentinel.
1134
+ */
1135
+ type SwapQuote = ZeroExSwapQuote | JupiterSwapQuote;
1136
+ type ZeroExSwapQuote = {
1137
+ readonly provider: "0x";
1138
+ readonly network: string;
1139
+ readonly taker: string;
1140
+ readonly sell: string;
1141
+ readonly buy: string;
1142
+ readonly sellAmount: bigint;
1143
+ readonly buyAmount: bigint;
1144
+ readonly minBuyAmount: bigint;
1145
+ readonly allowanceTarget: string | undefined;
1146
+ readonly transaction: {
1147
+ readonly to: string;
1148
+ readonly data: string;
1149
+ readonly value: bigint;
1150
+ readonly gas: bigint | undefined;
1151
+ };
1152
+ readonly fees: {
1153
+ readonly integrator: {
1154
+ readonly token: string;
1155
+ readonly amount: bigint;
1156
+ } | undefined;
1157
+ readonly zeroEx: {
1158
+ readonly token: string;
1159
+ readonly amount: bigint;
1160
+ } | undefined;
1161
+ };
1162
+ readonly blockNumber: bigint;
1163
+ readonly fetchedAt: number;
1164
+ };
1165
+ /** One instruction of a Jupiter `/build` set — wire accounts, raw base64-decoded data. */
1166
+ type JupiterInstruction = {
1167
+ readonly programId: string;
1168
+ readonly accounts: ReadonlyArray<{
1169
+ readonly address: string;
1170
+ readonly signer: boolean;
1171
+ readonly writable: boolean;
1172
+ }>;
1173
+ readonly data: Uint8Array;
1174
+ };
1175
+ /**
1176
+ * A Jupiter build the engine verifies on-chain before signing — mints use the engine's asset ids
1177
+ * (`lamports` for native SOL), amounts are base-unit bigints.
1178
+ */
1179
+ type JupiterSwapQuote = {
1180
+ readonly provider: "jupiter";
1181
+ readonly network: string;
1182
+ readonly taker: string;
1183
+ readonly sell: string;
1184
+ readonly buy: string;
1185
+ readonly sellAmount: bigint;
1186
+ readonly buyAmount: bigint;
1187
+ readonly minBuyAmount: bigint;
1188
+ readonly setup: ReadonlyArray<JupiterInstruction>;
1189
+ readonly swap: JupiterInstruction;
1190
+ readonly cleanup: JupiterInstruction | undefined;
1191
+ /** Address lookup table addresses — contents are read from chain, never the gateway. */
1192
+ readonly lookupTables: ReadonlyArray<string>;
1193
+ readonly fetchedAt: number;
1194
+ };
1195
+ type ChainApis = Omit<ReturnType<typeof chains>, "sign"> & {
1196
+ readonly sign: (params: Parameters<ChainsApi["sign"]>[0] & {
1197
+ readonly acknowledgeUnconfirmed?: true;
1198
+ }) => ReturnType<ChainsApi["sign"]>;
1199
+ };
1200
+ type SignParams = Parameters<ChainApis["sign"]>[0];
1201
+ type SignResult = Awaited<ReturnType<ChainApis["sign"]>>;
1202
+ type AccountRef = Exclude<SignParams["request"], {
1203
+ kind: "bitcoin.psbt";
1204
+ }>["account"];
1205
+ type DisplayIntent$1 = ReturnType<typeof decodeEvm>;
1206
+ type TxState = "draft" | "signed" | "submitted" | "pending" | "confirmed" | "failed" | "rejected" | "dropped" | "replaced";
1207
+ /** Where an on-chain transaction sits, as its tracker last saw it. */
1208
+ type TxBlock = {
1209
+ /** Block hash; absent on Solana, whose status answer names only the slot. */
1210
+ readonly hash?: string;
1211
+ /** Block number (EVM), height (Bitcoin) or slot (Solana). */
1212
+ readonly height: number;
1213
+ };
1214
+ /** A bitcoin transaction that funds the wallet's own Spark account; it is claimed once confirmed. */
1215
+ type SparkDepositTag = {
1216
+ readonly walletId: string;
1217
+ readonly groupIndex: number;
1218
+ readonly network: SparkNetwork;
1219
+ readonly claimed?: boolean;
1220
+ };
1221
+ type TrackedTransaction = {
1222
+ readonly id: string;
1223
+ readonly family: "evm" | "solana" | "bitcoin" | "tron";
1224
+ readonly network: string;
1225
+ /** The signer's identity label — `walletId` for HD accounts, `keyId` for imported keys. */
1226
+ readonly account: string;
1227
+ readonly hash: string | undefined;
1228
+ readonly state: TxState;
1229
+ readonly intent: DisplayIntent$1 | undefined;
1230
+ readonly nonce: number;
1231
+ /**
1232
+ * The block a `confirmed` or on-chain `failed` transaction is in; cleared when a reorg returns it
1233
+ * to `submitted`.
1234
+ */
1235
+ readonly block?: TxBlock | undefined;
1236
+ /**
1237
+ * Past the network's finality rule (EVM `finalized` tag, 6 Bitcoin confirmations, Solana
1238
+ * `finalized`): never changes again, no longer polled.
1239
+ */
1240
+ readonly final?: boolean | undefined;
1241
+ /** Solana only — the blockhash expiry that turns an unconfirmed tx `dropped`. */
1242
+ readonly lastValidBlockHeight?: number;
1243
+ /**
1244
+ * Solana only — a durable-nonce transaction has no block-height expiry: `account` is the nonce
1245
+ * account and `value` the nonce its first instruction advances, read back on each poll. `account`
1246
+ * is undefined when the message loads it from a lookup table: nothing to read on it, so the
1247
+ * transaction is never dropped — only resolved by landing.
1248
+ */
1249
+ readonly durableNonce?: {
1250
+ readonly account: string | undefined;
1251
+ readonly value: string;
1252
+ };
1253
+ /**
1254
+ * TRON build record — `raw_data.expiration` bounds drop proofs (past it the network can never
1255
+ * include the transaction); `from` is the sender, for group membership like `evm.from`.
1256
+ * `dappSignature` is set on a dApp-observed entry: the wallet-signed signature (lowercase hex)
1257
+ * `submitDappTron` later matches against the bytes the dApp broadcasts.
1258
+ */
1259
+ readonly tron?: {
1260
+ readonly expiration: number;
1261
+ readonly from: string;
1262
+ readonly dappSignature?: string;
1263
+ };
1264
+ /** EVM replacement — the earlier transaction this one bumps or cancels. */
1265
+ readonly replaces?: string;
1266
+ /** CPFP — the unconfirmed parent this child pushes. */
1267
+ readonly parentId?: string;
1268
+ /** Set on a Spark deposit; `claimed` flips once the deposit is credited on Spark. */
1269
+ readonly sparkDeposit?: SparkDepositTag;
1270
+ /**
1271
+ * Absent: the tracker may rebroadcast the persisted bytes while the network does not know them.
1272
+ * `false`: recovered from a broadcast whose outcome never settled — it may have been refused — so
1273
+ * the bytes are watched but never resent; a speed-up or cancel is the remedy.
1274
+ */
1275
+ readonly rebroadcast?: false;
1276
+ /**
1277
+ * EVM and Bitcoin: neither endpoint has known this transaction for `STUCK_AFTER_MS`. It stays
1278
+ * `submitted`, still holds its nonce or inputs and is polled at the finality interval; offer
1279
+ * speed-up or cancel.
1280
+ */
1281
+ readonly stuck?: boolean | undefined;
1282
+ /**
1283
+ * The signed transaction exactly as broadcast — EVM and Bitcoin hex, Solana base64 wire —
1284
+ * persisted with `hash` before it leaves, so an unknown outcome is rebroadcast, even after a
1285
+ * restart. Cleared when the node refuses it.
1286
+ */
1287
+ readonly raw?: string | undefined;
1288
+ /** EVM build record persisted with `raw`, for drop detection and replacement. */
1289
+ readonly evm?: {
1290
+ readonly from: string;
1291
+ readonly account: AccountRef;
1292
+ };
1293
+ /** Bitcoin build record persisted at send for RBF/CPFP rebuilds. */
1294
+ readonly btc?: {
1295
+ readonly inputs: ReadonlyArray<{
1296
+ readonly txid: string;
1297
+ readonly vout: number;
1298
+ readonly value: number;
1299
+ readonly address: string;
1300
+ }>;
1301
+ readonly outputs: ReadonlyArray<{
1302
+ readonly address: string;
1303
+ readonly value: number;
1304
+ readonly own: boolean;
1305
+ }>;
1306
+ readonly vsize: number;
1307
+ readonly fee: number;
1308
+ readonly feeRate: number;
1309
+ /** The account shape the transaction was built from — needed to rebuild it after a restart. */
1310
+ readonly template: BitcoinAccountTemplate;
1311
+ readonly groupIndex: number;
1312
+ readonly tier: "fast" | "normal" | "slow";
1313
+ };
1314
+ readonly submittedAt: number;
1315
+ readonly error: string | undefined;
1316
+ };
1317
+ type SendParams = {
1318
+ readonly account: AccountRef;
1319
+ readonly network: string;
1320
+ readonly to: string;
1321
+ readonly amount: bigint;
1322
+ /** ERC-20 contract — when set, `to`/`amount` are the transfer recipient/units and value is 0. */
1323
+ readonly token?: string;
1324
+ readonly fee: EvmFeeTier | SolanaFeeTier;
1325
+ /** SPL mint decimals — required when `token` is a Solana mint. */
1326
+ readonly decimals?: number;
1327
+ /**
1328
+ * Bitcoin only — the exact outpoints (`txid:vout`) this send spends; omit for automatic
1329
+ * selection. Naming an inscription-protected output opts into spending it.
1330
+ */
1331
+ readonly inputs?: ReadonlyArray<string>;
1332
+ /** TRON only — the `raw_data.data` memo; refused on every other family. */
1333
+ readonly memo?: string;
1334
+ readonly verify: SignParams["verify"];
1335
+ };
1336
+ type PrepareParams = Omit<SendParams, "verify">;
1337
+ /** One standing EVM approval to remove. */
1338
+ type EvmRevokeTarget = {
1339
+ readonly kind: "erc20";
1340
+ readonly token: string;
1341
+ readonly spender: string;
1342
+ } | {
1343
+ readonly kind: "permit2";
1344
+ readonly token: string;
1345
+ readonly spender: string;
1346
+ } | {
1347
+ readonly kind: "operator";
1348
+ readonly contract: string;
1349
+ readonly operator: string;
1350
+ } | {
1351
+ readonly kind: "nft";
1352
+ readonly contract: string;
1353
+ readonly tokenId: bigint;
1354
+ };
1355
+ /** What a request asks for; replacements and CPFP name the original transaction. */
1356
+ type ChainRequestInput = ({
1357
+ readonly method: "send";
1358
+ readonly origin?: DappOrigin;
1359
+ } & PrepareParams) | {
1360
+ readonly method: "speed-up" | "cancel";
1361
+ readonly txId: string;
1362
+ } | {
1363
+ readonly method: "cpfp";
1364
+ readonly txId: string;
1365
+ readonly feeRate: number;
1366
+ } | {
1367
+ readonly method: "evm-delegation";
1368
+ readonly account: AccountRef;
1369
+ readonly network: string;
1370
+ readonly action: "upgrade" | "revoke";
1371
+ readonly fee: PrepareParams["fee"];
1372
+ } | {
1373
+ readonly method: "evm-batch";
1374
+ readonly account: AccountRef;
1375
+ readonly network: string;
1376
+ readonly calls: ReadonlyArray<{
1377
+ readonly to: string;
1378
+ readonly value: bigint;
1379
+ readonly data: string;
1380
+ }>;
1381
+ readonly fee: PrepareParams["fee"];
1382
+ /** A page asking for the batch (`wallet_sendCalls`); absent means the wallet itself. */
1383
+ readonly origin?: DappOrigin;
1384
+ } | {
1385
+ readonly method: "evm-approve";
1386
+ readonly account: AccountRef;
1387
+ readonly network: string;
1388
+ readonly token: string;
1389
+ readonly spender: string;
1390
+ readonly amount: bigint;
1391
+ readonly fee: PrepareParams["fee"];
1392
+ } | {
1393
+ readonly method: "evm-revoke";
1394
+ readonly account: AccountRef;
1395
+ readonly network: string;
1396
+ /**
1397
+ * 1..EVM_BATCH_LIMIT distinct targets; more than one needs the account delegated to the
1398
+ * wallet's delegator.
1399
+ */
1400
+ readonly targets: ReadonlyArray<EvmRevokeTarget>;
1401
+ readonly fee: PrepareParams["fee"];
1402
+ } | {
1403
+ /** The Hyperliquid CCTP deposit — `depositForBurnWithHook` on the route's messenger. */
1404
+ readonly method: "evm-cctp";
1405
+ readonly account: AccountRef;
1406
+ readonly network: string;
1407
+ readonly amount: bigint;
1408
+ readonly dex: "perps" | "spot";
1409
+ /** The Circle forward fee bound — strictly below `amount`. */
1410
+ readonly maxFee: bigint;
1411
+ readonly fee: PrepareParams["fee"];
1412
+ } | {
1413
+ readonly method: "evm-swap";
1414
+ readonly account: AccountRef;
1415
+ readonly network: string;
1416
+ readonly quote: ZeroExSwapQuote;
1417
+ readonly fee: PrepareParams["fee"];
1418
+ } | {
1419
+ readonly method: "evm-bridge";
1420
+ readonly account: AccountRef;
1421
+ readonly network: string;
1422
+ readonly quote: AcrossBridgeQuote;
1423
+ readonly fee: PrepareParams["fee"];
1424
+ } | {
1425
+ readonly method: "evm-nft-send";
1426
+ readonly account: AccountRef;
1427
+ readonly network: string;
1428
+ /** The ERC-721 or ERC-1155 contract. */
1429
+ readonly contract: string;
1430
+ /** The ids sent — one for ERC-721, up to `EVM_BATCH_LIMIT` for ERC-1155. */
1431
+ readonly items: ReadonlyArray<{
1432
+ readonly tokenId: bigint;
1433
+ readonly amount?: bigint;
1434
+ }>;
1435
+ readonly to: string;
1436
+ readonly fee: PrepareParams["fee"];
1437
+ } | {
1438
+ readonly method: "solana-nft-send";
1439
+ readonly account: AccountRef;
1440
+ readonly network: string;
1441
+ /** The SPL mint or Core asset account. */
1442
+ readonly asset: string;
1443
+ readonly to: string;
1444
+ readonly fee: PrepareParams["fee"];
1445
+ } | {
1446
+ readonly method: "solana-swap";
1447
+ readonly account: AccountRef;
1448
+ readonly network: string;
1449
+ readonly quote: JupiterSwapQuote;
1450
+ readonly fee: PrepareParams["fee"];
1451
+ } | {
1452
+ readonly method: "evm-lido";
1453
+ readonly account: AccountRef;
1454
+ readonly network: string;
1455
+ readonly action: {
1456
+ readonly kind: "stake";
1457
+ readonly amount: bigint;
1458
+ } | {
1459
+ readonly kind: "request";
1460
+ readonly amount: bigint;
1461
+ } | {
1462
+ readonly kind: "claim";
1463
+ readonly requestIds: ReadonlyArray<bigint>;
1464
+ };
1465
+ readonly fee: PrepareParams["fee"];
1466
+ } | {
1467
+ readonly method: "solana-revoke";
1468
+ readonly account: AccountRef;
1469
+ readonly network: string;
1470
+ /** 1..10 distinct token accounts the signer owns whose delegate is removed — one Revoke each. */
1471
+ readonly tokenAccounts: ReadonlyArray<string>;
1472
+ readonly fee: PrepareParams["fee"];
1473
+ } | {
1474
+ readonly method: "solana-stake";
1475
+ readonly account: AccountRef;
1476
+ readonly network: string;
1477
+ readonly action: {
1478
+ readonly kind: "delegate";
1479
+ readonly lamports: bigint;
1480
+ readonly vote: string;
1481
+ } | {
1482
+ readonly kind: "deactivate";
1483
+ readonly stakeAccount: string;
1484
+ } | {
1485
+ readonly kind: "withdraw";
1486
+ readonly stakeAccount: string;
1487
+ readonly lamports: bigint;
1488
+ };
1489
+ readonly fee: PrepareParams["fee"];
1490
+ } | {
1491
+ readonly method: "tron-stake";
1492
+ readonly account: AccountRef;
1493
+ readonly network: string;
1494
+ readonly action: {
1495
+ readonly kind: "freeze" | "unfreeze";
1496
+ readonly amount: bigint;
1497
+ readonly resource: "bandwidth" | "energy";
1498
+ } | {
1499
+ readonly kind: "withdraw-expired";
1500
+ } | {
1501
+ readonly kind: "cancel-unfreeze";
1502
+ } | {
1503
+ readonly kind: "delegate";
1504
+ readonly receiver: string;
1505
+ readonly amount: bigint;
1506
+ readonly resource: "bandwidth" | "energy";
1507
+ /** Lock the delegation for this many blocks (1..getMaxDelegateLockPeriod). */
1508
+ readonly lockBlocks?: number;
1509
+ } | {
1510
+ readonly kind: "undelegate";
1511
+ readonly receiver: string;
1512
+ readonly amount: bigint;
1513
+ readonly resource: "bandwidth" | "energy";
1514
+ } | {
1515
+ readonly kind: "vote";
1516
+ readonly votes: ReadonlyArray<{
1517
+ readonly witness: string;
1518
+ readonly count: bigint;
1519
+ }>;
1520
+ } | {
1521
+ readonly kind: "claim-rewards";
1522
+ };
1523
+ } | {
1524
+ readonly method: "tron-approve";
1525
+ readonly account: AccountRef;
1526
+ readonly network: string;
1527
+ readonly token: string;
1528
+ readonly spender: string;
1529
+ /** The new allowance in token units; 0 revokes. */
1530
+ readonly amount: bigint;
1531
+ };
1532
+ /**
1533
+ * One `wallet_sendCalls` bundle: the tracked transactions it produced so `wallet_getCallsStatus`
1534
+ * can aggregate them, retained alongside those transactions.
1535
+ */
1536
+ type BatchRecord = {
1537
+ readonly origin: string;
1538
+ readonly id: string;
1539
+ readonly network: string;
1540
+ readonly atomic: boolean;
1541
+ readonly txIds: ReadonlyArray<string>;
1542
+ readonly expected: number;
1543
+ readonly createdAt: number;
1544
+ };
1545
+ /** The account's EIP-7702 delegation state: `supported` follows the registry hash entry. */
1546
+ type DelegationStatus = {
1547
+ readonly supported: boolean;
1548
+ readonly state: "none" | "ours" | "other";
1549
+ readonly address?: string;
1550
+ };
1551
+ /**
1552
+ * A fully built, estimated and cross-checked send that has not been signed. The unsigned content
1553
+ * lives in the closures and cannot change after `prepare` returns.
1554
+ */
1555
+ type PreparedRequest = {
1556
+ /** Id of the tracked transaction `submit` creates. */
1557
+ readonly txId: string;
1558
+ readonly account: AccountRef;
1559
+ readonly network: string;
1560
+ /** The transaction being replaced or accelerated; absent for a plain send. */
1561
+ readonly target?: string;
1562
+ readonly intent: DisplayIntent$1;
1563
+ /** The address the route resolved for `account` — what recipient risk calls self. */
1564
+ readonly signer?: string;
1565
+ readonly checks: ReadonlyArray<RequestCheckCode>;
1566
+ /** Findings a route can only see on-chain (contract recipient, empty token balance). */
1567
+ readonly risk?: ReadonlyArray<RiskFinding>;
1568
+ /** The TRON fee quote — the intent's fee field carries only `fee_limit`. */
1569
+ readonly tronFee?: TronFeeQuote;
1570
+ /** Absent when the request is not simulated (replacements, Bitcoin). */
1571
+ readonly simulation?: SimulationOutcome;
1572
+ /** Re-runs the same simulated call at approval; absent when there is nothing to re-run. */
1573
+ readonly resimulate?: () => Promise<SimulationOutcome>;
1574
+ /** Why the build can no longer be signed (nonce taken, blockhash expired), if so. */
1575
+ readonly staleReason: () => string | undefined | Promise<string | undefined>;
1576
+ /**
1577
+ * Signs, finalizes, broadcasts and hands the transaction to tracking. `commit` must run
1578
+ * immediately (no await in between) before the network send; a throw there means nothing may be
1579
+ * sent.
1580
+ */
1581
+ readonly submit: (verify: SendParams["verify"], commit: () => void) => Promise<TrackedTransaction>;
1582
+ /** Frees what `prepare` reserved; safe to call more than once. */
1583
+ readonly release: () => void;
1584
+ };
1585
+ type SignatureResult = {
1586
+ readonly kind: "evm.personal-message" | "evm.fiat24-session" | "evm.typed-data" | "tron.message" | "tron.typed-data";
1587
+ readonly signature: Uint8Array;
1588
+ };
1589
+ /** A prepared message signature: nothing is broadcast or tracked, `submit` returns the signature. */
1590
+ type PreparedMessage = Omit<PreparedRequest, "submit" | "txId"> & {
1591
+ /** The address that will sign. */
1592
+ readonly signer: string;
1593
+ readonly submit: (verify: SendParams["verify"]) => Promise<SignatureResult>;
1594
+ };
1595
+ /** A transaction signed for a counterpart that broadcasts it itself — nothing is tracked or sent. */
1596
+ type SignedTransactionResult = {
1597
+ readonly kind: "evm.signed-transaction";
1598
+ readonly signedTransaction: Uint8Array;
1599
+ } | {
1600
+ readonly kind: "tron.signed-transaction";
1601
+ readonly signature: Uint8Array;
1602
+ };
1603
+ /**
1604
+ * A prepared QR transaction signature: all of `PreparedRequest`'s checks without its tracking —
1605
+ * `submit` signs the request's own bytes, `commit()`s before returning, and hands back the signed
1606
+ * material for the counterpart to broadcast.
1607
+ */
1608
+ type PreparedQrSign = Omit<PreparedRequest, "submit" | "txId"> & {
1609
+ /** The address that will sign. */
1610
+ readonly signer: string;
1611
+ readonly submit: (verify: SendParams["verify"], commit: () => void) => Promise<SignedTransactionResult>;
1612
+ };
1613
+ type Options = {
1614
+ readonly wallet: Wallet;
1615
+ readonly networks: NetworkController;
1616
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
1617
+ readonly openStore: () => Promise<EngineStore>;
1618
+ readonly random: (n: number) => Uint8Array;
1619
+ readonly setTimer: (ms: number, fn: () => unknown) => () => void;
1620
+ readonly now: () => number;
1621
+ readonly logger: EngineLogger;
1622
+ readonly pollMs?: number;
1623
+ /** The engine's signing path — `signers.apis`: custody dispatch lives in the signers module. */
1624
+ readonly chains: ReturnType<typeof chains>;
1625
+ /** A card wallet still waiting on a member card holds no groups — its addresses do not exist. */
1626
+ readonly isWalletIncomplete?: (walletId: string) => boolean;
1627
+ };
1628
+ type TransactionControllerState = {
1629
+ readonly txs: Record<string, TrackedTransaction>;
1630
+ };
1631
+ declare class TransactionController extends Controller<TransactionControllerState> {
1632
+ private readonly options;
1633
+ private engineStore?;
1634
+ private readonly timers;
1635
+ private evmRoute;
1636
+ private bitcoinRoute;
1637
+ private locked;
1638
+ /**
1639
+ * Bumped on every `lock`: a `RouteContext` captures it at creation, so an async result that
1640
+ * outlives its session — a broadcast settling after lock→unlock — is recognized as stale and
1641
+ * never writes into the new session's state or store, and never touches its timers.
1642
+ */
1643
+ private generation;
1644
+ private readonly batches;
1645
+ /**
1646
+ * The latest row whose bookkeeping write has not reached the store — set by a locked vault or a
1647
+ * failed write, replayed at `init` and by the flush loop. Locking keeps it: these rows describe
1648
+ * bytes that may already be out, so losing one means losing a refusal.
1649
+ */
1650
+ private readonly unsaved;
1651
+ /** The running flush loop while `unsaved` is non-empty and the vault is unlocked. */
1652
+ private unsavedFlush;
1653
+ /** In-flight drop/reorg corroboration — poll streaks die with the session. */
1654
+ private dropEvidence;
1655
+ constructor(options: Options);
1656
+ init(): Promise<void>;
1657
+ destroy(): Promise<void>;
1658
+ /** One `wallet_sendCalls` bundle the user approved; retained alongside the transactions it lists. */
1659
+ recordBatch(record: BatchRecord): Promise<void>;
1660
+ /** The bundle `origin` asked for, or `undefined` when it is not theirs (or is gone). */
1661
+ batchById(origin: string, id: string): BatchRecord | undefined;
1662
+ /** A tracked transaction by id — for `wallet_getCallsStatus`. */
1663
+ txById(id: string): TrackedTransaction | undefined;
1664
+ lock(): void;
1665
+ private persist;
1666
+ private transition;
1667
+ /** Arms the bookkeeping retry while the vault is unlocked and a row still needs the store. */
1668
+ private armUnsavedFlush;
1669
+ private stopUnsavedFlush;
1670
+ /** Writes every parked row; a row that lands leaves `unsaved`, an empty `unsaved` stops the loop. */
1671
+ private flushUnsaved;
1672
+ private routeCtx;
1673
+ /**
1674
+ * Internal entry for the request pipeline: builds, estimates and cross-checks a send without
1675
+ * signing it. Bitcoin outputs it selects stay locked under `requestId` until the returned
1676
+ * `release` runs or the broadcast moves them to the transaction.
1677
+ */
1678
+ prepareSend(params: PrepareParams, requestId: string, sparkDeposit?: SparkDepositTag): Promise<PreparedRequest>;
1679
+ /** The group's next unused `btc.bip84` receive address on a bitcoin `network`. */
1680
+ nextReceiveAddress(walletId: string, groupIndex: number, network: string): Promise<{
1681
+ address: string;
1682
+ confirmed: boolean;
1683
+ }>;
1684
+ /**
1685
+ * Freeze or unfreeze bitcoin outpoints (`txid:vout`) for one account on one `network`. Freezing
1686
+ * is intent, not utxo state — the outpoint need not be unspent — and it never lifts the derived
1687
+ * inscription protection.
1688
+ */
1689
+ setUtxosFrozen(account: {
1690
+ readonly walletId: string;
1691
+ readonly groupIndex: number;
1692
+ }, network: string, outpoints: ReadonlyArray<string>, frozen: boolean): Promise<void>;
1693
+ /** The outpoints the account froze on `network`. */
1694
+ frozenUtxos(account: {
1695
+ readonly walletId: string;
1696
+ readonly groupIndex: number;
1697
+ }, network: string): ReadonlyArray<string>;
1698
+ /**
1699
+ * Internal entry for the dApp `signTransaction` send path: a dApp-built transaction has no build
1700
+ * record; it joins tracking under its signed bytes like a wallet send.
1701
+ */
1702
+ submitDappBitcoin(network: string, walletId: string, prepared: PreparedBitcoinPsbt, result: SignResult): Promise<string>;
1703
+ /**
1704
+ * Internal entry for the dApp `signAndSendTransaction` path: a dApp-built transaction has no
1705
+ * build record; it joins tracking under its signed bytes like a wallet send.
1706
+ */
1707
+ submitDappSolana(network: string, walletId: string, wire: Uint8Array, lastValidBlockHeight: bigint, intent: DisplayIntent$1): Promise<string>;
1708
+ /**
1709
+ * Internal entry for the dApp `solana-sign` path: proves every message's lifetime — recent
1710
+ * blockhash or durable nonce — belongs to the session's cluster before anything is prompted or
1711
+ * signed. Throws `SolanaClusterBindingError` on an unbound message; the returned checks join the
1712
+ * request's when a mainnet build could only be gateway-bound.
1713
+ */
1714
+ bindDappSolana(network: string, messages: ReadonlyArray<Uint8Array>): Promise<ReadonlyArray<RequestCheckCode>>;
1715
+ /** Records that a Spark deposit was credited; persisted with the transaction. */
1716
+ markDepositClaimed(id: string): Promise<void>;
1717
+ /**
1718
+ * Internal entry for a dApp's EVM signature request: the request is normalized first, a
1719
+ * transaction is rebuilt with fresh nonce and fees (the dApp's own are discarded), and a message
1720
+ * is decoded and signed as is.
1721
+ */
1722
+ prepareDapp(account: AccountRef, request: SignRequest, options?: {
1723
+ readonly nonce?: number;
1724
+ }): Promise<PreparedRequest | PreparedMessage>;
1725
+ /**
1726
+ * Internal entry for a scanned QR EVM transaction: normalized with the same rules, but the
1727
+ * request's own nonce and fees are signed unchanged — a QR counterpart broadcasts the signed
1728
+ * envelope itself, so nothing is tracked or sent here.
1729
+ */
1730
+ prepareQrEvm(account: AccountRef, request: SignRequest): Promise<PreparedQrSign>;
1731
+ /**
1732
+ * Internal entry for a dApp's TRON request: the transaction bytes are validated, proven fresh and
1733
+ * quoted but never re-encoded — the kernel signs exactly the bytes the dApp sent. Messages and
1734
+ * typed data decode and sign like the EVM path.
1735
+ */
1736
+ prepareDappTron(account: AccountRef, request: SignRequest, options?: {
1737
+ readonly broadcast: false;
1738
+ }): Promise<PreparedRequest | PreparedMessage | PreparedQrSign>;
1739
+ /**
1740
+ * Internal entry for the dApp broadcast path (`wallet/sign` then the dApp sends the signed
1741
+ * transaction back): pairs the signature with the observed entry and broadcasts — once.
1742
+ */
1743
+ submitDappTron(network: string, rawData: Uint8Array, signature: Uint8Array): Promise<TrackedTransaction>;
1744
+ /**
1745
+ * Internal entry for replacements and CPFP: builds, cross-checks and reserves what the
1746
+ * replacement needs without signing it. The original must be `submitted` or `pending`.
1747
+ */
1748
+ prepareReplacement(input: Extract<ChainRequestInput, {
1749
+ method: "speed-up" | "cancel" | "cpfp";
1750
+ }>, requestId: string): Promise<PreparedRequest>;
1751
+ /**
1752
+ * Internal EVM requests (`evm-delegation`/`evm-batch`/`evm-approve`/`evm-swap`/`evm-lido`):
1753
+ * builds, estimates and cross-checks the self-transaction without signing it.
1754
+ */
1755
+ prepareEvmInternal(input: Extract<ChainRequestInput, {
1756
+ method: "evm-delegation" | "evm-batch" | "evm-approve" | "evm-revoke" | "evm-cctp" | "evm-swap" | "evm-bridge" | "evm-nft-send" | "evm-lido";
1757
+ }>, _requestId: string): Promise<PreparedRequest>;
1758
+ /**
1759
+ * Internal `solana-stake` requests: checks the delegation rules, then builds the stake
1760
+ * transaction through the same fee/simulation path as a SOL send without signing it.
1761
+ */
1762
+ prepareSolanaStake(input: Extract<ChainRequestInput, {
1763
+ method: "solana-stake";
1764
+ }>, _requestId: string): Promise<PreparedRequest>;
1765
+ /**
1766
+ * Internal `solana-revoke` requests: every token account is re-read on both endpoints before a
1767
+ * program-matched `Revoke` goes through the same fee/simulation tail as a send.
1768
+ */
1769
+ prepareSolanaRevoke(input: Extract<ChainRequestInput, {
1770
+ method: "solana-revoke";
1771
+ }>, _requestId: string): Promise<PreparedRequest>;
1772
+ /**
1773
+ * Internal `tron-stake` requests: the java-tron actuator rules are checked against node reads,
1774
+ * then the operation goes through the same build/sign/track tail as a send.
1775
+ */
1776
+ prepareTronStake(input: Extract<ChainRequestInput, {
1777
+ method: "tron-stake";
1778
+ }>, _requestId: string): Promise<PreparedRequest>;
1779
+ /** Internal `tron-approve` requests: TRC-20 `approve` (amount 0 revokes). */
1780
+ prepareTronApprove(input: Extract<ChainRequestInput, {
1781
+ method: "tron-approve";
1782
+ }>, _requestId: string): Promise<PreparedRequest>;
1783
+ prepareSolanaSwap(input: Extract<ChainRequestInput, {
1784
+ method: "solana-swap";
1785
+ }>, _requestId: string): Promise<PreparedRequest>;
1786
+ prepareSolanaNftSend(input: Extract<ChainRequestInput, {
1787
+ method: "solana-nft-send";
1788
+ }>, _requestId: string): Promise<PreparedRequest>;
1789
+ /** The account's 7702 delegation state on `network` (primary endpoint only). */
1790
+ delegationState(account: AccountRef, network: string): Promise<DelegationStatus>;
1791
+ /**
1792
+ * The address `account` resolves to on `network` — HD through the chains proxy, imported from the
1793
+ * vault's key list; the ref's family must match the network's.
1794
+ */
1795
+ addressOf(account: AccountRef, network: string): Promise<string>;
1796
+ private track;
1797
+ /**
1798
+ * Re-arms a transaction's loop — at the finality interval once included, back to `pollMs` after a
1799
+ * reorg.
1800
+ */
1801
+ private retrack;
1802
+ private untrack;
1803
+ /**
1804
+ * One status poll. `included` keeps a non-final row tracked at the finality interval; `reorged`
1805
+ * clears the block and returns the row to the pool as `submitted`; `ended` stops the loop. An
1806
+ * answer describes the snapshot the poll started from — a concurrent transition (a sibling
1807
+ * marking this replaced, a reload) means the row moved on and the next poll decides.
1808
+ */
1809
+ private pollOnce;
1810
+ /** When one of a replace pair is included, its live siblings are `replaced`. */
1811
+ private markReplacedSiblings;
1812
+ /** A reorged transaction revives `replaced` siblings: each is `submitted` and polled again. */
1813
+ private reviveSiblings;
1814
+ /** A reorged transaction re-anchors what it consumed — EVM nonces, Bitcoin inputs. */
1815
+ private reopen;
1816
+ /** A transaction that settled frees what it locked, whichever way it settled. */
1817
+ private settle;
1818
+ }
1819
+ type SignLogOutcome = "submitted" | "rejected" | "failed" | "expired" | "invalidated";
1820
+ type SignLogEntry = {
1821
+ readonly id: string;
1822
+ readonly at: number;
1823
+ readonly origin: RequestOrigin;
1824
+ readonly method: RequestMethod;
1825
+ readonly account: AccountRef | SparkAccountRef | NostrKeyRef | SolanaAccount | BitcoinAccount | BitcoinGroup;
1826
+ readonly network: string;
1827
+ readonly summary: string;
1828
+ readonly verification: "verified" | "unverifiable";
1829
+ readonly checks: ReadonlyArray<RequestCheckCode>;
1830
+ readonly risk: ReadonlyArray<RiskFinding>;
1831
+ readonly outcome: SignLogOutcome;
1832
+ readonly error?: string;
1833
+ };
1834
+ /**
1835
+ * `signed` is the point of no return: the signature exists and is being returned or broadcast, so
1836
+ * invalidation no longer applies.
1837
+ */
1838
+ type RequestStage = "awaiting-approval" | "signing" | "signed" | "submitted" | "rejected" | "failed" | "expired" | "invalidated";
1839
+ /** A Spark, Lightning (including LNURL-pay and lightning addresses) or cooperative-exit payment. */
1840
+ type PayInput = {
1841
+ readonly method: "pay";
1842
+ readonly origin?: DappOrigin;
1843
+ } & PayParams;
1844
+ /** A prepared zap; its invoice was fetched by `engine.zaps.prepare` and is paid as-is. */
1845
+ type ZapInput = {
1846
+ readonly method: "zap";
1847
+ readonly account: SparkAccountRef;
1848
+ readonly zap: PreparedZap;
1849
+ readonly maxFeeSats: number;
1850
+ };
1851
+ /**
1852
+ * A dApp's EVM request: a transaction (rebuilt here with fresh nonce and fees), a personal message
1853
+ * or EIP-712 typed data.
1854
+ */
1855
+ type EvmSignInput = {
1856
+ readonly method: "evm-sign";
1857
+ /** A page asking for the signature; a QR request carries a QrOrigin; absent means the wallet. */
1858
+ readonly origin?: DappOrigin | QrOrigin;
1859
+ readonly account: AccountRef;
1860
+ readonly network: string;
1861
+ readonly request: SignRequest;
1862
+ /**
1863
+ * App requests with an `evm.transaction` only: the nonce the transaction must carry. `prepare`
1864
+ * refuses with a `NonceConflictError` before anything is shown when the sender's next free nonce
1865
+ * differs, and rejects with a plain validation error when `nonce` is set on any other request
1866
+ * kind, on a request with a dApp or no app origin, or is not a safe non-negative integer.
1867
+ */
1868
+ readonly nonce?: number;
1869
+ };
1870
+ /**
1871
+ * A dApp's TRON request: a transaction whose exact `raw_data` bytes are validated and signed
1872
+ * unchanged, a TIP-191 message or TIP-712 typed data.
1873
+ */
1874
+ type TronSignInput = {
1875
+ readonly method: "tron-sign";
1876
+ /** A page asking for the signature; a QR request carries a QrOrigin; absent means the wallet. */
1877
+ readonly origin?: DappOrigin | QrOrigin;
1878
+ readonly account: AccountRef;
1879
+ readonly network: string;
1880
+ readonly request: SignRequest;
1881
+ };
1882
+ /**
1883
+ * Funds the wallet's own Spark account from a bitcoin account of the same wallet; the transaction
1884
+ * is an ordinary bitcoin send to a fresh Spark deposit address and is claimed once confirmed.
1885
+ */
1886
+ type SparkDepositInput = {
1887
+ readonly method: "spark-deposit";
1888
+ readonly account: SparkAccountRef;
1889
+ readonly from: AccountRef;
1890
+ readonly amountSats: number;
1891
+ readonly fee: PrepareParams["fee"];
1892
+ };
1893
+ /** A cooperative exit to the group's own next unused `btc.bip84` receive address. */
1894
+ type SparkExitInput = {
1895
+ readonly method: "spark-exit";
1896
+ readonly account: SparkAccountRef;
1897
+ readonly amountSats: number;
1898
+ readonly maxFeeSats: number;
1899
+ readonly speed?: "FAST" | "MEDIUM" | "SLOW";
1900
+ };
1901
+ /**
1902
+ * A NIP-07 `signEvent` that the policy sends through the pipeline: no factor on approval (Nostr
1903
+ * events are not per-event verifiable, WD-065); the display is the kind, a short content preview
1904
+ * and the tag count — the sign log records kind and event id only.
1905
+ */
1906
+ type NostrSignInput = {
1907
+ readonly method: "nostr-sign";
1908
+ readonly origin: DappOrigin;
1909
+ /** The active identity — the signer the page's pubkey must match. */
1910
+ readonly ref: NostrKeyRef;
1911
+ readonly event: UnsignedEvent;
1912
+ };
1913
+ /**
1914
+ * A WebLN `makeInvoice` confirmation: no factor (it only asks the user to confirm generating an
1915
+ * invoice — WD-065 does not apply; the factor-free rule mirrors `nostr-sign`), `display` carries
1916
+ * the requested amount and memo.
1917
+ */
1918
+ type WeblnInvoiceInput = {
1919
+ readonly method: "webln-invoice";
1920
+ readonly origin: DappOrigin;
1921
+ readonly ref: SparkAccountRef;
1922
+ readonly amountSats: number;
1923
+ readonly memo?: string;
1924
+ };
1925
+ /**
1926
+ * A dApp's `wallet_watchAsset`: confirm adding an ERC-20 token to the tracked list. No factor;
1927
+ * `symbol` and `decimals` are read on-chain by the pipeline, never taken from the page.
1928
+ */
1929
+ type WatchAssetInput = {
1930
+ readonly method: "watch-asset";
1931
+ readonly origin: DappOrigin;
1932
+ readonly account: AccountRef;
1933
+ readonly network: string;
1934
+ readonly address: string;
1935
+ };
1936
+ /**
1937
+ * A dApp's Solana request: one `solana-sign` covers a batch of transactions (signed sequentially —
1938
+ * each prompts) or a `solana.message` raw-message signature.
1939
+ */
1940
+ type SolanaSignInput = {
1941
+ readonly method: "solana-sign";
1942
+ readonly origin: DappOrigin | QrOrigin;
1943
+ readonly account: SolanaAccount;
1944
+ readonly network: string;
1945
+ readonly request: {
1946
+ readonly kind: "transactions";
1947
+ /** Serialized transactions as the Wallet Standard passes them. */
1948
+ readonly transactions: ReadonlyArray<Uint8Array>;
1949
+ readonly send: boolean;
1950
+ } | {
1951
+ readonly kind: "message";
1952
+ readonly message: Uint8Array;
1953
+ /** Set for a Sign In With Solana request; `message` is its text. */
1954
+ readonly signIn?: SignInFields;
1955
+ };
1956
+ };
1957
+ /**
1958
+ * A dApp's Bitcoin request: a BIP-322 simple message signature, or a batch of PSBTs signed one
1959
+ * after another under one approval (`send` also finalizes and broadcasts each).
1960
+ */
1961
+ type BitcoinSignInput = {
1962
+ readonly method: "bitcoin-sign";
1963
+ readonly origin: DappOrigin;
1964
+ readonly account: BitcoinAccount;
1965
+ readonly network: string;
1966
+ readonly request: {
1967
+ readonly kind: "message";
1968
+ readonly message: string;
1969
+ };
1970
+ } | {
1971
+ readonly method: "bitcoin-sign";
1972
+ readonly origin: DappOrigin | QrOrigin;
1973
+ readonly account: BitcoinGroup;
1974
+ readonly network: string;
1975
+ readonly request: {
1976
+ readonly kind: "psbt";
1977
+ readonly psbts: ReadonlyArray<BitcoinPsbtInput>;
1978
+ readonly send: boolean;
1979
+ };
1980
+ };
1981
+ type RequestInput = ChainRequestInput | PayInput | ZapInput | EvmSignInput | TronSignInput | NostrSignInput | WeblnInvoiceInput | WatchAssetInput | SolanaSignInput | BitcoinSignInput | SparkDepositInput | SparkExitInput;
1982
+ /** `approve` of a `nostr-sign` request: the signed event. */
1983
+ type NostrSignResult = {
1984
+ readonly kind: "nostr.event";
1985
+ readonly event: Event;
1986
+ };
1987
+ /** `nostr-sign` display: the kind, a content preview and the tag count — nothing else is shown. */
1988
+ type NostrDisplay = {
1989
+ readonly kind: "nostr.event";
1990
+ readonly eventKind: number;
1991
+ readonly preview: string;
1992
+ readonly tagCount: number;
1993
+ };
1994
+ /** `approve` of a `webln-invoice` request: the created invoice's BOLT11 payment request. */
1995
+ type WeblnInvoiceResult = {
1996
+ readonly kind: "lightning.invoice";
1997
+ readonly paymentRequest: string;
1998
+ };
1999
+ /** `solana-sign` display: each transaction's decode (fee payer + transfers) or the raw message. */
2000
+ type SolanaDisplay = {
2001
+ readonly kind: "solana.sign";
2002
+ readonly send: boolean;
2003
+ readonly count: number;
2004
+ readonly transactions: ReadonlyArray<DisplayIntent$1>;
2005
+ /** A message request's content — text, or raw bytes when it is not UTF-8. */
2006
+ readonly message?: MessageContent;
2007
+ readonly signIn?: SignInFields;
2008
+ };
2009
+ /** `approve` of a `solana-sign` request: the signatures (or signed transactions) per input. */
2010
+ type SolanaSignResult = {
2011
+ readonly kind: "solana.transactions";
2012
+ readonly send: boolean;
2013
+ readonly signatures?: ReadonlyArray<string>;
2014
+ readonly signedTransactions?: ReadonlyArray<Uint8Array>;
2015
+ /** Where the batch stopped; `signatures` holds exactly the ids that went out. */
2016
+ readonly stopped?: {
2017
+ readonly index: number;
2018
+ readonly reason: "refused" | "not-sent";
2019
+ readonly error: string;
2020
+ };
2021
+ } | {
2022
+ readonly kind: "solana.message";
2023
+ readonly signature: Uint8Array;
2024
+ };
2025
+ /** `bitcoin-sign` display: the message text, or each PSBT's decode. */
2026
+ type BitcoinDisplay = {
2027
+ readonly kind: "bitcoin.sign";
2028
+ readonly message?: MessageContent;
2029
+ readonly psbts?: ReadonlyArray<DisplayIntent$1>;
2030
+ readonly send?: boolean;
2031
+ };
2032
+ /**
2033
+ * `approve` of a `bitcoin-sign` request: the BIP-322 simple signature (base64 of the witness), or
2034
+ * the signed PSBTs and, when sent, their txids.
2035
+ */
2036
+ type BitcoinSignResult = {
2037
+ readonly kind: "bitcoin.message";
2038
+ readonly signature: string;
2039
+ } | {
2040
+ readonly kind: "bitcoin.psbts";
2041
+ readonly signedPsbts: ReadonlyArray<Uint8Array>;
2042
+ readonly txids: ReadonlyArray<string>;
2043
+ /** Where the batch stopped; `txids` holds exactly the ids that went out. */
2044
+ readonly stopped?: {
2045
+ readonly index: number;
2046
+ readonly reason: "refused" | "not-sent";
2047
+ readonly error: string;
2048
+ };
2049
+ };
2050
+ /** `approve` of a `watch-asset` request: the token was added. */
2051
+ type TokenWatchResult = {
2052
+ readonly kind: "token.watch";
2053
+ };
2054
+ /** `watch-asset` display: the token as read on-chain; `verified` means it is in the built-in table. */
2055
+ type TokenWatchDisplay = {
2056
+ readonly kind: "token.watch";
2057
+ readonly network: string;
2058
+ readonly address: string;
2059
+ readonly symbol: string;
2060
+ readonly decimals: number;
2061
+ readonly verified: boolean;
2062
+ };
2063
+ /** `webln-invoice` display: the requested amount and memo. */
2064
+ type LightningInvoiceDisplay = {
2065
+ readonly kind: "lightning.invoice";
2066
+ readonly amountSats: number;
2067
+ readonly memo?: string;
2068
+ };
2069
+ /** `approve` refused a blind request for a vault whose owner has not allowed blind signing. */
2070
+ declare class BlindSigningDisabledError extends Error {
2071
+ constructor();
2072
+ }
2073
+ /**
2074
+ * The approval-time re-simulation differs from the prepared outcome; the request went back to
2075
+ * `awaiting-approval` with the fresh result and stays approvable.
2076
+ */
2077
+ declare class SimulationChangedError extends Error {
2078
+ constructor();
2079
+ }
2080
+ /**
2081
+ * What the user must have confirmed for a request to be approved: its `danger` findings and every
2082
+ * recorded check. The host passes back the codes it showed, so a finding that appeared after the
2083
+ * approval screen was drawn is never confirmed unseen.
2084
+ */
2085
+ type RequestAcknowledgement = {
2086
+ readonly risk: ReadonlyArray<RiskFinding["code"]>;
2087
+ readonly checks: ReadonlyArray<RequestCheckCode>;
2088
+ };
2089
+ type ApproveOptions = {
2090
+ /** The factor for requests that sign with a secret; requests that do not take none. */
2091
+ readonly verify?: SendParams["verify"];
2092
+ /** Required, and exact, whenever {@link requiredAcknowledgement} is not empty. */
2093
+ readonly acknowledged?: RequestAcknowledgement;
2094
+ };
2095
+ /** The acknowledgement `approve` requires for the request as it stands now. */
2096
+ declare const requiredAcknowledgement: (request: Pick<PendingRequest, "risk" | "checks">) => RequestAcknowledgement;
2097
+ /**
2098
+ * `approve` was called without confirming exactly the request's current danger findings and checks.
2099
+ * The request stays `awaiting-approval`; `required` is what to show and pass back.
2100
+ */
2101
+ declare class AcknowledgementRequiredError extends Error {
2102
+ readonly required: RequestAcknowledgement;
2103
+ constructor(required: RequestAcknowledgement);
2104
+ }
2105
+ type PendingRequest = {
2106
+ readonly id: string;
2107
+ readonly origin: RequestOrigin;
2108
+ readonly method: RequestMethod;
2109
+ readonly account: AccountRef | SparkAccountRef | NostrKeyRef | SolanaAccount | BitcoinAccount | BitcoinGroup;
2110
+ readonly network: string;
2111
+ readonly stage: RequestStage;
2112
+ /** Decoded locally from the exact content that will be signed; `family` tells the shapes apart. */
2113
+ readonly display: DisplayIntent$1 | SparkDisplay | NostrDisplay | LightningInvoiceDisplay | TokenWatchDisplay | SolanaDisplay | BitcoinDisplay;
2114
+ /** `unverifiable` as soon as any check is recorded; `approve` requires each to be acknowledged. */
2115
+ readonly verification: "verified" | "unverifiable";
2116
+ readonly checks: ReadonlyArray<RequestCheckCode>;
2117
+ /**
2118
+ * Recipient risk; independent of `verification`. `approve` requires each `danger` to be
2119
+ * acknowledged.
2120
+ */
2121
+ readonly risk: ReadonlyArray<RiskFinding>;
2122
+ /** Present for simulated requests: sends and dApp transactions; absent otherwise. */
2123
+ readonly simulation?: SimulationOutcome;
2124
+ /** The TRON fee quote a tron send built — bandwidth, activation and energy detail. */
2125
+ readonly tronFee?: TronFeeQuote;
2126
+ /** When `simulation` was produced (ms); one older than {@link RESIMULATE_AFTER_MS} re-runs. */
2127
+ readonly simulatedAt?: number;
2128
+ readonly createdAt: number;
2129
+ readonly expiresAt: number;
2130
+ /** The transaction being replaced or accelerated; absent for a plain send. */
2131
+ readonly target?: string;
2132
+ /** The tracked transaction once submitted. */
2133
+ readonly txId?: string;
2134
+ readonly error?: string;
2135
+ };
2136
+ type RequestControllerState = {
2137
+ readonly requests: Record<string, PendingRequest>;
2138
+ };
2139
+ type RequestControllerOptions = {
2140
+ readonly transactions: TransactionController;
2141
+ /** The full controller: its payment methods are reachable only through this pipeline. */
2142
+ readonly spark: SparkController;
2143
+ readonly addressBook: AddressBookController;
2144
+ /** The session EngineStore — the engine opens it once per unlock and closes it on lock. */
2145
+ readonly openStore: () => Promise<EngineStore>;
2146
+ readonly fetch: typeof globalThis.fetch;
2147
+ readonly random: (n: number) => Uint8Array;
2148
+ readonly now: () => number;
2149
+ readonly setTimer: (ms: number, fn: () => unknown) => () => void;
2150
+ readonly logger: EngineLogger;
2151
+ /** Signs a Nostr event for `nostr-sign` — `nostr(wallet).signer(ref).signEvent`. */
2152
+ readonly nostrSign: (ref: NostrKeyRef, event: UnsignedEvent) => Promise<Event>;
2153
+ readonly phishing: Pick<PhishingController, "check">;
2154
+ /** Reads a token's metadata and adds it to the tracked list, for `watch-asset`. */
2155
+ readonly tokens: {
2156
+ readonly metadata: (network: string, address: string) => Promise<{
2157
+ readonly symbol: string;
2158
+ readonly decimals: number;
2159
+ }>;
2160
+ readonly add: (network: string, address: string) => Promise<void>;
2161
+ };
2162
+ /**
2163
+ * The vault's blind-signing setting (`WalletSnapshot.blindSigning`); `approve` refuses a blind
2164
+ * request while it is off, and the kernel enforces it again.
2165
+ */
2166
+ readonly blindSigning: () => boolean;
2167
+ /** Simulates one `solana-sign` transaction for display; failures are the caller's `unavailable`. */
2168
+ readonly simulateSolana: (account: SolanaAccount, network: string, message: Uint8Array) => Promise<SimulationOutcome>;
2169
+ /** Signs/broadcasts a `solana-sign` request — `chains.sign` per tx, then the Solana adapter. */
2170
+ readonly solanaSign: (account: {
2171
+ readonly walletId: string;
2172
+ readonly groupIndex: number;
2173
+ readonly address: string;
2174
+ }, network: string, request: SolanaSignInput["request"], verify: SendParams["verify"], commit: () => void) => Promise<SolanaSignResult>;
2175
+ /** Signs a `bitcoin-sign` message — `chains.sign` with the account's template. */
2176
+ readonly bitcoinSign: (account: BitcoinAccount, network: string, request: {
2177
+ readonly kind: "message";
2178
+ readonly message: string;
2179
+ }, verify: SendParams["verify"]) => Promise<BitcoinSignResult>;
2180
+ /** Adds the group's derivation data to a dApp's PSBTs; refuses inputs that are not its own. */
2181
+ readonly bitcoinPrepare: (account: BitcoinGroup, network: string, psbts: ReadonlyArray<BitcoinPsbtInput>) => Promise<ReadonlyArray<PreparedBitcoinPsbt>>;
2182
+ /** Signs (and with `send` broadcasts) the prepared PSBTs. */
2183
+ readonly bitcoinSignPsbts: (account: BitcoinGroup, network: string, prepared: ReadonlyArray<PreparedBitcoinPsbt>, send: boolean, verify: SendParams["verify"], commit: () => void) => Promise<BitcoinSignResult>;
2184
+ };
2185
+ /** Requests expire this long after creation. */
2186
+ declare const REQUEST_TTL_MS: number;
2187
+ /** A simulation older than this is re-run at approval before any signing. */
2188
+ declare const RESIMULATE_AFTER_MS = 60000;
2189
+ /** What an approved request resolves with, whichever kind it is. */
2190
+ type RequestResult = TrackedTransaction | SparkResult | SignatureResult | SignedTransactionResult | NostrSignResult | WeblnInvoiceResult | TokenWatchResult | SolanaSignResult | BitcoinSignResult;
2191
+ declare class RequestController extends Controller<RequestControllerState> {
2192
+ private readonly options;
2193
+ private readonly entries;
2194
+ private readonly log;
2195
+ private readonly settlers;
2196
+ /** Original transaction id → the unfinished request replacing or accelerating it. */
2197
+ private readonly targets;
2198
+ /** Requests still being built, request id → the prepare in flight. */
2199
+ private readonly preparing;
2200
+ private locked;
2201
+ constructor(options: RequestControllerOptions);
2202
+ init(): Promise<void>;
2203
+ destroy(): Promise<void>;
2204
+ /** Locking is not consent: every unfinished request becomes `invalidated` and frees its resources. */
2205
+ lock(): void;
2206
+ /**
2207
+ * Locking, unlocking and switching account group void every unfinished request (requests.mdx
2208
+ * invariant 1).
2209
+ */
2210
+ invalidateAll(): void;
2211
+ /** A page navigated away, was revoked or changed network: its unfinished requests are void. */
2212
+ invalidateOrigin(origin: string): void;
2213
+ /** The signature record, newest first. */
2214
+ signLog(): Promise<ReadonlyArray<SignLogEntry>>;
2215
+ clearSignLog(): Promise<void>;
2216
+ prepare(input: RequestInput, app?: AppOrigin): Promise<PendingRequest>;
2217
+ /**
2218
+ * Resolves with what `approve` returned, or rejects with `RequestEndedError` when the request
2219
+ * ends any other way — how a dApp's pending call learns the outcome.
2220
+ */
2221
+ outcome(id: string): Promise<RequestResult>;
2222
+ private openSettler;
2223
+ private settle;
2224
+ /** The bitcoin network `account`'s Spark network settles on; any other pairing is refused. */
2225
+ private l1Network;
2226
+ private sparkBuilt;
2227
+ private simulateOne;
2228
+ private build;
2229
+ /**
2230
+ * Signs and submits a request. Anything but a live, unexpired request of this method throws
2231
+ * before any signing; a stale build (nonce taken, blockhash expired) fails without signing. So
2232
+ * does a request with `danger` findings or checks unless `options.acknowledged` names exactly
2233
+ * those — including the ones a re-simulation at approval adds ({@link requiredAcknowledgement}).
2234
+ */
2235
+ approve(id: string, method: ChainRequestMethod | "spark-deposit", options?: ApproveOptions): Promise<TrackedTransaction>;
2236
+ approve(id: string, method: "pay" | "zap" | "spark-exit", options?: ApproveOptions): Promise<SparkResult>;
2237
+ approve(id: string, method: "evm-sign" | "tron-sign", options?: ApproveOptions): Promise<TrackedTransaction | SignatureResult | SignedTransactionResult>;
2238
+ approve(id: string, method: "nostr-sign", options?: ApproveOptions): Promise<NostrSignResult>;
2239
+ approve(id: string, method: "webln-invoice", options?: ApproveOptions): Promise<WeblnInvoiceResult>;
2240
+ approve(id: string, method: "watch-asset", options?: ApproveOptions): Promise<TokenWatchResult>;
2241
+ approve(id: string, method: "solana-sign", options?: ApproveOptions): Promise<SolanaSignResult>;
2242
+ approve(id: string, method: "bitcoin-sign", options?: ApproveOptions): Promise<BitcoinSignResult>;
2243
+ /**
2244
+ * A cancelled or refused verification is `reject`; anything after it is `fail`. Chain requests
2245
+ * record which step failed on the tracked transaction; for Spark, the approval round is the only
2246
+ * source of `WalletError`.
2247
+ */
2248
+ private failureEvent;
2249
+ reject(id: string): void;
2250
+ /** `approve` for a factor-required run: a missing factor is invalid input. */
2251
+ private requireVerify;
2252
+ private requireRequest;
2253
+ private put;
2254
+ private unclaim;
2255
+ /**
2256
+ * Applies a terminal event: the request ends in the stage `event` maps to and frees what it
2257
+ * reserved. A no-op when the event cannot happen in the current stage, so a terminal stage, its
2258
+ * sign-log record and its settlement each happen exactly once.
2259
+ */
2260
+ private end;
2261
+ /** Applies `event` to `id`'s stage; returns the new stage, `undefined` when it cannot happen. */
2262
+ private transition;
2263
+ /** `approve` resumes after each await here: the request must still be `signing`. */
2264
+ private assertSigning;
2265
+ /**
2266
+ * `signing` → `signed` — the point of no return: the signature exists and is being returned or
2267
+ * broadcast, so invalidation no longer applies. Idempotent while `signed`; throws otherwise.
2268
+ */
2269
+ private commit;
2270
+ /** Appends the final stage to the signature record; a failed write is a warning, not an error. */
2271
+ private record;
2272
+ private appendLog;
2273
+ /**
2274
+ * Addresses the wallet already knows for a family: contacts, plus recipients of tracked chain
2275
+ * sends (Spark payments are not tracked).
2276
+ */
2277
+ private knownAddresses;
2278
+ /**
2279
+ * A decoder-marked blind request carries one danger; `approve` refuses it while the setting is
2280
+ * off.
2281
+ */
2282
+ private blindRisk;
2283
+ /** Risk of a Sign-In with X message; a message for another domain throws `SignInOriginError`. */
2284
+ private signInRisk;
2285
+ /** Every recipient the decoded intent names, minus the signer — the one rule for all requests. */
2286
+ private recipientRisk;
2287
+ private chainRisk;
2288
+ /**
2289
+ * Sats/token transfers name a Spark receiver and exits a bitcoin one — both assessed. Lightning
2290
+ * names a payee public key, which no address book holds, so it is not assessed.
2291
+ */
2292
+ private sparkRisk;
2293
+ }
2294
+ export { TxBlock as $, SparkControllerState as $t, WatchAssetInput as A, Controller as An, PhishingController as At, AccountRef as B, createEventBus as Bn, WithdrawLnurlParams as Bt, SolanaSignInput as C, PublicStore as Cn, SignInOriginError as Ct, TokenWatchDisplay as D, NftTransferError as Dn, dappUrl as Dt, SparkExitInput as E, NftRefusal as En, WalletConnectVerify as Et, RequestStage as F, Esplora as Fn, PrepareZapParams as Ft, DisplayIntent$1 as G, parsePayment as Gt, ChainApis as H, PaymentOption as Ht, SignLogEntry as I, SetTimer as In, PreparedZap as It, SendParams as J, SparkResult as Jt, EvmRevokeTarget as K, PreparedSparkAction as Kt, SignLogOutcome as L, timeoutSignal as Ln, ZapRecipient as Lt, WeblnInvoiceResult as M, TronApi as Mn, PhishingState as Mt, ZapInput as N, TronFeeQuote as Nn, PhishingStatus as Nt, TokenWatchResult as O, GatewayConfig as On, walletConnectKey as Ot, requiredAcknowledgement as P, TronThrottledError as Pn, PrepareZapContext as Pt, TrackedTransaction as Q, SparkControllerOptions as Qt, TransactionController as R, EngineLogger as Rn, prepareZap as Rt, SolanaDisplay as S, EngineStore as Sn, RequestOrigin as St, SparkDepositInput as T, EngineStoreError as Tn, WalletConnectOrigin as Tt, ChainRequestInput as U, PaymentParse as Ut, BatchRecord as V, ParseOptions as Vt, DelegationStatus as W, PaymentRequest as Wt, SignedTransactionResult as X, SparkClientFactory as Xt, SignatureResult as Y, SparkAccountState as Yt, SparkDepositTag as Z, SparkController as Zt, RequestController as _, AddressFamily as _n, NonceConflictError as _t, BitcoinSignResult as a, PaymentNote as an, AcrossBridgeQuote as at, RequestResult as b, SolanaRpc as bn, RequestEndedError as bt, LightningInvoiceDisplay as c, SolanaFeeTier as cn, AppOrigin as ct, NostrSignResult as d, SimulationOutcome as dn, BitcoinPsbtInput as dt, SparkTokenBalance as en, TxState as et, PayInput as f, SignInFields as fn, BitcoinSigHash as ft, RequestAcknowledgement as g, AddressBookRecord as gn, InvalidTokenError as gt, RESIMULATE_AFTER_MS as h, AddressBookEntry as hn, DappOrigin as ht, BitcoinSignInput as i, SparkPaymentState as in, ZeroExSwapQuote as it, WeblnInvoiceInput as j, ControllerOptions as jn, PhishingControllerOptions as jt, TronSignInput as k, GatewayScope as kn, PHISHING_REFRESH_MS as kt, NostrDisplay as l, EvmFeeTier as ln, BitcoinAccount as lt, REQUEST_TTL_MS as m, AddressBookState as mn, ChainRequestMethod as mt, ApproveOptions as n, SparkPaymentKind as nn, JupiterSwapQuote as nt, BlindSigningDisabledError as o, SparkActivity as on, AcrossBridgeStatus as ot, PendingRequest as p, AddressBookController as pn, BrowserOrigin as pt, PrepareParams as q, SparkDisplay as qt, BitcoinDisplay as r, SparkPaymentRecord as rn, SwapQuote as rt, EvmSignInput as s, RequestCheckCode as sn, RiskFinding as st, AcknowledgementRequiredError as t, sparkStore as tn, JupiterInstruction as tt, NostrSignInput as u, AssetChange as un, BitcoinGroup as ut, RequestControllerState as v, NetworkController as vn, OriginBusyError as vt, SolanaSignResult as w, EngineErrorCode as wn, SolanaAccount as wt, SimulationChangedError as x, EngineCollection as xn, RequestMethod as xt, RequestInput as y, NetworkControllerState as yn, QrOrigin as yt, TransactionControllerState as z, EventBus as zn, PayParams as zt };
2295
+ //# sourceMappingURL=controller-DpNVHVsj.d.mts.map