Browse Source

listing contracts and accounts

cl-refactor
Joey Zhou 11 years ago
parent
commit
aae9624744
  1. 36
      eth/main.cpp

36
eth/main.cpp

@ -78,6 +78,8 @@ void interactiveHelp()
<< " transact Execute a given transaction." << endl
<< " send Execute a given transaction with current secret." << endl
<< " contract Create a new contract with current secret." << endl
<< " listAccounts List the accounts on the network." << endl
<< " listContract List the contracts on the network." << endl
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl
<< " exit Exits the application." << endl;
}
@ -460,6 +462,40 @@ int main(int argc, char** argv)
cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA";
}
}
else if (cmd == "listContracts")
{
ClientGuard g(&c);
auto const& st = c.state();
auto acs = st.addresses();
for (auto const& i: acs)
{
auto r = i.first;
string ss;
ss = toString(r) + pretty(r, st) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]";
// cwarn << ss;
if (st.addressHasCode(r))
{
ss = toString(r) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]";
cwarn << ss;
}
}
}
else if (cmd == "listAccounts")
{
ClientGuard g(&c);
auto const& st = c.state();
auto acs = st.addresses();
for (auto const& i: acs)
{
auto r = i.first;
string ss;
ss = toString(r) + pretty(r, st) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]";
cwarn << ss;
}
}
else if (cmd == "send")
{
ClientGuard g(&c);

Loading…
Cancel
Save