MCPcopy Create free account
hub / github.com/bitpay/bitcore / import

Method import

packages/bitcore-cli/src/wallet.ts:362–384  ·  view source on GitHub ↗
(args: {
    filename: string;
    importPassword?: string;
  })

Source from the content-addressed store, hash-verified

360 }
361
362 async import(args: {
363 filename: string;
364 importPassword?: string;
365 }) {
366 const { filename, importPassword } = args;
367 let data: any = await fs.promises.readFile(filename, 'utf8');
368 data = Encryption.decryptWithPassword(data, importPassword);
369 data = Utils.jsonParseWithBuffer(data);
370 if (data.key) { // no data.key means it's a readonly wallet
371 if (data.key.keychain) {
372 data.key = new TssKey.TssKey(data.key);
373 } else {
374 data.key = new Key({ seedType: 'object', seedData: data.key });
375 }
376 const walletPassword = await getPassword('Set a wallet password:', { minLength: 6, hidden: false });
377 data.key.encrypt(walletPassword);
378 }
379 this.#walletData = {
380 key: data.key,
381 credentials: Credentials.fromObj(data.credentials)
382 };
383 await this.save();
384 }
385
386 isComplete() {
387 if (!this.client) {

Callers

nothing calls this directly

Calls 6

saveMethod · 0.95
getPasswordFunction · 0.90
decryptWithPasswordMethod · 0.80
jsonParseWithBufferMethod · 0.80
encryptMethod · 0.45
fromObjMethod · 0.45

Tested by

no test coverage detected