Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Implement personal_sendTransaction() and personal_lockAccount()
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Feb 14, 2017
1 parent c4d2448 commit 636454c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ The RPC methods currently implemented are:
* `miner_start`
* `miner_stop`
* `personal_listAccounts`
* `personal_lockAccount`
* `personal_newAccount`
* `personal_unlockAccount`
* `personal_sendTransaction`
* `rpc_modules`
* `web3_clientVersion`
* `web3_sha3`
Expand Down
29 changes: 27 additions & 2 deletions lib/subproviders/geth_api_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ GethApiDouble.prototype.personal_newAccount = function(password, callback) {
callback(null, account.address);
};

GethApiDouble.prototype.personal_lockAccount = function(address, callback) {
var account = this.state.personal_accounts[account.address];
if (account !== true) {
return callback("Account not found")
}
this.state.unlocked_accounts[address.toLowerCase()] = false;
callback(null, true);
};

GethApiDouble.prototype.personal_unlockAccount = function(address, password, duration, callback) {
// FIXME handle duration
var account = this.state.personal_accounts[address];
Expand All @@ -326,8 +335,24 @@ GethApiDouble.prototype.personal_unlockAccount = function(address, password, dur
callback(null, true);
};

// FIXME: implement sendTransaction
// FIXME: implement signAndSendTransaction
GethApiDouble.prototype.personal_sendTransaction = function(tx_data, password, callback) {
if (tx_data.from == null) {
callback("Sender not found");
return;
}

var from = utils.addHexPrefix(tx_data.from).toLowerCase();

this.personal_unlockAccount(from, password, null, function(err) {
if (err) {
return callback(err)
}
this.state.queueTransaction("eth_sendTransaction", tx_data, function(err, ret) {
this.state.unlocked_accounts[from] = false;
callback(err, ret);
});
});
};

/* Functions for testing purposes only. */

Expand Down

0 comments on commit 636454c

Please sign in to comment.