|
|
@ -158,6 +158,11 @@ void help() |
|
|
|
<< " --port <port> Connect to remote port (default: 30303)." << endl |
|
|
|
<< " --network-id <n> Only connect to other hosts with this network id (default:0)." << endl |
|
|
|
<< " --upnp <on/off> Use UPnP for NAT (default: on)." << endl |
|
|
|
<< endl |
|
|
|
<< "Client structured logging:" << endl |
|
|
|
<< " --structured-logging Enable structured logging (default output to stdout)." << endl |
|
|
|
<< " --structured-logging-format <format> Set the structured logging time format." << endl |
|
|
|
<< " --structured-logging-url <URL> Set the structured logging destination (currently only file:// supported)." << endl |
|
|
|
#if ETH_JSONRPC || !ETH_TRUE |
|
|
|
<< endl |
|
|
|
<< "Work farming mode:" << endl |
|
|
@ -806,8 +811,11 @@ int main(int argc, char** argv) |
|
|
|
structuredLoggingFormat = string(argv[++i]); |
|
|
|
else if (arg == "--structured-logging") |
|
|
|
structuredLogging = true; |
|
|
|
else if (arg == "--structured-logging-destination" && i + 1 < argc) |
|
|
|
else if (arg == "--structured-logging-url" && i + 1 < argc) |
|
|
|
{ |
|
|
|
structuredLogging = true; |
|
|
|
structuredLoggingURL = argv[++i]; |
|
|
|
} |
|
|
|
else if ((arg == "-d" || arg == "--path" || arg == "--db-path") && i + 1 < argc) |
|
|
|
dbPath = argv[++i]; |
|
|
|
else if ((arg == "-D" || arg == "--create-dag") && i + 1 < argc) |
|
|
@ -1033,6 +1041,28 @@ int main(int argc, char** argv) |
|
|
|
if (!clientName.empty()) |
|
|
|
clientName += "/"; |
|
|
|
|
|
|
|
string logbuf; |
|
|
|
bool silence = false; |
|
|
|
std::string additional; |
|
|
|
g_logPost = [&](std::string const& a, char const*){ |
|
|
|
if (silence) |
|
|
|
logbuf += a + "\n"; |
|
|
|
else |
|
|
|
cout << "\r \r" << a << endl << additional << flush; |
|
|
|
}; |
|
|
|
|
|
|
|
auto getPassword = [&](string const& prompt){ |
|
|
|
auto s = silence; |
|
|
|
silence = true; |
|
|
|
cout << endl; |
|
|
|
string ret = dev::getPassword(prompt); |
|
|
|
silence = s; |
|
|
|
return ret; |
|
|
|
}; |
|
|
|
auto getAccountPassword = [&](Address const& a){ |
|
|
|
return getPassword("Enter password for address " + keyManager.accountDetails()[a].first + " (" + a.abridged() + "; hint:" + keyManager.accountDetails()[a].second + "): "); |
|
|
|
}; |
|
|
|
|
|
|
|
StructuredLogger::get().initialize(structuredLogging, structuredLoggingFormat, structuredLoggingURL); |
|
|
|
VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter); |
|
|
|
auto netPrefs = publicIP.empty() ? NetworkPreferences(listenIP ,listenPort, upnp) : NetworkPreferences(publicIP, listenIP ,listenPort, upnp); |
|
|
@ -1042,13 +1072,38 @@ int main(int argc, char** argv) |
|
|
|
clientImplString, |
|
|
|
dbPath, |
|
|
|
killChain, |
|
|
|
nodeMode == NodeMode::Full ? set<string>{"eth", "shh"} : set<string>(), |
|
|
|
nodeMode == NodeMode::Full ? set<string>{"eth"/*, "shh"*/} : set<string>(), |
|
|
|
netPrefs, |
|
|
|
&nodesState); |
|
|
|
|
|
|
|
if (mode == OperationMode::DAGInit) |
|
|
|
doInitDAG(web3.ethereum()->blockChain().number() + (initDAG == PendingBlock ? 30000 : 0)); |
|
|
|
|
|
|
|
if (keyManager.exists()) |
|
|
|
while (masterPassword.empty()) |
|
|
|
{ |
|
|
|
masterPassword = getPassword("Please enter your MASTER password: "); |
|
|
|
if (!keyManager.load(masterPassword)) |
|
|
|
{ |
|
|
|
cout << "Password invalid. Try again." << endl; |
|
|
|
masterPassword.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
while (masterPassword.empty()) |
|
|
|
{ |
|
|
|
masterPassword = getPassword("Please enter a MASTER password to protect your key store (make it strong!): "); |
|
|
|
string confirm = getPassword("Please confirm the password by entering it again: "); |
|
|
|
if (masterPassword != confirm) |
|
|
|
{ |
|
|
|
cout << "Passwords were different. Try again." << endl; |
|
|
|
masterPassword.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
keyManager.create(masterPassword); |
|
|
|
} |
|
|
|
|
|
|
|
auto toNumber = [&](string const& s) -> unsigned { |
|
|
|
if (s == "latest") |
|
|
|
return web3.ethereum()->number(); |
|
|
@ -1137,53 +1192,13 @@ int main(int argc, char** argv) |
|
|
|
if (remoteHost.size()) |
|
|
|
web3.addNode(p2p::NodeId(), remoteHost + ":" + toString(remotePort)); |
|
|
|
|
|
|
|
if (keyManager.exists()) |
|
|
|
while (masterPassword.empty()) |
|
|
|
{ |
|
|
|
masterPassword = getPassword("Please enter your MASTER password: "); |
|
|
|
if (!keyManager.load(masterPassword)) |
|
|
|
{ |
|
|
|
cout << "Password invalid. Try again." << endl; |
|
|
|
masterPassword.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
while (masterPassword.empty()) |
|
|
|
{ |
|
|
|
masterPassword = getPassword("Please enter a MASTER password to protect your key store (make it strong!): "); |
|
|
|
string confirm = getPassword("Please confirm the password by entering it again: "); |
|
|
|
if (masterPassword != confirm) |
|
|
|
{ |
|
|
|
cout << "Passwords were different. Try again." << endl; |
|
|
|
masterPassword.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
keyManager.create(masterPassword); |
|
|
|
} |
|
|
|
|
|
|
|
string logbuf; |
|
|
|
bool silence = false; |
|
|
|
std::string additional; |
|
|
|
g_logPost = [&](std::string const& a, char const*) { if (silence) logbuf += a + "\n"; else cout << "\r \r" << a << endl << additional << flush; }; |
|
|
|
|
|
|
|
// TODO: give hints &c.
|
|
|
|
auto getPassword = [&](Address const& a){ |
|
|
|
auto s = silence; |
|
|
|
silence = true; |
|
|
|
cout << endl; |
|
|
|
string ret = dev::getPassword("Enter password for address " + keyManager.accountDetails()[a].first + " (" + a.abridged() + "; hint:" + keyManager.accountDetails()[a].second + "): "); |
|
|
|
silence = s; |
|
|
|
return ret; |
|
|
|
}; |
|
|
|
|
|
|
|
#if ETH_JSONRPC || !ETH_TRUE |
|
|
|
shared_ptr<WebThreeStubServer> jsonrpcServer; |
|
|
|
unique_ptr<jsonrpc::AbstractServerConnector> jsonrpcConnector; |
|
|
|
if (jsonrpc > -1) |
|
|
|
{ |
|
|
|
jsonrpcConnector = unique_ptr<jsonrpc::AbstractServerConnector>(new jsonrpc::HttpServer(jsonrpc, "", "", SensibleHttpThreads)); |
|
|
|
jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer(*jsonrpcConnector.get(), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum();}, getPassword, keyManager), vector<KeyPair>())); |
|
|
|
jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer(*jsonrpcConnector.get(), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum();}, getAccountPassword, keyManager), vector<KeyPair>())); |
|
|
|
jsonrpcServer->StartListening(); |
|
|
|
} |
|
|
|
#endif |
|
|
@ -1327,7 +1342,7 @@ int main(int argc, char** argv) |
|
|
|
if (jsonrpc < 0) |
|
|
|
jsonrpc = SensibleHttpPort; |
|
|
|
jsonrpcConnector = unique_ptr<jsonrpc::AbstractServerConnector>(new jsonrpc::HttpServer(jsonrpc, "", "", SensibleHttpThreads)); |
|
|
|
jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer(*jsonrpcConnector.get(), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum();}, getPassword, keyManager), vector<KeyPair>())); |
|
|
|
jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer(*jsonrpcConnector.get(), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum();}, getAccountPassword, keyManager), vector<KeyPair>())); |
|
|
|
jsonrpcServer->StartListening(); |
|
|
|
} |
|
|
|
else if (cmd == "jsonstop") |
|
|
@ -1479,7 +1494,7 @@ int main(int argc, char** argv) |
|
|
|
try |
|
|
|
{ |
|
|
|
Address dest = h160(fromHex(hexAddr, WhenError::Throw)); |
|
|
|
c->submitTransaction(keyManager.secret(signingKey, [&](){ return getPassword(signingKey); }), amount, dest, bytes(), minGas); |
|
|
|
c->submitTransaction(keyManager.secret(signingKey, [&](){ return getAccountPassword(signingKey); }), amount, dest, bytes(), minGas); |
|
|
|
} |
|
|
|
catch (BadHexCharacter& _e) |
|
|
|
{ |
|
|
@ -1548,7 +1563,7 @@ int main(int argc, char** argv) |
|
|
|
else if (gas < minGas) |
|
|
|
cwarn << "Minimum gas amount is" << minGas; |
|
|
|
else |
|
|
|
c->submitTransaction(keyManager.secret(signingKey, [&](){ return getPassword(signingKey); }), endowment, init, gas, gasPrice); |
|
|
|
c->submitTransaction(keyManager.secret(signingKey, [&](){ return getAccountPassword(signingKey); }), endowment, init, gas, gasPrice); |
|
|
|
} |
|
|
|
else |
|
|
|
cwarn << "Require parameters: contract ENDOWMENT GASPRICE GAS CODEHEX"; |
|
|
|