Skip to content

Commit 8f429c1

Browse files
fix(sdk-core): improve createUserKeychain
- use standard naming for the wallet passphrase - return the unencrypted private key in the response Issue: BTC-1708
1 parent 88ba6bb commit 8f429c1

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

modules/sdk-core/src/bitgo/keychain/keychains.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -498,25 +498,28 @@ export class Keychains implements IKeychains {
498498
}
499499

500500
/**
501-
* Create keychain for ofc wallet using the password
502-
* @param userPassword
503-
* @returns
501+
* Create user keychain, encrypt the private key with the wallet passphrase and store it in BitGo.
502+
* @param walletPassphrase
503+
* @returns Keychain including the decrypted private key
504504
*/
505-
async createUserKeychain(userPassword: string): Promise<Keychain> {
505+
async createUserKeychain(walletPassphrase: string): Promise<Keychain> {
506506
const keychains = this.baseCoin.keychains();
507507
const newKeychain = keychains.create();
508508
const originalPasscodeEncryptionCode = generateRandomPassword(5);
509509

510510
const encryptedPrv = this.bitgo.encrypt({
511-
password: userPassword,
511+
password: walletPassphrase,
512512
input: newKeychain.prv,
513513
});
514514

515-
return await keychains.add({
516-
encryptedPrv,
517-
originalPasscodeEncryptionCode,
518-
pub: newKeychain.pub,
519-
source: 'user',
520-
});
515+
return {
516+
...(await keychains.add({
517+
encryptedPrv,
518+
originalPasscodeEncryptionCode,
519+
pub: newKeychain.pub,
520+
source: 'user',
521+
})),
522+
prv: newKeychain.prv,
523+
};
521524
}
522525
}

0 commit comments

Comments
 (0)