Commit 9439b087 authored by Alex Beregszaszi's avatar Alex Beregszaszi

Use the personal account API in Web3

parent fcbed88f
......@@ -50,12 +50,16 @@ 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.newAccount = function (password) {
if (!this.executionContext.isVM()) {
this.web3.personal.newAccount(password);
} else {
var privateKey;
do {
privateKey = crypto.randomBytes(32);
} while (!ethJSUtil.isValidPrivate(privateKey));
this._addAccount(privateKey);
}
};
UniversalDApp.prototype._addAccount = function (privateKey, balance) {
......@@ -80,7 +84,7 @@ UniversalDApp.prototype.getAccounts = function (cb) {
var self = this;
if (!self.executionContext.isVM()) {
self.web3.eth.getAccounts(cb);
self.web3.personal.getAccounts(cb);
} else {
if (!self.accounts) {
return cb('No accounts?');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment