diff --git a/index.js b/index.js index f7b2440e2..fa8c34014 100644 --- a/index.js +++ b/index.js @@ -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;