Added summonBrainWallet function.
This commit is contained in:
parent
b298d41c22
commit
839c2a10aa
17
index.js
17
index.js
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var rlp = require('rlp');
|
var rlp = require('rlp');
|
||||||
|
var scrypt = require('scrypt-js');
|
||||||
|
|
||||||
var Contract = require('./lib/contract.js');
|
var Contract = require('./lib/contract.js');
|
||||||
var secretStorage = require('./lib/secret-storage.js');
|
var secretStorage = require('./lib/secret-storage.js');
|
||||||
@ -32,6 +33,8 @@ utils.defineProperty(exportUtils, 'getContractAddress', function(transaction) {
|
|||||||
module.exports = Wallet;
|
module.exports = Wallet;
|
||||||
|
|
||||||
|
|
||||||
|
utils.defineProperty(Wallet, 'etherSymbol', '\uD835\uDF63');
|
||||||
|
|
||||||
utils.defineProperty(Wallet, 'getAddress', SigningKey.getAddress);
|
utils.defineProperty(Wallet, 'getAddress', SigningKey.getAddress);
|
||||||
utils.defineProperty(Wallet, 'getIcapAddress', SigningKey.getIcapAddress);
|
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);
|
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());
|
utils.defineProperty(Wallet, 'randomish', new Randomish());
|
||||||
|
|
||||||
module.exports = Wallet;
|
module.exports = Wallet;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user