diff --git a/eth/main.cpp b/eth/main.cpp index ba12ff8ef..7b2767757 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -418,7 +418,8 @@ int main(int argc, char** argv) auto h = bc.currentHash(); auto blockData = bc.block(h); BlockInfo info(blockData); - if(iss.peek()!=-1){ + if (iss.peek() != -1) + { string hexAddr; u256 amount; u256 gasPrice; @@ -445,8 +446,6 @@ int main(int argc, char** argv) if (size > 0) cwarn << "Invalid address length: " << size; } - else if (amount < 0) - cwarn << "Invalid amount: " << amount; else if (gasPrice < info.minGasPrice) cwarn << "Minimum gas price is " << info.minGasPrice; else if (gas < minGas) @@ -462,9 +461,9 @@ int main(int argc, char** argv) Address dest = h160(fromHex(hexAddr)); c.transact(secret, amount, dest, data, gas, gasPrice); } - } else { - cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA"; } + else + cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA"; } else if (cmd == "listContracts") { @@ -502,7 +501,8 @@ int main(int argc, char** argv) else if (cmd == "send") { ClientGuard g(&c); - if(iss.peek() != -1){ + if (iss.peek() != -1) + { string hexAddr; u256 amount; int size = hexAddr.length(); @@ -513,9 +513,8 @@ int main(int argc, char** argv) if (size > 0) cwarn << "Invalid address length: " << size; } - else if (amount < 0) { - cwarn << "Invalid amount: " << amount; - } else { + else + { auto const& bc = c.blockChain(); auto h = bc.currentHash(); auto blockData = bc.block(h); @@ -525,9 +524,9 @@ int main(int argc, char** argv) c.transact(us.secret(), amount, dest, bytes(), minGas, info.minGasPrice); } - } else { + } + else cwarn << "Require parameters: send ADDRESS AMOUNT"; - } } else if (cmd == "contract") { @@ -568,12 +567,10 @@ int main(int argc, char** argv) else if (gas < minGas) cwarn << "Minimum gas amount is " << minGas; else - { c.transact(us.secret(), endowment, init, gas, gasPrice); - } - } else { + } + else cwarn << "Require parameters: contract ENDOWMENT GASPRICE GAS CODEHEX"; - } } else if (cmd == "inspect") { @@ -602,9 +599,60 @@ int main(int argc, char** argv) } else if (cmd == "setSecret") { - string hexSec; - iss >> hexSec; - us = KeyPair(h256(fromHex(hexSec))); + if (iss.peek() != -1) + { + string hexSec; + iss >> hexSec; + us = KeyPair(h256(fromHex(hexSec))); + } + else + cwarn << "Require parameter: setSecret HEXSECRETKEY"; + } + else if (cmd == "setAddress") + { + if (iss.peek() != -1) + { + string hexAddr; + iss >> hexAddr; + if (hexAddr.length() != 40) + cwarn << "Invalid address length: " << hexAddr.length(); + else + coinbase = h160(fromHex(hexAddr)); + } + else + cwarn << "Require parameter: setAddress HEXADDRESS"; + } + else if (cmd == "exportConfig") + { + if (iss.peek() != -1) + { + string path; + iss >> path; + RLPStream config(2); + config << us.secret() << coinbase; + writeFile(path, config.out()); + } + else + cwarn << "Require parameter: exportConfig PATH"; + } + else if (cmd == "importConfig") + { + if (iss.peek() != -1) + { + string path; + iss >> path; + bytes b = contents(path); + if (b.size()) + { + RLP config(b); + us = KeyPair(config[0].toHash()); + coinbase = config[1].toHash
(); + } + else + cwarn << path << "has no content!"; + } + else + cwarn << "Require parameter: importConfig PATH"; } else if (cmd == "help") interactiveHelp(); diff --git a/neth/main.cpp b/neth/main.cpp index a350a9d75..2078da004 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -665,8 +665,6 @@ int main(int argc, char** argv) if (size > 0) cwarn << "Invalid address length: " << size; } - else if (amount < 0) - cwarn << "Invalid amount: " << amount; else if (gasPrice < info.minGasPrice) cwarn << "Minimum gas price is " << info.minGasPrice; else if (gas < minGas) @@ -712,8 +710,6 @@ int main(int argc, char** argv) if (size > 0) cwarn << "Invalid address length: " << size; } - else if (amount <= 0) - cwarn << "Invalid amount: " << amount; else { auto const& bc = c.blockChain();