@unicitylabs/sphere-sdk 0.4.6 → 0.4.8

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
@@ -1503,6 +1503,14 @@ interface TransportProvider extends BaseProvider {
1503
1503
  * @returns PeerInfo or null if no binding found
1504
1504
  */
1505
1505
  resolveTransportPubkeyInfo?(transportPubkey: string): Promise<PeerInfo | null>;
1506
+ /**
1507
+ * Batch-resolve multiple transport pubkeys to peer info.
1508
+ * Used for HD address discovery: derives transport pubkeys for indices 0..N
1509
+ * and queries binding events in a single batch.
1510
+ * @param transportPubkeys - Array of transport-specific pubkeys to look up
1511
+ * @returns Array of PeerInfo for pubkeys that have binding events (may be shorter than input)
1512
+ */
1513
+ discoverAddresses?(transportPubkeys: string[]): Promise<PeerInfo[]>;
1506
1514
  /**
1507
1515
  * Recover nametag for current identity by decrypting stored encrypted nametag
1508
1516
  * Used after wallet import to recover associated nametag
@@ -3446,6 +3454,12 @@ declare class GroupChatModule {
3446
3454
  onMessage(handler: (message: GroupMessageData) => void): () => void;
3447
3455
  getRelayUrls(): string[];
3448
3456
  getMyPublicKey(): string | null;
3457
+ /**
3458
+ * Returns the latest message timestamp (in Nostr seconds) across the given groups,
3459
+ * or 0 if no messages exist. Used to set `since` on subscriptions so the relay
3460
+ * only sends events we don't already have.
3461
+ */
3462
+ private getLatestMessageTimestamp;
3449
3463
  private fetchRelayAdmins;
3450
3464
  private doFetchRelayAdmins;
3451
3465
  private fetchGroupMetadataInternal;
@@ -3866,9 +3880,9 @@ declare const COIN_TYPES: {
3866
3880
  readonly TEST: "TEST";
3867
3881
  };
3868
3882
  /** Default Fulcrum electrum server for mainnet */
3869
- declare const DEFAULT_ELECTRUM_URL: "wss://fulcrum.alpha.unicity.network:50004";
3883
+ declare const DEFAULT_ELECTRUM_URL: "wss://fulcrum.unicity.network:50004";
3870
3884
  /** Testnet Fulcrum electrum server */
3871
- declare const TEST_ELECTRUM_URL: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3885
+ declare const TEST_ELECTRUM_URL: "wss://fulcrum.unicity.network:50004";
3872
3886
  /** Testnet Nostr relays */
3873
3887
  declare const TEST_NOSTR_RELAYS: readonly ["wss://nostr-relay.testnet.unicity.network"];
3874
3888
  /** Default group chat relays (NIP-29 Zooid relay) */
@@ -3880,7 +3894,7 @@ declare const NETWORKS: {
3880
3894
  readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
3881
3895
  readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
3882
3896
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3883
- readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
3897
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
3884
3898
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3885
3899
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3886
3900
  };
@@ -3889,7 +3903,7 @@ declare const NETWORKS: {
3889
3903
  readonly aggregatorUrl: "https://goggregator-test.unicity.network";
3890
3904
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
3891
3905
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3892
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3906
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
3893
3907
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3894
3908
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3895
3909
  };
@@ -3898,7 +3912,7 @@ declare const NETWORKS: {
3898
3912
  readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
3899
3913
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
3900
3914
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3901
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3915
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
3902
3916
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3903
3917
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3904
3918
  };
@@ -3990,6 +4004,70 @@ interface ScanAddressesResult {
3990
4004
  scannedCount: number;
3991
4005
  }
3992
4006
 
4007
+ /**
4008
+ * HD Address Discovery — discover previously used addresses via transport binding events.
4009
+ *
4010
+ * Derives transport pubkeys for HD indices and batch-queries the relay.
4011
+ * Complements L1 scan (scan.ts) by finding L3-only addresses.
4012
+ */
4013
+
4014
+ /** Progress callback for address discovery */
4015
+ interface DiscoverAddressProgress {
4016
+ /** Current batch being queried */
4017
+ currentBatch: number;
4018
+ /** Total batches planned */
4019
+ totalBatches: number;
4020
+ /** Number of addresses discovered so far */
4021
+ discoveredCount: number;
4022
+ /** Current gap count (consecutive empty indices) */
4023
+ currentGap: number;
4024
+ /** Phase: 'transport' or 'l1' */
4025
+ phase: 'transport' | 'l1';
4026
+ }
4027
+ /** Single discovered address result */
4028
+ interface DiscoveredAddress {
4029
+ /** HD derivation index */
4030
+ index: number;
4031
+ /** L1 bech32 address (alpha1...) */
4032
+ l1Address: string;
4033
+ /** L3 DIRECT address */
4034
+ directAddress: string;
4035
+ /** 33-byte compressed chain pubkey */
4036
+ chainPubkey: string;
4037
+ /** Nametag (from binding event) */
4038
+ nametag?: string;
4039
+ /** L1 balance in ALPHA (0 if only discovered via transport) */
4040
+ l1Balance: number;
4041
+ /** Discovery source */
4042
+ source: 'transport' | 'l1' | 'both';
4043
+ }
4044
+ /** Options for address discovery */
4045
+ interface DiscoverAddressesOptions {
4046
+ /** Max HD indices to probe (default: 50) */
4047
+ maxAddresses?: number;
4048
+ /** Stop after N consecutive empty indices (default: 20) */
4049
+ gapLimit?: number;
4050
+ /** Batch size for transport queries (default: 20) */
4051
+ batchSize?: number;
4052
+ /** Also run L1 balance scan (default: true) */
4053
+ includeL1Scan?: boolean;
4054
+ /** Progress callback */
4055
+ onProgress?: (progress: DiscoverAddressProgress) => void;
4056
+ /** Abort signal */
4057
+ signal?: AbortSignal;
4058
+ /** Auto-track discovered addresses (default: true) */
4059
+ autoTrack?: boolean;
4060
+ }
4061
+ /** Result of address discovery */
4062
+ interface DiscoverAddressesResult {
4063
+ /** All discovered addresses */
4064
+ addresses: DiscoveredAddress[];
4065
+ /** Total indices scanned */
4066
+ scannedCount: number;
4067
+ /** Whether scan was aborted */
4068
+ aborted: boolean;
4069
+ }
4070
+
3993
4071
  /**
3994
4072
  * Legacy File Serialization Types
3995
4073
  */
@@ -4052,6 +4130,17 @@ interface LegacyFileImportOptions {
4052
4130
 
4053
4131
  declare function isValidNametag(nametag: string): boolean;
4054
4132
 
4133
+ /** Steps reported by the onProgress callback during wallet init/create/load/import */
4134
+ type InitProgressStep = 'clearing' | 'storing_keys' | 'initializing' | 'recovering_nametag' | 'registering_nametag' | 'syncing_identity' | 'syncing_tokens' | 'discovering_addresses' | 'finalizing' | 'complete';
4135
+ /** Progress info passed to onProgress callback */
4136
+ interface InitProgress {
4137
+ /** Current step identifier */
4138
+ readonly step: InitProgressStep;
4139
+ /** Human-readable description of what's happening */
4140
+ readonly message: string;
4141
+ }
4142
+ /** Callback for tracking wallet initialization progress */
4143
+ type InitProgressCallback = (progress: InitProgress) => void;
4055
4144
  /** Options for creating a new wallet */
4056
4145
  interface SphereCreateOptions {
4057
4146
  /** BIP39 mnemonic (12 or 24 words) */
@@ -4084,6 +4173,15 @@ interface SphereCreateOptions {
4084
4173
  market?: MarketModuleConfig | boolean;
4085
4174
  /** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
4086
4175
  password?: string;
4176
+ /**
4177
+ * Auto-discover previously used HD addresses after creation.
4178
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4179
+ * - DiscoverAddressesOptions: custom config
4180
+ * - false/undefined: no auto-discovery (default)
4181
+ */
4182
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4183
+ /** Optional callback to report initialization progress steps */
4184
+ onProgress?: InitProgressCallback;
4087
4185
  }
4088
4186
  /** Options for loading existing wallet */
4089
4187
  interface SphereLoadOptions {
@@ -4111,6 +4209,15 @@ interface SphereLoadOptions {
4111
4209
  market?: MarketModuleConfig | boolean;
4112
4210
  /** Optional password to decrypt the wallet. Must match the password used during creation. */
4113
4211
  password?: string;
4212
+ /**
4213
+ * Auto-discover previously used HD addresses on load.
4214
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4215
+ * - DiscoverAddressesOptions: custom config
4216
+ * - false/undefined: no auto-discovery (default)
4217
+ */
4218
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4219
+ /** Optional callback to report initialization progress steps */
4220
+ onProgress?: InitProgressCallback;
4114
4221
  }
4115
4222
  /** Options for importing a wallet */
4116
4223
  interface SphereImportOptions {
@@ -4146,6 +4253,15 @@ interface SphereImportOptions {
4146
4253
  market?: MarketModuleConfig | boolean;
4147
4254
  /** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
4148
4255
  password?: string;
4256
+ /**
4257
+ * Auto-discover previously used HD addresses after import.
4258
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4259
+ * - DiscoverAddressesOptions: custom config
4260
+ * - false/undefined: no auto-discovery (default)
4261
+ */
4262
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4263
+ /** Optional callback to report initialization progress steps */
4264
+ onProgress?: InitProgressCallback;
4149
4265
  }
4150
4266
  /** L1 (ALPHA blockchain) configuration */
4151
4267
  interface L1Config {
@@ -4195,6 +4311,16 @@ interface SphereInitOptions {
4195
4311
  market?: MarketModuleConfig | boolean;
4196
4312
  /** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
4197
4313
  password?: string;
4314
+ /**
4315
+ * Auto-discover previously used HD addresses when creating from mnemonic.
4316
+ * Only applies when wallet is newly created (not on load of existing wallet).
4317
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4318
+ * - DiscoverAddressesOptions: custom config
4319
+ * - false/undefined: no auto-discovery (default)
4320
+ */
4321
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4322
+ /** Optional callback to report initialization progress steps */
4323
+ onProgress?: InitProgressCallback;
4198
4324
  }
4199
4325
  /** Result of init operation */
4200
4326
  interface SphereInitResult {
@@ -4466,14 +4592,9 @@ declare class Sphere {
4466
4592
  * });
4467
4593
  * ```
4468
4594
  */
4469
- static importFromJSON(options: {
4595
+ static importFromJSON(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
4470
4596
  jsonContent: string;
4471
4597
  password?: string;
4472
- storage: StorageProvider;
4473
- transport: TransportProvider;
4474
- oracle: OracleProvider;
4475
- tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
4476
- l1?: L1Config;
4477
4598
  }): Promise<{
4478
4599
  success: boolean;
4479
4600
  mnemonic?: string;
@@ -4509,7 +4630,7 @@ declare class Sphere {
4509
4630
  * });
4510
4631
  * ```
4511
4632
  */
4512
- static importFromLegacyFile(options: {
4633
+ static importFromLegacyFile(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
4513
4634
  /** File content - Uint8Array for .dat, string for .txt */
4514
4635
  fileContent: string | Uint8Array;
4515
4636
  /** File name (used for type detection) */
@@ -4518,18 +4639,6 @@ declare class Sphere {
4518
4639
  password?: string;
4519
4640
  /** Progress callback for long decryption operations */
4520
4641
  onDecryptProgress?: DecryptionProgressCallback;
4521
- /** Storage provider instance */
4522
- storage: StorageProvider;
4523
- /** Transport provider instance */
4524
- transport: TransportProvider;
4525
- /** Oracle provider instance */
4526
- oracle: OracleProvider;
4527
- /** Optional token storage provider */
4528
- tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
4529
- /** Optional nametag to register */
4530
- nametag?: string;
4531
- /** L1 (ALPHA blockchain) configuration */
4532
- l1?: L1Config;
4533
4642
  }): Promise<{
4534
4643
  success: boolean;
4535
4644
  sphere?: Sphere;
@@ -4630,6 +4739,11 @@ declare class Sphere {
4630
4739
  switchToAddress(index: number, options?: {
4631
4740
  nametag?: string;
4632
4741
  }): Promise<void>;
4742
+ /**
4743
+ * Background transport sync and nametag operations after address switch.
4744
+ * Runs after switchToAddress returns so L1/L3 queries can start immediately.
4745
+ */
4746
+ private postSwitchSync;
4633
4747
  /**
4634
4748
  * Re-initialize modules after address switch
4635
4749
  */
@@ -4719,6 +4833,22 @@ declare class Sphere {
4719
4833
  hidden: boolean;
4720
4834
  nametag?: string;
4721
4835
  }>): Promise<void>;
4836
+ /**
4837
+ * Discover previously used HD addresses.
4838
+ *
4839
+ * Primary: queries Nostr relay for identity binding events (fast, single batch query).
4840
+ * Secondary: runs L1 balance scan to find legacy addresses with no binding event.
4841
+ *
4842
+ * @example
4843
+ * ```ts
4844
+ * const result = await sphere.discoverAddresses();
4845
+ * console.log(`Found ${result.addresses.length} addresses`);
4846
+ *
4847
+ * // With auto-tracking
4848
+ * await sphere.discoverAddresses({ autoTrack: true });
4849
+ * ```
4850
+ */
4851
+ discoverAddresses(options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
4722
4852
  /**
4723
4853
  * Get aggregated status of all providers, grouped by role.
4724
4854
  *
@@ -6440,4 +6570,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
6440
6570
  */
6441
6571
  declare function getCoinIdByName(name: string): string | undefined;
6442
6572
 
6443
- 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, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, 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_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, 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 IntentStatus, type IntentType, 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 MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, 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 PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, 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 SphereStatus, 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, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, 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, getAddressId, getAddressStorageKey, 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 };
6573
+ 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, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, 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_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InitProgress, type InitProgressCallback, type InitProgressStep, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, 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 MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, 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 PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, 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, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, 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, getAddressId, getAddressStorageKey, 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 };
package/dist/index.d.ts CHANGED
@@ -1503,6 +1503,14 @@ interface TransportProvider extends BaseProvider {
1503
1503
  * @returns PeerInfo or null if no binding found
1504
1504
  */
1505
1505
  resolveTransportPubkeyInfo?(transportPubkey: string): Promise<PeerInfo | null>;
1506
+ /**
1507
+ * Batch-resolve multiple transport pubkeys to peer info.
1508
+ * Used for HD address discovery: derives transport pubkeys for indices 0..N
1509
+ * and queries binding events in a single batch.
1510
+ * @param transportPubkeys - Array of transport-specific pubkeys to look up
1511
+ * @returns Array of PeerInfo for pubkeys that have binding events (may be shorter than input)
1512
+ */
1513
+ discoverAddresses?(transportPubkeys: string[]): Promise<PeerInfo[]>;
1506
1514
  /**
1507
1515
  * Recover nametag for current identity by decrypting stored encrypted nametag
1508
1516
  * Used after wallet import to recover associated nametag
@@ -3446,6 +3454,12 @@ declare class GroupChatModule {
3446
3454
  onMessage(handler: (message: GroupMessageData) => void): () => void;
3447
3455
  getRelayUrls(): string[];
3448
3456
  getMyPublicKey(): string | null;
3457
+ /**
3458
+ * Returns the latest message timestamp (in Nostr seconds) across the given groups,
3459
+ * or 0 if no messages exist. Used to set `since` on subscriptions so the relay
3460
+ * only sends events we don't already have.
3461
+ */
3462
+ private getLatestMessageTimestamp;
3449
3463
  private fetchRelayAdmins;
3450
3464
  private doFetchRelayAdmins;
3451
3465
  private fetchGroupMetadataInternal;
@@ -3866,9 +3880,9 @@ declare const COIN_TYPES: {
3866
3880
  readonly TEST: "TEST";
3867
3881
  };
3868
3882
  /** Default Fulcrum electrum server for mainnet */
3869
- declare const DEFAULT_ELECTRUM_URL: "wss://fulcrum.alpha.unicity.network:50004";
3883
+ declare const DEFAULT_ELECTRUM_URL: "wss://fulcrum.unicity.network:50004";
3870
3884
  /** Testnet Fulcrum electrum server */
3871
- declare const TEST_ELECTRUM_URL: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3885
+ declare const TEST_ELECTRUM_URL: "wss://fulcrum.unicity.network:50004";
3872
3886
  /** Testnet Nostr relays */
3873
3887
  declare const TEST_NOSTR_RELAYS: readonly ["wss://nostr-relay.testnet.unicity.network"];
3874
3888
  /** Default group chat relays (NIP-29 Zooid relay) */
@@ -3880,7 +3894,7 @@ declare const NETWORKS: {
3880
3894
  readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
3881
3895
  readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
3882
3896
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3883
- readonly electrumUrl: "wss://fulcrum.alpha.unicity.network:50004";
3897
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
3884
3898
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3885
3899
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3886
3900
  };
@@ -3889,7 +3903,7 @@ declare const NETWORKS: {
3889
3903
  readonly aggregatorUrl: "https://goggregator-test.unicity.network";
3890
3904
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
3891
3905
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3892
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3906
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
3893
3907
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3894
3908
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3895
3909
  };
@@ -3898,7 +3912,7 @@ declare const NETWORKS: {
3898
3912
  readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
3899
3913
  readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
3900
3914
  readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
3901
- readonly electrumUrl: "wss://fulcrum.alpha.testnet.unicity.network:50004";
3915
+ readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
3902
3916
  readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
3903
3917
  readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
3904
3918
  };
@@ -3990,6 +4004,70 @@ interface ScanAddressesResult {
3990
4004
  scannedCount: number;
3991
4005
  }
3992
4006
 
4007
+ /**
4008
+ * HD Address Discovery — discover previously used addresses via transport binding events.
4009
+ *
4010
+ * Derives transport pubkeys for HD indices and batch-queries the relay.
4011
+ * Complements L1 scan (scan.ts) by finding L3-only addresses.
4012
+ */
4013
+
4014
+ /** Progress callback for address discovery */
4015
+ interface DiscoverAddressProgress {
4016
+ /** Current batch being queried */
4017
+ currentBatch: number;
4018
+ /** Total batches planned */
4019
+ totalBatches: number;
4020
+ /** Number of addresses discovered so far */
4021
+ discoveredCount: number;
4022
+ /** Current gap count (consecutive empty indices) */
4023
+ currentGap: number;
4024
+ /** Phase: 'transport' or 'l1' */
4025
+ phase: 'transport' | 'l1';
4026
+ }
4027
+ /** Single discovered address result */
4028
+ interface DiscoveredAddress {
4029
+ /** HD derivation index */
4030
+ index: number;
4031
+ /** L1 bech32 address (alpha1...) */
4032
+ l1Address: string;
4033
+ /** L3 DIRECT address */
4034
+ directAddress: string;
4035
+ /** 33-byte compressed chain pubkey */
4036
+ chainPubkey: string;
4037
+ /** Nametag (from binding event) */
4038
+ nametag?: string;
4039
+ /** L1 balance in ALPHA (0 if only discovered via transport) */
4040
+ l1Balance: number;
4041
+ /** Discovery source */
4042
+ source: 'transport' | 'l1' | 'both';
4043
+ }
4044
+ /** Options for address discovery */
4045
+ interface DiscoverAddressesOptions {
4046
+ /** Max HD indices to probe (default: 50) */
4047
+ maxAddresses?: number;
4048
+ /** Stop after N consecutive empty indices (default: 20) */
4049
+ gapLimit?: number;
4050
+ /** Batch size for transport queries (default: 20) */
4051
+ batchSize?: number;
4052
+ /** Also run L1 balance scan (default: true) */
4053
+ includeL1Scan?: boolean;
4054
+ /** Progress callback */
4055
+ onProgress?: (progress: DiscoverAddressProgress) => void;
4056
+ /** Abort signal */
4057
+ signal?: AbortSignal;
4058
+ /** Auto-track discovered addresses (default: true) */
4059
+ autoTrack?: boolean;
4060
+ }
4061
+ /** Result of address discovery */
4062
+ interface DiscoverAddressesResult {
4063
+ /** All discovered addresses */
4064
+ addresses: DiscoveredAddress[];
4065
+ /** Total indices scanned */
4066
+ scannedCount: number;
4067
+ /** Whether scan was aborted */
4068
+ aborted: boolean;
4069
+ }
4070
+
3993
4071
  /**
3994
4072
  * Legacy File Serialization Types
3995
4073
  */
@@ -4052,6 +4130,17 @@ interface LegacyFileImportOptions {
4052
4130
 
4053
4131
  declare function isValidNametag(nametag: string): boolean;
4054
4132
 
4133
+ /** Steps reported by the onProgress callback during wallet init/create/load/import */
4134
+ type InitProgressStep = 'clearing' | 'storing_keys' | 'initializing' | 'recovering_nametag' | 'registering_nametag' | 'syncing_identity' | 'syncing_tokens' | 'discovering_addresses' | 'finalizing' | 'complete';
4135
+ /** Progress info passed to onProgress callback */
4136
+ interface InitProgress {
4137
+ /** Current step identifier */
4138
+ readonly step: InitProgressStep;
4139
+ /** Human-readable description of what's happening */
4140
+ readonly message: string;
4141
+ }
4142
+ /** Callback for tracking wallet initialization progress */
4143
+ type InitProgressCallback = (progress: InitProgress) => void;
4055
4144
  /** Options for creating a new wallet */
4056
4145
  interface SphereCreateOptions {
4057
4146
  /** BIP39 mnemonic (12 or 24 words) */
@@ -4084,6 +4173,15 @@ interface SphereCreateOptions {
4084
4173
  market?: MarketModuleConfig | boolean;
4085
4174
  /** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
4086
4175
  password?: string;
4176
+ /**
4177
+ * Auto-discover previously used HD addresses after creation.
4178
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4179
+ * - DiscoverAddressesOptions: custom config
4180
+ * - false/undefined: no auto-discovery (default)
4181
+ */
4182
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4183
+ /** Optional callback to report initialization progress steps */
4184
+ onProgress?: InitProgressCallback;
4087
4185
  }
4088
4186
  /** Options for loading existing wallet */
4089
4187
  interface SphereLoadOptions {
@@ -4111,6 +4209,15 @@ interface SphereLoadOptions {
4111
4209
  market?: MarketModuleConfig | boolean;
4112
4210
  /** Optional password to decrypt the wallet. Must match the password used during creation. */
4113
4211
  password?: string;
4212
+ /**
4213
+ * Auto-discover previously used HD addresses on load.
4214
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4215
+ * - DiscoverAddressesOptions: custom config
4216
+ * - false/undefined: no auto-discovery (default)
4217
+ */
4218
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4219
+ /** Optional callback to report initialization progress steps */
4220
+ onProgress?: InitProgressCallback;
4114
4221
  }
4115
4222
  /** Options for importing a wallet */
4116
4223
  interface SphereImportOptions {
@@ -4146,6 +4253,15 @@ interface SphereImportOptions {
4146
4253
  market?: MarketModuleConfig | boolean;
4147
4254
  /** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
4148
4255
  password?: string;
4256
+ /**
4257
+ * Auto-discover previously used HD addresses after import.
4258
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4259
+ * - DiscoverAddressesOptions: custom config
4260
+ * - false/undefined: no auto-discovery (default)
4261
+ */
4262
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4263
+ /** Optional callback to report initialization progress steps */
4264
+ onProgress?: InitProgressCallback;
4149
4265
  }
4150
4266
  /** L1 (ALPHA blockchain) configuration */
4151
4267
  interface L1Config {
@@ -4195,6 +4311,16 @@ interface SphereInitOptions {
4195
4311
  market?: MarketModuleConfig | boolean;
4196
4312
  /** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
4197
4313
  password?: string;
4314
+ /**
4315
+ * Auto-discover previously used HD addresses when creating from mnemonic.
4316
+ * Only applies when wallet is newly created (not on load of existing wallet).
4317
+ * - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
4318
+ * - DiscoverAddressesOptions: custom config
4319
+ * - false/undefined: no auto-discovery (default)
4320
+ */
4321
+ discoverAddresses?: boolean | DiscoverAddressesOptions;
4322
+ /** Optional callback to report initialization progress steps */
4323
+ onProgress?: InitProgressCallback;
4198
4324
  }
4199
4325
  /** Result of init operation */
4200
4326
  interface SphereInitResult {
@@ -4466,14 +4592,9 @@ declare class Sphere {
4466
4592
  * });
4467
4593
  * ```
4468
4594
  */
4469
- static importFromJSON(options: {
4595
+ static importFromJSON(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
4470
4596
  jsonContent: string;
4471
4597
  password?: string;
4472
- storage: StorageProvider;
4473
- transport: TransportProvider;
4474
- oracle: OracleProvider;
4475
- tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
4476
- l1?: L1Config;
4477
4598
  }): Promise<{
4478
4599
  success: boolean;
4479
4600
  mnemonic?: string;
@@ -4509,7 +4630,7 @@ declare class Sphere {
4509
4630
  * });
4510
4631
  * ```
4511
4632
  */
4512
- static importFromLegacyFile(options: {
4633
+ static importFromLegacyFile(options: Omit<SphereImportOptions, 'mnemonic' | 'masterKey' | 'chainCode' | 'derivationPath' | 'basePath' | 'derivationMode'> & {
4513
4634
  /** File content - Uint8Array for .dat, string for .txt */
4514
4635
  fileContent: string | Uint8Array;
4515
4636
  /** File name (used for type detection) */
@@ -4518,18 +4639,6 @@ declare class Sphere {
4518
4639
  password?: string;
4519
4640
  /** Progress callback for long decryption operations */
4520
4641
  onDecryptProgress?: DecryptionProgressCallback;
4521
- /** Storage provider instance */
4522
- storage: StorageProvider;
4523
- /** Transport provider instance */
4524
- transport: TransportProvider;
4525
- /** Oracle provider instance */
4526
- oracle: OracleProvider;
4527
- /** Optional token storage provider */
4528
- tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
4529
- /** Optional nametag to register */
4530
- nametag?: string;
4531
- /** L1 (ALPHA blockchain) configuration */
4532
- l1?: L1Config;
4533
4642
  }): Promise<{
4534
4643
  success: boolean;
4535
4644
  sphere?: Sphere;
@@ -4630,6 +4739,11 @@ declare class Sphere {
4630
4739
  switchToAddress(index: number, options?: {
4631
4740
  nametag?: string;
4632
4741
  }): Promise<void>;
4742
+ /**
4743
+ * Background transport sync and nametag operations after address switch.
4744
+ * Runs after switchToAddress returns so L1/L3 queries can start immediately.
4745
+ */
4746
+ private postSwitchSync;
4633
4747
  /**
4634
4748
  * Re-initialize modules after address switch
4635
4749
  */
@@ -4719,6 +4833,22 @@ declare class Sphere {
4719
4833
  hidden: boolean;
4720
4834
  nametag?: string;
4721
4835
  }>): Promise<void>;
4836
+ /**
4837
+ * Discover previously used HD addresses.
4838
+ *
4839
+ * Primary: queries Nostr relay for identity binding events (fast, single batch query).
4840
+ * Secondary: runs L1 balance scan to find legacy addresses with no binding event.
4841
+ *
4842
+ * @example
4843
+ * ```ts
4844
+ * const result = await sphere.discoverAddresses();
4845
+ * console.log(`Found ${result.addresses.length} addresses`);
4846
+ *
4847
+ * // With auto-tracking
4848
+ * await sphere.discoverAddresses({ autoTrack: true });
4849
+ * ```
4850
+ */
4851
+ discoverAddresses(options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
4722
4852
  /**
4723
4853
  * Get aggregated status of all providers, grouped by role.
4724
4854
  *
@@ -6440,4 +6570,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
6440
6570
  */
6441
6571
  declare function getCoinIdByName(name: string): string | undefined;
6442
6572
 
6443
- 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, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, 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_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, 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 IntentStatus, type IntentType, 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 MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, 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 PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, 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 SphereStatus, 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, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, 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, getAddressId, getAddressStorageKey, 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 };
6573
+ 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, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type ComposingIndicator, type ConversationPage, 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_MARKET_API_URL, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type ExtendedValidationResult, type FullIdentity, type GetConversationPageOptions, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InitProgress, type InitProgressCallback, type InitProgressStep, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type IntentStatus, type IntentType, 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 MarketIntent, MarketModule, type MarketModuleConfig, type MarketModuleDependencies, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, 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 PostIntentRequest, type PostIntentResult, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_KEYS_ADDRESS, STORAGE_KEYS_GLOBAL, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type SearchFilters, type SearchIntentResult, type SearchOptions, type SearchResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, 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, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createMarketModule, 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, getAddressId, getAddressStorageKey, 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 };