Browse Source

Merge pull request #219 from josephyzhou/develop

List contracts and accounts
cl-refactor
Gav Wood 11 years ago
parent
commit
05bdcb9ab7
  1. 47
      eth/main.cpp

47
eth/main.cpp

@ -74,10 +74,16 @@ void interactiveHelp()
<< " secret Gives the current secret" << endl << " secret Gives the current secret" << endl
<< " block Gives the current block height." << endl << " block Gives the current block height." << endl
<< " balance Gives the current balance." << endl << " balance Gives the current balance." << endl
<< " peers List the peers that are connected" << endl
<< " transact Execute a given transaction." << endl << " transact Execute a given transaction." << endl
<< " send Execute a given transaction with current secret." << endl << " send Execute a given transaction with current secret." << endl
<< " contract Create a new contract with current secret." << endl << " contract Create a new contract with current secret." << endl
<< " peers List the peers that are connected" << endl
<< " listAccounts List the accounts on the network." << endl
<< " listContracts List the contracts on the network." << endl
<< " setSecret <secret> Set the secret to the hex secret key." <<endl
<< " setAddress <addr> Set the coinbase (mining payout) address." <<endl
<< " exportConfig <path> Export the config (.RLP) to the path provided." <<endl
<< " importConfig <path> Import the config (.RLP) from the path provided." <<endl
<< " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl << " inspect <contract> Dumps a contract to <APPDATA>/<contract>.evm." << endl
<< " exit Exits the application." << endl; << " exit Exits the application." << endl;
} }
@ -460,6 +466,39 @@ int main(int argc, char** argv)
cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA"; 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();
string ss;
for (auto const& i: acs)
{
auto r = i.first;
if (st.addressHasCode(r))
{
ss = toString(r) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]";
cout << ss << endl;
}
}
}
else if (cmd == "listAccounts")
{
ClientGuard g(&c);
auto const& st = c.state();
auto acs = st.addresses();
string ss;
for (auto const& i: acs)
{
auto r = i.first;
if (!st.addressHasCode(r))
{
ss = toString(r) + pretty(r, st) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]";
cout << ss << endl;
}
}
}
else if (cmd == "send") else if (cmd == "send")
{ {
ClientGuard g(&c); ClientGuard g(&c);
@ -561,6 +600,12 @@ int main(int argc, char** argv)
ofs.close(); ofs.close();
} }
} }
else if (cmd == "setSecret")
{
string hexSec;
iss >> hexSec;
us = KeyPair(h256(fromHex(hexSec)));
}
else if (cmd == "help") else if (cmd == "help")
interactiveHelp(); interactiveHelp();
else if (cmd == "exit") else if (cmd == "exit")

Loading…
Cancel
Save