@unicitylabs/sphere-sdk 0.2.2 → 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.cts 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 {
@@ -886,7 +941,7 @@ interface PaymentRequest {
886
941
  readonly coinId: string;
887
942
  /** Optional message/memo */
888
943
  readonly message?: string;
889
- /** Recipient nametag (who should pay) */
944
+ /** Where tokens should be sent */
890
945
  readonly recipientNametag?: string;
891
946
  /** Custom metadata */
892
947
  readonly metadata?: Record<string, unknown>;
@@ -913,7 +968,7 @@ interface IncomingPaymentRequest$1 {
913
968
  readonly symbol: string;
914
969
  /** Message from sender */
915
970
  readonly message?: string;
916
- /** Who this request is for (our nametag) */
971
+ /** Requester's nametag (where tokens should be sent) */
917
972
  readonly recipientNametag?: string;
918
973
  /** Original request ID from sender */
919
974
  readonly requestId: string;
@@ -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;
@@ -1444,6 +1513,8 @@ interface IncomingPaymentRequest {
1444
1513
  id: string;
1445
1514
  /** Transport-specific pubkey of sender */
1446
1515
  senderTransportPubkey: string;
1516
+ /** Sender's nametag (if included in encrypted content) */
1517
+ senderNametag?: string;
1447
1518
  /** Parsed request data */
1448
1519
  request: {
1449
1520
  requestId: string;
@@ -1610,6 +1681,12 @@ declare class L1PaymentsModule {
1610
1681
  private _transport?;
1611
1682
  constructor(config?: L1PaymentsModuleConfig);
1612
1683
  initialize(deps: L1PaymentsModuleDependencies): Promise<void>;
1684
+ /**
1685
+ * Ensure the Fulcrum WebSocket is connected. Called lazily before any
1686
+ * operation that needs the network. If the singleton is already connected
1687
+ * (e.g. by the address scanner), this is a no-op.
1688
+ */
1689
+ private ensureConnected;
1613
1690
  destroy(): void;
1614
1691
  /**
1615
1692
  * Check if a string looks like an L1 address (alpha1... or alphat1...)
@@ -1619,7 +1696,7 @@ declare class L1PaymentsModule {
1619
1696
  * Resolve recipient to L1 address
1620
1697
  * Supports: L1 address (alpha1...), nametag (with or without @)
1621
1698
  */
1622
- private resolveL1Address;
1699
+ resolveL1Address(recipient: string): Promise<string>;
1623
1700
  /**
1624
1701
  * Resolve nametag to L1 address using transport provider
1625
1702
  */
@@ -1793,7 +1870,7 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
1793
1870
  */
1794
1871
  deleteToken?(tokenId: string): Promise<void>;
1795
1872
  }
1796
- 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';
1797
1874
  interface StorageEvent {
1798
1875
  type: StorageEventType;
1799
1876
  timestamp: number;
@@ -2134,7 +2211,30 @@ interface TransactionHistoryEntry {
2134
2211
  timestamp: number;
2135
2212
  recipientNametag?: string;
2136
2213
  senderPubkey?: string;
2137
- 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;
2138
2238
  }
2139
2239
  interface PaymentsModuleConfig {
2140
2240
  /** Auto-sync after operations */
@@ -2147,8 +2247,8 @@ interface PaymentsModuleConfig {
2147
2247
  maxRetries?: number;
2148
2248
  /** Enable debug logging */
2149
2249
  debug?: boolean;
2150
- /** L1 (ALPHA blockchain) configuration */
2151
- l1?: L1PaymentsModuleConfig;
2250
+ /** L1 (ALPHA blockchain) configuration. Set to null to explicitly disable L1. */
2251
+ l1?: L1PaymentsModuleConfig | null;
2152
2252
  }
2153
2253
  interface PaymentsModuleDependencies {
2154
2254
  identity: FullIdentity;
@@ -2174,6 +2274,7 @@ declare class PaymentsModule {
2174
2274
  readonly l1: L1PaymentsModule | null;
2175
2275
  private tokens;
2176
2276
  private pendingTransfers;
2277
+ private pendingBackgroundTasks;
2177
2278
  private tombstones;
2178
2279
  private archivedTokens;
2179
2280
  private forkedTokens;
@@ -2191,8 +2292,17 @@ declare class PaymentsModule {
2191
2292
  private proofPollingInterval;
2192
2293
  private static readonly PROOF_POLLING_INTERVAL_MS;
2193
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;
2194
2300
  constructor(config?: PaymentsModuleConfig);
2195
- /** Get module configuration */
2301
+ /**
2302
+ * Get the current module configuration (excluding L1 config).
2303
+ *
2304
+ * @returns Resolved configuration with all defaults applied.
2305
+ */
2196
2306
  getConfig(): Omit<Required<PaymentsModuleConfig>, 'l1'>;
2197
2307
  /** Price provider (optional) */
2198
2308
  private priceProvider;
@@ -2202,11 +2312,18 @@ declare class PaymentsModule {
2202
2312
  */
2203
2313
  initialize(deps: PaymentsModuleDependencies): void;
2204
2314
  /**
2205
- * 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.
2206
2320
  */
2207
2321
  load(): Promise<void>;
2208
2322
  /**
2209
- * 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.
2210
2327
  */
2211
2328
  destroy(): void;
2212
2329
  /**
@@ -2258,11 +2375,19 @@ declare class PaymentsModule {
2258
2375
  * @param senderPubkey - Sender's public key for verification
2259
2376
  * @returns Processing result with finalized token
2260
2377
  */
2261
- 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;
2262
2384
  /**
2263
- * 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.
2264
2389
  */
2265
- isInstantSplitBundle(payload: unknown): payload is InstantSplitBundle;
2390
+ private isInstantSplitBundle;
2266
2391
  /**
2267
2392
  * Send a payment request to someone
2268
2393
  * @param recipientPubkeyOrNametag - Recipient's pubkey or @nametag
@@ -2284,27 +2409,45 @@ declare class PaymentsModule {
2284
2409
  status?: PaymentRequestStatus;
2285
2410
  }): IncomingPaymentRequest$1[];
2286
2411
  /**
2287
- * Get pending payment requests count
2412
+ * Get the count of payment requests with status `'pending'`.
2413
+ *
2414
+ * @returns Number of pending incoming payment requests.
2288
2415
  */
2289
2416
  getPendingPaymentRequestsCount(): number;
2290
2417
  /**
2291
- * 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.
2292
2424
  */
2293
2425
  acceptPaymentRequest(requestId: string): Promise<void>;
2294
2426
  /**
2295
- * 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.
2296
2430
  */
2297
2431
  rejectPaymentRequest(requestId: string): Promise<void>;
2298
2432
  /**
2299
- * 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.
2300
2439
  */
2301
2440
  markPaymentRequestPaid(requestId: string): void;
2302
2441
  /**
2303
- * Clear processed (non-pending) payment requests
2442
+ * Remove all non-pending incoming payment requests from memory.
2443
+ *
2444
+ * Keeps only requests with status `'pending'`.
2304
2445
  */
2305
2446
  clearProcessedPaymentRequests(): void;
2306
2447
  /**
2307
- * 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.
2308
2451
  */
2309
2452
  removePaymentRequest(requestId: string): void;
2310
2453
  /**
@@ -2335,15 +2478,21 @@ declare class PaymentsModule {
2335
2478
  */
2336
2479
  waitForPaymentResponse(requestId: string, timeoutMs?: number): Promise<PaymentRequestResponse>;
2337
2480
  /**
2338
- * 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.
2339
2486
  */
2340
2487
  cancelWaitForPaymentResponse(requestId: string): void;
2341
2488
  /**
2342
- * 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.
2343
2492
  */
2344
2493
  removeOutgoingPaymentRequest(requestId: string): void;
2345
2494
  /**
2346
- * Clear completed/expired outgoing payment requests
2495
+ * Remove all outgoing payment requests that are `'paid'`, `'rejected'`, or `'expired'`.
2347
2496
  */
2348
2497
  clearCompletedOutgoingPaymentRequests(): void;
2349
2498
  private handlePaymentRequestResponse;
@@ -2351,36 +2500,141 @@ declare class PaymentsModule {
2351
2500
  * Send a response to a payment request (used internally by accept/reject/pay methods)
2352
2501
  */
2353
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>;
2354
2519
  /**
2355
2520
  * Set or update price provider
2356
2521
  */
2357
2522
  setPriceProvider(provider: PriceProvider): void;
2358
2523
  /**
2359
- * Get total portfolio value in USD
2360
- * 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.
2361
2526
  */
2362
- getBalance(): Promise<number | null>;
2527
+ waitForPendingOperations(): Promise<void>;
2363
2528
  /**
2364
- * Get aggregated assets (tokens grouped by coinId) with price data
2365
- * Only includes confirmed tokens
2529
+ * Get total portfolio value in USD.
2530
+ * Returns null if PriceProvider is not configured.
2531
+ */
2532
+ getFiatBalance(): Promise<number | null>;
2533
+ /**
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.
2366
2550
  */
2367
2551
  getAssets(coinId?: string): Promise<Asset[]>;
2368
2552
  /**
2369
- * 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).
2370
2564
  */
2371
2565
  getTokens(filter?: {
2372
2566
  coinId?: string;
2373
2567
  status?: TokenStatus;
2374
2568
  }): Token[];
2375
2569
  /**
2376
- * 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.
2377
2574
  */
2378
2575
  getToken(id: string): Token | undefined;
2379
2576
  /**
2380
- * Add a token
2381
- * Tokens are uniquely identified by (tokenId, stateHash) composite key.
2382
- * Multiple historic states of the same token can coexist.
2383
- * @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.
2384
2638
  */
2385
2639
  addToken(token: Token, skipHistory?: boolean): Promise<boolean>;
2386
2640
  /**
@@ -2395,11 +2649,24 @@ declare class PaymentsModule {
2395
2649
  */
2396
2650
  private loadTokensFromFileStorage;
2397
2651
  /**
2398
- * 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`.
2399
2658
  */
2400
2659
  updateToken(token: Token): Promise<void>;
2401
2660
  /**
2402
- * 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`).
2403
2670
  */
2404
2671
  removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
2405
2672
  /**
@@ -2408,78 +2675,145 @@ declare class PaymentsModule {
2408
2675
  */
2409
2676
  private deleteTokenFiles;
2410
2677
  /**
2411
- * 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.
2412
2684
  */
2413
2685
  getTombstones(): TombstoneEntry[];
2414
2686
  /**
2415
- * 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.
2416
2692
  */
2417
2693
  isStateTombstoned(tokenId: string, stateHash: string): boolean;
2418
2694
  /**
2419
- * Merge remote tombstones
2420
- * @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.
2421
2702
  */
2422
2703
  mergeTombstones(remoteTombstones: TombstoneEntry[]): Promise<number>;
2423
2704
  /**
2424
- * 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).
2425
2708
  */
2426
2709
  pruneTombstones(maxAge?: number): Promise<void>;
2427
2710
  /**
2428
- * 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.
2429
2717
  */
2430
2718
  getArchivedTokens(): Map<string, TxfToken>;
2431
2719
  /**
2432
- * 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.
2433
2727
  */
2434
2728
  getBestArchivedVersion(tokenId: string): TxfToken | null;
2435
2729
  /**
2436
- * Merge remote archived tokens
2437
- * @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.
2438
2739
  */
2439
2740
  mergeArchivedTokens(remoteArchived: Map<string, TxfToken>): Promise<number>;
2440
2741
  /**
2441
- * 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).
2442
2747
  */
2443
2748
  pruneArchivedTokens(maxCount?: number): Promise<void>;
2444
2749
  /**
2445
- * 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.
2446
2756
  */
2447
2757
  getForkedTokens(): Map<string, TxfToken>;
2448
2758
  /**
2449
- * 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.
2450
2766
  */
2451
2767
  storeForkedToken(tokenId: string, stateHash: string, txfToken: TxfToken): Promise<void>;
2452
2768
  /**
2453
- * Merge remote forked tokens
2454
- * @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.
2455
2773
  */
2456
2774
  mergeForkedTokens(remoteForked: Map<string, TxfToken>): Promise<number>;
2457
2775
  /**
2458
- * 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).
2459
2779
  */
2460
2780
  pruneForkedTokens(maxCount?: number): Promise<void>;
2461
2781
  /**
2462
- * Get transaction history
2782
+ * Get the transaction history sorted newest-first.
2783
+ *
2784
+ * @returns Array of {@link TransactionHistoryEntry} objects in descending timestamp order.
2463
2785
  */
2464
2786
  getHistory(): TransactionHistoryEntry[];
2465
2787
  /**
2466
- * 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`).
2467
2793
  */
2468
2794
  addToHistory(entry: Omit<TransactionHistoryEntry, 'id'>): Promise<void>;
2469
2795
  /**
2470
- * 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.
2471
2801
  */
2472
2802
  setNametag(nametag: NametagData): Promise<void>;
2473
2803
  /**
2474
- * Get nametag
2804
+ * Get the current nametag data.
2805
+ *
2806
+ * @returns The nametag data, or `null` if no nametag is set.
2475
2807
  */
2476
2808
  getNametag(): NametagData | null;
2477
2809
  /**
2478
- * Check if has nametag
2810
+ * Check whether a nametag is currently set.
2811
+ *
2812
+ * @returns `true` if nametag data is present.
2479
2813
  */
2480
2814
  hasNametag(): boolean;
2481
2815
  /**
2482
- * Clear nametag
2816
+ * Remove the current nametag data from memory and storage.
2483
2817
  */
2484
2818
  clearNametag(): Promise<void>;
2485
2819
  /**
@@ -2506,30 +2840,60 @@ declare class PaymentsModule {
2506
2840
  */
2507
2841
  isNametagAvailable(nametag: string): Promise<boolean>;
2508
2842
  /**
2509
- * Sync with all token storage providers (IPFS, MongoDB, etc.)
2510
- * 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.
2511
2850
  */
2512
2851
  sync(): Promise<{
2513
2852
  added: number;
2514
2853
  removed: number;
2515
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;
2516
2870
  /**
2517
2871
  * Get all active token storage providers
2518
2872
  */
2519
2873
  private getTokenStorageProviders;
2520
2874
  /**
2521
- * 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.
2522
2880
  */
2523
2881
  updateTokenStorageProviders(providers: Map<string, TokenStorageProvider<TxfStorageDataBase>>): void;
2524
2882
  /**
2525
- * 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.
2526
2888
  */
2527
2889
  validate(): Promise<{
2528
2890
  valid: Token[];
2529
2891
  invalid: Token[];
2530
2892
  }>;
2531
2893
  /**
2532
- * 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.
2533
2897
  */
2534
2898
  getPendingTransfers(): TransferResult[];
2535
2899
  /**
@@ -2714,6 +3078,8 @@ declare const STORAGE_KEYS: {
2714
3078
  readonly MESSAGES: "messages";
2715
3079
  /** Transaction history for this address */
2716
3080
  readonly TRANSACTION_HISTORY: "transaction_history";
3081
+ /** Pending V5 finalization tokens (unconfirmed instant split tokens) */
3082
+ readonly PENDING_V5_TOKENS: "pending_v5_tokens";
2717
3083
  /** Encrypted BIP39 mnemonic */
2718
3084
  readonly MNEMONIC: "mnemonic";
2719
3085
  /** Encrypted master private key */
@@ -2736,6 +3102,8 @@ declare const STORAGE_KEYS: {
2736
3102
  readonly ADDRESS_NAMETAGS: "address_nametags";
2737
3103
  /** Active addresses registry (JSON: TrackedAddressesStorage) */
2738
3104
  readonly TRACKED_ADDRESSES: "tracked_addresses";
3105
+ /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
3106
+ readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
2739
3107
  };
2740
3108
  /** Default Nostr relays */
2741
3109
  declare const DEFAULT_NOSTR_RELAYS: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
@@ -2956,6 +3324,8 @@ interface LegacyFileImportOptions {
2956
3324
  onDecryptProgress?: DecryptionProgressCallback;
2957
3325
  }
2958
3326
 
3327
+ declare function isValidNametag(nametag: string): boolean;
3328
+
2959
3329
  /** Options for creating a new wallet */
2960
3330
  interface SphereCreateOptions {
2961
3331
  /** BIP39 mnemonic (12 or 24 words) */
@@ -3309,6 +3679,7 @@ declare class Sphere {
3309
3679
  transport: TransportProvider;
3310
3680
  oracle: OracleProvider;
3311
3681
  tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
3682
+ l1?: L1Config;
3312
3683
  }): Promise<{
3313
3684
  success: boolean;
3314
3685
  mnemonic?: string;
@@ -3363,6 +3734,8 @@ declare class Sphere {
3363
3734
  tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
3364
3735
  /** Optional nametag to register */
3365
3736
  nametag?: string;
3737
+ /** L1 (ALPHA blockchain) configuration */
3738
+ l1?: L1Config;
3366
3739
  }): Promise<{
3367
3740
  success: boolean;
3368
3741
  sphere?: Sphere;
@@ -3683,9 +4056,9 @@ declare class Sphere {
3683
4056
  */
3684
4057
  private recoverNametagFromTransport;
3685
4058
  /**
3686
- * Validate nametag format
4059
+ * Strip @ prefix and normalize a nametag (lowercase, phone E.164, strip @unicity suffix).
3687
4060
  */
3688
- private validateNametag;
4061
+ private cleanNametag;
3689
4062
  destroy(): Promise<void>;
3690
4063
  private storeMnemonic;
3691
4064
  private storeMasterKey;
@@ -5034,4 +5407,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
5034
5407
  */
5035
5408
  declare function getCoinIdByName(name: string): string | undefined;
5036
5409
 
5037
- 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 };