@unicitylabs/sphere-sdk 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,73 @@
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';
4
+
5
+ /**
6
+ * Group Chat Types (NIP-29)
7
+ * Plain interfaces for SDK consumers — no classes, no UI helpers.
8
+ */
9
+ declare const GroupRole: {
10
+ readonly ADMIN: "ADMIN";
11
+ readonly MODERATOR: "MODERATOR";
12
+ readonly MEMBER: "MEMBER";
13
+ };
14
+ type GroupRole = (typeof GroupRole)[keyof typeof GroupRole];
15
+ declare const GroupVisibility: {
16
+ readonly PUBLIC: "PUBLIC";
17
+ readonly PRIVATE: "PRIVATE";
18
+ };
19
+ type GroupVisibility = (typeof GroupVisibility)[keyof typeof GroupVisibility];
20
+ interface GroupData {
21
+ id: string;
22
+ relayUrl: string;
23
+ name: string;
24
+ description?: string;
25
+ picture?: string;
26
+ visibility: GroupVisibility;
27
+ createdAt: number;
28
+ updatedAt?: number;
29
+ memberCount?: number;
30
+ unreadCount?: number;
31
+ lastMessageTime?: number;
32
+ lastMessageText?: string;
33
+ /** When the current user joined this group locally (used to filter old events) */
34
+ localJoinedAt?: number;
35
+ }
36
+ interface GroupMessageData {
37
+ id?: string;
38
+ groupId: string;
39
+ content: string;
40
+ timestamp: number;
41
+ senderPubkey: string;
42
+ senderNametag?: string;
43
+ replyToId?: string;
44
+ previousIds?: string[];
45
+ }
46
+ interface GroupMemberData {
47
+ pubkey: string;
48
+ groupId: string;
49
+ role: GroupRole;
50
+ nametag?: string;
51
+ joinedAt: number;
52
+ }
53
+ interface GroupChatModuleConfig {
54
+ /** Override relay URLs (default: from network config) */
55
+ relays?: string[];
56
+ /** Default message fetch limit (default: 50) */
57
+ defaultMessageLimit?: number;
58
+ /** Max previous message IDs in ordering tags (default: 3) */
59
+ maxPreviousTags?: number;
60
+ /** Reconnect delay in ms (default: 3000) */
61
+ reconnectDelayMs?: number;
62
+ /** Max reconnect attempts (default: 5) */
63
+ maxReconnectAttempts?: number;
64
+ }
65
+ interface CreateGroupOptions {
66
+ name: string;
67
+ description?: string;
68
+ picture?: string;
69
+ visibility?: GroupVisibility;
70
+ }
3
71
 
4
72
  /**
5
73
  * Cryptographic utilities for SDK2
@@ -310,11 +378,12 @@ interface TxfMeta$1 {
310
378
  interface TxfStorageData {
311
379
  _meta: TxfMeta$1;
312
380
  _nametag?: NametagData;
381
+ _nametags?: NametagData[];
313
382
  _tombstones?: TombstoneEntry[];
314
383
  _invalidatedNametags?: InvalidatedNametagEntry[];
315
384
  _outbox?: OutboxEntry[];
316
385
  _mintOutbox?: MintOutboxEntry[];
317
- [key: string]: TxfToken | TxfMeta$1 | NametagData | TombstoneEntry[] | InvalidatedNametagEntry[] | OutboxEntry[] | MintOutboxEntry[] | undefined;
386
+ [key: string]: TxfToken | TxfMeta$1 | NametagData | NametagData[] | TombstoneEntry[] | InvalidatedNametagEntry[] | OutboxEntry[] | MintOutboxEntry[] | undefined;
318
387
  }
319
388
  interface ValidationIssue {
320
389
  tokenId: string;
@@ -539,6 +608,8 @@ interface InstantSplitResult {
539
608
  error?: string;
540
609
  /** Whether background processing was started */
541
610
  backgroundStarted?: boolean;
611
+ /** Promise that resolves when background processing completes (change token saved) */
612
+ backgroundPromise?: Promise<void>;
542
613
  }
543
614
  /**
544
615
  * Result from processing an INSTANT_SPLIT bundle (recipient side)
@@ -614,6 +685,30 @@ interface SplitRecoveryResult {
614
685
  /** Total duration of recovery in ms */
615
686
  durationMs: number;
616
687
  }
688
+ /** Finalization stage for V5 bundles saved as unconfirmed */
689
+ type V5FinalizationStage = 'RECEIVED' | 'MINT_SUBMITTED' | 'MINT_PROVEN' | 'TRANSFER_SUBMITTED' | 'FINALIZED';
690
+ /** Pending finalization metadata stored in token.sdkData */
691
+ interface PendingV5Finalization {
692
+ type: 'v5_bundle';
693
+ stage: V5FinalizationStage;
694
+ bundleJson: string;
695
+ senderPubkey: string;
696
+ savedAt: number;
697
+ lastAttemptAt?: number;
698
+ attemptCount: number;
699
+ mintProofJson?: string;
700
+ }
701
+ /** Result of resolveUnconfirmed() */
702
+ interface UnconfirmedResolutionResult {
703
+ resolved: number;
704
+ stillPending: number;
705
+ failed: number;
706
+ details: Array<{
707
+ tokenId: string;
708
+ stage: string;
709
+ status: 'resolved' | 'pending' | 'failed';
710
+ }>;
711
+ }
617
712
 
618
713
  /**
619
714
  * Payment Session Types
@@ -837,6 +932,14 @@ interface Asset {
837
932
  readonly iconUrl?: string;
838
933
  readonly totalAmount: string;
839
934
  readonly tokenCount: number;
935
+ /** Sum of confirmed token amounts (smallest units) */
936
+ readonly confirmedAmount: string;
937
+ /** Sum of unconfirmed (submitted/pending) token amounts (smallest units) */
938
+ readonly unconfirmedAmount: string;
939
+ /** Number of confirmed tokens aggregated */
940
+ readonly confirmedTokenCount: number;
941
+ /** Number of unconfirmed tokens aggregated */
942
+ readonly unconfirmedTokenCount: number;
840
943
  /** Price per whole unit in USD (null if PriceProvider not configured) */
841
944
  readonly priceUsd: number | null;
842
945
  /** Price per whole unit in EUR (null if PriceProvider not configured) */
@@ -850,6 +953,7 @@ interface Asset {
850
953
  }
851
954
  type TransferStatus = 'pending' | 'submitted' | 'confirmed' | 'delivered' | 'completed' | 'failed';
852
955
  type AddressMode = 'auto' | 'direct' | 'proxy';
956
+ type TransferMode = 'instant' | 'conservative';
853
957
  interface TransferRequest {
854
958
  readonly coinId: string;
855
959
  readonly amount: string;
@@ -857,12 +961,31 @@ interface TransferRequest {
857
961
  readonly memo?: string;
858
962
  /** Address mode: 'auto' (default) uses directAddress if available, 'direct' forces DIRECT, 'proxy' forces PROXY */
859
963
  readonly addressMode?: AddressMode;
964
+ /** Transfer mode: 'instant' (default) sends via Nostr immediately, 'conservative' collects all proofs first */
965
+ readonly transferMode?: TransferMode;
966
+ }
967
+ /**
968
+ * Per-token transfer detail tracking the on-chain commitment or split operation
969
+ * for each source token involved in a transfer.
970
+ */
971
+ interface TokenTransferDetail {
972
+ /** Source token ID that was consumed in this transfer */
973
+ readonly sourceTokenId: string;
974
+ /** Transfer method used for this token */
975
+ readonly method: 'direct' | 'split';
976
+ /** Aggregator commitment request ID hex (for direct transfers) */
977
+ readonly requestIdHex?: string;
978
+ /** Split group ID (for split transfers — correlates sender/recipient/change tokens) */
979
+ readonly splitGroupId?: string;
980
+ /** Nostr event ID (for split transfers delivered via Nostr) */
981
+ readonly nostrEventId?: string;
860
982
  }
861
983
  interface TransferResult {
862
984
  readonly id: string;
863
985
  status: TransferStatus;
864
986
  readonly tokens: Token[];
865
- txHash?: string;
987
+ /** Per-token transfer details — one entry per source token consumed */
988
+ readonly tokenTransfers: TokenTransferDetail[];
866
989
  error?: string;
867
990
  }
868
991
  interface IncomingTransfer {
@@ -1039,7 +1162,7 @@ interface TrackedAddress extends TrackedAddressEntry {
1039
1162
  /** Primary nametag (from nametag cache, without @ prefix) */
1040
1163
  readonly nametag?: string;
1041
1164
  }
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';
1165
+ 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' | 'groupchat:message' | 'groupchat:joined' | 'groupchat:left' | 'groupchat:kicked' | 'groupchat:group_deleted' | 'groupchat:updated' | 'groupchat:connection';
1043
1166
  interface SphereEventMap {
1044
1167
  'transfer:incoming': IncomingTransfer;
1045
1168
  'transfer:confirmed': TransferResult;
@@ -1098,6 +1221,34 @@ interface SphereEventMap {
1098
1221
  index: number;
1099
1222
  addressId: string;
1100
1223
  };
1224
+ 'sync:remote-update': {
1225
+ providerId: string;
1226
+ name: string;
1227
+ sequence: number;
1228
+ cid: string;
1229
+ added: number;
1230
+ removed: number;
1231
+ };
1232
+ 'groupchat:message': GroupMessageData;
1233
+ 'groupchat:joined': {
1234
+ groupId: string;
1235
+ groupName: string;
1236
+ };
1237
+ 'groupchat:left': {
1238
+ groupId: string;
1239
+ };
1240
+ 'groupchat:kicked': {
1241
+ groupId: string;
1242
+ groupName: string;
1243
+ };
1244
+ 'groupchat:group_deleted': {
1245
+ groupId: string;
1246
+ groupName: string;
1247
+ };
1248
+ 'groupchat:updated': Record<string, never>;
1249
+ 'groupchat:connection': {
1250
+ connected: boolean;
1251
+ };
1101
1252
  }
1102
1253
  type SphereEventHandler<T extends SphereEventType> = (data: SphereEventMap[T]) => void;
1103
1254
  interface SphereConfig {
@@ -1362,6 +1513,12 @@ interface TransportProvider extends BaseProvider {
1362
1513
  * @returns Unsubscribe function
1363
1514
  */
1364
1515
  onInstantSplitReceived?(handler: InstantSplitBundleHandler): () => void;
1516
+ /**
1517
+ * Fetch pending events from transport (one-shot query).
1518
+ * Creates a temporary subscription, processes events through normal handlers,
1519
+ * and resolves after EOSE (End Of Stored Events).
1520
+ */
1521
+ fetchPendingEvents?(): Promise<void>;
1365
1522
  }
1366
1523
  /**
1367
1524
  * Payload for sending instant split bundles
@@ -1426,7 +1583,7 @@ interface IncomingTokenTransfer {
1426
1583
  payload: TokenTransferPayload;
1427
1584
  timestamp: number;
1428
1585
  }
1429
- type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void;
1586
+ type TokenTransferHandler = (transfer: IncomingTokenTransfer) => void | Promise<void>;
1430
1587
  interface PaymentRequestPayload {
1431
1588
  /** Amount requested (in smallest units) */
1432
1589
  amount: string | bigint;
@@ -1784,24 +1941,8 @@ interface TokenStorageProvider<TData = unknown> extends BaseProvider {
1784
1941
  * Subscribe to storage events
1785
1942
  */
1786
1943
  onEvent?(callback: StorageEventCallback): () => void;
1787
- /**
1788
- * Save individual token (for file-based storage like lottery pattern)
1789
- */
1790
- saveToken?(tokenId: string, tokenData: unknown): Promise<void>;
1791
- /**
1792
- * Get individual token
1793
- */
1794
- getToken?(tokenId: string): Promise<unknown | null>;
1795
- /**
1796
- * List all token IDs
1797
- */
1798
- listTokenIds?(): Promise<string[]>;
1799
- /**
1800
- * Delete individual token
1801
- */
1802
- deleteToken?(tokenId: string): Promise<void>;
1803
1944
  }
1804
- type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
1945
+ type StorageEventType = 'storage:saving' | 'storage:saved' | 'storage:loading' | 'storage:loaded' | 'storage:error' | 'storage:remote-updated' | 'sync:started' | 'sync:completed' | 'sync:conflict' | 'sync:error';
1805
1946
  interface StorageEvent {
1806
1947
  type: StorageEventType;
1807
1948
  timestamp: number;
@@ -2142,7 +2283,30 @@ interface TransactionHistoryEntry {
2142
2283
  timestamp: number;
2143
2284
  recipientNametag?: string;
2144
2285
  senderPubkey?: string;
2145
- txHash?: string;
2286
+ /** TransferResult.id that created this entry (links history to transfer operation) */
2287
+ transferId?: string;
2288
+ }
2289
+ interface ReceiveOptions {
2290
+ /** Wait for all unconfirmed tokens to be finalized (default: false).
2291
+ * When false, calls resolveUnconfirmed() once to submit pending commitments.
2292
+ * When true, polls resolveUnconfirmed() + load() until all confirmed or timeout. */
2293
+ finalize?: boolean;
2294
+ /** Finalization timeout in ms (default: 60000). Only used when finalize=true. */
2295
+ timeout?: number;
2296
+ /** Poll interval in ms (default: 2000). Only used when finalize=true. */
2297
+ pollInterval?: number;
2298
+ /** Progress callback after each resolveUnconfirmed() poll. Only used when finalize=true. */
2299
+ onProgress?: (result: UnconfirmedResolutionResult) => void;
2300
+ }
2301
+ interface ReceiveResult {
2302
+ /** Newly received incoming transfers. */
2303
+ transfers: IncomingTransfer[];
2304
+ /** Finalization result (from resolveUnconfirmed). */
2305
+ finalization?: UnconfirmedResolutionResult;
2306
+ /** Whether finalization timed out (only when finalize=true). */
2307
+ timedOut?: boolean;
2308
+ /** Duration of finalization in ms (only when finalize=true). */
2309
+ finalizationDurationMs?: number;
2146
2310
  }
2147
2311
  interface PaymentsModuleConfig {
2148
2312
  /** Auto-sync after operations */
@@ -2182,11 +2346,12 @@ declare class PaymentsModule {
2182
2346
  readonly l1: L1PaymentsModule | null;
2183
2347
  private tokens;
2184
2348
  private pendingTransfers;
2349
+ private pendingBackgroundTasks;
2185
2350
  private tombstones;
2186
2351
  private archivedTokens;
2187
2352
  private forkedTokens;
2188
2353
  private transactionHistory;
2189
- private nametag;
2354
+ private nametags;
2190
2355
  private paymentRequests;
2191
2356
  private paymentRequestHandlers;
2192
2357
  private outgoingPaymentRequests;
@@ -2199,8 +2364,17 @@ declare class PaymentsModule {
2199
2364
  private proofPollingInterval;
2200
2365
  private static readonly PROOF_POLLING_INTERVAL_MS;
2201
2366
  private static readonly PROOF_POLLING_MAX_ATTEMPTS;
2367
+ private storageEventUnsubscribers;
2368
+ private syncDebounceTimer;
2369
+ private static readonly SYNC_DEBOUNCE_MS;
2370
+ /** Sync coalescing: concurrent sync() calls share the same operation */
2371
+ private _syncInProgress;
2202
2372
  constructor(config?: PaymentsModuleConfig);
2203
- /** Get module configuration */
2373
+ /**
2374
+ * Get the current module configuration (excluding L1 config).
2375
+ *
2376
+ * @returns Resolved configuration with all defaults applied.
2377
+ */
2204
2378
  getConfig(): Omit<Required<PaymentsModuleConfig>, 'l1'>;
2205
2379
  /** Price provider (optional) */
2206
2380
  private priceProvider;
@@ -2210,11 +2384,18 @@ declare class PaymentsModule {
2210
2384
  */
2211
2385
  initialize(deps: PaymentsModuleDependencies): void;
2212
2386
  /**
2213
- * Load tokens from storage
2387
+ * Load all token data from storage providers and restore wallet state.
2388
+ *
2389
+ * Loads tokens, nametag data, transaction history, and pending transfers
2390
+ * from configured storage providers. Restores pending V5 tokens and
2391
+ * triggers a fire-and-forget {@link resolveUnconfirmed} call.
2214
2392
  */
2215
2393
  load(): Promise<void>;
2216
2394
  /**
2217
- * Cleanup resources
2395
+ * Cleanup all subscriptions, polling jobs, and pending resolvers.
2396
+ *
2397
+ * Should be called when the wallet is being shut down or the module is
2398
+ * no longer needed. Also destroys the L1 sub-module if present.
2218
2399
  */
2219
2400
  destroy(): void;
2220
2401
  /**
@@ -2266,11 +2447,19 @@ declare class PaymentsModule {
2266
2447
  * @param senderPubkey - Sender's public key for verification
2267
2448
  * @returns Processing result with finalized token
2268
2449
  */
2269
- processInstantSplitBundle(bundle: InstantSplitBundle, senderPubkey: string): Promise<InstantSplitProcessResult>;
2450
+ private processInstantSplitBundle;
2270
2451
  /**
2271
- * Check if a payload is an instant split bundle
2452
+ * Synchronous V4 bundle processing (dev mode only).
2453
+ * Kept for backward compatibility with V4 bundles.
2272
2454
  */
2273
- isInstantSplitBundle(payload: unknown): payload is InstantSplitBundle;
2455
+ private processInstantSplitBundleSync;
2456
+ /**
2457
+ * Type-guard: check whether a payload is a valid {@link InstantSplitBundle} (V4 or V5).
2458
+ *
2459
+ * @param payload - The object to test.
2460
+ * @returns `true` if the payload matches the InstantSplitBundle shape.
2461
+ */
2462
+ private isInstantSplitBundle;
2274
2463
  /**
2275
2464
  * Send a payment request to someone
2276
2465
  * @param recipientPubkeyOrNametag - Recipient's pubkey or @nametag
@@ -2292,27 +2481,45 @@ declare class PaymentsModule {
2292
2481
  status?: PaymentRequestStatus;
2293
2482
  }): IncomingPaymentRequest$1[];
2294
2483
  /**
2295
- * Get pending payment requests count
2484
+ * Get the count of payment requests with status `'pending'`.
2485
+ *
2486
+ * @returns Number of pending incoming payment requests.
2296
2487
  */
2297
2488
  getPendingPaymentRequestsCount(): number;
2298
2489
  /**
2299
- * Accept a payment request (marks it as accepted, user should then call send())
2490
+ * Accept a payment request and notify the requester.
2491
+ *
2492
+ * Marks the request as `'accepted'` and sends a response via transport.
2493
+ * The caller should subsequently call {@link send} to fulfill the payment.
2494
+ *
2495
+ * @param requestId - ID of the incoming payment request to accept.
2300
2496
  */
2301
2497
  acceptPaymentRequest(requestId: string): Promise<void>;
2302
2498
  /**
2303
- * Reject a payment request
2499
+ * Reject a payment request and notify the requester.
2500
+ *
2501
+ * @param requestId - ID of the incoming payment request to reject.
2304
2502
  */
2305
2503
  rejectPaymentRequest(requestId: string): Promise<void>;
2306
2504
  /**
2307
- * Mark a payment request as paid (after successful transfer)
2505
+ * Mark a payment request as paid (local status update only).
2506
+ *
2507
+ * Typically called after a successful {@link send} to record that the
2508
+ * request has been fulfilled.
2509
+ *
2510
+ * @param requestId - ID of the incoming payment request to mark as paid.
2308
2511
  */
2309
2512
  markPaymentRequestPaid(requestId: string): void;
2310
2513
  /**
2311
- * Clear processed (non-pending) payment requests
2514
+ * Remove all non-pending incoming payment requests from memory.
2515
+ *
2516
+ * Keeps only requests with status `'pending'`.
2312
2517
  */
2313
2518
  clearProcessedPaymentRequests(): void;
2314
2519
  /**
2315
- * Remove a specific payment request
2520
+ * Remove a specific incoming payment request by ID.
2521
+ *
2522
+ * @param requestId - ID of the payment request to remove.
2316
2523
  */
2317
2524
  removePaymentRequest(requestId: string): void;
2318
2525
  /**
@@ -2343,15 +2550,21 @@ declare class PaymentsModule {
2343
2550
  */
2344
2551
  waitForPaymentResponse(requestId: string, timeoutMs?: number): Promise<PaymentRequestResponse>;
2345
2552
  /**
2346
- * Cancel waiting for a payment response
2553
+ * Cancel an active {@link waitForPaymentResponse} call.
2554
+ *
2555
+ * The pending promise is rejected with a `'Cancelled'` error.
2556
+ *
2557
+ * @param requestId - The outgoing request ID whose wait should be cancelled.
2347
2558
  */
2348
2559
  cancelWaitForPaymentResponse(requestId: string): void;
2349
2560
  /**
2350
- * Remove an outgoing payment request
2561
+ * Remove an outgoing payment request and cancel any pending wait.
2562
+ *
2563
+ * @param requestId - ID of the outgoing request to remove.
2351
2564
  */
2352
2565
  removeOutgoingPaymentRequest(requestId: string): void;
2353
2566
  /**
2354
- * Clear completed/expired outgoing payment requests
2567
+ * Remove all outgoing payment requests that are `'paid'`, `'rejected'`, or `'expired'`.
2355
2568
  */
2356
2569
  clearCompletedOutgoingPaymentRequests(): void;
2357
2570
  private handlePaymentRequestResponse;
@@ -2359,147 +2572,312 @@ declare class PaymentsModule {
2359
2572
  * Send a response to a payment request (used internally by accept/reject/pay methods)
2360
2573
  */
2361
2574
  private sendPaymentRequestResponse;
2575
+ /**
2576
+ * Fetch and process pending incoming transfers from the transport layer.
2577
+ *
2578
+ * Performs a one-shot query to fetch all pending events, processes them
2579
+ * through the existing pipeline, and resolves after all stored events
2580
+ * are handled. Useful for batch/CLI apps that need explicit receive.
2581
+ *
2582
+ * When `finalize` is true, polls resolveUnconfirmed() + load() until all
2583
+ * tokens are confirmed or the timeout expires. Otherwise calls
2584
+ * resolveUnconfirmed() once to submit pending commitments.
2585
+ *
2586
+ * @param options - Optional receive options including finalization control
2587
+ * @param callback - Optional callback invoked for each newly received transfer
2588
+ * @returns ReceiveResult with transfers and finalization metadata
2589
+ */
2590
+ receive(options?: ReceiveOptions, callback?: (transfer: IncomingTransfer) => void): Promise<ReceiveResult>;
2362
2591
  /**
2363
2592
  * Set or update price provider
2364
2593
  */
2365
2594
  setPriceProvider(provider: PriceProvider): void;
2366
2595
  /**
2367
- * Get total portfolio value in USD
2368
- * Returns null if PriceProvider is not configured
2596
+ * Wait for all pending background operations (e.g., instant split change token creation).
2597
+ * Call this before process exit to ensure all tokens are saved.
2369
2598
  */
2370
- getBalance(): Promise<number | null>;
2599
+ waitForPendingOperations(): Promise<void>;
2371
2600
  /**
2372
- * Get aggregated assets (tokens grouped by coinId) with price data
2373
- * Only includes confirmed tokens
2601
+ * Get total portfolio value in USD.
2602
+ * Returns null if PriceProvider is not configured.
2603
+ */
2604
+ getFiatBalance(): Promise<number | null>;
2605
+ /**
2606
+ * Get token balances grouped by coin type.
2607
+ *
2608
+ * Returns an array of {@link Asset} objects, one per coin type held.
2609
+ * Each entry includes confirmed and unconfirmed breakdowns. Tokens with
2610
+ * status `'spent'`, `'invalid'`, or `'transferring'` are excluded.
2611
+ *
2612
+ * This is synchronous — no price data is included. Use {@link getAssets}
2613
+ * for the async version with fiat pricing.
2614
+ *
2615
+ * @param coinId - Optional coin ID to filter by (e.g. hex string). When omitted, all coin types are returned.
2616
+ * @returns Array of balance summaries (synchronous — no await needed).
2617
+ */
2618
+ getBalance(coinId?: string): Asset[];
2619
+ /**
2620
+ * Get aggregated assets (tokens grouped by coinId) with price data.
2621
+ * Includes both confirmed and unconfirmed tokens with breakdown.
2374
2622
  */
2375
2623
  getAssets(coinId?: string): Promise<Asset[]>;
2376
2624
  /**
2377
- * Get all tokens
2625
+ * Aggregate tokens by coinId with confirmed/unconfirmed breakdown.
2626
+ * Excludes tokens with status 'spent', 'invalid', or 'transferring'.
2627
+ */
2628
+ private aggregateTokens;
2629
+ /**
2630
+ * Get all tokens, optionally filtered by coin type and/or status.
2631
+ *
2632
+ * @param filter - Optional filter criteria.
2633
+ * @param filter.coinId - Return only tokens of this coin type.
2634
+ * @param filter.status - Return only tokens with this status (e.g. `'submitted'` for unconfirmed).
2635
+ * @returns Array of matching {@link Token} objects (synchronous).
2378
2636
  */
2379
2637
  getTokens(filter?: {
2380
2638
  coinId?: string;
2381
2639
  status?: TokenStatus;
2382
2640
  }): Token[];
2383
2641
  /**
2384
- * Get single token
2642
+ * Get a single token by its local ID.
2643
+ *
2644
+ * @param id - The local UUID assigned when the token was added.
2645
+ * @returns The token, or `undefined` if not found.
2385
2646
  */
2386
2647
  getToken(id: string): Token | undefined;
2387
2648
  /**
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)
2649
+ * Attempt to resolve unconfirmed (status `'submitted'`) tokens by acquiring
2650
+ * their missing aggregator proofs.
2651
+ *
2652
+ * Each unconfirmed V5 token progresses through stages:
2653
+ * `RECEIVED` → `MINT_SUBMITTED` → `MINT_PROVEN` → `TRANSFER_SUBMITTED` → `FINALIZED`
2654
+ *
2655
+ * Uses 500 ms quick-timeouts per proof check so the call returns quickly even
2656
+ * when proofs are not yet available. Tokens that exceed 50 failed attempts are
2657
+ * marked `'invalid'`.
2658
+ *
2659
+ * Automatically called (fire-and-forget) by {@link load}.
2660
+ *
2661
+ * @returns Summary with counts of resolved, still-pending, and failed tokens plus per-token details.
2392
2662
  */
2393
- addToken(token: Token, skipHistory?: boolean): Promise<boolean>;
2663
+ resolveUnconfirmed(): Promise<UnconfirmedResolutionResult>;
2394
2664
  /**
2395
- * Save token as individual file to token storage providers
2396
- * Similar to lottery's saveReceivedToken() pattern
2665
+ * Process a single V5 token through its finalization stages with quick-timeout proof checks.
2397
2666
  */
2398
- private saveTokenToFileStorage;
2667
+ private resolveV5Token;
2399
2668
  /**
2400
- * Load tokens from file storage providers (lottery compatibility)
2401
- * This loads tokens from file-based storage that may have been saved
2402
- * by other applications using the same storage directory.
2669
+ * Non-blocking proof check with 500ms timeout.
2403
2670
  */
2404
- private loadTokensFromFileStorage;
2671
+ private quickProofCheck;
2405
2672
  /**
2406
- * Update an existing token
2673
+ * Perform V5 bundle finalization from stored bundle data and proofs.
2674
+ * Extracted from InstantSplitProcessor.processV5Bundle() steps 4-10.
2407
2675
  */
2408
- updateToken(token: Token): Promise<void>;
2676
+ private finalizeFromV5Bundle;
2409
2677
  /**
2410
- * Remove a token by ID
2678
+ * Parse pending finalization metadata from token's sdkData.
2411
2679
  */
2412
- removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
2680
+ private parsePendingFinalization;
2681
+ /**
2682
+ * Update pending finalization metadata in token's sdkData.
2683
+ * Creates a new token object since sdkData is readonly.
2684
+ */
2685
+ private updatePendingFinalization;
2686
+ /**
2687
+ * Save pending V5 tokens to key-value storage.
2688
+ * These tokens can't be serialized to TXF format (no genesis/state),
2689
+ * so we persist them separately and restore on load().
2690
+ */
2691
+ private savePendingV5Tokens;
2692
+ /**
2693
+ * Load pending V5 tokens from key-value storage and merge into tokens map.
2694
+ * Called during load() to restore tokens that TXF format can't represent.
2695
+ */
2696
+ private loadPendingV5Tokens;
2697
+ /**
2698
+ * Add a token to the wallet.
2699
+ *
2700
+ * Tokens are uniquely identified by a `(tokenId, stateHash)` composite key.
2701
+ * Duplicate detection:
2702
+ * - **Tombstoned** — rejected if the exact `(tokenId, stateHash)` pair has a tombstone.
2703
+ * - **Exact duplicate** — rejected if a token with the same composite key already exists.
2704
+ * - **State replacement** — if the same `tokenId` exists with a *different* `stateHash`,
2705
+ * the old state is archived and replaced with the incoming one.
2706
+ *
2707
+ * @param token - The token to add.
2708
+ * @param skipHistory - When `true`, do not create a `RECEIVED` transaction history entry (default `false`).
2709
+ * @returns `true` if the token was added, `false` if rejected as duplicate or tombstoned.
2710
+ */
2711
+ addToken(token: Token, skipHistory?: boolean): Promise<boolean>;
2413
2712
  /**
2414
- * Delete physical token file(s) from all storage providers.
2415
- * Finds files by matching the SDK token ID prefix in the filename.
2713
+ * Update an existing token or add it if not found.
2714
+ *
2715
+ * Looks up the token by genesis `tokenId` (from `sdkData`) first, then by
2716
+ * `token.id`. If no match is found, falls back to {@link addToken}.
2717
+ *
2718
+ * @param token - The token with updated data. Must include a valid `id`.
2719
+ */
2720
+ updateToken(token: Token): Promise<void>;
2721
+ /**
2722
+ * Remove a token from the wallet.
2723
+ *
2724
+ * The token is archived first, then a tombstone `(tokenId, stateHash)` is
2725
+ * created to prevent re-addition via Nostr re-delivery. A `SENT` history
2726
+ * entry is created unless `skipHistory` is `true`.
2727
+ *
2728
+ * @param tokenId - Local UUID of the token to remove.
2729
+ * @param recipientNametag - Optional nametag of the transfer recipient (for history).
2730
+ * @param skipHistory - When `true`, skip creating a transaction history entry (default `false`).
2416
2731
  */
2417
- private deleteTokenFiles;
2732
+ removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
2418
2733
  /**
2419
- * Get all tombstones
2734
+ * Get all tombstone entries.
2735
+ *
2736
+ * Each tombstone is keyed by `(tokenId, stateHash)` and prevents a spent
2737
+ * token state from being re-added (e.g. via Nostr re-delivery).
2738
+ *
2739
+ * @returns A shallow copy of the tombstone array.
2420
2740
  */
2421
2741
  getTombstones(): TombstoneEntry[];
2422
2742
  /**
2423
- * Check if token state is tombstoned
2743
+ * Check whether a specific `(tokenId, stateHash)` combination is tombstoned.
2744
+ *
2745
+ * @param tokenId - The genesis token ID.
2746
+ * @param stateHash - The state hash of the token version to check.
2747
+ * @returns `true` if the exact combination has been tombstoned.
2424
2748
  */
2425
2749
  isStateTombstoned(tokenId: string, stateHash: string): boolean;
2426
2750
  /**
2427
- * Merge remote tombstones
2428
- * @returns number of local tokens removed
2751
+ * Merge tombstones received from a remote sync source.
2752
+ *
2753
+ * Any local token whose `(tokenId, stateHash)` matches a remote tombstone is
2754
+ * removed. The remote tombstones are then added to the local set (union merge).
2755
+ *
2756
+ * @param remoteTombstones - Tombstone entries from the remote source.
2757
+ * @returns Number of local tokens that were removed.
2429
2758
  */
2430
2759
  mergeTombstones(remoteTombstones: TombstoneEntry[]): Promise<number>;
2431
2760
  /**
2432
- * Prune old tombstones
2761
+ * Remove tombstones older than `maxAge` and cap the list at 100 entries.
2762
+ *
2763
+ * @param maxAge - Maximum age in milliseconds (default: 30 days).
2433
2764
  */
2434
2765
  pruneTombstones(maxAge?: number): Promise<void>;
2435
2766
  /**
2436
- * Get archived tokens
2767
+ * Get all archived (spent/superseded) tokens in TXF format.
2768
+ *
2769
+ * Archived tokens are kept for recovery and sync purposes. The map key is
2770
+ * the genesis token ID.
2771
+ *
2772
+ * @returns A shallow copy of the archived token map.
2437
2773
  */
2438
2774
  getArchivedTokens(): Map<string, TxfToken>;
2439
2775
  /**
2440
- * Get best archived version of a token
2776
+ * Get the best (most committed transactions) archived version of a token.
2777
+ *
2778
+ * Searches both archived and forked token maps and returns the version with
2779
+ * the highest number of committed transactions.
2780
+ *
2781
+ * @param tokenId - The genesis token ID to look up.
2782
+ * @returns The best TXF token version, or `null` if not found.
2441
2783
  */
2442
2784
  getBestArchivedVersion(tokenId: string): TxfToken | null;
2443
2785
  /**
2444
- * Merge remote archived tokens
2445
- * @returns number of tokens updated/added
2786
+ * Merge archived tokens from a remote sync source.
2787
+ *
2788
+ * For each remote token:
2789
+ * - If missing locally, it is added.
2790
+ * - If the remote version is an incremental update of the local, it replaces it.
2791
+ * - If the histories diverge (fork), the remote version is stored via {@link storeForkedToken}.
2792
+ *
2793
+ * @param remoteArchived - Map of genesis token ID → TXF token from remote.
2794
+ * @returns Number of tokens that were updated or added locally.
2446
2795
  */
2447
2796
  mergeArchivedTokens(remoteArchived: Map<string, TxfToken>): Promise<number>;
2448
2797
  /**
2449
- * Prune archived tokens
2798
+ * Prune archived tokens to keep at most `maxCount` entries.
2799
+ *
2800
+ * Oldest entries (by insertion order) are removed first.
2801
+ *
2802
+ * @param maxCount - Maximum number of archived tokens to retain (default: 100).
2450
2803
  */
2451
2804
  pruneArchivedTokens(maxCount?: number): Promise<void>;
2452
2805
  /**
2453
- * Get forked tokens
2806
+ * Get all forked token versions.
2807
+ *
2808
+ * Forked tokens represent alternative histories detected during sync.
2809
+ * The map key is `{tokenId}_{stateHash}`.
2810
+ *
2811
+ * @returns A shallow copy of the forked tokens map.
2454
2812
  */
2455
2813
  getForkedTokens(): Map<string, TxfToken>;
2456
2814
  /**
2457
- * Store a forked token
2815
+ * Store a forked token version (alternative history).
2816
+ *
2817
+ * No-op if the exact `(tokenId, stateHash)` key already exists.
2818
+ *
2819
+ * @param tokenId - Genesis token ID.
2820
+ * @param stateHash - State hash of this forked version.
2821
+ * @param txfToken - The TXF token data to store.
2458
2822
  */
2459
2823
  storeForkedToken(tokenId: string, stateHash: string, txfToken: TxfToken): Promise<void>;
2460
2824
  /**
2461
- * Merge remote forked tokens
2462
- * @returns number of tokens added
2825
+ * Merge forked tokens from a remote sync source. Only new keys are added.
2826
+ *
2827
+ * @param remoteForked - Map of `{tokenId}_{stateHash}` → TXF token from remote.
2828
+ * @returns Number of new forked tokens added.
2463
2829
  */
2464
2830
  mergeForkedTokens(remoteForked: Map<string, TxfToken>): Promise<number>;
2465
2831
  /**
2466
- * Prune forked tokens
2832
+ * Prune forked tokens to keep at most `maxCount` entries.
2833
+ *
2834
+ * @param maxCount - Maximum number of forked tokens to retain (default: 50).
2467
2835
  */
2468
2836
  pruneForkedTokens(maxCount?: number): Promise<void>;
2469
2837
  /**
2470
- * Get transaction history
2838
+ * Get the transaction history sorted newest-first.
2839
+ *
2840
+ * @returns Array of {@link TransactionHistoryEntry} objects in descending timestamp order.
2471
2841
  */
2472
2842
  getHistory(): TransactionHistoryEntry[];
2473
2843
  /**
2474
- * Add to transaction history
2844
+ * Append an entry to the transaction history.
2845
+ *
2846
+ * A unique `id` is auto-generated. The entry is immediately persisted to storage.
2847
+ *
2848
+ * @param entry - History entry fields (without `id`).
2475
2849
  */
2476
2850
  addToHistory(entry: Omit<TransactionHistoryEntry, 'id'>): Promise<void>;
2477
2851
  /**
2478
- * Set nametag for current identity
2852
+ * Set the nametag data for the current identity.
2853
+ *
2854
+ * Persists to both key-value storage and file storage (lottery compatibility).
2855
+ *
2856
+ * @param nametag - The nametag data including minted token JSON.
2479
2857
  */
2480
2858
  setNametag(nametag: NametagData): Promise<void>;
2481
2859
  /**
2482
- * Get nametag
2860
+ * Get the current (first) nametag data.
2861
+ *
2862
+ * @returns The nametag data, or `null` if no nametag is set.
2483
2863
  */
2484
2864
  getNametag(): NametagData | null;
2485
2865
  /**
2486
- * Check if has nametag
2487
- */
2488
- hasNametag(): boolean;
2489
- /**
2490
- * Clear nametag
2866
+ * Get all nametag data entries.
2867
+ *
2868
+ * @returns A copy of the nametags array.
2491
2869
  */
2492
- clearNametag(): Promise<void>;
2870
+ getNametags(): NametagData[];
2493
2871
  /**
2494
- * Save nametag to file storage for lottery compatibility
2495
- * Creates file: nametag-{name}.json
2872
+ * Check whether a nametag is currently set.
2873
+ *
2874
+ * @returns `true` if nametag data is present.
2496
2875
  */
2497
- private saveNametagToFileStorage;
2876
+ hasNametag(): boolean;
2498
2877
  /**
2499
- * Load nametag from file storage (lottery compatibility)
2500
- * Looks for file: nametag-{name}.json
2878
+ * Remove all nametag data from memory and storage.
2501
2879
  */
2502
- private loadNametagFromFileStorage;
2880
+ clearNametag(): Promise<void>;
2503
2881
  /**
2504
2882
  * Mint a nametag token on-chain (like Sphere wallet and lottery)
2505
2883
  * This creates the nametag token required for receiving tokens via PROXY addresses
@@ -2514,30 +2892,60 @@ declare class PaymentsModule {
2514
2892
  */
2515
2893
  isNametagAvailable(nametag: string): Promise<boolean>;
2516
2894
  /**
2517
- * Sync with all token storage providers (IPFS, MongoDB, etc.)
2518
- * Syncs with each provider and merges results
2895
+ * Sync local token state with all configured token storage providers (IPFS, file, etc.).
2896
+ *
2897
+ * For each provider, the local data is packaged into TXF storage format, sent
2898
+ * to the provider's `sync()` method, and the merged result is applied locally.
2899
+ * Emits `sync:started`, `sync:completed`, and `sync:error` events.
2900
+ *
2901
+ * @returns Summary with counts of tokens added and removed during sync.
2519
2902
  */
2520
2903
  sync(): Promise<{
2521
2904
  added: number;
2522
2905
  removed: number;
2523
2906
  }>;
2907
+ private _doSync;
2908
+ /**
2909
+ * Subscribe to 'storage:remote-updated' events from all token storage providers.
2910
+ * When a provider emits this event, a debounced sync is triggered.
2911
+ */
2912
+ private subscribeToStorageEvents;
2913
+ /**
2914
+ * Unsubscribe from all storage provider events and clear debounce timer.
2915
+ */
2916
+ private unsubscribeStorageEvents;
2917
+ /**
2918
+ * Debounced sync triggered by a storage:remote-updated event.
2919
+ * Waits 500ms to batch rapid updates, then performs sync.
2920
+ */
2921
+ private debouncedSyncFromRemoteUpdate;
2524
2922
  /**
2525
2923
  * Get all active token storage providers
2526
2924
  */
2527
2925
  private getTokenStorageProviders;
2528
2926
  /**
2529
- * Update token storage providers (called when providers are added/removed dynamically)
2927
+ * Replace the set of token storage providers at runtime.
2928
+ *
2929
+ * Use when providers are added or removed dynamically (e.g. IPFS node started).
2930
+ *
2931
+ * @param providers - New map of provider ID → TokenStorageProvider.
2530
2932
  */
2531
2933
  updateTokenStorageProviders(providers: Map<string, TokenStorageProvider<TxfStorageDataBase>>): void;
2532
2934
  /**
2533
- * Validate tokens with aggregator
2935
+ * Validate all tokens against the aggregator (oracle provider).
2936
+ *
2937
+ * Tokens that fail validation or are detected as spent are marked `'invalid'`.
2938
+ *
2939
+ * @returns Object with arrays of valid and invalid tokens.
2534
2940
  */
2535
2941
  validate(): Promise<{
2536
2942
  valid: Token[];
2537
2943
  invalid: Token[];
2538
2944
  }>;
2539
2945
  /**
2540
- * Get pending transfers
2946
+ * Get all in-progress (pending) outgoing transfers.
2947
+ *
2948
+ * @returns Array of {@link TransferResult} objects for transfers that have not yet completed.
2541
2949
  */
2542
2950
  getPendingTransfers(): TransferResult[];
2543
2951
  /**
@@ -2704,6 +3112,127 @@ declare class CommunicationsModule {
2704
3112
  }
2705
3113
  declare function createCommunicationsModule(config?: CommunicationsModuleConfig): CommunicationsModule;
2706
3114
 
3115
+ /**
3116
+ * Group Chat Module (NIP-29)
3117
+ *
3118
+ * Relay-based group chat using NIP-29 protocol on a dedicated Nostr relay.
3119
+ * Embeds its own NostrClient — does NOT share the wallet's TransportProvider.
3120
+ */
3121
+
3122
+ interface GroupChatModuleDependencies {
3123
+ identity: FullIdentity;
3124
+ storage: StorageProvider;
3125
+ emitEvent: <T extends SphereEventType>(type: T, data: SphereEventMap[T]) => void;
3126
+ }
3127
+ declare class GroupChatModule {
3128
+ private config;
3129
+ private deps;
3130
+ private client;
3131
+ private keyManager;
3132
+ private connected;
3133
+ private connecting;
3134
+ private connectPromise;
3135
+ private reconnectAttempts;
3136
+ private reconnectTimer;
3137
+ private subscriptionIds;
3138
+ private groups;
3139
+ private messages;
3140
+ private members;
3141
+ private processedEventIds;
3142
+ private pendingLeaves;
3143
+ private persistTimer;
3144
+ private persistPromise;
3145
+ private relayAdminPubkeys;
3146
+ private relayAdminFetchPromise;
3147
+ private messageHandlers;
3148
+ constructor(config?: GroupChatModuleConfig);
3149
+ initialize(deps: GroupChatModuleDependencies): void;
3150
+ load(): Promise<void>;
3151
+ destroy(): void;
3152
+ private destroyConnection;
3153
+ connect(): Promise<void>;
3154
+ getConnectionStatus(): boolean;
3155
+ private doConnect;
3156
+ private scheduleReconnect;
3157
+ private subscribeToJoinedGroups;
3158
+ private subscribeToGroup;
3159
+ private handleGroupEvent;
3160
+ private handleMetadataEvent;
3161
+ private handleModerationEvent;
3162
+ private updateMembersFromEvent;
3163
+ private updateAdminsFromEvent;
3164
+ private restoreJoinedGroups;
3165
+ fetchAvailableGroups(): Promise<GroupData[]>;
3166
+ joinGroup(groupId: string, inviteCode?: string): Promise<boolean>;
3167
+ leaveGroup(groupId: string): Promise<boolean>;
3168
+ createGroup(options: CreateGroupOptions): Promise<GroupData | null>;
3169
+ deleteGroup(groupId: string): Promise<boolean>;
3170
+ createInvite(groupId: string): Promise<string | null>;
3171
+ sendMessage(groupId: string, content: string, replyToId?: string): Promise<GroupMessageData | null>;
3172
+ fetchMessages(groupId: string, since?: number, limit?: number): Promise<GroupMessageData[]>;
3173
+ getGroups(): GroupData[];
3174
+ getGroup(groupId: string): GroupData | null;
3175
+ getMessages(groupId: string): GroupMessageData[];
3176
+ getMembers(groupId: string): GroupMemberData[];
3177
+ getMember(groupId: string, pubkey: string): GroupMemberData | null;
3178
+ getTotalUnreadCount(): number;
3179
+ markGroupAsRead(groupId: string): void;
3180
+ kickUser(groupId: string, userPubkey: string, reason?: string): Promise<boolean>;
3181
+ deleteMessage(groupId: string, messageId: string): Promise<boolean>;
3182
+ isCurrentUserAdmin(groupId: string): boolean;
3183
+ isCurrentUserModerator(groupId: string): boolean;
3184
+ /**
3185
+ * Check if current user can moderate a group:
3186
+ * - Group admin/moderator can always moderate their group
3187
+ * - Relay admins can moderate public groups
3188
+ */
3189
+ canModerateGroup(groupId: string): Promise<boolean>;
3190
+ isCurrentUserRelayAdmin(): Promise<boolean>;
3191
+ getCurrentUserRole(groupId: string): GroupRole | null;
3192
+ onMessage(handler: (message: GroupMessageData) => void): () => void;
3193
+ getRelayUrls(): string[];
3194
+ getMyPublicKey(): string | null;
3195
+ private fetchRelayAdmins;
3196
+ private doFetchRelayAdmins;
3197
+ private fetchGroupMetadataInternal;
3198
+ private fetchAndSaveMembers;
3199
+ private fetchGroupMembersInternal;
3200
+ private fetchGroupAdminsInternal;
3201
+ private saveMessageToMemory;
3202
+ private deleteMessageFromMemory;
3203
+ private saveMemberToMemory;
3204
+ private removeMemberFromMemory;
3205
+ private removeGroupFromMemory;
3206
+ private updateGroupLastMessage;
3207
+ private updateMemberNametag;
3208
+ private addProcessedEventId;
3209
+ /** Schedule a debounced persist (coalesces rapid event bursts). */
3210
+ private schedulePersist;
3211
+ /** Persist immediately (for explicit flush points). */
3212
+ private persistAll;
3213
+ private doPersistAll;
3214
+ private persistGroups;
3215
+ private persistMessages;
3216
+ private persistMembers;
3217
+ private persistProcessedEvents;
3218
+ private checkAndClearOnRelayChange;
3219
+ private wrapMessageContent;
3220
+ private unwrapMessageContent;
3221
+ private getGroupIdFromEvent;
3222
+ private getGroupIdFromMetadataEvent;
3223
+ private extractReplyTo;
3224
+ private extractPreviousIds;
3225
+ private parseGroupMetadata;
3226
+ /** Subscribe and track the subscription ID for cleanup. */
3227
+ private trackSubscription;
3228
+ /** Subscribe for a one-shot fetch, auto-unsubscribe on EOSE or timeout. */
3229
+ private oneshotSubscription;
3230
+ private ensureInitialized;
3231
+ private ensureConnected;
3232
+ private randomId;
3233
+ }
3234
+ declare function createGroupChatModule(config?: GroupChatModuleConfig): GroupChatModule;
3235
+
2707
3236
  /**
2708
3237
  * SDK2 Constants
2709
3238
  * Default configuration values and storage keys
@@ -2722,6 +3251,8 @@ declare const STORAGE_KEYS: {
2722
3251
  readonly MESSAGES: "messages";
2723
3252
  /** Transaction history for this address */
2724
3253
  readonly TRANSACTION_HISTORY: "transaction_history";
3254
+ /** Pending V5 finalization tokens (unconfirmed instant split tokens) */
3255
+ readonly PENDING_V5_TOKENS: "pending_v5_tokens";
2725
3256
  /** Encrypted BIP39 mnemonic */
2726
3257
  readonly MNEMONIC: "mnemonic";
2727
3258
  /** Encrypted master private key */
@@ -2746,6 +3277,16 @@ declare const STORAGE_KEYS: {
2746
3277
  readonly TRACKED_ADDRESSES: "tracked_addresses";
2747
3278
  /** Last processed Nostr wallet event timestamp (unix seconds), keyed per pubkey */
2748
3279
  readonly LAST_WALLET_EVENT_TS: "last_wallet_event_ts";
3280
+ /** Group chat: joined groups */
3281
+ readonly GROUP_CHAT_GROUPS: "group_chat_groups";
3282
+ /** Group chat: messages */
3283
+ readonly GROUP_CHAT_MESSAGES: "group_chat_messages";
3284
+ /** Group chat: members */
3285
+ readonly GROUP_CHAT_MEMBERS: "group_chat_members";
3286
+ /** Group chat: processed event IDs for deduplication */
3287
+ readonly GROUP_CHAT_PROCESSED_EVENTS: "group_chat_processed_events";
3288
+ /** Group chat: last used relay URL (stale data detection) */
3289
+ readonly GROUP_CHAT_RELAY_URL: "group_chat_relay_url";
2749
3290
  };
2750
3291
  /** Default Nostr relays */
2751
3292
  declare const DEFAULT_NOSTR_RELAYS: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
@@ -2764,6 +3305,44 @@ declare const NOSTR_EVENT_KINDS: {
2764
3305
  /** Public broadcast */
2765
3306
  readonly BROADCAST: 1;
2766
3307
  };
3308
+ /**
3309
+ * NIP-29 Event Kinds for relay-based group chat
3310
+ * https://github.com/nostr-protocol/nips/blob/master/29.md
3311
+ */
3312
+ declare const NIP29_KINDS: {
3313
+ /** Chat message sent to group */
3314
+ readonly CHAT_MESSAGE: 9;
3315
+ /** Thread root message */
3316
+ readonly THREAD_ROOT: 11;
3317
+ /** Thread reply message */
3318
+ readonly THREAD_REPLY: 12;
3319
+ /** User join request */
3320
+ readonly JOIN_REQUEST: 9021;
3321
+ /** User leave request */
3322
+ readonly LEAVE_REQUEST: 9022;
3323
+ /** Admin: add/update user */
3324
+ readonly PUT_USER: 9000;
3325
+ /** Admin: remove user */
3326
+ readonly REMOVE_USER: 9001;
3327
+ /** Admin: edit group metadata */
3328
+ readonly EDIT_METADATA: 9002;
3329
+ /** Admin: delete event */
3330
+ readonly DELETE_EVENT: 9005;
3331
+ /** Admin: create group */
3332
+ readonly CREATE_GROUP: 9007;
3333
+ /** Admin: delete group */
3334
+ readonly DELETE_GROUP: 9008;
3335
+ /** Admin: create invite code */
3336
+ readonly CREATE_INVITE: 9009;
3337
+ /** Relay-signed group metadata */
3338
+ readonly GROUP_METADATA: 39000;
3339
+ /** Relay-signed group admins */
3340
+ readonly GROUP_ADMINS: 39001;
3341
+ /** Relay-signed group members */
3342
+ readonly GROUP_MEMBERS: 39002;
3343
+ /** Relay-signed group roles */
3344
+ readonly GROUP_ROLES: 39003;
3345
+ };
2767
3346
  /**
2768
3347
  * Default aggregator URL
2769
3348
  * Note: The aggregator is conceptually an oracle - a trusted service that provides
@@ -2795,6 +3374,8 @@ declare const DEFAULT_ELECTRUM_URL: "wss://fulcrum.alpha.unicity.network:50004";
2795
3374
  declare const TEST_ELECTRUM_URL: "wss://fulcrum.alpha.testnet.unicity.network:50004";
2796
3375
  /** Testnet Nostr relays */
2797
3376
  declare const TEST_NOSTR_RELAYS: readonly ["wss://nostr-relay.testnet.unicity.network"];
3377
+ /** Default group chat relays (NIP-29 Zooid relay) */
3378
+ declare const DEFAULT_GROUP_RELAYS: readonly ["wss://sphere-relay.unicity.network"];
2798
3379
  /** Network configurations */
2799
3380
  declare const NETWORKS: {
2800
3381
  readonly mainnet: {
@@ -2803,6 +3384,7 @@ declare const NETWORKS: {
2803
3384
  readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
2804
3385
  readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
2805
3386
  readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
3387
+ readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
2806
3388
  };
2807
3389
  readonly testnet: {
2808
3390
  readonly name: "Testnet";
@@ -2810,6 +3392,7 @@ declare const NETWORKS: {
2810
3392
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
2811
3393
  readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
2812
3394
  readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3395
+ readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
2813
3396
  };
2814
3397
  readonly dev: {
2815
3398
  readonly name: "Development";
@@ -2817,6 +3400,7 @@ declare const NETWORKS: {
2817
3400
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
2818
3401
  readonly ipfsGateways: readonly ["https://ipfs.unicity.network", "https://dweb.link", "https://ipfs.io"];
2819
3402
  readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3403
+ readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
2820
3404
  };
2821
3405
  };
2822
3406
  type NetworkType = keyof typeof NETWORKS;
@@ -2966,6 +3550,8 @@ interface LegacyFileImportOptions {
2966
3550
  onDecryptProgress?: DecryptionProgressCallback;
2967
3551
  }
2968
3552
 
3553
+ declare function isValidNametag(nametag: string): boolean;
3554
+
2969
3555
  /** Options for creating a new wallet */
2970
3556
  interface SphereCreateOptions {
2971
3557
  /** BIP39 mnemonic (12 or 24 words) */
@@ -2992,6 +3578,8 @@ interface SphereCreateOptions {
2992
3578
  * Use createBrowserProviders({ network: 'testnet' }) to set up testnet providers.
2993
3579
  */
2994
3580
  network?: NetworkType;
3581
+ /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3582
+ groupChat?: GroupChatModuleConfig | boolean;
2995
3583
  }
2996
3584
  /** Options for loading existing wallet */
2997
3585
  interface SphereLoadOptions {
@@ -3013,6 +3601,8 @@ interface SphereLoadOptions {
3013
3601
  * Use createBrowserProviders({ network: 'testnet' }) to set up testnet providers.
3014
3602
  */
3015
3603
  network?: NetworkType;
3604
+ /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3605
+ groupChat?: GroupChatModuleConfig | boolean;
3016
3606
  }
3017
3607
  /** Options for importing a wallet */
3018
3608
  interface SphereImportOptions {
@@ -3042,6 +3632,8 @@ interface SphereImportOptions {
3042
3632
  l1?: L1Config;
3043
3633
  /** Optional price provider for fiat conversion */
3044
3634
  price?: PriceProvider;
3635
+ /** Group chat configuration (NIP-29). Omit to disable groupchat. */
3636
+ groupChat?: GroupChatModuleConfig | boolean;
3045
3637
  }
3046
3638
  /** L1 (ALPHA blockchain) configuration */
3047
3639
  interface L1Config {
@@ -3080,6 +3672,13 @@ interface SphereInitOptions {
3080
3672
  * Use createBrowserProviders({ network: 'testnet' }) to set up testnet providers.
3081
3673
  */
3082
3674
  network?: NetworkType;
3675
+ /**
3676
+ * Group chat configuration (NIP-29).
3677
+ * - `true`: Enable with network-default relays
3678
+ * - `GroupChatModuleConfig`: Enable with custom config
3679
+ * - Omit/undefined: No groupchat module
3680
+ */
3681
+ groupChat?: GroupChatModuleConfig | boolean;
3083
3682
  }
3084
3683
  /** Result of init operation */
3085
3684
  interface SphereInitResult {
@@ -3115,6 +3714,7 @@ declare class Sphere {
3115
3714
  private _priceProvider;
3116
3715
  private _payments;
3117
3716
  private _communications;
3717
+ private _groupChat;
3118
3718
  private eventHandlers;
3119
3719
  private constructor();
3120
3720
  /**
@@ -3147,6 +3747,18 @@ declare class Sphere {
3147
3747
  * ```
3148
3748
  */
3149
3749
  static init(options: SphereInitOptions): Promise<SphereInitResult>;
3750
+ /**
3751
+ * Resolve groupChat config from init/create/load options.
3752
+ * - `true` → use network-default relays
3753
+ * - `GroupChatModuleConfig` → pass through
3754
+ * - `undefined` → no groupchat
3755
+ */
3756
+ /**
3757
+ * Resolve GroupChat config from Sphere.init() options.
3758
+ * Note: impl/shared/resolvers.ts has a similar resolver for provider-level config
3759
+ * (different input shape: { enabled?, relays? }). Both fill relay URLs from network defaults.
3760
+ */
3761
+ private static resolveGroupChatConfig;
3150
3762
  /**
3151
3763
  * Create new wallet with mnemonic
3152
3764
  */
@@ -3203,6 +3815,8 @@ declare class Sphere {
3203
3815
  get payments(): PaymentsModule;
3204
3816
  /** Communications module */
3205
3817
  get communications(): CommunicationsModule;
3818
+ /** Group chat module (NIP-29). Null if not configured. */
3819
+ get groupChat(): GroupChatModule | null;
3206
3820
  /** Current identity (public info only) */
3207
3821
  get identity(): Identity | null;
3208
3822
  /** Is ready */
@@ -3696,9 +4310,9 @@ declare class Sphere {
3696
4310
  */
3697
4311
  private recoverNametagFromTransport;
3698
4312
  /**
3699
- * Validate nametag format
4313
+ * Strip @ prefix and normalize a nametag (lowercase, phone E.164, strip @unicity suffix).
3700
4314
  */
3701
- private validateNametag;
4315
+ private cleanNametag;
3702
4316
  destroy(): Promise<void>;
3703
4317
  private storeMnemonic;
3704
4318
  private storeMasterKey;
@@ -3990,7 +4604,7 @@ declare function txfToToken(tokenId: string, txf: TxfToken): Token;
3990
4604
  * Build TXF storage data from tokens and metadata
3991
4605
  */
3992
4606
  declare function buildTxfStorageData(tokens: Token[], meta: Omit<TxfMeta$1, 'formatVersion'>, options?: {
3993
- nametag?: NametagData;
4607
+ nametags?: NametagData[];
3994
4608
  tombstones?: TombstoneEntry[];
3995
4609
  archivedTokens?: Map<string, TxfToken>;
3996
4610
  forkedTokens?: Map<string, TxfToken>;
@@ -4001,7 +4615,7 @@ declare function buildTxfStorageData(tokens: Token[], meta: Omit<TxfMeta$1, 'for
4001
4615
  interface ParsedStorageData {
4002
4616
  tokens: Token[];
4003
4617
  meta: TxfMeta$1 | null;
4004
- nametag: NametagData | null;
4618
+ nametags: NametagData[];
4005
4619
  tombstones: TombstoneEntry[];
4006
4620
  archivedTokens: Map<string, TxfToken>;
4007
4621
  forkedTokens: Map<string, TxfToken>;
@@ -5047,4 +5661,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
5047
5661
  */
5048
5662
  declare function getCoinIdByName(name: string): string | undefined;
5049
5663
 
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 };
5664
+ 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, type CreateGroupOptions, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, 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, NIP29_KINDS, 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, createGroupChatModule, 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 };