Skip to content

Commit

Permalink
Added keystore parameter to findKeyFile
Browse files Browse the repository at this point in the history
  • Loading branch information
tinybike committed Dec 14, 2015
1 parent a70186d commit 0ff004e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
9 changes: 5 additions & 4 deletions dist/keythereum.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ module.exports = {
* @return {buffer} Plaintext private key.
*/
recover: function (password, keyObject, cb) {
var self = this;

function verifyAndDecrypt(derivedKey, salt, iv, ciphertext) {

Expand All @@ -468,7 +469,6 @@ module.exports = {
}
}

var self = this;
var iv = keyObject.Crypto.cipherparams.iv;
var salt = keyObject.Crypto.kdfparams.salt;
var ciphertext = keyObject.Crypto.ciphertext;
Expand Down Expand Up @@ -569,7 +569,8 @@ module.exports = {
*/
importFromFile: function (address, datadir, cb) {
address = address.replace('0x', '');
function findKeyfile(address, files) {

function findKeyfile(keystore, address, files) {
var filepath = null;
for (var i = 0, len = files.length; i < len; ++i) {
if (files[i].indexOf(address) > -1) {
Expand All @@ -591,7 +592,7 @@ module.exports = {
if (cb && cb.constructor === Function) {
fs.readdir(keystore, function (ex, files) {
if (ex) throw ex;
var filepath = findKeyfile(address, files);
var filepath = findKeyfile(keystore, address, files);
if (filepath) {
cb(JSON.parse(fs.readFileSync(filepath)));
} else {
Expand All @@ -603,7 +604,7 @@ module.exports = {

} else {

var filepath = findKeyfile(address, fs.readdirSync(keystore));
var filepath = findKeyfile(keystore, address, fs.readdirSync(keystore));
if (filepath) {
return JSON.parse(fs.readFileSync(filepath));
} else {
Expand Down
22 changes: 11 additions & 11 deletions dist/keythereum.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ module.exports = {
* @return {buffer} Plaintext private key.
*/
recover: function (password, keyObject, cb) {
var self = this;

function verifyAndDecrypt(derivedKey, salt, iv, ciphertext) {

Expand All @@ -460,7 +461,6 @@ module.exports = {
}
}

var self = this;
var iv = keyObject.Crypto.cipherparams.iv;
var salt = keyObject.Crypto.kdfparams.salt;
var ciphertext = keyObject.Crypto.ciphertext;
Expand Down Expand Up @@ -561,7 +561,8 @@ module.exports = {
*/
importFromFile: function (address, datadir, cb) {
address = address.replace('0x', '');
function findKeyfile(address, files) {

function findKeyfile(keystore, address, files) {
var filepath = null;
for (var i = 0, len = files.length; i < len; ++i) {
if (files[i].indexOf(address) > -1) {
Expand All @@ -583,7 +584,7 @@ module.exports = {
if (cb && cb.constructor === Function) {
fs.readdir(keystore, function (ex, files) {
if (ex) throw ex;
var filepath = findKeyfile(address, files);
var filepath = findKeyfile(keystore, address, files);
if (filepath) {
cb(JSON.parse(fs.readFileSync(filepath)));
} else {
Expand All @@ -595,7 +596,7 @@ module.exports = {

} else {

var filepath = findKeyfile(address, fs.readdirSync(keystore));
var filepath = findKeyfile(keystore, address, fs.readdirSync(keystore));
if (filepath) {
return JSON.parse(fs.readFileSync(filepath));
} else {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keythereum",
"version": "0.1.9",
"version": "0.1.10",
"description": "Create, import and export Ethereum keys",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 0ff004e

Please sign in to comment.