@unicitylabs/sphere-sdk 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Token as Token$1 } from '@unicitylabs/state-transition-sdk/lib/token/Token';
2
2
  import elliptic from 'elliptic';
3
+ export { areSameNametag, hashNametag, isPhoneNumber, normalizeNametag } from '@unicitylabs/nostr-js-sdk';
3
4
 
4
5
  /**
5
6
  * Cryptographic utilities for SDK2
@@ -539,6 +540,8 @@ interface InstantSplitResult {
539
540
  error?: string;
540
541
  /** Whether background processing was started */
541
542
  backgroundStarted?: boolean;
543
+ /** Promise that resolves when background processing completes (change token saved) */
544
+ backgroundPromise?: Promise<void>;
542
545
  }
543
546
  /**
544
547
  * Result from processing an INSTANT_SPLIT bundle (recipient side)
@@ -614,6 +617,30 @@ interface SplitRecoveryResult {
614
617
  /** Total duration of recovery in ms */
615
618
  durationMs: number;
616
619
  }
620
+ /** Finalization stage for V5 bundles saved as unconfirmed */
621
+ type V5FinalizationStage = 'RECEIVED' | 'MINT_SUBMITTED' | 'MINT_PROVEN' | 'TRANSFER_SUBMITTED' | 'FINALIZED';
622
+ /** Pending finalization metadata stored in token.sdkData */
623
+ interface PendingV5Finalization {
624
+ type: 'v5_bundle';
625
+ stage: V5FinalizationStage;
626
+ bundleJson: string;
627
+ senderPubkey: string;
628
+ savedAt: number;
629
+ lastAttemptAt?: number;
630
+ attemptCount: number;
631
+ mintProofJson?: string;
632
+ }
633
+ /** Result of resolveUnconfirmed() */
634
+ interface UnconfirmedResolutionResult {
635
+ resolved: number;
636
+ stillPending: number;
637
+ failed: number;
638
+ details: Array<{
639
+ tokenId: string;
640
+ stage: string;
641
+ status: 'resolved' | 'pending' | 'failed';
642
+ }>;
643
+ }
617
644
 
618
645
  /**
619
646
  * Payment Session Types
@@ -837,6 +864,14 @@ interface Asset {
837
864
  readonly iconUrl?: string;
838
865
  readonly totalAmount: string;
839
866
  readonly tokenCount: number;
867
+ /** Sum of confirmed token amounts (smallest units) */
868
+ readonly confirmedAmount: string;
869
+ /** Sum of unconfirmed (submitted/pending) token amounts (smallest units) */
870
+ readonly unconfirmedAmount: string;
871
+ /** Number of confirmed tokens aggregated */
872
+ readonly confirmedTokenCount: number;
873
+ /** Number of unconfirmed tokens aggregated */
874
+ readonly unconfirmedTokenCount: number;
840
875
  /** Price per whole unit in USD (null if PriceProvider not configured) */
841
876
  readonly priceUsd: number | null;
842
877
  /** Price per whole unit in EUR (null if PriceProvider not configured) */
@@ -850,6 +885,7 @@ interface Asset {
850
885
  }
851
886
  type TransferStatus = 'pending' | 'submitted' | 'confirmed' | 'delivered' | 'completed' | 'failed';
852
887
  type AddressMode = 'auto' | 'direct' | 'proxy';
