diff --git a/src/wallet/db/level/db.ts b/src/wallet/db/level/db.ts index 01ae128..d79dd31 100644 --- a/src/wallet/db/level/db.ts +++ b/src/wallet/db/level/db.ts @@ -39,24 +39,24 @@ export class WalletDB implements DbInterface { await this.db.put(wdb.V, version.toString()); } - public async getMasterKey(): Promise<{ - privateKey: Buffer; + public async getEncryptedMasterKey(): Promise<{ + encryptedKey: string; chaincode: Buffer; }> { const masterKey = await this.db.get(wdb.M); - const privateKey = Buffer.from(masterKey.slice(0, 64), 'hex'); - const chaincode = Buffer.from(masterKey.slice(64), 'hex'); + const [chainCodeHex, encryptedKey] = masterKey.split(':'); + const chaincode = Buffer.from(chainCodeHex, 'hex'); - return { privateKey, chaincode }; + return { encryptedKey, chaincode }; } - public async setMasterKey( - privateKey: Buffer, + public async setEncryptedMasterKey( + encryptedKey: string, chaincode: Buffer, ): Promise { await this.db.put( wdb.M, - Buffer.concat([privateKey, chaincode]).toString('hex'), + `${chaincode.toString('hex')}:${encryptedKey}`, ); }