Use the personal account API in Web3

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

@ -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?');

Loading…
Cancel
Save