@unicitylabs/sphere-sdk 0.6.1 → 0.6.2

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.
@@ -1,717 +0,0 @@
1
- import elliptic from 'elliptic';
2
-
3
- interface Wallet {
4
- masterPrivateKey: string;
5
- chainCode?: string;
6
- addresses: WalletAddress[];
7
- createdAt?: number;
8
- isEncrypted?: boolean;
9
- encryptedMasterKey?: string;
10
- childPrivateKey?: string | null;
11
- isImportedAlphaWallet?: boolean;
12
- masterChainCode?: string | null;
13
- isBIP32?: boolean;
14
- descriptorPath?: string | null;
15
- }
16
- interface WalletAddress {
17
- address: string;
18
- publicKey?: string;
19
- privateKey?: string;
20
- path: string | null;
21
- index: number;
22
- createdAt?: string;
23
- isChange?: boolean;
24
- }
25
- interface StoredWallet {
26
- key: string;
27
- data: Wallet;
28
- }
29
- interface TransactionInput {
30
- txid: string;
31
- vout: number;
32
- value: number;
33
- address: string;
34
- }
35
- interface TransactionOutput {
36
- value: number;
37
- address: string;
38
- }
39
- interface Transaction {
40
- input: TransactionInput;
41
- outputs: TransactionOutput[];
42
- fee: number;
43
- changeAmount: number;
44
- changeAddress: string;
45
- }
46
- interface TransactionPlan {
47
- success: boolean;
48
- transactions: Transaction[];
49
- error?: string;
50
- }
51
- interface UTXO {
52
- txid?: string;
53
- tx_hash?: string;
54
- vout?: number;
55
- tx_pos?: number;
56
- value: number;
57
- height?: number;
58
- address?: string;
59
- }
60
- interface RestoreWalletResult {
61
- success: boolean;
62
- wallet: Wallet;
63
- message?: string;
64
- error?: string;
65
- /** Indicates that the wallet.dat file is encrypted and requires a password */
66
- isEncryptedDat?: boolean;
67
- }
68
- interface ExportOptions {
69
- password?: string;
70
- filename?: string;
71
- }
72
- /**
73
- * JSON Wallet Export Format v1.0
74
- *
75
- * Supports multiple wallet sources:
76
- * - "mnemonic": Created from BIP39 mnemonic phrase (new standard)
77
- * - "file_bip32": Imported from file with chain code (BIP32 HD wallet)
78
- * - "file_standard": Imported from file without chain code (HMAC-based)
79
- * - "dat_descriptor": Imported from wallet.dat descriptor wallet
80
- * - "dat_hd": Imported from wallet.dat HD wallet
81
- * - "dat_legacy": Imported from wallet.dat legacy wallet
82
- */
83
- type WalletJSONSource = "mnemonic" | "file_bip32" | "file_standard" | "dat_descriptor" | "dat_hd" | "dat_legacy";
84
- type WalletJSONDerivationMode = "bip32" | "wif_hmac" | "legacy_hmac";
85
- interface WalletJSONAddress {
86
- address: string;
87
- publicKey: string;
88
- path: string;
89
- index?: number;
90
- isChange?: boolean;
91
- }
92
- /**
93
- * JSON Wallet Export structure
94
- */
95
- interface WalletJSON {
96
- /** Format version */
97
- version: "1.0";
98
- /** Generation timestamp ISO 8601 */
99
- generated: string;
100
- /** Security warning */
101
- warning: string;
102
- /** Master private key (hex, 64 chars) */
103
- masterPrivateKey: string;
104
- /** Master chain code for BIP32 (hex, 64 chars) - optional for HMAC wallets */
105
- chainCode?: string;
106
- /** BIP39 mnemonic phrase - only present if source is "mnemonic" */
107
- mnemonic?: string;
108
- /** Derivation mode used */
109
- derivationMode: WalletJSONDerivationMode;
110
- /** Source of the wallet */
111
- source: WalletJSONSource;
112
- /** First address for verification */
113
- firstAddress: WalletJSONAddress;
114
- /** Descriptor path for BIP32 wallets (e.g., "84'/0'/0'") */
115
- descriptorPath?: string;
116
- /** Encrypted fields (when password protected) */
117
- encrypted?: {
118
- /** Encrypted master private key (AES-256) */
119
- masterPrivateKey: string;
120
- /** Encrypted mnemonic (AES-256) - only if source is "mnemonic" */
121
- mnemonic?: string;
122
- /** Salt used for key derivation */
123
- salt: string;
124
- /** Number of PBKDF2 iterations */
125
- iterations: number;
126
- };
127
- /** Additional addresses beyond first (optional) */
128
- addresses?: WalletJSONAddress[];
129
- }
130
- interface WalletJSONExportOptions {
131
- /** Password for encryption (optional) */
132
- password?: string;
133
- /** Include all addresses (default: only first address) */
134
- includeAllAddresses?: boolean;
135
- /** Number of addresses to include (if includeAllAddresses is false) */
136
- addressCount?: number;
137
- }
138
- interface WalletJSONImportResult {
139
- success: boolean;
140
- wallet?: Wallet;
141
- source?: WalletJSONSource;
142
- derivationMode?: WalletJSONDerivationMode;
143
- /** Indicates if mnemonic was found in the JSON */
144
- hasMnemonic?: boolean;
145
- /** The decrypted mnemonic phrase (if available) */
146
- mnemonic?: string;
147
- message?: string;
148
- error?: string;
149
- }
150
- type VestingMode = "all" | "vested" | "unvested";
151
- interface ClassifiedUTXO extends UTXO {
152
- vestingStatus?: "vested" | "unvested" | "error";
153
- coinbaseHeight?: number | null;
154
- }
155
- interface VestingBalances {
156
- vested: bigint;
157
- unvested: bigint;
158
- all: bigint;
159
- }
160
- interface ClassificationResult {
161
- isVested: boolean;
162
- coinbaseHeight: number | null;
163
- error?: string;
164
- }
165
- /**
166
- * Parse BIP32 path components from a derivation path string
167
- * @param path - Full path like "m/84'/1'/0'/0/5" or "m/44'/0'/0'/1/3"
168
- * @returns { chain: number, index: number } where chain=0 is external, chain=1 is change
169
- * Returns null if path is invalid
170
- *
171
- * Examples:
172
- * "m/84'/1'/0'/0/5" -> { chain: 0, index: 5 } (external address 5)
173
- * "m/84'/1'/0'/1/3" -> { chain: 1, index: 3 } (change address 3)
174
- */
175
- declare function parsePathComponents(path: string): {
176
- chain: number;
177
- index: number;
178
- } | null;
179
- /**
180
- * Check if a BIP32 path represents a change address (chain=1)
181
- * @param path - Full BIP32 path string
182
- * @returns true if this is a change address path
183
- */
184
- declare function isChangePath(path: string): boolean;
185
- /**
186
- * Get display-friendly index from path (for UI display only)
187
- * @param path - Full BIP32 path string
188
- * @returns The address index number, or 0 if invalid
189
- */
190
- declare function getIndexFromPath(path: string): number;
191
- /**
192
- * Convert a BIP32 path to a DOM-safe ID string
193
- * Replaces characters that are invalid in DOM IDs:
194
- * - ' (apostrophe) -> 'h' (hardened marker)
195
- * - / (forward slash) -> '-' (dash)
196
- *
197
- * @param path - Full BIP32 path like "m/84'/1'/0'/0/5"
198
- * @returns DOM-safe ID like "m-84h-1h-0h-0-5"
199
- *
200
- * Examples:
201
- * "m/84'/1'/0'/0/5" -> "m-84h-1h-0h-0-5"
202
- * "m/44'/0'/0'/1/3" -> "m-44h-0h-0h-1-3"
203
- */
204
- declare function pathToDOMId(path: string): string;
205
- /**
206
- * Convert a DOM-safe ID back to a BIP32 path string
207
- * Reverses the transformation done by pathToDOMId:
208
- * - 'h' -> ' (apostrophe for hardened)
209
- * - '-' -> / (forward slash)
210
- *
211
- * @param encoded - DOM-safe ID like "m-84h-1h-0h-0-5"
212
- * @returns BIP32 path like "m/84'/1'/0'/0/5"
213
- *
214
- * Examples:
215
- * "m-84h-1h-0h-0-5" -> "m/84'/1'/0'/0/5"
216
- * "m-44h-0h-0h-1-3" -> "m/44'/0'/0'/1/3"
217
- */
218
- declare function domIdToPath(encoded: string): string;
219
-
220
- /**
221
- * Bech32 Encoding/Decoding
222
- * BIP-173 implementation for address encoding
223
- */
224
- /** Bech32 character set from BIP-173 */
225
- declare const CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
226
- /**
227
- * Convert between bit arrays (8→5 or 5→8)
228
- */
229
- declare function convertBits(data: number[], fromBits: number, toBits: number, pad: boolean): number[] | null;
230
- /**
231
- * Encode data to bech32 address
232
- *
233
- * @example
234
- * ```ts
235
- * const address = encodeBech32('alpha', 1, pubkeyHash);
236
- * // 'alpha1qw...'
237
- * ```
238
- */
239
- declare function encodeBech32(hrp: string, version: number, program: Uint8Array): string;
240
- /**
241
- * Decode bech32 address
242
- *
243
- * @example
244
- * ```ts
245
- * const result = decodeBech32('alpha1qw...');
246
- * // { hrp: 'alpha', witnessVersion: 1, data: Uint8Array }
247
- * ```
248
- */
249
- declare function decodeBech32(addr: string): {
250
- hrp: string;
251
- witnessVersion: number;
252
- data: Uint8Array;
253
- } | null;
254
- /**
255
- * Alias for encodeBech32 (L1 SDK compatibility)
256
- */
257
- declare const createBech32: typeof encodeBech32;
258
-
259
- /**
260
- * Convert "alpha1xxxx" Bech32 → Electrum script hash
261
- * Required for:
262
- * - blockchain.scripthash.get_history
263
- * - blockchain.scripthash.listunspent
264
- */
265
- declare function addressToScriptHash(address: string): string;
266
-
267
- /**
268
- * Cryptographic utilities for SDK2
269
- *
270
- * Provides BIP39 mnemonic and BIP32 key derivation functions.
271
- * Platform-independent - no browser-specific APIs.
272
- */
273
-
274
- declare const ec: elliptic.ec;
275
- interface DerivedKey {
276
- privateKey: string;
277
- chainCode: string;
278
- }
279
- interface KeyPair {
280
- privateKey: string;
281
- publicKey: string;
282
- }
283
- interface AddressInfo extends KeyPair {
284
- address: string;
285
- path: string;
286
- index: number;
287
- }
288
- /**
289
- * Derive child key using BIP32 standard
290
- * @param parentPrivKey - Parent private key (64 hex chars)
291
- * @param parentChainCode - Parent chain code (64 hex chars)
292
- * @param index - Child index (>= 0x80000000 for hardened)
293
- */
294
- declare function deriveChildKey$1(parentPrivKey: string, parentChainCode: string, index: number): DerivedKey;
295
- /**
296
- * Derive key at a full BIP32/BIP44 path
297
- * @param masterPrivKey - Master private key
298
- * @param masterChainCode - Master chain code
299
- * @param path - BIP44 path like "m/44'/0'/0'/0/0"
300
- */
301
- declare function deriveKeyAtPath$1(masterPrivKey: string, masterChainCode: string, path: string): DerivedKey;
302
- /**
303
- * Compute HASH160 (SHA256 -> RIPEMD160)
304
- */
305
- declare function hash160(data: string): string;
306
- /**
307
- * Alias for hash160 (L1 SDK compatibility)
308
- */
309
- declare const computeHash160: typeof hash160;
310
- /**
311
- * Convert hex string to Uint8Array for witness program
312
- */
313
- declare function hash160ToBytes(hash160Hex: string): Uint8Array;
314
- /**
315
- * Generate bech32 address from public key
316
- * @param publicKey - Compressed public key as hex string
317
- * @param prefix - Address prefix (default: "alpha")
318
- * @param witnessVersion - Witness version (default: 0 for P2WPKH)
319
- * @returns Bech32 encoded address
320
- */
321
- declare function publicKeyToAddress(publicKey: string, prefix?: string, witnessVersion?: number): string;
322
- /**
323
- * Get address info from private key
324
- */
325
- declare function privateKeyToAddressInfo(privateKey: string, prefix?: string): {
326
- address: string;
327
- publicKey: string;
328
- };
329
- /**
330
- * Generate full address info from private key with index and path
331
- * (L1 SDK compatibility)
332
- */
333
- declare function generateAddressInfo(privateKey: string, index: number, path: string, prefix?: string): AddressInfo;
334
-
335
- declare function encrypt(text: string, password: string): string;
336
- declare function decrypt(encrypted: string, password: string): string;
337
- declare function generatePrivateKey(): string;
338
- /**
339
- * Encrypt wallet master key with password using PBKDF2 + AES
340
- */
341
- declare function encryptWallet(masterPrivateKey: string, password: string): string;
342
- /**
343
- * Decrypt wallet master key with password
344
- */
345
- declare function decryptWallet(encryptedData: string, password: string): string;
346
- /**
347
- * Convert hex private key to WIF format
348
- */
349
- declare function hexToWIF(hexKey: string): string;
350
-
351
- /**
352
- * L1 Address Derivation
353
- *
354
- * Uses core crypto functions for standard BIP32 derivation,
355
- * plus legacy functions for backward compatibility with old wallets.
356
- */
357
-
358
- /**
359
- * Standard BIP32 child key derivation
360
- * Re-export from core with L1 naming convention
361
- */
362
- declare const deriveChildKeyBIP32: typeof deriveChildKey$1;
363
- /**
364
- * Derive key at a full BIP44 path
365
- * Re-export from core
366
- */
367
- declare const deriveKeyAtPath: typeof deriveKeyAtPath$1;
368
- /**
369
- * Generate master key and chain code from seed (BIP32 standard)
370
- * Wrapper around core function with L1 return type naming
371
- */
372
- declare function generateMasterKeyFromSeed(seedHex: string): {
373
- masterPrivateKey: string;
374
- masterChainCode: string;
375
- };
376
- /**
377
- * Generate HD address using standard BIP32
378
- * Standard path: m/44'/0'/0'/0/{index} (external chain, non-hardened)
379
- * For change addresses, use isChange = true to get m/44'/0'/0'/1/{index}
380
- */
381
- declare function generateHDAddressBIP32(masterPriv: string, chainCode: string, index: number, basePath?: string, isChange?: boolean): AddressInfo;
382
- /**
383
- * Generate address from master private key using HMAC-SHA512 derivation
384
- * This matches exactly the original index.html implementation
385
- * NOTE: This is NON-STANDARD derivation for legacy wallet compatibility
386
- *
387
- * @param masterPrivateKey - 32-byte hex private key (64 chars)
388
- * @param index - Address index
389
- */
390
- declare function generateAddressFromMasterKey(masterPrivateKey: string, index: number): AddressInfo;
391
- /**
392
- * @deprecated Use deriveChildKeyBIP32 for new wallets
393
- * Legacy HMAC-SHA512 derivation (non-standard)
394
- * Kept for backward compatibility with old wallets
395
- */
396
- declare function deriveChildKey(masterPriv: string, chainCode: string, index: number): {
397
- privateKey: string;
398
- nextChainCode: string;
399
- };
400
- /**
401
- * @deprecated Use generateHDAddressBIP32 for new wallets
402
- * Legacy HD address generation (non-standard derivation)
403
- */
404
- declare function generateHDAddress(masterPriv: string, chainCode: string, index: number): AddressInfo;
405
-
406
- interface BlockHeader {
407
- height: number;
408
- hex: string;
409
- [key: string]: unknown;
410
- }
411
- declare function isWebSocketConnected(): boolean;
412
- declare function waitForConnection(): Promise<void>;
413
- declare function connect(endpoint?: string): Promise<void>;
414
- declare function rpc(method: string, params?: unknown[]): Promise<unknown>;
415
- declare function getUtxo(address: string): Promise<{
416
- tx_hash: string | undefined;
417
- tx_pos: number | undefined;
418
- value: number;
419
- height: number | undefined;
420
- address: string;
421
- }[]>;
422
- declare function getBalance(address: string): Promise<number>;
423
- declare function broadcast(rawHex: string): Promise<unknown>;
424
- declare function subscribeBlocks(cb: (header: BlockHeader) => void): Promise<() => void>;
425
- interface TransactionHistoryItem {
426
- tx_hash: string;
427
- height: number;
428
- fee?: number;
429
- }
430
- interface TransactionDetail {
431
- txid: string;
432
- version: number;
433
- locktime: number;
434
- vin: Array<{
435
- txid: string;
436
- vout: number;
437
- scriptSig?: {
438
- hex: string;
439
- };
440
- sequence: number;
441
- }>;
442
- vout: Array<{
443
- value: number;
444
- n: number;
445
- scriptPubKey: {
446
- hex: string;
447
- type: string;
448
- addresses?: string[];
449
- address?: string;
450
- };
451
- }>;
452
- blockhash?: string;
453
- confirmations?: number;
454
- time?: number;
455
- blocktime?: number;
456
- }
457
- declare function getTransactionHistory(address: string): Promise<TransactionHistoryItem[]>;
458
- declare function getTransaction(txid: string): Promise<unknown>;
459
- declare function getBlockHeader(height: number): Promise<unknown>;
460
- declare function getCurrentBlockHeight(): Promise<number>;
461
- declare function disconnect(): void;
462
-
463
- /**
464
- * Create scriptPubKey for address (P2WPKH for bech32)
465
- * Exact copy from index.html
466
- */
467
- declare function createScriptPubKey(address: string): string;
468
- /**
469
- * Build a proper SegWit transaction
470
- * Exact copy from index.html buildSegWitTransaction()
471
- */
472
- declare function buildSegWitTransaction(txPlan: {
473
- input: {
474
- tx_hash: string;
475
- tx_pos: number;
476
- value: number;
477
- };
478
- outputs: Array<{
479
- value: number;
480
- address: string;
481
- }>;
482
- }, keyPair: elliptic.ec.KeyPair, publicKey: string): {
483
- hex: string;
484
- txid: string;
485
- };
486
- /**
487
- * Create and sign a transaction
488
- * Uses the private key for the specific address being spent from
489
- */
490
- declare function createAndSignTransaction(wallet: Wallet, txPlan: Transaction): {
491
- raw: string;
492
- txid: string;
493
- };
494
- /**
495
- * Collect UTXOs for required amount
496
- * Based on index.html collectUtxosForAmount()
497
- *
498
- * Strategy: First try to find a single UTXO that can cover amount + fee.
499
- * If not found, fall back to combining multiple UTXOs.
500
- */
501
- declare function collectUtxosForAmount(utxoList: UTXO[], amountSats: number, recipientAddress: string, senderAddress: string): TransactionPlan;
502
- /**
503
- * Create transaction plan from wallet
504
- * @param wallet - The wallet
505
- * @param toAddress - Recipient address
506
- * @param amountAlpha - Amount in ALPHA
507
- * @param fromAddress - Optional: specific address to send from (defaults to first address)
508
- */
509
- declare function createTransactionPlan(wallet: Wallet, toAddress: string, amountAlpha: number, fromAddress?: string): Promise<TransactionPlan>;
510
- /**
511
- * Send ALPHA to address
512
- * @param wallet - The wallet
513
- * @param toAddress - Recipient address
514
- * @param amountAlpha - Amount in ALPHA
515
- * @param fromAddress - Optional: specific address to send from
516
- */
517
- declare function sendAlpha(wallet: Wallet, toAddress: string, amountAlpha: number, fromAddress?: string): Promise<{
518
- txid: string;
519
- raw: string;
520
- broadcastResult: unknown;
521
- }[]>;
522
-
523
- declare const VESTING_THRESHOLD = 280000;
524
- declare class VestingClassifier {
525
- private memoryCache;
526
- private dbName;
527
- private storeName;
528
- private db;
529
- /**
530
- * Initialize IndexedDB for persistent caching.
531
- * In Node.js (no IndexedDB), silently falls back to memory-only caching.
532
- */
533
- initDB(): Promise<void>;
534
- /**
535
- * Check if transaction is coinbase
536
- */
537
- private isCoinbaseTransaction;
538
- /**
539
- * Load from IndexedDB cache
540
- */
541
- private loadFromDB;
542
- /**
543
- * Save to IndexedDB cache
544
- */
545
- private saveToDB;
546
- /**
547
- * Trace a transaction to its coinbase origin
548
- * Alpha blockchain has single-input transactions, making this a linear trace
549
- */
550
- traceToOrigin(txHash: string): Promise<{
551
- coinbaseHeight: number | null;
552
- error?: string;
553
- }>;
554
- /**
555
- * Classify a single UTXO
556
- */
557
- classifyUtxo(utxo: UTXO): Promise<ClassificationResult>;
558
- /**
559
- * Classify multiple UTXOs with progress callback
560
- */
561
- classifyUtxos(utxos: UTXO[], onProgress?: (current: number, total: number) => void): Promise<{
562
- vested: ClassifiedUTXO[];
563
- unvested: ClassifiedUTXO[];
564
- errors: Array<{
565
- utxo: UTXO;
566
- error: string;
567
- }>;
568
- }>;
569
- /**
570
- * Clear all caches
571
- */
572
- clearCaches(): void;
573
- /**
574
- * Destroy caches and delete the IndexedDB database entirely.
575
- */
576
- destroy(): Promise<void>;
577
- }
578
- declare const vestingClassifier: VestingClassifier;
579
-
580
- declare class VestingStateManager {
581
- private currentMode;
582
- private addressCache;
583
- private classificationInProgress;
584
- /**
585
- * Set the current vesting mode
586
- */
587
- setMode(mode: VestingMode): void;
588
- getMode(): VestingMode;
589
- /**
590
- * Classify all UTXOs for an address
591
- */
592
- classifyAddressUtxos(address: string, utxos: UTXO[], onProgress?: (current: number, total: number) => void): Promise<void>;
593
- /**
594
- * Get filtered UTXOs based on current vesting mode
595
- */
596
- getFilteredUtxos(address: string): ClassifiedUTXO[];
597
- /**
598
- * Get all UTXOs regardless of vesting mode (for transactions)
599
- */
600
- getAllUtxos(address: string): ClassifiedUTXO[];
601
- /**
602
- * Get balance for current vesting mode (in satoshis)
603
- */
604
- getBalance(address: string): bigint;
605
- /**
606
- * Get all balances for display
607
- */
608
- getAllBalances(address: string): VestingBalances;
609
- /**
610
- * Check if address has been classified
611
- */
612
- hasClassifiedData(address: string): boolean;
613
- /**
614
- * Check if classification is in progress
615
- */
616
- isClassifying(): boolean;
617
- /**
618
- * Clear cache for an address
619
- */
620
- clearAddressCache(address: string): void;
621
- /**
622
- * Clear all caches
623
- */
624
- clearAllCaches(): void;
625
- }
626
- declare const vestingState: VestingStateManager;
627
-
628
- /**
629
- * WalletAddressHelper - Path-based address lookup and mutation utilities
630
- *
631
- * Key principle: A BIP32 path ALWAYS derives the same address from a given master key.
632
- * - If we try to add a different address for an existing path → FATAL ERROR
633
- * - This indicates corruption, wrong derivation, or data integrity issue
634
- *
635
- * Performance: O(n) lookup is negligible for typical wallet sizes (5-100 addresses)
636
- */
637
-
638
- declare class WalletAddressHelper {
639
- /**
640
- * Find address by BIP32 derivation path
641
- * @param wallet - The wallet to search
642
- * @param path - Full BIP32 path like "m/84'/1'/0'/0/5"
643
- * @returns The address if found, undefined otherwise
644
- */
645
- static findByPath(wallet: Wallet, path: string): WalletAddress | undefined;
646
- /**
647
- * Get the default address (first external/non-change address)
648
- * This replaces `wallet.addresses[0]` pattern for safer access
649
- *
650
- * @param wallet - The wallet
651
- * @returns First non-change address, or first address if all are change
652
- */
653
- static getDefault(wallet: Wallet): WalletAddress;
654
- /**
655
- * Get the default address, or undefined if wallet has no addresses
656
- * Safe version that doesn't throw on empty wallet
657
- */
658
- static getDefaultOrNull(wallet: Wallet): WalletAddress | undefined;
659
- /**
660
- * Add new address to wallet (immutable operation)
661
- *
662
- * THROWS if address with same path but different address string already exists.
663
- * This indicates a serious derivation or data corruption issue.
664
- *
665
- * If the same path+address already exists, returns wallet unchanged (idempotent).
666
- *
667
- * @param wallet - The wallet to add to
668
- * @param newAddress - The address to add
669
- * @returns New wallet object with address added
670
- * @throws Error if path exists with different address (corruption indicator)
671
- */
672
- static add(wallet: Wallet, newAddress: WalletAddress): Wallet;
673
- /**
674
- * Remove address by path (immutable operation)
675
- * @param wallet - The wallet to modify
676
- * @param path - The path of the address to remove
677
- * @returns New wallet object with address removed
678
- */
679
- static removeByPath(wallet: Wallet, path: string): Wallet;
680
- /**
681
- * Get all external (non-change) addresses
682
- * @param wallet - The wallet
683
- * @returns Array of external addresses
684
- */
685
- static getExternal(wallet: Wallet): WalletAddress[];
686
- /**
687
- * Get all change addresses
688
- * @param wallet - The wallet
689
- * @returns Array of change addresses
690
- */
691
- static getChange(wallet: Wallet): WalletAddress[];
692
- /**
693
- * Check if wallet has an address with the given path
694
- * @param wallet - The wallet to check
695
- * @param path - The path to look for
696
- * @returns true if path exists
697
- */
698
- static hasPath(wallet: Wallet, path: string): boolean;
699
- /**
700
- * Validate wallet address array integrity
701
- * Checks for duplicate paths which indicate data corruption
702
- *
703
- * @param wallet - The wallet to validate
704
- * @throws Error if duplicate paths found
705
- */
706
- static validate(wallet: Wallet): void;
707
- /**
708
- * Sort addresses with external first, then change, each sorted by index
709
- * Useful for display purposes
710
- *
711
- * @param wallet - The wallet
712
- * @returns New wallet with sorted addresses
713
- */
714
- static sortAddresses(wallet: Wallet): Wallet;
715
- }
716
-
717
- export { type BlockHeader, CHARSET, type ClassificationResult, type ClassifiedUTXO, type ExportOptions, type RestoreWalletResult, type StoredWallet, type Transaction, type TransactionDetail, type TransactionHistoryItem, type TransactionInput, type TransactionOutput, type TransactionPlan, type UTXO, VESTING_THRESHOLD, type VestingBalances, type VestingMode, type Wallet, type WalletAddress, WalletAddressHelper, type WalletJSON, type WalletJSONAddress, type WalletJSONDerivationMode, type WalletJSONExportOptions, type WalletJSONImportResult, type WalletJSONSource, addressToScriptHash, broadcast, buildSegWitTransaction, collectUtxosForAmount, computeHash160, connect, convertBits, createAndSignTransaction, createBech32, createScriptPubKey, createTransactionPlan, decodeBech32, decrypt, decryptWallet, deriveChildKey, deriveChildKeyBIP32, deriveKeyAtPath, disconnect, domIdToPath, ec, encodeBech32, encrypt, encryptWallet, generateAddressFromMasterKey, generateAddressInfo, generateHDAddress, generateHDAddressBIP32, generateMasterKeyFromSeed, generatePrivateKey, getBalance, getBlockHeader, getCurrentBlockHeight, getIndexFromPath, getTransaction, getTransactionHistory, getUtxo, hash160, hash160ToBytes, hexToWIF, isChangePath, isWebSocketConnected, parsePathComponents, pathToDOMId, privateKeyToAddressInfo, publicKeyToAddress, rpc, sendAlpha, subscribeBlocks, vestingClassifier, vestingState, waitForConnection };