Skip to content

Commit

Permalink
fix: Use lumos to init Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
yanguoyu committed May 22, 2024
1 parent 286f199 commit 0586f69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/controllers/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ export default class WalletsController {
const keystoreObject = Keystore.fromJson(keystore)
const masterPrivateKey = keystoreObject.extendedPrivateKey(password)
const masterKeychain = new Keychain(
Buffer.from(masterPrivateKey.privateKey, 'hex'),
Buffer.from(masterPrivateKey.chainCode, 'hex')
Buffer.from(bytes.bytify(masterPrivateKey.privateKey)),
Buffer.from(bytes.bytify(masterPrivateKey.chainCode))
)
const accountKeychain = masterKeychain.derivePath(AccountExtendedPublicKey.ckbAccountPath)
const accountExtendedPublicKey = new AccountExtendedPublicKey(
Expand Down
5 changes: 3 additions & 2 deletions packages/neuron-wallet/src/services/sign-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ec as EC } from 'elliptic'
import { AddressNotFound } from '../exceptions'
import HardwareWalletService from './hardware'
import AddressParser from '../models/address-parser'
import { bytes } from '@ckb-lumos/codec'

export default class SignMessage {
static GENERATE_COUNT = 100
Expand Down Expand Up @@ -91,8 +92,8 @@ export default class SignMessage {
private static getPrivateKey(wallet: Wallet, path: string, password: string): string {
const masterPrivateKey = wallet.loadKeystore().extendedPrivateKey(password)
const masterKeychain = new Keychain(
Buffer.from(masterPrivateKey.privateKey, 'hex'),
Buffer.from(masterPrivateKey.chainCode, 'hex')
Buffer.from(bytes.bytify(masterPrivateKey.privateKey)),
Buffer.from(bytes.bytify(masterPrivateKey.chainCode))
)

return `0x${masterKeychain.derivePath(path).privateKey.toString('hex')}`
Expand Down

1 comment on commit 0586f69

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 9187093440

Please sign in to comment.