Use the personal account API in Web3

pull/1/head
Alex Beregszaszi 9 years ago
parent fcbed88ffa
commit 9439b087f0
  1. 8
      src/universal-dapp.js

@ -50,12 +50,16 @@ UniversalDApp.prototype.reset = function (contracts, getAddress, getValue, getGa
} }
}; };
UniversalDApp.prototype.newAccount = function () { UniversalDApp.prototype.newAccount = function (password) {
if (!this.executionContext.isVM()) {
this.web3.personal.newAccount(password);
} else {
var privateKey; var privateKey;
do { do {
privateKey = crypto.randomBytes(32); privateKey = crypto.randomBytes(32);
} while (!ethJSUtil.isValidPrivate(privateKey)); } while (!ethJSUtil.isValidPrivate(privateKey));
this._addAccount(privateKey); this._addAccount(privateKey);
}
}; };
UniversalDApp.prototype._addAccount = function (privateKey, balance) { UniversalDApp.prototype._addAccount = function (privateKey, balance) {
@ -80,7 +84,7 @@ UniversalDApp.prototype.getAccounts = function (cb) {
var self = this; var self = this;
if (!self.executionContext.isVM()) { if (!self.executionContext.isVM()) {
self.web3.eth.getAccounts(cb); self.web3.personal.getAccounts(cb);
} else { } else {
if (!self.accounts) { if (!self.accounts) {
return cb('No accounts?'); return cb('No accounts?');

Loading…
Cancel
Save