* Derives keys from words/xPrivKey and checks for existing wallets against BWS. * If wallets exist, generates credentials and returns a single `key` and an array of found wallets as `clients`
(
opts: {
/** Mnemonic words */
words?: string;
/** Extended Private Key */
xPrivKey?: string;
/** Mnemonic's passphrase */
passphrase?: string;
/** Include testnet wallets */
includeTestnetWallets?: boolean;
/** Search legacy wallets (pre-fork BCH & old multisig wallets) */
includeLegacyWallets?: boolean;
},
/** BWS connection options (see ClientAPI constructor) */
clientOpts: API | any,
/** Event emitter to consume status updates, errors, and the end result */
events?: ServerAssistedImportEvents
)
| 3512 | * If wallets exist, generates credentials and returns a single `key` and an array of found wallets as `clients` |
| 3513 | */ |
| 3514 | static async serverAssistedImport( |
| 3515 | opts: { |
| 3516 | /** Mnemonic words */ |
| 3517 | words?: string; |
| 3518 | /** Extended Private Key */ |
| 3519 | xPrivKey?: string; |
| 3520 | /** Mnemonic's passphrase */ |
| 3521 | passphrase?: string; |
| 3522 | /** Include testnet wallets */ |
| 3523 | includeTestnetWallets?: boolean; |
| 3524 | /** Search legacy wallets (pre-fork BCH & old multisig wallets) */ |
| 3525 | includeLegacyWallets?: boolean; |
| 3526 | }, |
| 3527 | /** BWS connection options (see ClientAPI constructor) */ |
| 3528 | clientOpts: API | any, |
| 3529 | /** Event emitter to consume status updates, errors, and the end result */ |
| 3530 | events?: ServerAssistedImportEvents |
| 3531 | ) { |
| 3532 | $.checkArgument(!events || events instanceof EventEmitter, 'Invalid argument: events must be an EventEmitter instance'); |
| 3533 | try { |
| 3534 | const { words, xPrivKey, passphrase, includeTestnetWallets, includeLegacyWallets } = opts || {}; |
| 3535 | $.checkArgument(words || xPrivKey, 'Missing argument: words or xPrivKey at <serverAssistedImport()>'); |
| 3536 | const client = clientOpts instanceof API ? API.clone(clientOpts) : new API(clientOpts); |
| 3537 | const keyConfigs: Array<{ |
| 3538 | chains?: Set<string>; |
| 3539 | nonCompliantDerivation: boolean; |
| 3540 | useLegacyCoinType?: boolean; |
| 3541 | useLegacyPurpose: boolean; |
| 3542 | passphrase?: string; |
| 3543 | }> = [ |
| 3544 | { |
| 3545 | // current wallets: /[44,48]/[0,145]'/ |
| 3546 | nonCompliantDerivation: false, |
| 3547 | useLegacyCoinType: false, |
| 3548 | useLegacyPurpose: false, |
| 3549 | passphrase: undefined // is set later |
| 3550 | } |
| 3551 | ]; |
| 3552 | |
| 3553 | if (includeLegacyWallets) { |
| 3554 | const legacyConfigs = [ |
| 3555 | { |
| 3556 | // old BCH wallets: m/48'/0'/ |
| 3557 | nonCompliantDerivation: false, |
| 3558 | useLegacyCoinType: true, |
| 3559 | useLegacyPurpose: false |
| 3560 | }, |
| 3561 | { |
| 3562 | // old BTC/BCH multisig wallets: m/44'/145'/ |
| 3563 | nonCompliantDerivation: false, |
| 3564 | useLegacyCoinType: false, |
| 3565 | useLegacyPurpose: true |
| 3566 | }, |
| 3567 | { |
| 3568 | // old multisig BCH wallets: m/44'/0'/ |
| 3569 | nonCompliantDerivation: false, |
| 3570 | useLegacyCoinType: true, |
| 3571 | useLegacyPurpose: true |
no test coverage detected