Skip to content

Commit

Permalink
import wallet standardised private key input
Browse files Browse the repository at this point in the history
  • Loading branch information
SDargarh committed Jun 21, 2023
1 parent 3498573 commit 910b0a1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
##### Implement sign functionality

- Added sign() to sign a message or transaction and get signature along with v,r,s.

### 1.2.1 (2023-06-21)

- update import wallet to accept private key with or without '0x’ prefixed
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@getsafle/vault-bsc-controller",
"version": "1.2.0",
"version": "1.2.1",
"description": "",
"engines": {
"node": ">= 10"
Expand Down
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ class KeyringController extends EventEmitter {

importWallet(_privateKey) {
try {
const privateKey = ethUtil.toBuffer(_privateKey)

if (_privateKey.startsWith('0x')) {
_privateKey = _privateKey.slice(2)
}
const privateKey = Buffer.from(_privateKey, 'hex')

if (!ethUtil.isValidPrivate(privateKey))
throw "Enter a valid private key"

Expand Down

0 comments on commit 910b0a1

Please sign in to comment.