Skip to content

Commit

Permalink
feat: change db implementation for strings
Browse files Browse the repository at this point in the history
  • Loading branch information
emjshrx committed Feb 3, 2024
1 parent 330b3b9 commit ebb8794
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/wallet/db/level/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
await this.db.put(
wdb.M,
Buffer.concat([privateKey, chaincode]).toString('hex'),
`${chaincode.toString('hex')}:${encryptedKey}`,
);
}

Expand Down

0 comments on commit ebb8794

Please sign in to comment.