888
+ type TransferMode = 'instant' | 'conservative';
853
889
  interface TransferRequest {
854
890
  readonly coinId: string;
855
891
  readonly amount: string;
@@ -857,12 +893,31 @@ interface TransferRequest {
857
893
  readonly memo?: string;
858
894
  /** Address mode: 'auto' (default) uses directAddress if available, 'direct' forces DIRECT, 'proxy' forces PROXY */
859
895
  readonly addressMode?: AddressMode;
896
+ /** Transfer mode: 'instant' (default) sends via Nostr immediately, 'conservative' collects all proofs first */
897
+ readonly transferMode?: TransferMode;
898
+ }
899
+ /**
900
+ * Per-token transfer detail tracking the on-chain commitment or split operation
901
+ * for each source token involved in a transfer.
902
+ */
903
+ interface TokenTransferDetail {
904
+ /** Source token ID that was consumed in this transfer */
905
+ readonly sourceTokenId: string;
906
+ /** Transfer method used for this token */
907
+ readonly method: 'direct' | 'split';
908
+ /** Aggregator commitment request ID hex (for direct transfers) */
909
+ readonly requestIdHex?: string;
910
+ /** Split group ID (for split transfers — correlates sender/recipient/change tokens) */
911
+ readonly splitGroupId?: string;
912
+ /** Nostr event ID (for split transfers delivered via Nostr) */
913
+ readonly nostrEventId?: string;
860
914
  }
861
915
  interface TransferResult {
862
916
  readonly id: string;
863
917
  status: TransferStatus;
864
918
  readonly tokens: Token[];
865
- txHash?: string;
919
+ /** Per-token transfer details — one entry per source token consumed */
920
+ readonly tokenTransfers: TokenTransferDetail[];
866
921
  error?: string;
867
922
  }
868
923
  interface IncomingTransfer {
@@ -1039,7 +1094,7 @@ interface TrackedAddress extends TrackedAddressEntry {
1039
1094
  /** Primary nametag (from nametag cache, without @ prefix) */
1040
1095
  readonly nametag?: string;
1041
1096
  }
1042
- type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'nametag:recovered' | 'identity:changed' | 'address:activated' | 'address:hidden' | 'address:unhidden';
1097
+ type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'nametag:recovered' | 'identity:changed' | 'address:activated' | 'address:hidden' | 'address:unhidden' | 'sync:remote-update';
1043
1098
  interface SphereEventMap {
1044
1099
  'transfer:incoming': IncomingTransfer;
1045
1100
  'transfer:confirmed': TransferResult;
@@ -1098,6 +1153,14 @@ interface SphereEventMap {
1098
1153
  index: number;
1099
1154
  addressId: string;
1100
1155
  };
1156
+ 'sync:remote-update': {
1157
+ providerId: string;
1158
+ name: string;
1159
+ sequence: number;
1160
+ cid: string;
1161
+ added: number;
1162
+ removed: number;
1163
+ };
1101
1164
  }
1102
1165
  type SphereEventHandler<T extends SphereEventType> = (data: SphereEventMap[T]) => void;
1103
1166
  interface SphereConfig {
@@ -1362,6 +1425,12 @@ interface TransportProvider extends BaseProvider {
1362
1425
  * @returns Unsubscribe function
1363
1426
  */
1364
1427
  onInstantSplitReceived?(handler: InstantSplitBundleHandler): () => void;
1428
+ /**
1429
+ * Fetch pending events from transport (one-shot query).
1430
+ * Creates a temporary subscription, processes events through normal handlers,
1431
+ * and resolves after EOSE (End Of Stored Events).
1432
+ */
1433
+ fetchPendingEvents?(): Promise<void>;
1365
1434
  }
1366
1435
  /**
1367
1436
  * Payload for sending instant split bundles
@@ -1426,7 +1495,7 @@ interface IncomingTokenTransfer {
1426
1495
  payload: TokenTransferPayload;
1427
1496
  timestamp: number;
1428
1497
  }
1429
- type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void;
1498
+ type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void | Promise<void>;
1430
1499
  interface PaymentRequestPayload {
1431
1500
  /** Amount requested (in smallest units) */
1432
1501
  amount: string | bigint;
@@ -1801,7 +1870,7 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
1801
1870
  */
1802
1871
  deleteToken?(tokenId: string): Promise<void>;
1803
1872
  }
1804
- type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
1873
+ type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'storage:remote-updated' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
1805
1874
  interface StorageEvent {
1806
1875
  type: StorageEventType;
1807
1876
  timestamp: number;
@@ -2142,7 +2211,30 @@ interface TransactionHistoryEntry {
2142
2211
  timestamp: number;
2143
2212
  recipientNametag?: string;
2144
2213
  senderPubkey?: string;
2145
- txHash?: string;
2214
+ /** TransferResult.id that created this entry (links history to transfer operation) */
2215
+ transferId?: string;
2216
+ }
2217
+ interface ReceiveOptions {
2218
+ /** Wait for all unconfirmed tokens to be finalized (default: false).
2219
+ * When false, calls resolveUnconfirmed() once to submit pending commitments.
2220
+ * When true, polls resolveUnconfirmed() + load() until all confirmed or timeout. */
2221
+ finalize?: boolean;
2222
+ /** Finalization timeout in ms (default: 60000). Only used when finalize=true. */
2223
+ timeout?: number;
2224
+ /** Poll interval in ms (default: 2000). Only used when finalize=true. */
2225
+ pollInterval?: number;
2226
+ /** Progress callback after each resolveUnconfirmed() poll. Only used when finalize=true. */
2227
+ onProgress?: (result: UnconfirmedResolutionResult) => void;
2228
+ }
2229
+ interface ReceiveResult {
2230
+ /** Newly received incoming transfers. */
2231
+ transfers: IncomingTransfer[];
2232
+ /** Finalization result (from resolveUnconfirmed). */
2233
+ finalization?: UnconfirmedResolutionResult;
2234
+ /** Whether finalization timed out (only when finalize=true). */
2235
+ timedOut?: boolean;
2236
+ /** Duration of finalization in ms (only when finalize=true). */
2237
+ finalizationDurationMs?: number;
2146
2238
  }
2147
2239
  interface PaymentsModuleConfig {
2148
2240
  /** Auto-sync after operations */
@@ -2182,6 +2274,7 @@ declare class PaymentsModule {
2182
2274
  readonly l1: L1PaymentsModule | null;
2183
2275
  private tokens;
2184
2276
  private pendingTransfers;
2277
+ private pendingBackgroundTasks;
2185
2278
  private tombstones;
2186
2279
  private archivedTokens;
2187
2280
  private forkedTokens;
@@ -2199,8 +2292,17 @@ declare class PaymentsModule {
2199
2292
  private proofPollingInterval;
2200
2293
  private static readonly PROOF_POLLING_INTERVAL_MS;
2201
2294
  private static readonly PROOF_POLLING_MAX_ATTEMPTS;
2295
+ private storageEventUnsubscribers;
2296
+ private syncDebounceTimer;
2297
+ private static readonly SYNC_DEBOUNCE_MS;
2298
+ /** Sync coalescing: concurrent sync() calls share the same operation */
2299
+ private _syncInProgress;
2202
2300
  constructor(config?: PaymentsModuleConfig);
2203
- /** Get module configuration */
2301
+ /**
2302
+ * Get the current module configuration (excluding L1 config).
2303
+ *
2304
+ * @returns Resolved configuration with all defaults applied.
2305
+ */
2204
2306
  getConfig(): Omit<Required<PaymentsModuleConfig>, 'l1'>;
2205
2307
  /** Price provider (optional) */
2206
2308
  private priceProvider;
@@ -2210,11 +2312,18 @@ declare class PaymentsModule {
2210
2312
  */
2211
2313
  initialize(deps: PaymentsModuleDependencies): void;
2212
2314
  /**
2213
- * Load tokens from storage
2315
+ * Load all token data from storage providers and restore wallet state.
2316
+ *
2317
+ * Loads tokens, nametag data, transaction history, and pending transfers
2318
+ * from configured storage providers. Restores pending V5 tokens and
2319
+ * triggers a fire-and-forget {@link resolveUnconfirmed} call.
2214
2320
  */
2215
2321
  load(): Promise<void>;
2216
2322
  /**
2217
- * Cleanup resources
2323
+ * Cleanup all subscriptions, polling jobs, and pending resolvers.
2324
+ *
2325
+ * Should be called when the wallet is being shut down or the module is
2326
+ * no longer needed. Also destroys the L1 sub-module if present.
2218
2327
  */
2219
2328
  destroy(): void;
2220
2329
  /**
@@ -2266,11 +2375,19 @@ declare class PaymentsModule {
2266
2375
  * @param senderPubkey - Sender's public key for verification
2267
2376
  * @returns Processing result with finalized token
2268
2377
  */
2269
- processInstantSplitBundle(bundle: InstantSplitBundle, senderPubkey: string): Promise<InstantSplitProcessResult>;
2378
+ private processInstantSplitBundle;
2379
+ /**
2380
+ * Synchronous V4 bundle processing (dev mode only).
2381
+ * Kept for backward compatibility with V4 bundles.
2382
+ */
2383
+ private processInstantSplitBundleSync;
2270
2384
  /**
2271
- * Check if a payload is an instant split bundle
2385
+ * Type-guard: check whether a payload is a valid {@link InstantSplitBundle} (V4 or V5).
2386
+ *
2387
+ * @param payload - The object to test.
2388
+ * @returns `true` if the payload matches the InstantSplitBundle shape.
2272
2389
  */
2273
- isInstantSplitBundle(payload: unknown): payload is InstantSplitBundle;
2390
+ private isInstantSplitBundle;
2274
2391
  /**
2275
2392
  * Send a payment request to someone
2276
2393
  * @param recipientPubkeyOrNametag - Recipient's pubkey or @nametag
@@ -2292,27 +2409,45 @@ declare class PaymentsModule {
2292
2409
  status?: PaymentRequestStatus;
2293
2410
  }): IncomingPaymentRequest$1[];
2294
2411
  /**
2295
- * Get pending payment requests count
2412
+ * Get the count of payment requests with status `'pending'`.
2413
+ *
2414
+ * @returns Number of pending incoming payment requests.
2296
2415
  */
2297
2416
  getPendingPaymentRequestsCount(): number;
2298
2417
  /**
2299
- * Accept a payment request (marks it as accepted, user should then call send())
2418
+ * Accept a payment request and notify the requester.
2419
+ *
2420
+ * Marks the request as `'accepted'` and sends a response via transport.
2421
+ * The caller should subsequently call {@link send} to fulfill the payment.
2422
+ *
2423
+ * @param requestId - ID of the incoming payment request to accept.
2300
2424
  */
2301
2425
  acceptPaymentRequest(requestId: string): Promise<void>;
2302
2426
  /**
2303
- * Reject a payment request
2427
+ * Reject a payment request and notify the requester.
2428
+ *
2429
+ * @param requestId - ID of the incoming payment request to reject.
2304
2430
  */
2305
2431
  rejectPaymentRequest(requestId: string): Promise<void>;
2306
2432
  /**
2307
- * Mark a payment request as paid (after successful transfer)
2433
+ * Mark a payment request as paid (local status update only).
2434
+ *
2435
+ * Typically called after a successful {@link send} to record that the
2436
+ * request has been fulfilled.
2437
+ *
2438
+ * @param requestId - ID of the incoming payment request to mark as paid.
2308
2439
  */
2309
2440
  markPaymentRequestPaid(requestId: string): void;
2310
2441
  /**
2311
- * Clear processed (non-pending) payment requests
2442
+ * Remove all non-pending incoming payment requests from memory.
2443
+ *
2444
+ * Keeps only requests with status `'pending'`.
2312
2445
  */
2313
2446
  clearProcessedPaymentRequests(): void;
2314
2447
  /**
2315
- * Remove a specific payment request
2448
+ * Remove a specific incoming payment request by ID.
2449
+ *
2450
+ * @param requestId - ID of the payment request to remove.
2316
2451
  */
2317
2452
  removePaymentRequest(requestId: string): void;
2318
2453
  /**
@@ -2343,15 +2478,21 @@ declare class PaymentsModule {
2343
2478
  */
2344
2479
  waitForPaymentResponse(requestId: string, timeoutMs?: number): Promise<PaymentRequestResponse>;
2345
2480
  /**
2346
- * Cancel waiting for a payment response
2481
+ * Cancel an active {@link waitForPaymentResponse} call.
2482
+ *
2483
+ * The pending promise is rejected with a `'Cancelled'` error.
2484
+ *
2485
+ * @param requestId - The outgoing request ID whose wait should be cancelled.
2347
2486
  */
2348
2487
  cancelWaitForPaymentResponse(requestId: string): void;
2349
2488
  /**
2350
- * Remove an outgoing payment request
2489
+ * Remove an outgoing payment request and cancel any pending wait.
2490
+ *
2491
+ * @param requestId - ID of the outgoing request to remove.
2351
2492
  */
2352
2493
  removeOutgoingPaymentRequest(requestId: string): void;
2353
2494
  /**
2354
- * Clear completed/expired outgoing payment requests
2495
+ * Remove all outgoing payment requests that are `'paid'`, `'rejected'`, or `'expired'`.
2355
2496
  */
2356
2497
  clearCompletedOutgoingPaymentRequests(): void;
2357
2498
  private handlePaymentRequestResponse;
@@ -2359,36 +2500,141 @@ declare class PaymentsModule {
2359
2500
  * Send a response to a payment request (used internally by accept/reject/pay methods)
2360
2501
  */
2361
2502
  private sendPaymentRequestResponse;
2503
+ /**
2504
+ * Fetch and process pending incoming transfers from the transport layer.
2505
+ *
2506
+ * Performs a one-shot query to fetch all pending events, processes them
2507
+ * through the existing pipeline, and resolves after all stored events
2508
+ * are handled. Useful for batch/CLI apps that need explicit receive.
2509
+ *
2510
+ * When `finalize` is true, polls resolveUnconfirmed() + load() until all
2511
+ * tokens are confirmed or the timeout expires. Otherwise calls
2512
+ * resolveUnconfirmed() once to submit pending commitments.
2513
+ *
2514
+ * @param options - Optional receive options including finalization control
2515
+ * @param callback - Optional callback invoked for each newly received transfer
2516
+ * @returns ReceiveResult with transfers and finalization metadata
2517
+ */
2518
+ receive(options?: ReceiveOptions, callback?: (transfer: IncomingTransfer) => void): Promise<ReceiveResult>;
2362
2519
  /**
2363
2520
  * Set or update price provider
2364
2521
  */
2365
2522
  setPriceProvider(provider: PriceProvider): void;
2366
2523
  /**
2367
- * Get total portfolio value in USD
2368
- * Returns null if PriceProvider is not configured
2524
+ * Wait for all pending background operations (e.g., instant split change token creation).
2525
+ * Call this before process exit to ensure all tokens are saved.
2526
+ */
2527
+ waitForPendingOperations(): Promise<void>;
2528
+ /**
2529
+ * Get total portfolio value in USD.
2530
+ * Returns null if PriceProvider is not configured.
2369
2531
  */
2370
- getBalance(): Promise<number | null>;
2532
+ getFiatBalance(): Promise<number | null>;
2371
2533
  /**
2372
- * Get aggregated assets (tokens grouped by coinId) with price data
2373
- * Only includes confirmed tokens
2534
+ * Get token balances grouped by coin type.
2535
+ *
2536
+ * Returns an array of {@link Asset} objects, one per coin type held.
2537
+ * Each entry includes confirmed and unconfirmed breakdowns. Tokens with
2538
+ * status `'spent'`, `'invalid'`, or `'transferring'` are excluded.
2539
+ *
2540
+ * This is synchronous — no price data is included. Use {@link getAssets}
2541
+ * for the async version with fiat pricing.
2542
+ *
2543
+ * @param coinId - Optional coin ID to filter by (e.g. hex string). When omitted, all coin types are returned.
2544
+ * @returns Array of balance summaries (synchronous — no await needed).
2545
+ */
2546
+ getBalance(coinId?: string): Asset[];
2547
+ /**
2548
+ * Get aggregated assets (tokens grouped by coinId) with price data.
2549
+ * Includes both confirmed and unconfirmed tokens with breakdown.
2374
2550
  */
2375
2551
  getAssets(coinId?: string): Promise<Asset[]>;
2376
2552
  /**
2377
- * Get all tokens
2553
+ * Aggregate tokens by coinId with confirmed/unconfirmed breakdown.
2554
+ * Excludes tokens with status 'spent', 'invalid', or 'transferring'.
2555
+ */
2556
+ private aggregateTokens;
2557
+ /**
2558
+ * Get all tokens, optionally filtered by coin type and/or status.
2559
+ *
2560
+ * @param filter - Optional filter criteria.
2561
+ * @param filter.coinId - Return only tokens of this coin type.
2562
+ * @param filter.status - Return only tokens with this status (e.g. `'submitted'` for unconfirmed).
2563
+ * @returns Array of matching {@link Token} objects (synchronous).
2378
2564
  */
2379
2565
  getTokens(filter?: {
2380
2566
  coinId?: string;
2381
2567
  status?: TokenStatus;
2382
2568
  }): Token[];
2383
2569
  /**
2384
- * Get single token
2570
+ * Get a single token by its local ID.
2571
+ *
2572
+ * @param id - The local UUID assigned when the token was added.
2573
+ * @returns The token, or `undefined` if not found.
2385
2574
  */
2386
2575
  getToken(id: string): Token | undefined;
2387
2576
  /**
2388
- * Add a token
2389
- * Tokens are uniquely identified by (tokenId, stateHash) composite key.
2390
- * Multiple historic states of the same token can coexist.
2391
- * @returns false if exact duplicate (same tokenId AND same stateHash)
2577
+ * Attempt to resolve unconfirmed (status `'submitted'`) tokens by acquiring
2578
+ * their missing aggregator proofs.
2579
+ *
2580
+ * Each unconfirmed V5 token progresses through stages:
2581
+ * `RECEIVED` → `MINT_SUBMITTED` → `MINT_PROVEN` → `TRANSFER_SUBMITTED` → `FINALIZED`
2582
+ *
2583
+ * Uses 500 ms quick-timeouts per proof check so the call returns quickly even
2584
+ * when proofs are not yet available. Tokens that exceed 50 failed attempts are
2585
+ * marked `'invalid'`.
2586
+ *
2587
+ * Automatically called (fire-and-forget) by {@link load}.
2588
+ *
2589
+ * @returns Summary with counts of resolved, still-pending, and failed tokens plus per-token details.
2590
+ */
2591
+ resolveUnconfirmed(): Promise<UnconfirmedResolutionResult>;
2592
+ /**
2593
+ * Process a single V5 token through its finalization stages with quick-timeout proof checks.
2594
+ */
2595
+ private resolveV5Token;
2596
+ /**
2597
+ * Non-blocking proof check with 500ms timeout.
2598
+ */
2599
+ private quickProofCheck;
2600
+ /**
2601
+ * Perform V5 bundle finalization from stored bundle data and proofs.
2602
+ * Extracted from InstantSplitProcessor.processV5Bundle() steps 4-10.
2603
+ */
2604
+ private finalizeFromV5Bundle;
2605
+ /**
2606
+ * Parse pending finalization metadata from token's sdkData.
2607
+ */
2608
+ private parsePendingFinalization;
2609
+ /**
2610
+ * Update pending finalization metadata in token's sdkData.
2611
+ * Creates a new token object since sdkData is readonly.
2612
+ */
2613
+ private updatePendingFinalization;
2614
+ /**
2615
+ * Save pending V5 tokens to key-value storage.
2616
+ * These tokens can't be serialized to TXF format (no genesis/state),
2617
+ * so we persist them separately and restore on load().
2618
+ */
2619
+ private savePendingV5Tokens;
2620
+ /**
2621
+ * Load pending V5 tokens from key-value storage and merge into tokens map.
2622
+ * Called during load() to restore tokens that TXF format can't represent.
2623
+ */
2624
+ private loadPendingV5Tokens;
2625
+ /**
2626
+ * Add a token to the wallet.
2627
+ *
2628
+ * Tokens are uniquely identified by a `(tokenId, stateHash)` composite key.
2629
+ * Duplicate detection:
2630
+ * - **Tombstoned** — rejected if the exact `(tokenId, stateHash)` pair has a tombstone.
2631
+ * - **Exact duplicate** — rejected if a token with the same composite key already exists.
2632
+ * - **State replacement** — if the same `tokenId` exists with a *different* `stateHash`,
2633
+ * the old state is archived and replaced with the incoming one.
2634
+ *
2635
+ * @param token - The token to add.
2636
+ * @param skipHistory - When `true`, do not create a `RECEIVED` transaction history entry (default `false`).
2637
+ * @returns `true` if the token was added, `false` if rejected as duplicate or tombstoned.
2392
2638
  */
2393
2639
  addToken(token: Token, skipHistory?: boolean): Promise<boolean>;
2394
2640
  /**
@@ -2403,11 +2649,24 @@ declare class PaymentsModule {
2403
2649
  */
2404
2650
  private loadTokensFromFileStorage;
2405
2651
  /**
2406
- * Update an existing token
2652
+ * Update an existing token or add it if not found.
2653
+ *
2654
+ * Looks up the token by genesis `tokenId` (from `sdkData`) first, then by
2655
+ * `token.id`. If no match is found, falls back to {@link addToken}.
2656
+ *
2657
+ * @param token - The token with updated data. Must include a valid `id`.
2407
2658
  */
2408
2659
  updateToken(token: Token): Promise<void>;
2409
2660
  /**
2410
- * Remove a token by ID
2661
+ * Remove a token from the wallet.
2662
+ *
2663
+ * The token is archived first, then a tombstone `(tokenId, stateHash)` is
2664
+ * created to prevent re-addition via Nostr re-delivery. A `SENT` history
2665
+ * entry is created unless `skipHistory` is `true`.
2666
+ *
2667
+ * @param tokenId - Local UUID of the token to remove.
2668
+ * @param recipientNametag - Optional nametag of the transfer recipient (for history).
2669
+ * @param skipHistory - When `true`, skip creating a transaction history entry (default `false`).
2411
2670
  */
2412
2671
  removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
2413
2672
  /**
@@ -2416,78 +2675,145 @@ declare class PaymentsModule {
2416
2675
  */
2417
2676
  private deleteTokenFiles;
2418
2677
  /**
2419
- * Get all tombstones
2678
+ * Get all tombstone entries.
2679
+ *
2680
+ * Each tombstone is keyed by `(tokenId, stateHash)` and prevents a spent
2681
+ * token state from being re-added (e.g. via Nostr re-delivery).
2682
+ *
2683
+ * @returns A shallow copy of the tombstone array.
2420
2684
  */
2421
2685
  getTombstones(): TombstoneEntry[];
2422
2686
  /**
2423
- * Check if token state is tombstoned
2687
+ * Check whether a specific `(tokenId, stateHash)` combination is tombstoned.
2688
+ *
2689
+ * @param tokenId - The genesis token ID.
2690
+ * @param stateHash - The state hash of the token version to check.
2691
+ * @returns `true` if the exact combination has been tombstoned.
2424
2692
  */
2425
2693
  isStateTombstoned(tokenId: string, stateHash: string): boolean;
2426
2694
  /**
2427
- * Merge remote tombstones
2428
- * @returns number of local tokens removed
2695
+ * Merge tombstones received from a remote sync source.
2696
+ *
2697
+ * Any local token whose `(tokenId, stateHash)` matches a remote tombstone is
2698
+ * removed. The remote tombstones are then added to the local set (union merge).
2699
+ *
2700
+ * @param remoteTombstones - Tombstone entries from the remote source.
2701
+ * @returns Number of local tokens that were removed.
2429
2702
  */
2430
2703
  mergeTombstones(remoteTombstones: TombstoneEntry[]): Promise<number>;
2431
2704
  /**
2432
- * Prune old tombstones
2705
+ * Remove tombstones older than `maxAge` and cap the list at 100 entries.
2706
+ *
2707
+ * @param maxAge - Maximum age in milliseconds (default: 30 days).
2433
2708
  */
2434
2709
  pruneTombstones(maxAge?: number): Promise<void>;
2435
2710
  /**
2436
- * Get archived tokens
2711
+ * Get all archived (spent/superseded) tokens in TXF format.
2712
+ *
2713
+ * Archived tokens are kept for recovery and sync purposes. The map key is
2714
+ * the genesis token ID.
2715
+ *
2716
+ * @returns A shallow copy of the archived token map.
2437
2717
  */
2438
2718
  getArchivedTokens(): Map<string, TxfToken>;
2439
2719
  /**
2440
- * Get best archived version of a token
2720
+ * Get the best (most committed transactions) archived version of a token.
2721
+ *
2722
+ * Searches both archived and forked token maps and returns the version with
2723
+ * the highest number of committed transactions.
2724
+ *
2725
+ * @param tokenId - The genesis token ID to look up.
2726
+ * @returns The best TXF token version, or `null` if not found.
2441
2727
  */
2442
2728
  getBestArchivedVersion(tokenId: string): TxfToken | null;
2443
2729
  /**
2444
- * Merge remote archived tokens
2445
- * @returns number of tokens updated/added
2730
+ * Merge archived tokens from a remote sync source.
2731
+ *
2732
+ * For each remote token:
2733
+ * - If missing locally, it is added.
2734
+ * - If the remote version is an incremental update of the local, it replaces it.
2735
+ * - If the histories diverge (fork), the remote version is stored via {@link storeForkedToken}.
2736
+ *
2737
+ * @param remoteArchived - Map of genesis token ID → TXF token from remote.
2738
+ * @returns Number of tokens that were updated or added locally.
2446
2739
  */
2447
2740
  mergeArchivedTokens(remoteArchived: Map<string, TxfToken>): Promise<number>;
2448
2741
  /**
2449
- * Prune archived tokens
2742
+ * Prune archived tokens to keep at most `maxCount` entries.
2743
+ *
2744
+ * Oldest entries (by insertion order) are removed first.
2745
+ *
2746
+ * @param maxCount - Maximum number of archived tokens to retain (default: 100).
2450
2747
  */
2451
2748
  pruneArchivedTokens(maxCount?: number): Promise<void>;
2452
2749
  /**
2453
- * Get forked tokens
2750
+ * Get all forked token versions.
2751
+ *
2752
+ * Forked tokens represent alternative histories detected during sync.
2753
+ * The map key is `{tokenId}_{stateHash}`.
2754
+ *
2755
+ * @returns A shallow copy of the forked tokens map.
2454
2756
  */
2455
2757
  getForkedTokens(): Map<string, TxfToken>;
2456
2758
  /**
2457
- * Store a forked token
2759
+ * Store a forked token version (alternative history).
2760
+ *
2761
+ * No-op if the exact `(tokenId, stateHash)` key already exists.
2762
+ *
2763
+ * @param tokenId - Genesis token ID.
2764
+ * @param stateHash - State hash of this forked version.
2765
+ * @param txfToken - The TXF token data to store.
2458
2766
  */
2459
2767
  storeForkedToken(tokenId: string, stateHash: string, txfToken: TxfToken): Promise<void>;
2460
2768
  /**
2461
- * Merge remote forked tokens
2462
- * @returns number of tokens added
2769
+ * Merge forked tokens from a remote sync source. Only new keys are added.
2770
+ *
2771
+ * @param remoteForked - Map of `{tokenId}_{stateHash}` → TXF token from remote.
2772
+ * @returns Number of new forked tokens added.
2463
2773
  */
2464
2774
  mergeForkedTokens(remoteForked: Map<string, TxfToken>): Promise<number>;
2465
2775
  /**
2466
- * Prune forked tokens
2776
+ * Prune forked tokens to keep at most `maxCount` entries.
2777
+ *
2778
+ * @param maxCount - Maximum number of forked tokens to retain (default: 50).
2467
2779
  */
2468
2780
  pruneForkedTokens(maxCount?: number): Promise<void>;
2469
2781
  /**
2470
- * Get transaction history
2782
+ * Get the transaction history sorted newest-first.
2783
+ *
2784
+ * @returns Array of {@link TransactionHistoryEntry} objects in descending timestamp order.
2471
2785
  */
2472
2786
  getHistory(): TransactionHistoryEntry[];
2473
2787
  /**
2474
- * Add to transaction history
2788
+ * Append an entry to the transaction history.
2789
+ *
2790
+ * A unique `id` is auto-generated. The entry is immediately persisted to storage.
2791
+ *
2792
+ * @param entry - History entry fields (without `id`).
2475
2793
  */
2476
2794
  addToHistory(entry: Omit<TransactionHistoryEntry, 'id'>): Promise<void>;
2477
2795
  /**
2478
- * Set nametag for current identity
2796
+ * Set the nametag data for the current identity.
2797
+ *
2798
+ * Persists to both key-value storage and file storage (lottery compatibility).
2799
+ *
2800
+ * @param nametag - The nametag data including minted token JSON.
2479
2801
  */
2480
2802
  setNametag(nametag: NametagData): Promise<void>;
2481
2803
  /**
2482
- * Get nametag
2804
+ * Get the current nametag data.
2805
+ *
2806
+ * @returns The nametag data, or `null` if no nametag is set.
2483
2807
  */
2484
2808
  getNametag(): NametagData | null;
2485
2809
  /**
2486
- * Check if has nametag
2810
+ * Check whether a nametag is currently set.
2811
+ *
2812
+ * @returns `true` if nametag data is present.
2487
2813
  */
2488
2814
  hasNametag(): boolean;
2489
2815
  /**
2490
- * Clear nametag
2816
+ * Remove the current nametag data from memory and storage.
2491
2817
  */
2492
2818
  clearNametag(): Promise<void>;
2493
2819
  /**
@@ -2514,30 +2840,60 @@ declare class PaymentsModule {
2514
2840
  */
2515
2841
  isNametagAvailable(nametag: string): Promise<boolean>;
2516
2842
  /**
2517
- * Sync with all token storage providers (IPFS, MongoDB, etc.)
2518
- * Syncs with each provider and merges results
2843
+ * Sync local token state with all configured token storage providers (IPFS, file, etc.).
2844
+ *
2845
+ * For each provider, the local data is packaged into TXF storage format, sent
2846
+ * to the provider's `sync()` method, and the merged result is applied locally.
2847
+ * Emits `sync:started`, `sync:completed`, and `sync:error` events.
2848
+ *
2849
+ * @returns Summary with counts of tokens added and removed during sync.
2519
2850
  */
2520
2851
  sync(): Promise<{
2521
2852
  added: number;
2522
2853
  removed: number;
2523
2854
  }>;
2855
+ private _doSync;
2856
+ /**
2857
+ * Subscribe to 'storage:remote-updated' events from all token storage providers.
2858
+ * When a provider emits this event, a debounced sync is triggered.
2859
+ */
2860
+ private subscribeToStorageEvents;
2861
+ /**
2862
+ * Unsubscribe from all storage provider events and clear debounce timer.
2863
+ */
2864
+ private unsubscribeStorageEvents;
2865
+ /**
2866
+ * Debounced sync triggered by a storage:remote-updated event.
2867
+ * Waits 500ms to batch rapid updates, then performs sync.
2868
+ */
2869
+ private debouncedSyncFromRemoteUpdate;
2524
2870
  /**
2525
2871
  * Get all active token storage providers
2526
2872
  */
2527
2873
  private getTokenStorageProviders;
2528
2874
  /**
2529
- * Update token storage providers (called when providers are added/removed dynamically)
2875
+ * Replace the set of token storage providers at runtime.
2876
+ *
2877
+ * Use when providers are added or removed dynamically (e.g. IPFS node started).
2878
+ *
2879
+ * @param providers - New map of provider ID → TokenStorageProvider.
2530
2880
  */
2531
2881
  updateTokenStorageProviders(providers: Map<string, TokenStorageProvider<TxfStorageDataBase>>): void;
2532
2882
  /**
2533
- * Validate tokens with aggregator
2883
+ * Validate all tokens against the aggregator (oracle provider).
2884
+ *
2885
+ * Tokens that fail validation or are detected as spent are marked `'invalid'`.
2886
+ *
2887
+ * @returns Object with arrays of valid and invalid tokens.
2534
2888
  */
2535
2889
  validate(): Promise<{
2536
2890
  valid: Token[];
2537
2891
  invalid: Token[];
2538
2892
  }>;
2539
2893
  /**
2540
- * Get pending transfers
2894
+ * Get all in-progress (pending) outgoing transfers.
2895
+ *
2896
+ * @returns Array of {@link TransferResult} objects for transfers that have not yet completed.
2541
2897
  */
2542
2898
  getPendingTransfers(): TransferResult[];
2543
2899
  /**
@@ -2722,6 +3078,8 @@ declare const STORAGE_KEYS: {
2722
3078
  readonly MESSAGES: "messages";
2723
3079
  /** Transaction history for this address */
2724
3080
  readonly TRANSACTION_HISTORY: "transaction_history";
3081
+ /** Pending V5 finalization tokens (unconfirmed instant split tokens) */
3082
+ readonly PENDING_V5_TOKENS: "pending_v5_tokens";
2725
3083
  /** Encrypted BIP39 mnemonic */
2726
3084
  readonly MNEMONIC: "mnemonic";
2727
3085
  /** Encrypted master private key */
@@ -2966,6 +3324,8 @@ interface LegacyFileImportOptions {
2966
3324
  onDecryptProgress?: DecryptionProgressCallback;
2967
3325
  }
2968
3326
 
3327
+ declare function isValidNametag(nametag: string): boolean;
3328
+
2969
3329
  /** Options for creating a new wallet */
2970
3330
  interface SphereCreateOptions {
2971
3331
  /** BIP39 mnemonic (12 or 24 words) */
@@ -3696,9 +4056,9 @@ declare class Sphere {
3696
4056
  */
3697
4057
  private recoverNametagFromTransport;
3698
4058
  /**
3699
- * Validate nametag format
4059
+ * Strip @ prefix and normalize a nametag (lowercase, phone E.164, strip @unicity suffix).
3700
4060
  */
3701
- private validateNametag;
4061
+ private cleanNametag;
3702
4062
  destroy(): Promise<void>;
3703
4063
  private storeMnemonic;
3704
4064
  private storeMasterKey;
@@ -5047,4 +5407,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
5047
5407
  */
5048
5408
  declare function getCoinIdByName(name: string): string | undefined;
5049
5409
 
5050
- export { type AddressInfo, type AddressMode, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NOSTR_EVENT_KINDS, type NametagData, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderStatus, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId, base58Decode, base58Encode, buildTxfStorageData, bytesToHex, countCommittedTransactions, createAddress, createCommunicationsModule, createKeyPair, createL1PaymentsModule, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createTokenValidator, decodeBech32, decryptCMasterKey, decryptPrivateKey, decryptTextFormatKey, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey, generateMnemonic, getAddressHrp, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hexToBytes, identityFromMnemonicSync, initSphere, isArchivedKey, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isTextWalletEncrypted, isTokenKey, isValidBech32, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateMnemonic };
5410
+ export { type AddressInfo, type AddressMode, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NOSTR_EVENT_KINDS, type NametagData, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderStatus, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId, base58Decode, base58Encode, buildTxfStorageData, bytesToHex, countCommittedTransactions, createAddress, createCommunicationsModule, createKeyPair, createL1PaymentsModule, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createTokenValidator, decodeBech32, decryptCMasterKey, decryptPrivateKey, decryptTextFormatKey, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey, generateMnemonic, getAddressHrp, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hexToBytes, identityFromMnemonicSync, initSphere, isArchivedKey, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isTextWalletEncrypted, isTokenKey, isValidBech32, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateMnemonic };