Add newAccount() method to universal-dapp for creating a new account

pull/1/head
Alex Beregszaszi 9 years ago
parent 26c4a9683e
commit a6f8207063
  1. 9
      src/universal-dapp.js

@ -7,6 +7,7 @@ var ethJSABI = require('ethereumjs-abi');
var EthJSBlock = require('ethereumjs-block');
var BN = ethJSUtil.BN;
var EventManager = require('./lib/eventManager');
var crypto = require('crypto');
/*
trigger debugRequested
@ -49,6 +50,14 @@ UniversalDApp.prototype.reset = function (contracts, getAddress, getValue, getGa
}
};
UniversalDApp.prototype.newAccount = function () {
var privateKey;
do {
privateKey = crypto.randomBytes(32);
} while (!ethJSUtil.isValidPrivate(privateKey));
this._addAccount(privateKey);
};
UniversalDApp.prototype.addAccount = function (privateKey, balance) {
var self = this;

Loading…
Cancel
Save