@unicitylabs/sphere-sdk 0.4.7 → 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/connect/index.cjs.map +1 -1
- package/dist/connect/index.js.map +1 -1
- package/dist/core/index.cjs +441 -177
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +163 -4
- package/dist/core/index.d.ts +163 -4
- package/dist/core/index.js +440 -177
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/connect/index.cjs.map +1 -1
- package/dist/impl/browser/connect/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +40 -2
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +40 -2
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/connect/index.cjs.map +1 -1
- package/dist/impl/nodejs/connect/index.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +40 -2
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +16 -3
- package/dist/impl/nodejs/index.d.ts +16 -3
- package/dist/impl/nodejs/index.js +40 -2
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +497 -228
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +147 -6
- package/dist/index.d.ts +147 -6
- package/dist/index.js +497 -228
- package/dist/index.js.map +1 -1
- package/dist/l1/index.cjs +68 -1
- package/dist/l1/index.cjs.map +1 -1
- package/dist/l1/index.js +68 -1
- package/dist/l1/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -984,6 +984,14 @@ interface TransportProvider extends BaseProvider {
|
|
|
984
984
|
* @returns PeerInfo or null if no binding found
|
|
985
985
|
*/
|
|
986
986
|
resolveTransportPubkeyInfo?(transportPubkey: string): Promise<PeerInfo | null>;
|
|
987
|
+
/**
|
|
988
|
+
* Batch-resolve multiple transport pubkeys to peer info.
|
|
989
|
+
* Used for HD address discovery: derives transport pubkeys for indices 0..N
|
|
990
|
+
* and queries binding events in a single batch.
|
|
991
|
+
* @param transportPubkeys - Array of transport-specific pubkeys to look up
|
|
992
|
+
* @returns Array of PeerInfo for pubkeys that have binding events (may be shorter than input)
|
|
993
|
+
*/
|
|
994
|
+
discoverAddresses?(transportPubkeys: string[]): Promise<PeerInfo[]>;
|
|
987
995
|
/**
|
|
988
996
|
* Recover nametag for current identity by decrypting stored encrypted nametag
|
|
989
997
|
* Used after wallet import to recover associated nametag
|
|
@@ -2993,7 +3001,7 @@ declare const NETWORKS: {
|
|
|
2993
3001
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
2994
3002
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
2995
3003
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2996
|
-
readonly electrumUrl: "wss://fulcrum.
|
|
3004
|
+
readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
|
|
2997
3005
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2998
3006
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
2999
3007
|
};
|
|
@@ -3002,7 +3010,7 @@ declare const NETWORKS: {
|
|
|
3002
3010
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
3003
3011
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3004
3012
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3005
|
-
readonly electrumUrl: "wss://fulcrum.
|
|
3013
|
+
readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
|
|
3006
3014
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3007
3015
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
3008
3016
|
};
|
|
@@ -3011,7 +3019,7 @@ declare const NETWORKS: {
|
|
|
3011
3019
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
3012
3020
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3013
3021
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3014
|
-
readonly electrumUrl: "wss://fulcrum.
|
|
3022
|
+
readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
|
|
3015
3023
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3016
3024
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
3017
3025
|
};
|
|
@@ -3089,6 +3097,88 @@ interface ScanAddressesResult {
|
|
|
3089
3097
|
*/
|
|
3090
3098
|
declare function scanAddressesImpl(deriveAddress: (index: number, isChange: boolean) => AddressInfo, options?: ScanAddressesOptions): Promise<ScanAddressesResult>;
|
|
3091
3099
|
|
|
3100
|
+
/**
|
|
3101
|
+
* HD Address Discovery — discover previously used addresses via transport binding events.
|
|
3102
|
+
*
|
|
3103
|
+
* Derives transport pubkeys for HD indices and batch-queries the relay.
|
|
3104
|
+
* Complements L1 scan (scan.ts) by finding L3-only addresses.
|
|
3105
|
+
*/
|
|
3106
|
+
|
|
3107
|
+
/** Progress callback for address discovery */
|
|
3108
|
+
interface DiscoverAddressProgress {
|
|
3109
|
+
/** Current batch being queried */
|
|
3110
|
+
currentBatch: number;
|
|
3111
|
+
/** Total batches planned */
|
|
3112
|
+
totalBatches: number;
|
|
3113
|
+
/** Number of addresses discovered so far */
|
|
3114
|
+
discoveredCount: number;
|
|
3115
|
+
/** Current gap count (consecutive empty indices) */
|
|
3116
|
+
currentGap: number;
|
|
3117
|
+
/** Phase: 'transport' or 'l1' */
|
|
3118
|
+
phase: 'transport' | 'l1';
|
|
3119
|
+
}
|
|
3120
|
+
/** Single discovered address result */
|
|
3121
|
+
interface DiscoveredAddress {
|
|
3122
|
+
/** HD derivation index */
|
|
3123
|
+
index: number;
|
|
3124
|
+
/** L1 bech32 address (alpha1...) */
|
|
3125
|
+
l1Address: string;
|
|
3126
|
+
/** L3 DIRECT address */
|
|
3127
|
+
directAddress: string;
|
|
3128
|
+
/** 33-byte compressed chain pubkey */
|
|
3129
|
+
chainPubkey: string;
|
|
3130
|
+
/** Nametag (from binding event) */
|
|
3131
|
+
nametag?: string;
|
|
3132
|
+
/** L1 balance in ALPHA (0 if only discovered via transport) */
|
|
3133
|
+
l1Balance: number;
|
|
3134
|
+
/** Discovery source */
|
|
3135
|
+
source: 'transport' | 'l1' | 'both';
|
|
3136
|
+
}
|
|
3137
|
+
/** Options for address discovery */
|
|
3138
|
+
interface DiscoverAddressesOptions {
|
|
3139
|
+
/** Max HD indices to probe (default: 50) */
|
|
3140
|
+
maxAddresses?: number;
|
|
3141
|
+
/** Stop after N consecutive empty indices (default: 20) */
|
|
3142
|
+
gapLimit?: number;
|
|
3143
|
+
/** Batch size for transport queries (default: 20) */
|
|
3144
|
+
batchSize?: number;
|
|
3145
|
+
/** Also run L1 balance scan (default: true) */
|
|
3146
|
+
includeL1Scan?: boolean;
|
|
3147
|
+
/** Progress callback */
|
|
3148
|
+
onProgress?: (progress: DiscoverAddressProgress) => void;
|
|
3149
|
+
/** Abort signal */
|
|
3150
|
+
signal?: AbortSignal;
|
|
3151
|
+
/** Auto-track discovered addresses (default: true) */
|
|
3152
|
+
autoTrack?: boolean;
|
|
3153
|
+
}
|
|
3154
|
+
/** Result of address discovery */
|
|
3155
|
+
interface DiscoverAddressesResult {
|
|
3156
|
+
/** All discovered addresses */
|
|
3157
|
+
addresses: DiscoveredAddress[];
|
|
3158
|
+
/** Total indices scanned */
|
|
3159
|
+
scannedCount: number;
|
|
3160
|
+
/** Whether scan was aborted */
|
|
3161
|
+
aborted: boolean;
|
|
3162
|
+
}
|
|
3163
|
+
/** Info derived for a single HD index */
|
|
3164
|
+
interface DerivedAddressInfo {
|
|
3165
|
+
transportPubkey: string;
|
|
3166
|
+
chainPubkey: string;
|
|
3167
|
+
l1Address: string;
|
|
3168
|
+
directAddress: string;
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Discover used HD addresses via transport binding events.
|
|
3172
|
+
*
|
|
3173
|
+
* Derives transport pubkeys in batches, queries the relay, and uses
|
|
3174
|
+
* gap limit to determine when to stop.
|
|
3175
|
+
*
|
|
3176
|
+
* @param deriveTransportPubkey - function(index) → address info with transportPubkey
|
|
3177
|
+
* @param batchResolve - function(transportPubkeys[]) → PeerInfo[]
|
|
3178
|
+
* @param options - Discovery options
|
|
3179
|
+
*/
|
|
3180
|
+
declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
3181
|
+
|
|
3092
3182
|
/**
|
|
3093
3183
|
* Legacy File Serialization Types
|
|
3094
3184
|
*/
|
|
@@ -3101,6 +3191,17 @@ type DecryptionProgressCallback = (iteration: number, total: number) => Promise<
|
|
|
3101
3191
|
|
|
3102
3192
|
declare function isValidNametag(nametag: string): boolean;
|
|
3103
3193
|
|
|
3194
|
+
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
3195
|
+
type InitProgressStep = 'clearing' | 'storing_keys' | 'initializing' | 'recovering_nametag' | 'registering_nametag' | 'syncing_identity' | 'syncing_tokens' | 'discovering_addresses' | 'finalizing' | 'complete';
|
|
3196
|
+
/** Progress info passed to onProgress callback */
|
|
3197
|
+
interface InitProgress {
|
|
3198
|
+
/** Current step identifier */
|
|
3199
|
+
readonly step: InitProgressStep;
|
|
3200
|
+
/** Human-readable description of what's happening */
|
|
3201
|
+
readonly message: string;
|
|
3202
|
+
}
|
|
3203
|
+
/** Callback for tracking wallet initialization progress */
|
|
3204
|
+
type InitProgressCallback = (progress: InitProgress) => void;
|
|
3104
3205
|
/** Options for creating a new wallet */
|
|
3105
3206
|
interface SphereCreateOptions {
|
|
3106
3207
|
/** BIP39 mnemonic (12 or 24 words) */
|
|
@@ -3133,6 +3234,15 @@ interface SphereCreateOptions {
|
|
|
3133
3234
|
market?: MarketModuleConfig | boolean;
|
|
3134
3235
|
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3135
3236
|
password?: string;
|
|
3237
|
+
/**
|
|
3238
|
+
* Auto-discover previously used HD addresses after creation.
|
|
3239
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3240
|
+
* - DiscoverAddressesOptions: custom config
|
|
3241
|
+
* - false/undefined: no auto-discovery (default)
|
|
3242
|
+
*/
|
|
3243
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3244
|
+
/** Optional callback to report initialization progress steps */
|
|
3245
|
+
onProgress?: InitProgressCallback;
|
|
3136
3246
|
}
|
|
3137
3247
|
/** Options for loading existing wallet */
|
|
3138
3248
|
interface SphereLoadOptions {
|
|
@@ -3160,6 +3270,15 @@ interface SphereLoadOptions {
|
|
|
3160
3270
|
market?: MarketModuleConfig | boolean;
|
|
3161
3271
|
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
3162
3272
|
password?: string;
|
|
3273
|
+
/**
|
|
3274
|
+
* Auto-discover previously used HD addresses on load.
|
|
3275
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3276
|
+
* - DiscoverAddressesOptions: custom config
|
|
3277
|
+
* - false/undefined: no auto-discovery (default)
|
|
3278
|
+
*/
|
|
3279
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3280
|
+
/** Optional callback to report initialization progress steps */
|
|
3281
|
+
onProgress?: InitProgressCallback;
|
|
3163
3282
|
}
|
|
3164
3283
|
/** Options for importing a wallet */
|
|
3165
3284
|
interface SphereImportOptions {
|
|
@@ -3195,6 +3314,15 @@ interface SphereImportOptions {
|
|
|
3195
3314
|
market?: MarketModuleConfig | boolean;
|
|
3196
3315
|
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
3197
3316
|
password?: string;
|
|
3317
|
+
/**
|
|
3318
|
+
* Auto-discover previously used HD addresses after import.
|
|
3319
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3320
|
+
* - DiscoverAddressesOptions: custom config
|
|
3321
|
+
* - false/undefined: no auto-discovery (default)
|
|
3322
|
+
*/
|
|
3323
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3324
|
+
/** Optional callback to report initialization progress steps */
|
|
3325
|
+
onProgress?: InitProgressCallback;
|
|
3198
3326
|
}
|
|
3199
3327
|
/** L1 (ALPHA blockchain) configuration */
|
|
3200
3328
|
interface L1Config {
|
|
@@ -3244,6 +3372,16 @@ interface SphereInitOptions {
|
|
|
3244
3372
|
market?: MarketModuleConfig | boolean;
|
|
3245
3373
|
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3246
3374
|
password?: string;
|
|
3375
|
+
/**
|
|
3376
|
+
* Auto-discover previously used HD addresses when creating from mnemonic.
|
|
3377
|
+
* Only applies when wallet is newly created (not on load of existing wallet).
|
|
3378
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3379
|
+
* - DiscoverAddressesOptions: custom config
|
|
3380
|
+
* - false/undefined: no auto-discovery (default)
|
|
3381
|
+
*/
|
|
3382
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3383
|
+
/** Optional callback to report initialization progress steps */
|
|
3384
|
+
onProgress?: InitProgressCallback;
|
|
3247
3385
|
}
|
|
3248
3386
|
/** Result of init operation */
|
|
3249
3387
|
interface SphereInitResult {
|
|
@@ -3662,6 +3800,11 @@ declare class Sphere {
|
|
|
3662
3800
|
switchToAddress(index: number, options?: {
|
|
3663
3801
|
nametag?: string;
|
|
3664
3802
|
}): Promise<void>;
|
|
3803
|
+
/**
|
|
3804
|
+
* Background transport sync and nametag operations after address switch.
|
|
3805
|
+
* Runs after switchToAddress returns so L1/L3 queries can start immediately.
|
|
3806
|
+
*/
|
|
3807
|
+
private postSwitchSync;
|
|
3665
3808
|
/**
|
|
3666
3809
|
* Re-initialize modules after address switch
|
|
3667
3810
|
*/
|
|
@@ -3751,6 +3894,22 @@ declare class Sphere {
|
|
|
3751
3894
|
hidden: boolean;
|
|
3752
3895
|
nametag?: string;
|
|
3753
3896
|
}>): Promise<void>;
|
|
3897
|
+
/**
|
|
3898
|
+
* Discover previously used HD addresses.
|
|
3899
|
+
*
|
|
3900
|
+
* Primary: queries Nostr relay for identity binding events (fast, single batch query).
|
|
3901
|
+
* Secondary: runs L1 balance scan to find legacy addresses with no binding event.
|
|
3902
|
+
*
|
|
3903
|
+
* @example
|
|
3904
|
+
* ```ts
|
|
3905
|
+
* const result = await sphere.discoverAddresses();
|
|
3906
|
+
* console.log(`Found ${result.addresses.length} addresses`);
|
|
3907
|
+
*
|
|
3908
|
+
* // With auto-tracking
|
|
3909
|
+
* await sphere.discoverAddresses({ autoTrack: true });
|
|
3910
|
+
* ```
|
|
3911
|
+
*/
|
|
3912
|
+
discoverAddresses(options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
3754
3913
|
/**
|
|
3755
3914
|
* Get aggregated status of all providers, grouped by role.
|
|
3756
3915
|
*
|
|
@@ -4302,4 +4461,4 @@ interface CheckNetworkHealthOptions {
|
|
|
4302
4461
|
*/
|
|
4303
4462
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
4304
4463
|
|
|
4305
|
-
export { type AddressInfo, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type EncryptedData, type EncryptionOptions, type KeyPair, type L1Config, type MasterKey, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|
|
4464
|
+
export { type AddressInfo, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type L1Config, type MasterKey, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -984,6 +984,14 @@ interface TransportProvider extends BaseProvider {
|
|
|
984
984
|
* @returns PeerInfo or null if no binding found
|
|
985
985
|
*/
|
|
986
986
|
resolveTransportPubkeyInfo?(transportPubkey: string): Promise<PeerInfo | null>;
|
|
987
|
+
/**
|
|
988
|
+
* Batch-resolve multiple transport pubkeys to peer info.
|
|
989
|
+
* Used for HD address discovery: derives transport pubkeys for indices 0..N
|
|
990
|
+
* and queries binding events in a single batch.
|
|
991
|
+
* @param transportPubkeys - Array of transport-specific pubkeys to look up
|
|
992
|
+
* @returns Array of PeerInfo for pubkeys that have binding events (may be shorter than input)
|
|
993
|
+
*/
|
|
994
|
+
discoverAddresses?(transportPubkeys: string[]): Promise<PeerInfo[]>;
|
|
987
995
|
/**
|
|
988
996
|
* Recover nametag for current identity by decrypting stored encrypted nametag
|
|
989
997
|
* Used after wallet import to recover associated nametag
|
|
@@ -2993,7 +3001,7 @@ declare const NETWORKS: {
|
|
|
2993
3001
|
readonly aggregatorUrl: "https://aggregator.unicity.network/rpc";
|
|
2994
3002
|
readonly nostrRelays: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
2995
3003
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
2996
|
-
readonly electrumUrl: "wss://fulcrum.
|
|
3004
|
+
readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
|
|
2997
3005
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
2998
3006
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
2999
3007
|
};
|
|
@@ -3002,7 +3010,7 @@ declare const NETWORKS: {
|
|
|
3002
3010
|
readonly aggregatorUrl: "https://goggregator-test.unicity.network";
|
|
3003
3011
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3004
3012
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3005
|
-
readonly electrumUrl: "wss://fulcrum.
|
|
3013
|
+
readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
|
|
3006
3014
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3007
3015
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
3008
3016
|
};
|
|
@@ -3011,7 +3019,7 @@ declare const NETWORKS: {
|
|
|
3011
3019
|
readonly aggregatorUrl: "https://dev-aggregator.dyndns.org/rpc";
|
|
3012
3020
|
readonly nostrRelays: readonly ["wss://nostr-relay.testnet.unicity.network"];
|
|
3013
3021
|
readonly ipfsGateways: readonly ["https://unicity-ipfs1.dyndns.org"];
|
|
3014
|
-
readonly electrumUrl: "wss://fulcrum.
|
|
3022
|
+
readonly electrumUrl: "wss://fulcrum.unicity.network:50004";
|
|
3015
3023
|
readonly groupRelays: readonly ["wss://sphere-relay.unicity.network"];
|
|
3016
3024
|
readonly tokenRegistryUrl: "https://raw.githubusercontent.com/unicitynetwork/unicity-ids/refs/heads/main/unicity-ids.testnet.json";
|
|
3017
3025
|
};
|
|
@@ -3089,6 +3097,88 @@ interface ScanAddressesResult {
|
|
|
3089
3097
|
*/
|
|
3090
3098
|
declare function scanAddressesImpl(deriveAddress: (index: number, isChange: boolean) => AddressInfo, options?: ScanAddressesOptions): Promise<ScanAddressesResult>;
|
|
3091
3099
|
|
|
3100
|
+
/**
|
|
3101
|
+
* HD Address Discovery — discover previously used addresses via transport binding events.
|
|
3102
|
+
*
|
|
3103
|
+
* Derives transport pubkeys for HD indices and batch-queries the relay.
|
|
3104
|
+
* Complements L1 scan (scan.ts) by finding L3-only addresses.
|
|
3105
|
+
*/
|
|
3106
|
+
|
|
3107
|
+
/** Progress callback for address discovery */
|
|
3108
|
+
interface DiscoverAddressProgress {
|
|
3109
|
+
/** Current batch being queried */
|
|
3110
|
+
currentBatch: number;
|
|
3111
|
+
/** Total batches planned */
|
|
3112
|
+
totalBatches: number;
|
|
3113
|
+
/** Number of addresses discovered so far */
|
|
3114
|
+
discoveredCount: number;
|
|
3115
|
+
/** Current gap count (consecutive empty indices) */
|
|
3116
|
+
currentGap: number;
|
|
3117
|
+
/** Phase: 'transport' or 'l1' */
|
|
3118
|
+
phase: 'transport' | 'l1';
|
|
3119
|
+
}
|
|
3120
|
+
/** Single discovered address result */
|
|
3121
|
+
interface DiscoveredAddress {
|
|
3122
|
+
/** HD derivation index */
|
|
3123
|
+
index: number;
|
|
3124
|
+
/** L1 bech32 address (alpha1...) */
|
|
3125
|
+
l1Address: string;
|
|
3126
|
+
/** L3 DIRECT address */
|
|
3127
|
+
directAddress: string;
|
|
3128
|
+
/** 33-byte compressed chain pubkey */
|
|
3129
|
+
chainPubkey: string;
|
|
3130
|
+
/** Nametag (from binding event) */
|
|
3131
|
+
nametag?: string;
|
|
3132
|
+
/** L1 balance in ALPHA (0 if only discovered via transport) */
|
|
3133
|
+
l1Balance: number;
|
|
3134
|
+
/** Discovery source */
|
|
3135
|
+
source: 'transport' | 'l1' | 'both';
|
|
3136
|
+
}
|
|
3137
|
+
/** Options for address discovery */
|
|
3138
|
+
interface DiscoverAddressesOptions {
|
|
3139
|
+
/** Max HD indices to probe (default: 50) */
|
|
3140
|
+
maxAddresses?: number;
|
|
3141
|
+
/** Stop after N consecutive empty indices (default: 20) */
|
|
3142
|
+
gapLimit?: number;
|
|
3143
|
+
/** Batch size for transport queries (default: 20) */
|
|
3144
|
+
batchSize?: number;
|
|
3145
|
+
/** Also run L1 balance scan (default: true) */
|
|
3146
|
+
includeL1Scan?: boolean;
|
|
3147
|
+
/** Progress callback */
|
|
3148
|
+
onProgress?: (progress: DiscoverAddressProgress) => void;
|
|
3149
|
+
/** Abort signal */
|
|
3150
|
+
signal?: AbortSignal;
|
|
3151
|
+
/** Auto-track discovered addresses (default: true) */
|
|
3152
|
+
autoTrack?: boolean;
|
|
3153
|
+
}
|
|
3154
|
+
/** Result of address discovery */
|
|
3155
|
+
interface DiscoverAddressesResult {
|
|
3156
|
+
/** All discovered addresses */
|
|
3157
|
+
addresses: DiscoveredAddress[];
|
|
3158
|
+
/** Total indices scanned */
|
|
3159
|
+
scannedCount: number;
|
|
3160
|
+
/** Whether scan was aborted */
|
|
3161
|
+
aborted: boolean;
|
|
3162
|
+
}
|
|
3163
|
+
/** Info derived for a single HD index */
|
|
3164
|
+
interface DerivedAddressInfo {
|
|
3165
|
+
transportPubkey: string;
|
|
3166
|
+
chainPubkey: string;
|
|
3167
|
+
l1Address: string;
|
|
3168
|
+
directAddress: string;
|
|
3169
|
+
}
|
|
3170
|
+
/**
|
|
3171
|
+
* Discover used HD addresses via transport binding events.
|
|
3172
|
+
*
|
|
3173
|
+
* Derives transport pubkeys in batches, queries the relay, and uses
|
|
3174
|
+
* gap limit to determine when to stop.
|
|
3175
|
+
*
|
|
3176
|
+
* @param deriveTransportPubkey - function(index) → address info with transportPubkey
|
|
3177
|
+
* @param batchResolve - function(transportPubkeys[]) → PeerInfo[]
|
|
3178
|
+
* @param options - Discovery options
|
|
3179
|
+
*/
|
|
3180
|
+
declare function discoverAddressesImpl(deriveTransportPubkey: (index: number) => DerivedAddressInfo, batchResolve: (transportPubkeys: string[]) => Promise<PeerInfo[]>, options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
3181
|
+
|
|
3092
3182
|
/**
|
|
3093
3183
|
* Legacy File Serialization Types
|
|
3094
3184
|
*/
|
|
@@ -3101,6 +3191,17 @@ type DecryptionProgressCallback = (iteration: number, total: number) => Promise<
|
|
|
3101
3191
|
|
|
3102
3192
|
declare function isValidNametag(nametag: string): boolean;
|
|
3103
3193
|
|
|
3194
|
+
/** Steps reported by the onProgress callback during wallet init/create/load/import */
|
|
3195
|
+
type InitProgressStep = 'clearing' | 'storing_keys' | 'initializing' | 'recovering_nametag' | 'registering_nametag' | 'syncing_identity' | 'syncing_tokens' | 'discovering_addresses' | 'finalizing' | 'complete';
|
|
3196
|
+
/** Progress info passed to onProgress callback */
|
|
3197
|
+
interface InitProgress {
|
|
3198
|
+
/** Current step identifier */
|
|
3199
|
+
readonly step: InitProgressStep;
|
|
3200
|
+
/** Human-readable description of what's happening */
|
|
3201
|
+
readonly message: string;
|
|
3202
|
+
}
|
|
3203
|
+
/** Callback for tracking wallet initialization progress */
|
|
3204
|
+
type InitProgressCallback = (progress: InitProgress) => void;
|
|
3104
3205
|
/** Options for creating a new wallet */
|
|
3105
3206
|
interface SphereCreateOptions {
|
|
3106
3207
|
/** BIP39 mnemonic (12 or 24 words) */
|
|
@@ -3133,6 +3234,15 @@ interface SphereCreateOptions {
|
|
|
3133
3234
|
market?: MarketModuleConfig | boolean;
|
|
3134
3235
|
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3135
3236
|
password?: string;
|
|
3237
|
+
/**
|
|
3238
|
+
* Auto-discover previously used HD addresses after creation.
|
|
3239
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3240
|
+
* - DiscoverAddressesOptions: custom config
|
|
3241
|
+
* - false/undefined: no auto-discovery (default)
|
|
3242
|
+
*/
|
|
3243
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3244
|
+
/** Optional callback to report initialization progress steps */
|
|
3245
|
+
onProgress?: InitProgressCallback;
|
|
3136
3246
|
}
|
|
3137
3247
|
/** Options for loading existing wallet */
|
|
3138
3248
|
interface SphereLoadOptions {
|
|
@@ -3160,6 +3270,15 @@ interface SphereLoadOptions {
|
|
|
3160
3270
|
market?: MarketModuleConfig | boolean;
|
|
3161
3271
|
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
3162
3272
|
password?: string;
|
|
3273
|
+
/**
|
|
3274
|
+
* Auto-discover previously used HD addresses on load.
|
|
3275
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3276
|
+
* - DiscoverAddressesOptions: custom config
|
|
3277
|
+
* - false/undefined: no auto-discovery (default)
|
|
3278
|
+
*/
|
|
3279
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3280
|
+
/** Optional callback to report initialization progress steps */
|
|
3281
|
+
onProgress?: InitProgressCallback;
|
|
3163
3282
|
}
|
|
3164
3283
|
/** Options for importing a wallet */
|
|
3165
3284
|
interface SphereImportOptions {
|
|
@@ -3195,6 +3314,15 @@ interface SphereImportOptions {
|
|
|
3195
3314
|
market?: MarketModuleConfig | boolean;
|
|
3196
3315
|
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
3197
3316
|
password?: string;
|
|
3317
|
+
/**
|
|
3318
|
+
* Auto-discover previously used HD addresses after import.
|
|
3319
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3320
|
+
* - DiscoverAddressesOptions: custom config
|
|
3321
|
+
* - false/undefined: no auto-discovery (default)
|
|
3322
|
+
*/
|
|
3323
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3324
|
+
/** Optional callback to report initialization progress steps */
|
|
3325
|
+
onProgress?: InitProgressCallback;
|
|
3198
3326
|
}
|
|
3199
3327
|
/** L1 (ALPHA blockchain) configuration */
|
|
3200
3328
|
interface L1Config {
|
|
@@ -3244,6 +3372,16 @@ interface SphereInitOptions {
|
|
|
3244
3372
|
market?: MarketModuleConfig | boolean;
|
|
3245
3373
|
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3246
3374
|
password?: string;
|
|
3375
|
+
/**
|
|
3376
|
+
* Auto-discover previously used HD addresses when creating from mnemonic.
|
|
3377
|
+
* Only applies when wallet is newly created (not on load of existing wallet).
|
|
3378
|
+
* - true: discover with defaults (Nostr + L1 scan, autoTrack: true)
|
|
3379
|
+
* - DiscoverAddressesOptions: custom config
|
|
3380
|
+
* - false/undefined: no auto-discovery (default)
|
|
3381
|
+
*/
|
|
3382
|
+
discoverAddresses?: boolean | DiscoverAddressesOptions;
|
|
3383
|
+
/** Optional callback to report initialization progress steps */
|
|
3384
|
+
onProgress?: InitProgressCallback;
|
|
3247
3385
|
}
|
|
3248
3386
|
/** Result of init operation */
|
|
3249
3387
|
interface SphereInitResult {
|
|
@@ -3662,6 +3800,11 @@ declare class Sphere {
|
|
|
3662
3800
|
switchToAddress(index: number, options?: {
|
|
3663
3801
|
nametag?: string;
|
|
3664
3802
|
}): Promise<void>;
|
|
3803
|
+
/**
|
|
3804
|
+
* Background transport sync and nametag operations after address switch.
|
|
3805
|
+
* Runs after switchToAddress returns so L1/L3 queries can start immediately.
|
|
3806
|
+
*/
|
|
3807
|
+
private postSwitchSync;
|
|
3665
3808
|
/**
|
|
3666
3809
|
* Re-initialize modules after address switch
|
|
3667
3810
|
*/
|
|
@@ -3751,6 +3894,22 @@ declare class Sphere {
|
|
|
3751
3894
|
hidden: boolean;
|
|
3752
3895
|
nametag?: string;
|
|
3753
3896
|
}>): Promise<void>;
|
|
3897
|
+
/**
|
|
3898
|
+
* Discover previously used HD addresses.
|
|
3899
|
+
*
|
|
3900
|
+
* Primary: queries Nostr relay for identity binding events (fast, single batch query).
|
|
3901
|
+
* Secondary: runs L1 balance scan to find legacy addresses with no binding event.
|
|
3902
|
+
*
|
|
3903
|
+
* @example
|
|
3904
|
+
* ```ts
|
|
3905
|
+
* const result = await sphere.discoverAddresses();
|
|
3906
|
+
* console.log(`Found ${result.addresses.length} addresses`);
|
|
3907
|
+
*
|
|
3908
|
+
* // With auto-tracking
|
|
3909
|
+
* await sphere.discoverAddresses({ autoTrack: true });
|
|
3910
|
+
* ```
|
|
3911
|
+
*/
|
|
3912
|
+
discoverAddresses(options?: DiscoverAddressesOptions): Promise<DiscoverAddressesResult>;
|
|
3754
3913
|
/**
|
|
3755
3914
|
* Get aggregated status of all providers, grouped by role.
|
|
3756
3915
|
*
|
|
@@ -4302,4 +4461,4 @@ interface CheckNetworkHealthOptions {
|
|
|
4302
4461
|
*/
|
|
4303
4462
|
declare function checkNetworkHealth(network?: NetworkType, options?: CheckNetworkHealthOptions): Promise<NetworkHealthResult>;
|
|
4304
4463
|
|
|
4305
|
-
export { type AddressInfo, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type EncryptedData, type EncryptionOptions, type KeyPair, type L1Config, type MasterKey, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|
|
4464
|
+
export { type AddressInfo, CHARSET, type CheckNetworkHealthOptions, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type DiscoverAddressProgress, type DiscoverAddressesOptions, type DiscoverAddressesResult, type DiscoveredAddress, type EncryptedData, type EncryptionOptions, type InitProgress, type InitProgressCallback, type InitProgressStep, type KeyPair, type L1Config, type MasterKey, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, Sphere, type SphereCreateOptions, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, checkNetworkHealth, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, decryptWithSalt, deriveAddressInfo, deriveChildKey, deriveKeyAtPath, deserializeEncrypted, discoverAddressesImpl, doubleSha256, ec, encodeBech32, encrypt, encryptMnemonic, encryptSimple, entropyToMnemonic, extractFromText, findPattern, formatAmount, generateAddressInfo, generateMasterKey, generateMnemonic, generateRandomKey, getAddressHrp, getPublicKey, getSphere, hash160, hash160ToBytes, hexToBytes, identityFromMnemonic, identityFromMnemonicSync, importSphere, initSphere, isEncryptedData, isValidBech32, isValidNametag, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|