diff -uNr a/bitcoin/manifest b/bitcoin/manifest --- a/bitcoin/manifest 719127a6ce6e341bb8d959957434f25276df9f8db29285bccc1f796295bbc3b608bb5237c8c29f44eef3b5c0b32422b61c3b22d4139e155a6ea08225268df84f +++ b/bitcoin/manifest dc1d0405721e05f48556907247b1817114b7db546f0cee61e4b5955b1f8a9cf8ec606ceadbc6f8f0c59cd6296e2e4fe10605ebe6314b738a483ecee323e5146d @@ -35,3 +35,4 @@ 625543 bitcoin_rawtx_get_send jfw Add hex raw transaction RPC commands: 'getrawtransaction' fetches from mempool or database; 'sendrawtransaction' injects to mempool or wallet and broadcasts (based loosely on earlier sendrawtransaction patch by polarbeard). Minor simplifications based on new higher-level mempool accessors. 625543 bitcoin_system_compiler jfw Build system simplification focused on using the system compiler. 688130 bitcoin_dumpblock_no_losers jfw Correct 'dumpblock' to restrict its search to the current best chain, rather than dumping the first matching block by height (which may have lost the mining race and been reorganized away). +696655 bitcoin_help_tuneups jfw Don't hide help for wallet commands based on current encryption state; accept -help for consistency; rewrite inane help for -highs/-lows options; add help for -disablesafemode; make it and -testsafemode use explicit variables for consistency and centricity of options; clarify warning message shown in safe mode and change the political interpretation it offers; fix inept formatting in the parts otherwise touched. diff -uNr a/bitcoin/src/bitcoinrpc.cpp b/bitcoin/src/bitcoinrpc.cpp --- a/bitcoin/src/bitcoinrpc.cpp 48e11afd9f1ad6cd2a8f61d3d49f5cf7c7519a86d8cc494a16cd6bc04f31f92b8d9b4adf6c14117c661a83fadfa8ead46c2d0d882ce4fdfb777568be4e377bcf +++ b/bitcoin/src/bitcoinrpc.cpp 4b2f744b166ce0a5632bf003bcede45f4c713629b96bc3833942ee534d965ac8c6ebb7faf69fa5a801bfa6089e1034f665fabb6854a051cd76ec1de5dfc10143 @@ -490,15 +490,11 @@ Value sendtoaddress(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4)) + if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "sendtoaddress [comment] [comment-to]\n" " is a real and is rounded to the nearest 0.00000001\n" - "requires wallet passphrase to be set with walletpassphrase first"); - if (!pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4)) - throw runtime_error( - "sendtoaddress [comment] [comment-to]\n" - " is a real and is rounded to the nearest 0.00000001"); + "if wallet is encrypted, requires passphrase to be stored with walletpassphrase first"); CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) @@ -811,15 +807,11 @@ Value sendfrom(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() < 3 || params.size() > 6)) + if (fHelp || params.size() < 3 || params.size() > 6) throw runtime_error( "sendfrom [minconf=1] [comment] [comment-to]\n" " is a real and is rounded to the nearest 0.00000001\n" - "requires wallet passphrase to be set with walletpassphrase first"); - if (!pwalletMain->IsCrypted() && (fHelp || params.size() < 3 || params.size() > 6)) - throw runtime_error( - "sendfrom [minconf=1] [comment] [comment-to]\n" - " is a real and is rounded to the nearest 0.00000001"); + "if wallet is encrypted, requires passphrase to be stored with walletpassphrase first"); string strAccount = AccountFromValue(params[0]); CBitcoinAddress address(params[1].get_str()); @@ -856,15 +848,11 @@ Value sendmany(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4)) + if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "sendmany {address:amount,...} [minconf=1] [comment]\n" "amounts are double-precision floating point numbers\n" - "requires wallet passphrase to be set with walletpassphrase first"); - if (!pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 4)) - throw runtime_error( - "sendmany {address:amount,...} [minconf=1] [comment]\n" - "amounts are double-precision floating point numbers"); + "if wallet is encrypted, requires passphrase to be stored with walletpassphrase first"); string strAccount = AccountFromValue(params[0]); Object sendTo = params[1].get_obj(); @@ -1371,14 +1359,10 @@ Value keypoolrefill(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() > 0)) - throw runtime_error( - "keypoolrefill\n" - "Fills the keypool, requires wallet passphrase to be set."); - if (!pwalletMain->IsCrypted() && (fHelp || params.size() > 0)) + if (fHelp || params.size() > 0) throw runtime_error( "keypoolrefill\n" - "Fills the keypool."); + "Fills the keypool. If wallet is encrypted, requires passphrase to be stored."); if (pwalletMain->IsLocked()) throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); @@ -1440,12 +1424,10 @@ Value walletpassphrase(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) + if (fHelp || params.size() != 2 || params[0].get_str().length() == 0) throw runtime_error( "walletpassphrase \n" "Stores the wallet decryption key in memory for seconds."); - if (fHelp) - return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletpassphrase was called."); @@ -1479,12 +1461,10 @@ Value walletpassphrasechange(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) + if (fHelp || params.size() != 2) throw runtime_error( "walletpassphrasechange \n" "Changes the wallet passphrase from to ."); - if (fHelp) - return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletpassphrasechange was called."); @@ -1512,14 +1492,12 @@ Value walletlock(const Array& params, bool fHelp) { - if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0)) + if (fHelp || params.size() != 0) throw runtime_error( "walletlock\n" "Removes the wallet encryption key from memory, locking the wallet.\n" "After calling this method, you will need to call walletpassphrase again\n" "before being able to call any methods which require the wallet to be unlocked."); - if (fHelp) - return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an unencrypted wallet, but walletlock was called."); @@ -1535,12 +1513,10 @@ Value encryptwallet(const Array& params, bool fHelp) { - if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1)) + if (fHelp || params.size() != 1) throw runtime_error( "encryptwallet \n" - "Encrypts the wallet with ."); - if (fHelp) - return true; + "Encrypts an as-yet unencrypted wallet with ."); if (pwalletMain->IsCrypted()) throw JSONRPCError(-15, "Error: running with an encrypted wallet, but encryptwallet was called."); @@ -2385,9 +2361,11 @@ throw JSONRPCError(-32601, "Method not found"); // Observe safe mode - string strWarning = GetWarnings("rpc"); - if (strWarning != "" && !GetBoolArg("-disablesafemode") && !setAllowInSafeMode.count(strMethod)) - throw JSONRPCError(-2, string("Safe mode: ") + strWarning); + if (!fDisableSafeMode) { + string strWarning = GetWarnings("rpc"); + if (strWarning != "" && !setAllowInSafeMode.count(strMethod)) + throw JSONRPCError(-2, string("Safe mode: ") + strWarning); + } try { diff -uNr a/bitcoin/src/init.cpp b/bitcoin/src/init.cpp --- a/bitcoin/src/init.cpp f80dfd494a79def349b3725d51a5d79b7ec87f623ed8a43ec2fc9edc8a9b6692e032a32575b20ede56ff1173d9d782404b4866f67d5f7fc544079bbd06dcf8d9 +++ b/bitcoin/src/init.cpp 2d80ecb71871a017c1dd660af32e31d3c513cbb539a6dacb5eb0f7e939511bc8e49e6a9ebf17a74d66030833b077a264dff10557d1686110cfcd35989f3a8457 @@ -143,7 +143,7 @@ ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir - if (mapArgs.count("-?") || mapArgs.count("--help")) + if (mapArgs.count("-?") || mapArgs.count("-help") || mapArgs.count("--help")) { string strUsage = string() + _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" + @@ -174,12 +174,12 @@ " -paytxfee= \t " + _("Fee per kB to add to transactions you send\n") + " -daemon \t\t " + _("Run in the background as a daemon and accept commands\n") + " -debug \t\t " + _("Output extra debugging information\n") + - " -caneat \t\t " + _("Permit the use of 'eatblock'\n") + - " -verifyall \t\t " + _("Forbid the skipping of ECDSA signature verification between checkpoints.\n") + - " -setverstring \t\t " + _("Set a custom version string.\n") + - " -setvernum \t\t " + _("Set a custom version number.\n") + - " -highs \t\t " + _("Set all transactions to have DER 'S' Value set to 'high'.\n") + - " -lows \t\t " + _("Set all transactions to have DER 'S' Value set to 'low'.\n") + + " -caneat Permit the use of 'eatblock'\n" + + " -verifyall Forbid the skipping of ECDSA signature verification between checkpoints\n" + + " -setverstring Set a custom version string\n" + + " -setvernum Set a custom version number\n" + + " -highs Normalize ECDSA S-values to 'high' when signing\n" + + " -lows Normalize ECDSA S-values to 'low' when signing (may be necessary as some implementations refuse to relay transactions with high-S signatures)\n" + " -logtimestamps \t " + _("Prepend debug output with timestamp\n") + " -printtoconsole \t " + _("Send trace/debug info to console instead of debug.log file\n") + " -rpcuser= \t " + _("Username for JSON-RPC connections\n") + @@ -188,10 +188,9 @@ " -rpcallowip= \t\t " + _("Allow JSON-RPC connections from specified IP address\n") + " -rpcconnect= \t " + _("Send commands to node running on (default: 127.0.0.1)\n") + " -keypool= \t " + _("Set key pool size to (default: 100)\n") + - " -rescan \t " + _("Rescan the block chain for missing wallet transactions\n"); - - strUsage += string() + - " -? \t\t " + _("This help message\n"); + " -rescan Rescan the block chain for missing wallet transactions\n" + + " -disablesafemode Don't lock certain commands when hazards are detected such as DB corruption or network fork\n" + + " -? This help message\n"; // Remove tabs strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end()); @@ -205,11 +204,13 @@ fVerifyAll = GetBoolArg("-verifyall"); fHighS = GetBoolArg("-highs"); fLowS = GetBoolArg("-lows"); + fTestSafeMode = GetBoolArg("-testsafemode"); /* undocumented */ + fDisableSafeMode = GetBoolArg("-disablesafemode"); if (fHighS && fLowS) { - printf("Error: '-highs' and '-lows' can not be set at the same time.\n"); - return false; + printf("Error: '-highs' and '-lows' can not be set at the same time.\n"); + return false; } if (mapArgs.count("-setverstring")) diff -uNr a/bitcoin/src/main.cpp b/bitcoin/src/main.cpp --- a/bitcoin/src/main.cpp 64bc481577ff4e2b8fe4a0623332e4b60d1d7e208f29fc5036adca3965fe5766b4ea64f47d5442b8bfd990fe86bd37b4fab949439a402a771400fc346ac7ba7f +++ b/bitcoin/src/main.cpp 29a18b96d96476e66d743a10d5fb59eba97355607bd6d0617015662e7e9fd8403f5a3e862ae08b2af50bdb7d36097885edec4877103746c22b8fadccf30661b0 @@ -1615,25 +1615,18 @@ string GetWarnings(string strFor) { - int nPriority = 0; string strStatusBar; string strRPC; - if (GetBoolArg("-testsafemode")) + if (fTestSafeMode) strRPC = "test"; // Misc warnings like out of disk space and clock is wrong if (strMiscWarning != "") - { - nPriority = 1000; strStatusBar = strMiscWarning; - } // Longer invalid proof-of-work chain if (pindexBest && bnBestInvalidWork > bnBestChainWork + pindexBest->GetBlockWork() * 6) - { - nPriority = 2000; - strStatusBar = strRPC = "WARNING: Displayed transactions may not be correct! You may need to upgrade, or other nodes may need to upgrade."; - } + strStatusBar = strRPC = "WARNING: Received invalid chain with greater proof-of-work. Displayed transactions may not be correct! Your database or other nodes may be corrupted."; if (strFor == "statusbar") return strStatusBar; diff -uNr a/bitcoin/src/util.cpp b/bitcoin/src/util.cpp --- a/bitcoin/src/util.cpp 2130ec23d80df39382a0ec68b4e0c68526ad4b3b5dfd91375f62fa4c03715ab956c23fe0ff7821fae1a8d8150cc0c4267d5369e85d2ad7a730775afa82ec6d43 +++ b/bitcoin/src/util.cpp 739febb6ae393a0b2e8715b6615e8b4a604fad45e2e28408b70061e996f3067f7783ad41a94694c3459ce0fde95cfaafc14f5be081a890613147a455a414e23e @@ -34,6 +34,8 @@ bool fLogTimestamps = false; bool fLowS = false; bool fHighS = false; +bool fTestSafeMode = false; +bool fDisableSafeMode = false; std::string CLIENT_NAME(DEFAULT_CLIENT_NAME); diff -uNr a/bitcoin/src/util.h b/bitcoin/src/util.h --- a/bitcoin/src/util.h bb0bd8f585bf9d34edd89ea93710120105213eb931a48dfb0452055978b31444d988a14c6a9f82a4f9192c230579ee4ba607b867cf2a1a41d57fcad1b3a286ac +++ b/bitcoin/src/util.h c5c746c260901943a462709106d44184faf9986a16eec48f130946a62d0e5fa21a63b8be2a5e58906c49a2651d46dfe7accecb241bb1b7df8cda3e2a58876640 @@ -124,6 +124,8 @@ extern std::string CLIENT_NAME; extern bool fLowS; extern bool fHighS; +extern bool fTestSafeMode; +extern bool fDisableSafeMode; void RandAddSeed(); void RandAddSeedPerfmon();