Added summonBrainWallet function.

This commit is contained in:
ricmoo 2016-08-01 19:24:52 -04:00
parent b298d41c22
commit 839c2a10aa

@ -1,6 +1,7 @@
'use strict';
var rlp = require('rlp');
var scrypt = require('scrypt-js');
var Contract = require('./lib/contract.js');
var secretStorage = require('./lib/secret-storage.js');
@ -32,6 +33,8 @@ utils.defineProperty(exportUtils, 'getContractAddress', function(transaction) {
module.exports = Wallet;
utils.defineProperty(Wallet, 'etherSymbol', '\uD835\uDF63');
utils.defineProperty(Wallet, 'getAddress', SigningKey.getAddress);
utils.defineProperty(Wallet, 'getIcapAddress', SigningKey.getIcapAddress);
@ -63,6 +66,20 @@ utils.defineProperty(Wallet.prototype, 'encrypt', function(password, options, ca
secretStorage.encrypt(this.privateKey, password, options, callback);
});
utils.defineProperty(Wallet, 'summonBrainWallet', function(username, password, callback) {
if (typeof(callback) !== 'function') { throw new Error('invalid callback'); }
scrypt(password, username, (1 << 18), 8, 1, 32, function(error, progress, key) {
if (key) {
console.log(key, new Buffer(key), (new Buffer(key)).toString('hex'));
return callback(error, new Wallet(new Buffer(key)), 1);
} else {
return callback(error, null, progress);
}
});
});
utils.defineProperty(Wallet, 'randomish', new Randomish());
module.exports = Wallet;