@unicitylabs/sphere-sdk 0.2.1 → 0.2.3
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/README.md +22 -69
- package/dist/core/index.cjs +944 -465
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +127 -6
- package/dist/core/index.d.ts +127 -6
- package/dist/core/index.js +833 -351
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +115 -19
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +115 -19
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs +3 -1
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js +3 -1
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +85 -17
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +22 -0
- package/dist/impl/nodejs/index.d.ts +22 -0
- package/dist/impl/nodejs/index.js +85 -17
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +1083 -644
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -6
- package/dist/index.d.ts +118 -6
- package/dist/index.js +993 -554
- package/dist/index.js.map +1 -1
- package/dist/l1/index.cjs +18 -0
- package/dist/l1/index.cjs.map +1 -1
- package/dist/l1/index.d.cts +4 -0
- package/dist/l1/index.d.ts +4 -0
- package/dist/l1/index.js +18 -0
- package/dist/l1/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.cts
CHANGED
|
@@ -578,7 +578,7 @@ interface PaymentRequest {
|
|
|
578
578
|
readonly coinId: string;
|
|
579
579
|
/** Optional message/memo */
|
|
580
580
|
readonly message?: string;
|
|
581
|
-
/**
|
|
581
|
+
/** Where tokens should be sent */
|
|
582
582
|
readonly recipientNametag?: string;
|
|
583
583
|
/** Custom metadata */
|
|
584
584
|
readonly metadata?: Record<string, unknown>;
|
|
@@ -605,7 +605,7 @@ interface IncomingPaymentRequest$1 {
|
|
|
605
605
|
readonly symbol: string;
|
|
606
606
|
/** Message from sender */
|
|
607
607
|
readonly message?: string;
|
|
608
|
-
/**
|
|
608
|
+
/** Requester's nametag (where tokens should be sent) */
|
|
609
609
|
readonly recipientNametag?: string;
|
|
610
610
|
/** Original request ID from sender */
|
|
611
611
|
readonly requestId: string;
|
|
@@ -1094,6 +1094,8 @@ interface IncomingPaymentRequest {
|
|
|
1094
1094
|
id: string;
|
|
1095
1095
|
/** Transport-specific pubkey of sender */
|
|
1096
1096
|
senderTransportPubkey: string;
|
|
1097
|
+
/** Sender's nametag (if included in encrypted content) */
|
|
1098
|
+
senderNametag?: string;
|
|
1097
1099
|
/** Parsed request data */
|
|
1098
1100
|
request: {
|
|
1099
1101
|
requestId: string;
|
|
@@ -1252,6 +1254,12 @@ declare class L1PaymentsModule {
|
|
|
1252
1254
|
private _transport?;
|
|
1253
1255
|
constructor(config?: L1PaymentsModuleConfig);
|
|
1254
1256
|
initialize(deps: L1PaymentsModuleDependencies): Promise<void>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Ensure the Fulcrum WebSocket is connected. Called lazily before any
|
|
1259
|
+
* operation that needs the network. If the singleton is already connected
|
|
1260
|
+
* (e.g. by the address scanner), this is a no-op.
|
|
1261
|
+
*/
|
|
1262
|
+
private ensureConnected;
|
|
1255
1263
|
destroy(): void;
|
|
1256
1264
|
/**
|
|
1257
1265
|
* Check if a string looks like an L1 address (alpha1... or alphat1...)
|
|
@@ -1261,7 +1269,7 @@ declare class L1PaymentsModule {
|
|
|
1261
1269
|
* Resolve recipient to L1 address
|
|
1262
1270
|
* Supports: L1 address (alpha1...), nametag (with or without @)
|
|
1263
1271
|
*/
|
|
1264
|
-
|
|
1272
|
+
resolveL1Address(recipient: string): Promise<string>;
|
|
1265
1273
|
/**
|
|
1266
1274
|
* Resolve nametag to L1 address using transport provider
|
|
1267
1275
|
*/
|
|
@@ -1703,8 +1711,8 @@ interface PaymentsModuleConfig {
|
|
|
1703
1711
|
maxRetries?: number;
|
|
1704
1712
|
/** Enable debug logging */
|
|
1705
1713
|
debug?: boolean;
|
|
1706
|
-
/** L1 (ALPHA blockchain) configuration */
|
|
1707
|
-
l1?: L1PaymentsModuleConfig;
|
|
1714
|
+
/** L1 (ALPHA blockchain) configuration. Set to null to explicitly disable L1. */
|
|
1715
|
+
l1?: L1PaymentsModuleConfig | null;
|
|
1708
1716
|
}
|
|
1709
1717
|
interface PaymentsModuleDependencies {
|
|
1710
1718
|
identity: FullIdentity;
|
|
@@ -1958,6 +1966,11 @@ declare class PaymentsModule {
|
|
|
1958
1966
|
* Remove a token by ID
|
|
1959
1967
|
*/
|
|
1960
1968
|
removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
|
|
1969
|
+
/**
|
|
1970
|
+
* Delete physical token file(s) from all storage providers.
|
|
1971
|
+
* Finds files by matching the SDK token ID prefix in the filename.
|
|
1972
|
+
*/
|
|
1973
|
+
private deleteTokenFiles;
|
|
1961
1974
|
/**
|
|
1962
1975
|
* Get all tombstones
|
|
1963
1976
|
*/
|
|
@@ -2271,6 +2284,77 @@ declare const NETWORKS: {
|
|
|
2271
2284
|
};
|
|
2272
2285
|
type NetworkType = keyof typeof NETWORKS;
|
|
2273
2286
|
|
|
2287
|
+
/**
|
|
2288
|
+
* Address Scanning — Derive HD addresses and check L1 balances via Fulcrum.
|
|
2289
|
+
*
|
|
2290
|
+
* Used after importing BIP32/.dat wallets to discover which addresses have funds.
|
|
2291
|
+
*/
|
|
2292
|
+
|
|
2293
|
+
/** Progress callback for address scanning */
|
|
2294
|
+
interface ScanAddressProgress {
|
|
2295
|
+
/** Number of addresses scanned so far */
|
|
2296
|
+
scanned: number;
|
|
2297
|
+
/** Total addresses to scan (maxAddresses * chains) */
|
|
2298
|
+
total: number;
|
|
2299
|
+
/** Current address being checked */
|
|
2300
|
+
currentAddress: string;
|
|
2301
|
+
/** Number of addresses found with balance */
|
|
2302
|
+
foundCount: number;
|
|
2303
|
+
/** Current gap count (consecutive empty addresses) */
|
|
2304
|
+
currentGap: number;
|
|
2305
|
+
/** Number of found addresses that have a nametag */
|
|
2306
|
+
nametagsFoundCount: number;
|
|
2307
|
+
}
|
|
2308
|
+
/** Single scanned address result */
|
|
2309
|
+
interface ScannedAddressResult {
|
|
2310
|
+
/** HD derivation index */
|
|
2311
|
+
index: number;
|
|
2312
|
+
/** L1 bech32 address (alpha1...) */
|
|
2313
|
+
address: string;
|
|
2314
|
+
/** Full BIP32 derivation path */
|
|
2315
|
+
path: string;
|
|
2316
|
+
/** L1 balance in ALPHA */
|
|
2317
|
+
balance: number;
|
|
2318
|
+
/** Whether this is a change address (chain 1) */
|
|
2319
|
+
isChange: boolean;
|
|
2320
|
+
/** Nametag associated with this address (resolved during scan) */
|
|
2321
|
+
nametag?: string;
|
|
2322
|
+
}
|
|
2323
|
+
/** Options for scanning addresses */
|
|
2324
|
+
interface ScanAddressesOptions {
|
|
2325
|
+
/** Maximum number of addresses to scan per chain (default: 50) */
|
|
2326
|
+
maxAddresses?: number;
|
|
2327
|
+
/** Stop after this many consecutive 0-balance addresses (default: 20) */
|
|
2328
|
+
gapLimit?: number;
|
|
2329
|
+
/** Also scan change addresses (chain 1) (default: true) */
|
|
2330
|
+
includeChange?: boolean;
|
|
2331
|
+
/** Progress callback */
|
|
2332
|
+
onProgress?: (progress: ScanAddressProgress) => void;
|
|
2333
|
+
/** Abort signal for cancellation */
|
|
2334
|
+
signal?: AbortSignal;
|
|
2335
|
+
/** Resolve nametag for a found address. Return nametag string or null. */
|
|
2336
|
+
resolveNametag?: (l1Address: string) => Promise<string | null>;
|
|
2337
|
+
}
|
|
2338
|
+
/** Result of scanning */
|
|
2339
|
+
interface ScanAddressesResult {
|
|
2340
|
+
/** All addresses found with non-zero balance */
|
|
2341
|
+
addresses: ScannedAddressResult[];
|
|
2342
|
+
/** Total balance across all found addresses (in ALPHA) */
|
|
2343
|
+
totalBalance: number;
|
|
2344
|
+
/** Number of addresses actually scanned */
|
|
2345
|
+
scannedCount: number;
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Scan blockchain addresses to discover used addresses with balances.
|
|
2349
|
+
* Derives addresses sequentially and checks L1 balance via Fulcrum.
|
|
2350
|
+
* Uses gap limit to stop after N consecutive empty addresses.
|
|
2351
|
+
*
|
|
2352
|
+
* @param deriveAddress - Function to derive an address at a given index
|
|
2353
|
+
* @param options - Scanning options
|
|
2354
|
+
* @returns Scan results with found addresses and total balance
|
|
2355
|
+
*/
|
|
2356
|
+
declare function scanAddressesImpl(deriveAddress: (index: number, isChange: boolean) => AddressInfo, options?: ScanAddressesOptions): Promise<ScanAddressesResult>;
|
|
2357
|
+
|
|
2274
2358
|
/**
|
|
2275
2359
|
* Legacy File Serialization Types
|
|
2276
2360
|
*/
|
|
@@ -2634,6 +2718,7 @@ declare class Sphere {
|
|
|
2634
2718
|
transport: TransportProvider;
|
|
2635
2719
|
oracle: OracleProvider;
|
|
2636
2720
|
tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
2721
|
+
l1?: L1Config;
|
|
2637
2722
|
}): Promise<{
|
|
2638
2723
|
success: boolean;
|
|
2639
2724
|
mnemonic?: string;
|
|
@@ -2688,6 +2773,8 @@ declare class Sphere {
|
|
|
2688
2773
|
tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
2689
2774
|
/** Optional nametag to register */
|
|
2690
2775
|
nametag?: string;
|
|
2776
|
+
/** L1 (ALPHA blockchain) configuration */
|
|
2777
|
+
l1?: L1Config;
|
|
2691
2778
|
}): Promise<{
|
|
2692
2779
|
success: boolean;
|
|
2693
2780
|
sphere?: Sphere;
|
|
@@ -2848,6 +2935,35 @@ declare class Sphere {
|
|
|
2848
2935
|
* ```
|
|
2849
2936
|
*/
|
|
2850
2937
|
deriveAddresses(count: number, includeChange?: boolean): AddressInfo[];
|
|
2938
|
+
/**
|
|
2939
|
+
* Scan blockchain addresses to discover used addresses with balances.
|
|
2940
|
+
* Derives addresses sequentially and checks L1 balance via Fulcrum.
|
|
2941
|
+
* Uses gap limit to stop after N consecutive empty addresses.
|
|
2942
|
+
*
|
|
2943
|
+
* @param options - Scanning options
|
|
2944
|
+
* @returns Scan results with found addresses and total balance
|
|
2945
|
+
*
|
|
2946
|
+
* @example
|
|
2947
|
+
* ```ts
|
|
2948
|
+
* const result = await sphere.scanAddresses({
|
|
2949
|
+
* maxAddresses: 100,
|
|
2950
|
+
* gapLimit: 20,
|
|
2951
|
+
* onProgress: (p) => console.log(`Scanned ${p.scanned}/${p.total}, found ${p.foundCount}`),
|
|
2952
|
+
* });
|
|
2953
|
+
* console.log(`Found ${result.addresses.length} addresses, total: ${result.totalBalance} ALPHA`);
|
|
2954
|
+
* ```
|
|
2955
|
+
*/
|
|
2956
|
+
scanAddresses(options?: ScanAddressesOptions): Promise<ScanAddressesResult>;
|
|
2957
|
+
/**
|
|
2958
|
+
* Bulk-track scanned addresses with visibility and nametag data.
|
|
2959
|
+
* Selected addresses get `hidden: false`, unselected get `hidden: true`.
|
|
2960
|
+
* Performs only 2 storage writes total (tracked addresses + nametags).
|
|
2961
|
+
*/
|
|
2962
|
+
trackScannedAddresses(entries: Array<{
|
|
2963
|
+
index: number;
|
|
2964
|
+
hidden: boolean;
|
|
2965
|
+
nametag?: string;
|
|
2966
|
+
}>): Promise<void>;
|
|
2851
2967
|
getStatus(): {
|
|
2852
2968
|
storage: {
|
|
2853
2969
|
connected: boolean;
|
|
@@ -3064,6 +3180,11 @@ declare function encryptSimple(plaintext: string, password: string): string;
|
|
|
3064
3180
|
* @param password - Decryption password
|
|
3065
3181
|
*/
|
|
3066
3182
|
declare function decryptSimple(ciphertext: string, password: string): string;
|
|
3183
|
+
/**
|
|
3184
|
+
* Decrypt data encrypted with PBKDF2-derived key (legacy JSON wallet format).
|
|
3185
|
+
* Compatible with webwallet's encryptWithPassword/decryptWithPassword.
|
|
3186
|
+
*/
|
|
3187
|
+
declare function decryptWithSalt(ciphertext: string, password: string, salt: string): string | null;
|
|
3067
3188
|
/**
|
|
3068
3189
|
* Encrypt mnemonic phrase for storage
|
|
3069
3190
|
* Uses simple AES encryption compatible with existing wallet format
|
|
@@ -3257,4 +3378,4 @@ declare function randomHex(byteLength: number): string;
|
|
|
3257
3378
|
*/
|
|
3258
3379
|
declare function randomUUID(): string;
|
|
3259
3380
|
|
|
3260
|
-
export { type AddressInfo, CHARSET, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type EncryptedData, type EncryptionOptions, type KeyPair, type L1Config, type MasterKey, Sphere, type SphereCreateOptions, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, 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, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|
|
3381
|
+
export { type AddressInfo, CHARSET, 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, 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, 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
|
@@ -578,7 +578,7 @@ interface PaymentRequest {
|
|
|
578
578
|
readonly coinId: string;
|
|
579
579
|
/** Optional message/memo */
|
|
580
580
|
readonly message?: string;
|
|
581
|
-
/**
|
|
581
|
+
/** Where tokens should be sent */
|
|
582
582
|
readonly recipientNametag?: string;
|
|
583
583
|
/** Custom metadata */
|
|
584
584
|
readonly metadata?: Record<string, unknown>;
|
|
@@ -605,7 +605,7 @@ interface IncomingPaymentRequest$1 {
|
|
|
605
605
|
readonly symbol: string;
|
|
606
606
|
/** Message from sender */
|
|
607
607
|
readonly message?: string;
|
|
608
|
-
/**
|
|
608
|
+
/** Requester's nametag (where tokens should be sent) */
|
|
609
609
|
readonly recipientNametag?: string;
|
|
610
610
|
/** Original request ID from sender */
|
|
611
611
|
readonly requestId: string;
|
|
@@ -1094,6 +1094,8 @@ interface IncomingPaymentRequest {
|
|
|
1094
1094
|
id: string;
|
|
1095
1095
|
/** Transport-specific pubkey of sender */
|
|
1096
1096
|
senderTransportPubkey: string;
|
|
1097
|
+
/** Sender's nametag (if included in encrypted content) */
|
|
1098
|
+
senderNametag?: string;
|
|
1097
1099
|
/** Parsed request data */
|
|
1098
1100
|
request: {
|
|
1099
1101
|
requestId: string;
|
|
@@ -1252,6 +1254,12 @@ declare class L1PaymentsModule {
|
|
|
1252
1254
|
private _transport?;
|
|
1253
1255
|
constructor(config?: L1PaymentsModuleConfig);
|
|
1254
1256
|
initialize(deps: L1PaymentsModuleDependencies): Promise<void>;
|
|
1257
|
+
/**
|
|
1258
|
+
* Ensure the Fulcrum WebSocket is connected. Called lazily before any
|
|
1259
|
+
* operation that needs the network. If the singleton is already connected
|
|
1260
|
+
* (e.g. by the address scanner), this is a no-op.
|
|
1261
|
+
*/
|
|
1262
|
+
private ensureConnected;
|
|
1255
1263
|
destroy(): void;
|
|
1256
1264
|
/**
|
|
1257
1265
|
* Check if a string looks like an L1 address (alpha1... or alphat1...)
|
|
@@ -1261,7 +1269,7 @@ declare class L1PaymentsModule {
|
|
|
1261
1269
|
* Resolve recipient to L1 address
|
|
1262
1270
|
* Supports: L1 address (alpha1...), nametag (with or without @)
|
|
1263
1271
|
*/
|
|
1264
|
-
|
|
1272
|
+
resolveL1Address(recipient: string): Promise<string>;
|
|
1265
1273
|
/**
|
|
1266
1274
|
* Resolve nametag to L1 address using transport provider
|
|
1267
1275
|
*/
|
|
@@ -1703,8 +1711,8 @@ interface PaymentsModuleConfig {
|
|
|
1703
1711
|
maxRetries?: number;
|
|
1704
1712
|
/** Enable debug logging */
|
|
1705
1713
|
debug?: boolean;
|
|
1706
|
-
/** L1 (ALPHA blockchain) configuration */
|
|
1707
|
-
l1?: L1PaymentsModuleConfig;
|
|
1714
|
+
/** L1 (ALPHA blockchain) configuration. Set to null to explicitly disable L1. */
|
|
1715
|
+
l1?: L1PaymentsModuleConfig | null;
|
|
1708
1716
|
}
|
|
1709
1717
|
interface PaymentsModuleDependencies {
|
|
1710
1718
|
identity: FullIdentity;
|
|
@@ -1958,6 +1966,11 @@ declare class PaymentsModule {
|
|
|
1958
1966
|
* Remove a token by ID
|
|
1959
1967
|
*/
|
|
1960
1968
|
removeToken(tokenId: string, recipientNametag?: string, skipHistory?: boolean): Promise<void>;
|
|
1969
|
+
/**
|
|
1970
|
+
* Delete physical token file(s) from all storage providers.
|
|
1971
|
+
* Finds files by matching the SDK token ID prefix in the filename.
|
|
1972
|
+
*/
|
|
1973
|
+
private deleteTokenFiles;
|
|
1961
1974
|
/**
|
|
1962
1975
|
* Get all tombstones
|
|
1963
1976
|
*/
|
|
@@ -2271,6 +2284,77 @@ declare const NETWORKS: {
|
|
|
2271
2284
|
};
|
|
2272
2285
|
type NetworkType = keyof typeof NETWORKS;
|
|
2273
2286
|
|
|
2287
|
+
/**
|
|
2288
|
+
* Address Scanning — Derive HD addresses and check L1 balances via Fulcrum.
|
|
2289
|
+
*
|
|
2290
|
+
* Used after importing BIP32/.dat wallets to discover which addresses have funds.
|
|
2291
|
+
*/
|
|
2292
|
+
|
|
2293
|
+
/** Progress callback for address scanning */
|
|
2294
|
+
interface ScanAddressProgress {
|
|
2295
|
+
/** Number of addresses scanned so far */
|
|
2296
|
+
scanned: number;
|
|
2297
|
+
/** Total addresses to scan (maxAddresses * chains) */
|
|
2298
|
+
total: number;
|
|
2299
|
+
/** Current address being checked */
|
|
2300
|
+
currentAddress: string;
|
|
2301
|
+
/** Number of addresses found with balance */
|
|
2302
|
+
foundCount: number;
|
|
2303
|
+
/** Current gap count (consecutive empty addresses) */
|
|
2304
|
+
currentGap: number;
|
|
2305
|
+
/** Number of found addresses that have a nametag */
|
|
2306
|
+
nametagsFoundCount: number;
|
|
2307
|
+
}
|
|
2308
|
+
/** Single scanned address result */
|
|
2309
|
+
interface ScannedAddressResult {
|
|
2310
|
+
/** HD derivation index */
|
|
2311
|
+
index: number;
|
|
2312
|
+
/** L1 bech32 address (alpha1...) */
|
|
2313
|
+
address: string;
|
|
2314
|
+
/** Full BIP32 derivation path */
|
|
2315
|
+
path: string;
|
|
2316
|
+
/** L1 balance in ALPHA */
|
|
2317
|
+
balance: number;
|
|
2318
|
+
/** Whether this is a change address (chain 1) */
|
|
2319
|
+
isChange: boolean;
|
|
2320
|
+
/** Nametag associated with this address (resolved during scan) */
|
|
2321
|
+
nametag?: string;
|
|
2322
|
+
}
|
|
2323
|
+
/** Options for scanning addresses */
|
|
2324
|
+
interface ScanAddressesOptions {
|
|
2325
|
+
/** Maximum number of addresses to scan per chain (default: 50) */
|
|
2326
|
+
maxAddresses?: number;
|
|
2327
|
+
/** Stop after this many consecutive 0-balance addresses (default: 20) */
|
|
2328
|
+
gapLimit?: number;
|
|
2329
|
+
/** Also scan change addresses (chain 1) (default: true) */
|
|
2330
|
+
includeChange?: boolean;
|
|
2331
|
+
/** Progress callback */
|
|
2332
|
+
onProgress?: (progress: ScanAddressProgress) => void;
|
|
2333
|
+
/** Abort signal for cancellation */
|
|
2334
|
+
signal?: AbortSignal;
|
|
2335
|
+
/** Resolve nametag for a found address. Return nametag string or null. */
|
|
2336
|
+
resolveNametag?: (l1Address: string) => Promise<string | null>;
|
|
2337
|
+
}
|
|
2338
|
+
/** Result of scanning */
|
|
2339
|
+
interface ScanAddressesResult {
|
|
2340
|
+
/** All addresses found with non-zero balance */
|
|
2341
|
+
addresses: ScannedAddressResult[];
|
|
2342
|
+
/** Total balance across all found addresses (in ALPHA) */
|
|
2343
|
+
totalBalance: number;
|
|
2344
|
+
/** Number of addresses actually scanned */
|
|
2345
|
+
scannedCount: number;
|
|
2346
|
+
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Scan blockchain addresses to discover used addresses with balances.
|
|
2349
|
+
* Derives addresses sequentially and checks L1 balance via Fulcrum.
|
|
2350
|
+
* Uses gap limit to stop after N consecutive empty addresses.
|
|
2351
|
+
*
|
|
2352
|
+
* @param deriveAddress - Function to derive an address at a given index
|
|
2353
|
+
* @param options - Scanning options
|
|
2354
|
+
* @returns Scan results with found addresses and total balance
|
|
2355
|
+
*/
|
|
2356
|
+
declare function scanAddressesImpl(deriveAddress: (index: number, isChange: boolean) => AddressInfo, options?: ScanAddressesOptions): Promise<ScanAddressesResult>;
|
|
2357
|
+
|
|
2274
2358
|
/**
|
|
2275
2359
|
* Legacy File Serialization Types
|
|
2276
2360
|
*/
|
|
@@ -2634,6 +2718,7 @@ declare class Sphere {
|
|
|
2634
2718
|
transport: TransportProvider;
|
|
2635
2719
|
oracle: OracleProvider;
|
|
2636
2720
|
tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
2721
|
+
l1?: L1Config;
|
|
2637
2722
|
}): Promise<{
|
|
2638
2723
|
success: boolean;
|
|
2639
2724
|
mnemonic?: string;
|
|
@@ -2688,6 +2773,8 @@ declare class Sphere {
|
|
|
2688
2773
|
tokenStorage?: TokenStorageProvider<TxfStorageDataBase>;
|
|
2689
2774
|
/** Optional nametag to register */
|
|
2690
2775
|
nametag?: string;
|
|
2776
|
+
/** L1 (ALPHA blockchain) configuration */
|
|
2777
|
+
l1?: L1Config;
|
|
2691
2778
|
}): Promise<{
|
|
2692
2779
|
success: boolean;
|
|
2693
2780
|
sphere?: Sphere;
|
|
@@ -2848,6 +2935,35 @@ declare class Sphere {
|
|
|
2848
2935
|
* ```
|
|
2849
2936
|
*/
|
|
2850
2937
|
deriveAddresses(count: number, includeChange?: boolean): AddressInfo[];
|
|
2938
|
+
/**
|
|
2939
|
+
* Scan blockchain addresses to discover used addresses with balances.
|
|
2940
|
+
* Derives addresses sequentially and checks L1 balance via Fulcrum.
|
|
2941
|
+
* Uses gap limit to stop after N consecutive empty addresses.
|
|
2942
|
+
*
|
|
2943
|
+
* @param options - Scanning options
|
|
2944
|
+
* @returns Scan results with found addresses and total balance
|
|
2945
|
+
*
|
|
2946
|
+
* @example
|
|
2947
|
+
* ```ts
|
|
2948
|
+
* const result = await sphere.scanAddresses({
|
|
2949
|
+
* maxAddresses: 100,
|
|
2950
|
+
* gapLimit: 20,
|
|
2951
|
+
* onProgress: (p) => console.log(`Scanned ${p.scanned}/${p.total}, found ${p.foundCount}`),
|
|
2952
|
+
* });
|
|
2953
|
+
* console.log(`Found ${result.addresses.length} addresses, total: ${result.totalBalance} ALPHA`);
|
|
2954
|
+
* ```
|
|
2955
|
+
*/
|
|
2956
|
+
scanAddresses(options?: ScanAddressesOptions): Promise<ScanAddressesResult>;
|
|
2957
|
+
/**
|
|
2958
|
+
* Bulk-track scanned addresses with visibility and nametag data.
|
|
2959
|
+
* Selected addresses get `hidden: false`, unselected get `hidden: true`.
|
|
2960
|
+
* Performs only 2 storage writes total (tracked addresses + nametags).
|
|
2961
|
+
*/
|
|
2962
|
+
trackScannedAddresses(entries: Array<{
|
|
2963
|
+
index: number;
|
|
2964
|
+
hidden: boolean;
|
|
2965
|
+
nametag?: string;
|
|
2966
|
+
}>): Promise<void>;
|
|
2851
2967
|
getStatus(): {
|
|
2852
2968
|
storage: {
|
|
2853
2969
|
connected: boolean;
|
|
@@ -3064,6 +3180,11 @@ declare function encryptSimple(plaintext: string, password: string): string;
|
|
|
3064
3180
|
* @param password - Decryption password
|
|
3065
3181
|
*/
|
|
3066
3182
|
declare function decryptSimple(ciphertext: string, password: string): string;
|
|
3183
|
+
/**
|
|
3184
|
+
* Decrypt data encrypted with PBKDF2-derived key (legacy JSON wallet format).
|
|
3185
|
+
* Compatible with webwallet's encryptWithPassword/decryptWithPassword.
|
|
3186
|
+
*/
|
|
3187
|
+
declare function decryptWithSalt(ciphertext: string, password: string, salt: string): string | null;
|
|
3067
3188
|
/**
|
|
3068
3189
|
* Encrypt mnemonic phrase for storage
|
|
3069
3190
|
* Uses simple AES encryption compatible with existing wallet format
|
|
@@ -3257,4 +3378,4 @@ declare function randomHex(byteLength: number): string;
|
|
|
3257
3378
|
*/
|
|
3258
3379
|
declare function randomUUID(): string;
|
|
3259
3380
|
|
|
3260
|
-
export { type AddressInfo, CHARSET, CurrencyUtils, DEFAULT_DERIVATION_PATH, DEFAULT_TOKEN_DECIMALS, type DerivedKey, type EncryptedData, type EncryptionOptions, type KeyPair, type L1Config, type MasterKey, Sphere, type SphereCreateOptions, type SphereImportOptions, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, base58Decode, base58Encode, bytesToHex, computeHash160, convertBits, createAddress, createBech32, createKeyPair, createSphere, decodeBech32, decrypt, decryptJson, decryptMnemonic, decryptSimple, 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, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|
|
3381
|
+
export { type AddressInfo, CHARSET, 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, 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, isValidPrivateKey, loadSphere, mnemonicToEntropy, mnemonicToSeed, mnemonicToSeedSync, privateKeyToAddressInfo, publicKeyToAddress, randomBytes, randomHex, randomUUID, ripemd160, scanAddressesImpl, serializeEncrypted, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, validateMnemonic };
|