mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3119 from ethereum/rpc-account
Fix RPC account creation with gaps
This commit is contained in:
commit
90b0a6efb9
@ -339,22 +339,25 @@ Json::Value RPCSession::rpcCall(string const& _methodName, vector<string> const&
|
||||
return result["result"];
|
||||
}
|
||||
|
||||
string const& RPCSession::accountCreate()
|
||||
{
|
||||
m_accounts.push_back(personal_newAccount(""));
|
||||
personal_unlockAccount(m_accounts.back(), "", 100000);
|
||||
return m_accounts.back();
|
||||
}
|
||||
|
||||
string const& RPCSession::accountCreateIfNotExists(size_t _id)
|
||||
{
|
||||
if (_id >= m_accounts.size())
|
||||
{
|
||||
m_accounts.push_back(personal_newAccount(""));
|
||||
personal_unlockAccount(m_accounts.back(), "", 100000);
|
||||
}
|
||||
while ((_id + 1) > m_accounts.size())
|
||||
accountCreate();
|
||||
return m_accounts[_id];
|
||||
}
|
||||
|
||||
RPCSession::RPCSession(const string& _path):
|
||||
m_ipcSocket(_path)
|
||||
{
|
||||
string account = personal_newAccount("");
|
||||
personal_unlockAccount(account, "", 100000);
|
||||
m_accounts.push_back(account);
|
||||
accountCreate();
|
||||
// This will pre-fund the accounts create prior.
|
||||
test_setChainParams(m_accounts);
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
Json::Value rpcCall(std::string const& _methodName, std::vector<std::string> const& _args = std::vector<std::string>(), bool _canFail = false);
|
||||
|
||||
std::string const& account(size_t _id) const { return m_accounts.at(_id); }
|
||||
std::string const& accountCreate();
|
||||
std::string const& accountCreateIfNotExists(size_t _id);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user