@@ -158,6 +158,11 @@ void help()
158158 << " --port <port> Connect to remote port (default: 30303)." << endl
159159 << " --network-id <n> Only connect to other hosts with this network id (default:0)." << endl
160160 << " --upnp <on/off> Use UPnP for NAT (default: on)." << endl
161+ << endl
162+ << " Client structured logging:" << endl
163+ << " --structured-logging Enable structured logging (default output to stdout)." << endl
164+ << " --structured-logging-format <format> Set the structured logging time format." << endl
165+ << " --structured-logging-url <URL> Set the structured logging destination (currently only file:// supported)." << endl
161166#if ETH_JSONRPC || !ETH_TRUE
162167 << endl
163168 << " Work farming mode:" << endl
@@ -806,8 +811,11 @@ int main(int argc, char** argv)
806811 structuredLoggingFormat = string (argv[++i]);
807812 else if (arg == " --structured-logging" )
808813 structuredLogging = true ;
809- else if (arg == " --structured-logging-destination" && i + 1 < argc)
814+ else if (arg == " --structured-logging-url" && i + 1 < argc)
815+ {
816+ structuredLogging = true ;
810817 structuredLoggingURL = argv[++i];
818+ }
811819 else if ((arg == " -d" || arg == " --path" || arg == " --db-path" ) && i + 1 < argc)
812820 dbPath = argv[++i];
813821 else if ((arg == " -D" || arg == " --create-dag" ) && i + 1 < argc)
@@ -1033,6 +1041,28 @@ int main(int argc, char** argv)
10331041 if (!clientName.empty ())
10341042 clientName += " /" ;
10351043
1044+ string logbuf;
1045+ bool silence = false ;
1046+ std::string additional;
1047+ g_logPost = [&](std::string const & a, char const *){
1048+ if (silence)
1049+ logbuf += a + " \n " ;
1050+ else
1051+ cout << " \r \r " << a << endl << additional << flush;
1052+ };
1053+
1054+ auto getPassword = [&](string const & prompt){
1055+ auto s = silence;
1056+ silence = true ;
1057+ cout << endl;
1058+ string ret = dev::getPassword (prompt);
1059+ silence = s;
1060+ return ret;
1061+ };
1062+ auto getAccountPassword = [&](Address const & a){
1063+ return getPassword (" Enter password for address " + keyManager.accountDetails ()[a].first + " (" + a.abridged () + " ; hint:" + keyManager.accountDetails ()[a].second + " ): " );
1064+ };
1065+
10361066 StructuredLogger::get ().initialize (structuredLogging, structuredLoggingFormat, structuredLoggingURL);
10371067 VMFactory::setKind (jit ? VMKind::JIT : VMKind::Interpreter);
10381068 auto netPrefs = publicIP.empty () ? NetworkPreferences (listenIP ,listenPort, upnp) : NetworkPreferences (publicIP, listenIP ,listenPort, upnp);
@@ -1042,13 +1072,38 @@ int main(int argc, char** argv)
10421072 clientImplString,
10431073 dbPath,
10441074 killChain,
1045- nodeMode == NodeMode::Full ? set<string>{" eth" , " shh" } : set<string>(),
1075+ nodeMode == NodeMode::Full ? set<string>{" eth" /* , "shh"*/ } : set<string>(),
10461076 netPrefs,
10471077 &nodesState);
10481078
10491079 if (mode == OperationMode::DAGInit)
10501080 doInitDAG (web3.ethereum ()->blockChain ().number () + (initDAG == PendingBlock ? 30000 : 0 ));
10511081
1082+ if (keyManager.exists ())
1083+ while (masterPassword.empty ())
1084+ {
1085+ masterPassword = getPassword (" Please enter your MASTER password: " );
1086+ if (!keyManager.load (masterPassword))
1087+ {
1088+ cout << " Password invalid. Try again." << endl;
1089+ masterPassword.clear ();
1090+ }
1091+ }
1092+ else
1093+ {
1094+ while (masterPassword.empty ())
1095+ {
1096+ masterPassword = getPassword (" Please enter a MASTER password to protect your key store (make it strong!): " );
1097+ string confirm = getPassword (" Please confirm the password by entering it again: " );
1098+ if (masterPassword != confirm)
1099+ {
1100+ cout << " Passwords were different. Try again." << endl;
1101+ masterPassword.clear ();
1102+ }
1103+ }
1104+ keyManager.create (masterPassword);
1105+ }
1106+
10521107 auto toNumber = [&](string const & s) -> unsigned {
10531108 if (s == " latest" )
10541109 return web3.ethereum ()->number ();
@@ -1137,53 +1192,13 @@ int main(int argc, char** argv)
11371192 if (remoteHost.size ())
11381193 web3.addNode (p2p::NodeId (), remoteHost + " :" + toString (remotePort));
11391194
1140- if (keyManager.exists ())
1141- while (masterPassword.empty ())
1142- {
1143- masterPassword = getPassword (" Please enter your MASTER password: " );
1144- if (!keyManager.load (masterPassword))
1145- {
1146- cout << " Password invalid. Try again." << endl;
1147- masterPassword.clear ();
1148- }
1149- }
1150- else
1151- {
1152- while (masterPassword.empty ())
1153- {
1154- masterPassword = getPassword (" Please enter a MASTER password to protect your key store (make it strong!): " );
1155- string confirm = getPassword (" Please confirm the password by entering it again: " );
1156- if (masterPassword != confirm)
1157- {
1158- cout << " Passwords were different. Try again." << endl;
1159- masterPassword.clear ();
1160- }
1161- }
1162- keyManager.create (masterPassword);
1163- }
1164-
1165- string logbuf;
1166- bool silence = false ;
1167- std::string additional;
1168- g_logPost = [&](std::string const & a, char const *) { if (silence) logbuf += a + " \n " ; else cout << " \r \r " << a << endl << additional << flush; };
1169-
1170- // TODO: give hints &c.
1171- auto getPassword = [&](Address const & a){
1172- auto s = silence;
1173- silence = true ;
1174- cout << endl;
1175- string ret = dev::getPassword (" Enter password for address " + keyManager.accountDetails ()[a].first + " (" + a.abridged () + " ; hint:" + keyManager.accountDetails ()[a].second + " ): " );
1176- silence = s;
1177- return ret;
1178- };
1179-
11801195#if ETH_JSONRPC || !ETH_TRUE
11811196 shared_ptr<WebThreeStubServer> jsonrpcServer;
11821197 unique_ptr<jsonrpc::AbstractServerConnector> jsonrpcConnector;
11831198 if (jsonrpc > -1 )
11841199 {
11851200 jsonrpcConnector = unique_ptr<jsonrpc::AbstractServerConnector>(new jsonrpc::HttpServer (jsonrpc, " " , " " , SensibleHttpThreads));
1186- jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer (*jsonrpcConnector.get (), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum ();}, getPassword , keyManager), vector<KeyPair>()));
1201+ jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer (*jsonrpcConnector.get (), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum ();}, getAccountPassword , keyManager), vector<KeyPair>()));
11871202 jsonrpcServer->StartListening ();
11881203 }
11891204#endif
@@ -1327,7 +1342,7 @@ int main(int argc, char** argv)
13271342 if (jsonrpc < 0 )
13281343 jsonrpc = SensibleHttpPort;
13291344 jsonrpcConnector = unique_ptr<jsonrpc::AbstractServerConnector>(new jsonrpc::HttpServer (jsonrpc, " " , " " , SensibleHttpThreads));
1330- jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer (*jsonrpcConnector.get (), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum ();}, getPassword , keyManager), vector<KeyPair>()));
1345+ jsonrpcServer = shared_ptr<WebThreeStubServer>(new WebThreeStubServer (*jsonrpcConnector.get (), web3, make_shared<SimpleAccountHolder>([&](){return web3.ethereum ();}, getAccountPassword , keyManager), vector<KeyPair>()));
13311346 jsonrpcServer->StartListening ();
13321347 }
13331348 else if (cmd == " jsonstop" )
@@ -1479,7 +1494,7 @@ int main(int argc, char** argv)
14791494 try
14801495 {
14811496 Address dest = h160 (fromHex (hexAddr, WhenError::Throw));
1482- c->submitTransaction (keyManager.secret (signingKey, [&](){ return getPassword (signingKey); }), amount, dest, bytes (), minGas);
1497+ c->submitTransaction (keyManager.secret (signingKey, [&](){ return getAccountPassword (signingKey); }), amount, dest, bytes (), minGas);
14831498 }
14841499 catch (BadHexCharacter& _e)
14851500 {
@@ -1548,7 +1563,7 @@ int main(int argc, char** argv)
15481563 else if (gas < minGas)
15491564 cwarn << " Minimum gas amount is" << minGas;
15501565 else
1551- c->submitTransaction (keyManager.secret (signingKey, [&](){ return getPassword (signingKey); }), endowment, init, gas, gasPrice);
1566+ c->submitTransaction (keyManager.secret (signingKey, [&](){ return getAccountPassword (signingKey); }), endowment, init, gas, gasPrice);
15521567 }
15531568 else
15541569 cwarn << " Require parameters: contract ENDOWMENT GASPRICE GAS CODEHEX" ;
0 commit comments