From aae9624744c2b1eaa1682793b716d06464dad3e2 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 24 Jun 2014 13:07:43 -0700 Subject: [PATCH 1/6] listing contracts and accounts --- eth/main.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/eth/main.cpp b/eth/main.cpp index f3dfcf276..61a0fea01 100644 --- a/eth/main.cpp +++ b/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 Dumps a contract to /.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); From 708ad6b1ae6ff48cb4d052d327b391fa84df04ae Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 24 Jun 2014 13:17:49 -0700 Subject: [PATCH 2/6] typo --- eth/main.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 61a0fea01..8a5915225 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -79,7 +79,7 @@ void interactiveHelp() << " 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 + << " listContracts List the contracts on the network." << endl << " inspect Dumps a contract to /.evm." << endl << " exit Exits the application." << endl; } @@ -470,11 +470,7 @@ int main(int argc, char** argv) 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)) + "]"; @@ -490,7 +486,6 @@ int main(int argc, char** argv) 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; From 57d9ea7d408a500576560c4699fa68eaab233dec Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 24 Jun 2014 15:04:39 -0700 Subject: [PATCH 3/6] fix list accounts --- eth/main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 8a5915225..adca45c10 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -467,14 +467,14 @@ int main(int argc, char** argv) ClientGuard g(&c); auto const& st = c.state(); auto acs = st.addresses(); + string ss; for (auto const& i: acs) { auto r = i.first; - string ss; if (st.addressHasCode(r)) { ss = toString(r) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]"; - cwarn << ss; + cout << ss; } } } @@ -483,12 +483,16 @@ int main(int argc, char** argv) ClientGuard g(&c); auto const& st = c.state(); auto acs = st.addresses(); + string ss; 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) + pretty(r, st) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]"; + cout << ss; + } + } } else if (cmd == "send") From 7aff99bc724d19826959cef66d2e7ea116c58f80 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 24 Jun 2014 15:42:36 -0700 Subject: [PATCH 4/6] a few more commands --- eth/main.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/eth/main.cpp b/eth/main.cpp index adca45c10..7d317b7b2 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -74,12 +74,16 @@ void interactiveHelp() << " secret Gives the current secret" << endl << " block Gives the current block height." << endl << " balance Gives the current balance." << endl - << " peers List the peers that are connected" << endl << " transact Execute a given transaction." << endl << " send Execute a given transaction 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 Set the secret to the hex secret key." < Set the coinbase (mining payout) address." < Export the config (.RLP) to the path provided." < Import the config (.RLP) from the path provided." < Dumps a contract to /.evm." << endl << " exit Exits the application." << endl; } @@ -596,6 +600,12 @@ int main(int argc, char** argv) ofs.close(); } } + else if (cmd == "setSecret") + { + string hexSec; + iss >> hexSec; + us = KeyPair(h256(fromHex(argv[++i]))); + } else if (cmd == "help") interactiveHelp(); else if (cmd == "exit") From e9cd9c96bcf187b9232299c5c1d5aece83bd4a33 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Wed, 25 Jun 2014 10:35:07 -0700 Subject: [PATCH 5/6] line end --- eth/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 7d317b7b2..9fffc8def 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -478,7 +478,7 @@ int main(int argc, char** argv) if (st.addressHasCode(r)) { ss = toString(r) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]"; - cout << ss; + cout << ss << endl; } } } @@ -494,7 +494,7 @@ int main(int argc, char** argv) if (!st.addressHasCode(r)) { ss = toString(r) + pretty(r, st) + " : " + toString(formatBalance(i.second)) + " [" + toString((unsigned)st.transactionsFrom(i.first)) + "]"; - cout << ss; + cout << ss << endl; } } From dd0b8b86bbbd83562301ecdfe9918a8995118eb6 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Wed, 25 Jun 2014 10:38:09 -0700 Subject: [PATCH 6/6] fix for setsecret --- eth/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/main.cpp b/eth/main.cpp index 9fffc8def..7410fbe6d 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -604,7 +604,7 @@ int main(int argc, char** argv) { string hexSec; iss >> hexSec; - us = KeyPair(h256(fromHex(argv[++i]))); + us = KeyPair(h256(fromHex(hexSec))); } else if (cmd == "help") interactiveHelp();