(args: {
filename: string;
importPassword?: string;
})
| 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) { |
nothing calls this directly
no test coverage detected