30 #include <boost/algorithm/string.hpp> 31 #include <boost/algorithm/string/trim_all.hpp> 32 #include <boost/filesystem.hpp> 49 #include <jsonrpccpp/client/connectors/httpclient.h> 64 #include "BuildInfo.h" 73 static std::atomic<bool> g_silence = {
false};
78 <<
"Usage eth [OPTIONS]" << endl
79 <<
"Options:" << endl << endl
80 <<
"Wallet usage:" << endl;
86 <<
"Client mode (default):" << endl
87 <<
" --mainnet Use the main network protocol." << endl
88 <<
" --ropsten Use the Ropsten testnet." << endl
89 <<
" --private <name> Use a private chain." << endl
90 <<
" --test Testing mode: Disable PoW and provide test rpc interface." << endl
91 <<
" --config <file> Configure specialised blockchain using given JSON information." << endl
92 <<
" --oppose-dao-fork Ignore DAO hard fork (default is to participate)." << endl
94 <<
" -o,--mode <full/peer> Start a full node or a peer node (default: full)." << endl
96 <<
" -j,--json-rpc Enable JSON-RPC server (default: off)." << endl
97 <<
" --ipc Enable IPC server (default: on)." << endl
98 <<
" --ipcpath Set .ipc socket path (default: data directory)" << endl
99 <<
" --admin-via-http Expose admin interface via http - UNSAFE! (default: off)." << endl
100 <<
" --no-ipc Disable IPC server." << endl
101 <<
" --json-rpc-port <n> Specify JSON-RPC server port (implies '-j', default: " <<
SensibleHttpPort <<
")." << endl
102 <<
" --rpccorsdomain <domain> Domain on which to send Access-Control-Allow-Origin header." << endl
103 <<
" --admin <password> Specify admin session key for JSON-RPC (default: auto-generated and printed at start-up)." << endl
104 <<
" -K,--kill Kill the blockchain first." << endl
105 <<
" -R,--rebuild Rebuild the blockchain from the existing database." << endl
106 <<
" --rescue Attempt to rescue a corrupt database." << endl
108 <<
" --import-presale <file> Import a pre-sale key; you'll need to specify the password to this key." << endl
109 <<
" -s,--import-secret <secret> Import a secret key into the key store." << endl
110 <<
" --master <password> Give the master password for the key store. Use --master \"\" to show a prompt." << endl
111 <<
" --password <password> Give a password for a private key." << endl
113 <<
"Client transacting:" << endl
117 <<
" --ask <wei> Set the minimum ask gas price under which no transaction will be mined (default " <<
toString(DefaultGasPrice) <<
" )." << endl
118 <<
" --bid <wei> Set the bid gas price to pay for transactions (default " <<
toString(DefaultGasPrice) <<
" )." << endl
119 <<
" --unsafe-transactions Allow all transactions to proceed without verification. EXTREMELY UNSAFE." 121 <<
"Client mining:" << endl
122 <<
" -a,--address <addr> Set the author (mining payout) address to given address (default: auto)." << endl
123 <<
" -m,--mining <on/off/number> Enable mining, optionally for a specified number of blocks (default: off)." << endl
124 <<
" -f,--force-mining Mine even when there are no transactions to mine (default: off)." << endl
125 <<
" -C,--cpu When mining, use the CPU." << endl
126 <<
" -t, --mining-threads <n> Limit number of CPU/GPU miners to n (default: use everything available on selected platform)." << endl
128 <<
"Client networking:" << endl
129 <<
" --client-name <name> Add a name to your client's version string (default: blank)." << endl
130 <<
" --bootstrap Connect to the default Ethereum peer servers (default unless --no-discovery used)." << endl
131 <<
" --no-bootstrap Do not connect to the default Ethereum peer servers (default only when --no-discovery is used)." << endl
132 <<
" -x,--peers <number> Attempt to connect to a given number of peers (default: 11)." << endl
133 <<
" --peer-stretch <number> Give the accepted connection multiplier (default: 7)." << endl
135 <<
" --public-ip <ip> Force advertised public IP to the given IP (default: auto)." << endl
136 <<
" --listen-ip <ip>(:<port>) Listen on the given IP for incoming connections (default: 0.0.0.0)." << endl
137 <<
" --listen <port> Listen on the given port for incoming connections (default: 30303)." << endl
138 <<
" -r,--remote <host>(:<port>) Connect to the given remote host (default: none)." << endl
139 <<
" --port <port> Connect to the given remote port (default: 30303)." << endl
140 <<
" --network-id <n> Only connect to other hosts with this network id." << endl
141 <<
" --upnp <on/off> Use UPnP for NAT (default: on)." << endl
143 <<
" --peerset <list> Space delimited list of peers; element format: type:publickey@ipAddress[:port]." << endl
145 <<
" default Attempt connection when no other peers are available and pinning is disabled." << endl
146 <<
" required Keep connected at all times." << endl
150 <<
" --no-discovery Disable node discovery, implies --no-bootstrap." << endl
151 <<
" --pin Only accept or connect to trusted peers." << endl
152 <<
" --hermit Equivalent to --no-discovery --pin." << endl
153 <<
" --sociable Force discovery and no pinning." << endl
157 <<
"Import/export modes:" << endl
158 <<
" --from <n> Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl
159 <<
" --to <n> Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'." << endl
160 <<
" --only <n> Equivalent to --export-from n --export-to n." << endl
161 <<
" --dont-check Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid." << endl
163 <<
"General Options:" << endl
164 <<
" -d,--db-path,--datadir <path> Load database from path (default: " <<
getDataDir() <<
")." << endl
166 <<
" --vm <vm-kind> Select VM; options are: interpreter, jit or smart (default: interpreter)." << endl
168 <<
" -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (default: 8)." << endl
169 <<
" -V,--version Show the version and exit." << endl
170 <<
" -h,--help Show this help message and exit." << endl
172 <<
"Experimental / Proof of Concept:" << endl
173 <<
" --shh Enable Whisper." << endl
181 std::ostringstream cout;
184 <<
"Type 'exit' to quit" << endl << endl;
193 cout <<
"Build: " <<
DEV_QUOTED(ETH_BUILD_PLATFORM) <<
"/" <<
DEV_QUOTED(ETH_BUILD_TYPE) << endl;
213 if (!std::setlocale(LC_ALL,
""))
215 setenv(
"LC_ALL",
"C", 1);
223 _km.
import(k.
secret(),
"Presale wallet" + _file +
" (insecure)");
235 std::string s((
char const*)n.
data(), 32);
236 if (s.find_first_of(
'\0') != string::npos)
237 s.resize(s.find_first_of(
'\0'));
245 if (((!(_number & 1)) && _number != 2 ) || (_number < 2) || (_number % 3 == 0 && _number != 3))
247 for(
unsigned k = 1; 36 * k * k - 12 * k < _number; ++k)
248 if ((_number % (6 * k + 1) == 0) || (_number % (6 * k - 1) == 0))
280 io_mining = ~(unsigned)0;
283 catch (InvalidSealEngine&)
287 this_thread::sleep_for(chrono::milliseconds(100));
293 void exit() { exitHandler(0); }
303 int main(
int argc,
char** argv)
329 bool safeImport =
false;
332 string exportFrom =
"1";
333 string exportTo =
"latest";
338 bool interactive =
false;
341 bool adminViaHttp =
false;
343 std::string rpcCorsDomain =
"";
356 unsigned short listenPort = 30303;
359 unsigned short remotePort = 30303;
362 unsigned peerStretch = 7;
363 std::map<NodeID, pair<NodeIPEndpoint,bool>> preferredNodes;
364 bool bootstrap =
true;
365 bool disableDiscovery =
false;
366 bool pinning =
false;
367 bool enableDiscovery =
false;
368 bool noPinning =
false;
369 static const unsigned NoNetworkID = (unsigned)-1;
370 unsigned networkID = NoNetworkID;
382 u256 askPrice = DefaultGasPrice;
383 u256 bidPrice = DefaultGasPrice;
384 bool alwaysConfirm =
true;
387 string masterPassword;
388 bool masterSet =
false;
391 bool useWhisper =
false;
392 bool testingMode =
false;
394 string configFile =
getDataDir() +
"/config.rlp";
409 if (argc > 1 && (
string(argv[1]) ==
"wallet" ||
string(argv[1]) ==
"account"))
412 return !accountm.
execute(argc, argv);
418 bool listenSet =
false;
421 for (
int i = 1; i < argc; ++i)
423 string arg = argv[i];
427 else if (arg ==
"--listen-ip" && i + 1 < argc)
429 listenIP = argv[++i];
432 else if ((arg ==
"--listen" || arg ==
"--listen-port") && i + 1 < argc)
434 listenPort = (short)
atoi(argv[++i]);
437 else if ((arg ==
"--public-ip" || arg ==
"--public") && i + 1 < argc)
439 publicIP = argv[++i];
441 else if ((arg ==
"-r" || arg ==
"--remote") && i + 1 < argc)
443 string host = argv[++i];
444 string::size_type found = host.find_first_of(
':');
445 if (found != std::string::npos)
447 remoteHost = host.substr(0, found);
448 remotePort = (short)
atoi(host.substr(found + 1, host.length()).c_str());
453 else if (arg ==
"--port" && i + 1 < argc)
455 remotePort = (short)
atoi(argv[++i]);
457 else if (arg ==
"--password" && i + 1 < argc)
458 passwordsToNote.push_back(argv[++i]);
459 else if (arg ==
"--master" && i + 1 < argc)
461 masterPassword = argv[++i];
464 else if ((arg ==
"-I" || arg ==
"--import" || arg ==
"import") && i + 1 < argc)
467 filename = argv[++i];
469 else if (arg ==
"--dont-check")
471 else if ((arg ==
"-E" || arg ==
"--export" || arg ==
"export") && i + 1 < argc)
474 filename = argv[++i];
476 else if (arg ==
"--script" && i + 1 < argc)
477 scripts.push_back(argv[++i]);
478 else if (arg ==
"--format" && i + 1 < argc)
480 string m = argv[++i];
485 else if (m ==
"human")
489 cerr <<
"Bad " << arg <<
" option: " << m << endl;
493 else if (arg ==
"--to" && i + 1 < argc)
494 exportTo = argv[++i];
495 else if (arg ==
"--from" && i + 1 < argc)
496 exportFrom = argv[++i];
497 else if (arg ==
"--only" && i + 1 < argc)
498 exportTo = exportFrom = argv[++i];
499 else if (arg ==
"--upnp" && i + 1 < argc)
501 string m = argv[++i];
508 cerr <<
"Bad " << arg <<
" option: " << m << endl;
512 else if (arg ==
"--network-id" && i + 1 < argc)
514 networkID = stol(argv[++i]);
518 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
521 else if (arg ==
"--private" && i + 1 < argc)
523 privateChain = argv[++i];
527 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
530 else if (arg ==
"--independent" && i + 1 < argc)
532 privateChain = argv[++i];
533 noPinning = enableDiscovery =
true;
537 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
540 else if (arg ==
"-K" || arg ==
"--kill-blockchain" || arg ==
"--kill")
541 withExisting = WithExisting::Kill;
542 else if (arg ==
"-R" || arg ==
"--rebuild")
543 withExisting = WithExisting::Verify;
544 else if (arg ==
"-R" || arg ==
"--rescue")
545 withExisting = WithExisting::Rescue;
546 else if (arg ==
"--client-name" && i + 1 < argc)
547 clientName = argv[++i];
548 else if ((arg ==
"-a" || arg ==
"--address" || arg ==
"--author") && i + 1 < argc)
550 author =
h160(
fromHex(argv[++i], WhenError::Throw));
552 catch (BadHexCharacter&)
554 cerr <<
"Bad hex in " << arg <<
" option: " << argv[i] << endl;
559 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
562 else if ((arg ==
"-s" || arg ==
"--import-secret") && i + 1 < argc)
565 toImport.emplace_back(s);
567 else if ((arg ==
"-S" || arg ==
"--import-session-secret") && i + 1 < argc)
570 toImport.emplace_back(s);
572 else if ((arg ==
"-d" || arg ==
"--path" || arg ==
"--db-path" || arg ==
"--datadir") && i + 1 < argc)
574 else if (arg ==
"--ipcpath" && i + 1 < argc )
576 else if ((arg ==
"--genesis-json" || arg ==
"--genesis") && i + 1 < argc)
584 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
588 else if (arg ==
"--config" && i + 1 < argc)
596 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
600 else if (arg ==
"--extra-data" && i + 1 < argc)
604 extraData =
fromHex(argv[++i]);
608 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
612 else if (arg ==
"--gas-floor" && i + 1 < argc)
613 gasFloor =
u256(argv[++i]);
614 else if (arg ==
"--mainnet")
616 else if (arg ==
"--ropsten" || arg ==
"--testnet")
618 else if (arg ==
"--oppose-dao-fork")
623 else if (arg ==
"--support-dao-fork")
627 else if (arg ==
"--bob")
629 cout <<
"Asking Bob for blocks (this should work in theoreum)..." << endl;
632 u256 x(h256::random());
636 x = (x & 1) == 0 ? x / 2 : 3 * x + 1;
637 cout <<
toHex(x) << endl;
638 this_thread::sleep_for(chrono::seconds(1));
640 cout <<
"Block number: " << hex << c << endl;
668 else if (arg ==
"--ask" && i + 1 < argc)
672 askPrice =
u256(argv[++i]);
676 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
680 else if (arg ==
"--bid" && i + 1 < argc)
684 bidPrice =
u256(argv[++i]);
688 cerr <<
"Bad " << arg <<
" option: " << argv[i] << endl;
714 else if ((arg ==
"-m" || arg ==
"--mining") && i + 1 < argc)
716 string m = argv[++i];
718 mining = ~(unsigned)0;
726 cerr <<
"Unknown " << arg <<
" option: " << m << endl;
730 else if (arg ==
"-b" || arg ==
"--bootstrap")
732 else if (arg ==
"--no-bootstrap")
734 else if (arg ==
"--no-discovery")
736 disableDiscovery =
true;
739 else if (arg ==
"--pin")
741 else if (arg ==
"--hermit")
742 pinning = disableDiscovery =
true;
743 else if (arg ==
"--sociable")
744 noPinning = enableDiscovery =
true;
745 else if (arg ==
"--unsafe-transactions")
746 alwaysConfirm =
false;
747 else if (arg ==
"--import-presale" && i + 1 < argc)
748 presaleImports.push_back(argv[++i]);
749 else if (arg ==
"--old-interactive")
752 else if ((arg ==
"-j" || arg ==
"--json-rpc"))
754 else if (arg ==
"--admin-via-http")
756 else if (arg ==
"--json-rpc-port" && i + 1 < argc)
757 jsonRPCURL =
atoi(argv[++i]);
758 else if (arg ==
"--rpccorsdomain" && i + 1 < argc)
759 rpcCorsDomain = argv[++i];
760 else if (arg ==
"--json-admin" && i + 1 < argc)
761 jsonAdmin = argv[++i];
762 else if (arg ==
"--ipc")
764 else if (arg ==
"--no-ipc")
767 else if ((arg ==
"-v" || arg ==
"--verbosity") && i + 1 < argc)
769 else if ((arg ==
"-x" || arg ==
"--peers") && i + 1 < argc)
770 peers =
atoi(argv[++i]);
771 else if (arg ==
"--peer-stretch" && i + 1 < argc)
772 peerStretch =
atoi(argv[++i]);
773 else if (arg ==
"--peerset" && i + 1 < argc)
775 string peerset = argv[++i];
778 cerr <<
"--peerset argument must not be empty";
783 boost::split(each, peerset, boost::is_any_of(
"\t "));
784 for (
auto const& p: each)
789 unsigned short port = c_defaultListenPort;
792 vector<string> typeAndKeyAtHostAndPort;
793 boost::split(typeAndKeyAtHostAndPort, p, boost::is_any_of(
":"));
794 if (typeAndKeyAtHostAndPort.size() < 2 || typeAndKeyAtHostAndPort.size() > 3)
797 type = typeAndKeyAtHostAndPort[0];
798 if (typeAndKeyAtHostAndPort.size() == 3)
799 port = (uint16_t)
atoi(typeAndKeyAtHostAndPort[2].c_str());
801 vector<string> keyAndHost;
802 boost::split(keyAndHost, typeAndKeyAtHostAndPort[1], boost::is_any_of(
"@"));
803 if (keyAndHost.size() != 2)
805 pubk = keyAndHost[0];
806 if (pubk.size() != 128)
808 hostIP = keyAndHost[1];
811 if (hostIP.size() < 4 )
814 bool required = type ==
"required";
815 if (!required && type !=
"default")
821 preferredNodes[publicKey] = make_pair(
NodeIPEndpoint(bi::address::from_string(hostIP), port, port), required);
825 cerr <<
"Unrecognized peerset: " << peerset << endl;
830 else if ((arg ==
"-o" || arg ==
"--mode") && i + 1 < argc)
832 string m = argv[++i];
835 else if (m ==
"peer")
839 cerr <<
"Unknown mode: " << m << endl;
844 else if (arg ==
"--vm" && i + 1 < argc)
846 string vmKind = argv[++i];
847 if (vmKind ==
"interpreter")
848 VMFactory::setKind(VMKind::Interpreter);
849 else if (vmKind ==
"jit")
850 VMFactory::setKind(VMKind::JIT);
851 else if (vmKind ==
"smart")
852 VMFactory::setKind(VMKind::Smart);
855 cerr <<
"Unknown VM kind: " << vmKind << endl;
860 else if (arg ==
"--shh")
862 else if (arg ==
"-h" || arg ==
"--help")
864 else if (arg ==
"-V" || arg ==
"--version")
866 else if (arg ==
"--test")
869 enableDiscovery =
false;
870 disableDiscovery =
true;
876 cerr <<
"Invalid argument: " << arg << endl;
881 if (!configJSON.empty())
885 chainParams = chainParams.
loadConfig(configJSON);
889 cerr <<
"provided configuration is not well formatted" << endl;
890 cerr <<
"sample: " << endl <<
genesisInfo(eth::Network::MainNetworkTest) << endl;
896 if (!genesisJSON.empty())
900 chainParams = chainParams.
loadGenesis(genesisJSON);
904 cerr <<
"provided genesis block description is not well formatted" << endl;
905 string genesisSample =
908 "nonce": "0x0000000000000042", 909 "difficulty": "0x400000000", 910 "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 911 "author": "0x0000000000000000000000000000000000000000", 913 "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 914 "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa", 918 cerr << "sample: " << endl << genesisSample << endl;
924 if (!privateChain.empty())
939 std::string secretsPath;
941 secretsPath = (boost::filesystem::path(
getDataDir()) /
"keystore").
string();
943 secretsPath = SecretStore::defaultPath();
944 KeyManager keyManager(KeyManager::defaultPath(), secretsPath);
945 for (
auto const& s: passwordsToNote)
951 if (!clientName.empty())
955 std::string additional;
957 g_logPost = [&](std::string
const&
a,
char const*){
964 cout <<
"\r \r" << a << endl << additional << flush;
969 OutputDebugStringA(a.data());
970 OutputDebugStringA(
"\n");
983 auto getResponse = [&](
string const& prompt, unordered_set<string>
const& acceptable) {
992 if (acceptable.count(ret))
994 cout <<
"Invalid response: " << ret << endl;
1004 netPrefs.discovery = (privateChain.empty() && !disableDiscovery) || enableDiscovery;
1005 netPrefs.pin = (pinning || !privateChain.empty()) && !noPinning;
1008 auto caps = useWhisper ? set<string>{
"eth",
"shh"} : set<string>{
"eth"};
1013 chainParams.
otherParams[
"allowFutureBlocks"] =
"1";
1017 WebThreeDirect::composeClientVersion(
"eth"),
1027 if (!extraData.empty())
1030 auto toNumber = [&](
string const& s) ->
unsigned {
1033 if (s.size() == 64 || (s.size() == 66 && s.substr(0, 2) ==
"0x"))
1040 cerr <<
"Bad block number/hash option: " << s << endl;
1047 ofstream fout(filename, std::ofstream::binary);
1048 ostream& out = (filename.empty() || filename ==
"--") ? cout : fout;
1050 unsigned last = toNumber(exportTo);
1051 for (
unsigned i = toNumber(exportFrom); i <= last; ++i)
1054 switch (exportFormat)
1056 case Format::Binary: out.write((
char const*)block.data(), block.size());
break;
1067 ifstream fin(filename, std::ifstream::binary);
1068 istream& in = (filename.empty() || filename ==
"--") ? cin : fin;
1069 unsigned alreadyHave = 0;
1071 unsigned futureTime = 0;
1072 unsigned unknownParent = 0;
1076 unsigned lastImported = 0;
1077 unsigned imported = 0;
1078 while (in.peek() != -1)
1081 in.read((
char*)block.data(), 8);
1082 block.resize(
RLP(block, RLP::LaissezFaire).actualSize());
1083 in.read((
char*)block.data() + 8, block.size() - 8);
1087 case ImportResult::Success: good++;
break;
1088 case ImportResult::AlreadyKnown: alreadyHave++;
break;
1089 case ImportResult::UnknownParent: unknownParent++;
break;
1090 case ImportResult::FutureTimeUnknown: unknownParent++; futureTime++;
break;
1091 case ImportResult::FutureTimeKnown: futureTime++;
break;
1092 default: bad++;
break;
1097 imported += get<2>(r);
1099 double e = chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - t).
count() / 1000.0;
1100 if ((
unsigned)e >= last + 10)
1102 auto i = imported - lastImported;
1104 cout << i <<
" more imported at " << (
round(i * 10 /
d) / 10) <<
" blocks/s. " << imported <<
" imported in " << e <<
" seconds at " << (
round(imported * 10 / e) / 10) <<
" blocks/s (#" << web3.
ethereum()->
number() <<
")" << endl;
1106 lastImported = imported;
1111 bool moreToImport =
true;
1112 while (moreToImport)
1114 this_thread::sleep_for(chrono::seconds(1));
1117 double e = chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - t).
count() / 1000.0;
1118 cout << imported <<
" imported in " << e <<
" seconds at " << (
round(imported * 10 / e) / 10) <<
" blocks/s (#" << web3.
ethereum()->
number() <<
")" << endl;
1126 if (!keyManager.
load(masterPassword) && masterSet)
1130 masterPassword =
getPassword(
"Please enter your MASTER password: ");
1131 if (keyManager.
load(masterPassword))
1133 cout <<
"The password you entered is incorrect. If you have forgotten your password, and you wish to start afresh, manually remove the file: " +
getDataDir(
"ethereum") +
"/keys.info" << endl;
1140 keyManager.
create(masterPassword);
1142 keyManager.
create(std::string());
1147 cerr <<
"Error initializing key manager: " << boost::current_exception_diagnostic_information() << endl;
1151 for (
auto const& presale: presaleImports)
1152 importPresale(keyManager, presale, [&](){
return getPassword(
"Enter your wallet password for " + presale +
": "); });
1154 for (
auto const& s: toImport)
1156 keyManager.
import(s,
"Imported key (UNSAFE)");
1163 std::shared_ptr<eth::TrivialGasPricer> gasPricer = make_shared<eth::TrivialGasPricer>(askPrice, bidPrice);
1170 c->setAuthor(author);
1171 if (networkID != NoNetworkID)
1172 c->setNetworkId(networkID);
1175 auto renderFullAddress = [&](
Address const& _a) -> std::string
1181 cout <<
"Mining Beneficiary: " << renderFullAddress(author) << endl;
1183 if (bootstrap || !remoteHost.empty() || enableDiscovery || listenSet)
1186 cout <<
"Node ID: " << web3.
enode() << endl;
1189 cout <<
"Networking disabled. To start, use netstart or pass --bootstrap or a remote host." << endl;
1191 unique_ptr<ModularServer<>> jsonrpcHttpServer;
1192 unique_ptr<ModularServer<>> jsonrpcIpcServer;
1193 unique_ptr<rpc::SessionManager> sessionManager;
1198 std::function<bool(TransactionSkeleton const&, bool)> authenticator;
1204 if (!alwaysConfirm || allowedDestinations.count(_t.
to))
1210 h256 contractCodeHash = web3.ethereum()->postState().codeHash(_t.to);
1211 if (contractCodeHash == EmptySHA3)
1212 return std::make_pair(false, std::string());
1214 return std::make_pair(true, std::string());
1215 }, [&](
Address const& _a) { return ICAP(_a).encoded() +
" (" + _a.abridged() +
")"; }
1216 ) +
"\nEnter yes/no/always (always to this address): ", {
"yes",
"n",
"N",
"no",
"NO",
"always"});
1218 allowedDestinations.insert(_t.
to);
1219 return r ==
"yes" || r ==
"always";
1224 if (jsonRPCURL > -1 || ipc)
1236 rpc::TestFace* testEth =
nullptr;
1240 if (jsonRPCURL >= 0)
1243 rpc::PersonalFace* personal =
nullptr;
1249 adminEth =
new rpc::AdminEth(*web3.
ethereum(), *gasPricer.get(), keyManager, *sessionManager.get());
1254 jsonrpcHttpServer.reset(
new FullServer(
1257 adminEth, adminNet, adminUtils,
1262 httpConnector->setAllowedOrigin(rpcCorsDomain);
1263 jsonrpcHttpServer->addConnector(httpConnector);
1264 jsonrpcHttpServer->StartListening();
1268 jsonrpcIpcServer.reset(
new FullServer(
1277 auto ipcConnector =
new IpcServer(
"geth");
1278 jsonrpcIpcServer->addConnector(ipcConnector);
1279 ipcConnector->StartListening();
1282 if (jsonAdmin.empty())
1287 cout <<
"JSONRPC Admin Session Key: " << jsonAdmin << endl;
1292 for (
auto const& p: preferredNodes)
1293 if (p.second.second)
1298 if (bootstrap && privateChain.empty())
1299 for (
auto const& i: Host::pocHosts())
1301 if (!remoteHost.empty())
1310 unsigned n =
c->blockChain().details().number;
1314 while (!exitHandler.shouldExit())
1318 while (!exitHandler.shouldExit())
1319 this_thread::sleep_for(chrono::milliseconds(1000));
1321 if (jsonrpcHttpServer.get())
1322 jsonrpcHttpServer->StopListening();
1323 if (jsonrpcIpcServer.get())
1324 jsonrpcIpcServer->StopListening();
1327 if (!netData.empty())
std::string encoded() const
void stopSealing() override
Stop sealing.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
std::string toHex(T const &_data, int _w=2, HexPrefix _prefix=HexPrefix::DontAdd)
const unsigned c_protocolVersion
Current protocol version.
BlockDetails details(h256 const &_hash) const
Get the familial details concerning a block (or the most recent mined if none given). Thread-safe.
std::string const & clientVersion() const
static KeyPair presaleSecret(std::string const &_json, std::function< std::string(bool)> const &_password)
Extracts the secret key from the presale wallet.
string getAccountPassword(KeyManager &keyManager, Address const &a)
std::string const & accountName(Address const &_address) const
unique_ptr< AccountHolder > accountHolder
EthashClient & asEthashClient(Interface &_c)
static void streamWalletHelp(std::ostream &_out)
stream wallet help section
eth::Client * ethereum() const
void writeFile(std::string const &_file, bytesConstRef _data, bool _writeDeleteRename=false)
Write the given binary data into the given file, replacing the file if it pre-exists.
std::unordered_map< std::string, std::string > otherParams
Additional parameters.
h128 uuid(Address const &_a) const
void notePassword(std::string const &_pass)
Simple class that represents a "key pair".
h160 Address
An Ethereum address: 20 bytes.
void setExtraData(bytes const &_extraData)
Set the extra data that goes into sealed blocks.
std::vector< Secret > Secrets
A vector of secrets.
std::vector< std::string > strings
h256 const & genesisStateRoot(Network _n)
std::hash for asio::adress
std::string contentsString(std::string const &_file)
Retrieve and returns the contents of the given file as a std::string.
static void streamHelp(ostream &_out)
Main API hub for interfacing with Web 3 components.
int Add(word *C, const word *A, const word *B, size_t N)
std::string getDataDir(std::string _prefix="ethereum")
Secret const & secret() const
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Simple lock that waits for release without making context switch.
Model of an Ethereum state, essentially a facade for the trie.
void setIpcPath(std::string const &_ipcPath)
Sets the ipc socket dir.
ChainParams loadConfig(std::string const &_json, h256 const &_stateRoot=h256()) const
load config/genesis
string pretty(h160 _a, dev::eth::State const &_st)
std::string const & passwordHint(Address const &_address) const
std::string userReadable(bool _toProxy, std::function< std::pair< bool, std::string >(TransactionSkeleton const &)> const &_getNatSpec, std::function< std::string(Address const &)> const &_formatAddress) const
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 160, 160, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u160
h128 import(Secret const &_s, std::string const &_accountName, std::string const &_pass, std::string const &_passwordHint)
Public toPublic(Secret const &_secret)
Convert a secret key into the public key equivalent.
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
_N toHash(int _flags=Strict) const
void setDefaultOrCLocale()
static void streamAccountHelp(std::ostream &_out)
stream account help section
std::tuple< ImportRoute, bool, unsigned > syncQueue(unsigned _max=1)
Freeze worker thread and sync some of the block queue.
int main(int argc, char **argv)
ChainParams loadGenesis(std::string const &_json, h256 const &_stateRoot=h256()) const
High-level manager of password-encrypted keys for Ethereum.
void requirePeer(p2p::NodeID const &_node, bi::tcp::endpoint const &_endpoint) override
Require connection to peer.
BlockChain const & blockChain() const
Get the object representing the current canonical blockchain.
dev::bytes saveNetwork() override
Save peers.
unsigned number(h256 const &_hash) const
Get a number for the given hash (or the most recent mined if none given). Thread-safe.
h256 numberHash(unsigned _i) const
Get the hash for a given block's number.
std::string minerType() const
void stopSealingAfterXBlocks(eth::Client *_c, unsigned _start, unsigned &io_mining)
std::function< void(std::string const &, char const *)> g_logPost
The current method that the logging system uses to output the log messages. Defaults to simpleDebugOu...
void create(std::string const &_pass)
bool interpretOption(int &i, int argc, char **argv)
bool isPrime(unsigned _number)
void setDataDir(std::string const &_dir)
Sets the data dir for the default ("ethereum") prefix.
std::vector< byte > bytes
u256 storage(Address const &_contract, u256 const &_memory) const
Get the value of a storage position of an account.
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
static void exitHandler(int)
Main API hub for interfacing with Ethereum.
bool execute(int argc, char **argv)
uses argc, argv provided by the CLI and executes implemented options.
std::lock_guard< SpinLock > SpinGuard
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
const unsigned SensibleHttpPort
string ethCredits(bool _interactive=false)
bytes rlpList()
Export a list of items in RLP format, returning a byte array.
int g_logVerbosity
The logging system's current verbosity.
Add account management functionnalities to CLI.
void setPeerStretch(size_t _n)
Experimental. Sets ceiling for incoming connections to multiple of ideal peer count.
u256 u256Param(std::string const &_name) const
Convenience method to get an otherParam as a u256 int.
JSON-RPC api implementation.
std::string const & genesisInfo(Network _n)
Encapsulation of an ICAP address.
PlatformStyle::TableColorType type
bool load(std::string const &_pass)
std::string enode() const override
Get enode string.
std::string sealEngineName
The chain sealer name: e.g. Ethash, NoProof, BasicAuthority.
virtual void addNode(p2p::NodeID const &_node, bi::tcp::endpoint const &_hostEndpoint) override
Add node to connect to.
#define round(a, b, c, x, mul)
clock::time_point time_point
bool sha3(bytesConstRef _input, bytesRef o_output)
Calculate SHA3-256 hash of the given input and load it into the given output.
const unsigned SensibleHttpThreads
bool shouldPrecompute() const
const unsigned c_databaseVersion
Current database version.
virtual unsigned number() const override
void importPresale(KeyManager &_km, string const &_file, function< string()> _pass)
bytes block(h256 const &_hash) const
Get a block (RLP format) for the given hash (or the most recent mined if none given). Thread-safe.
std::string getPassword(std::string const &_prompt)
Requests the user to enter a password on the console.
UnixDomainSocketServer IpcServer
void setIdealPeerCount(size_t _n) override
Sets the ideal number of peers.
bytes contents(std::string const &_file)
Retrieve and returns the contents of the given file.
void setGasPricer(std::shared_ptr< GasPricer > _gp)
Resets the gas pricer to some other object.
Class for interpreting Recursive Linear-Prefix Data.
#define DEV_IGNORE_EXCEPTIONS(X)
bool isFalse(std::string const &_m)
int atoi(const std::string &str)
std::string toUUID(h128 const &_uuid)
void startNetwork() override
Start the network subsystem.
bool isTrue(std::string const &_m)
ImportResult queueBlock(bytes const &_block, bool _isSafe=false)
Queues a block for import.
std::unordered_set< h160 > AddressHash
A hash set of Ethereum addresses.