This function returns either one of EXIT_ codes when it's expected to stop the process or CONTINUE_EXECUTION when it's expected to continue further.
| 44 | // This function returns either one of EXIT_ codes when it's expected to stop the process or |
| 45 | // CONTINUE_EXECUTION when it's expected to continue further. |
| 46 | static int AppInitUtil(ArgsManager& args, int argc, char* argv[]) |
| 47 | { |
| 48 | SetupBitcoinUtilArgs(args); |
| 49 | std::string error; |
| 50 | if (!args.ParseParameters(argc, argv, error)) { |
| 51 | tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error); |
| 52 | return EXIT_FAILURE; |
| 53 | } |
| 54 | |
| 55 | if (HelpRequested(args) || args.GetBoolArg("-version", false)) { |
| 56 | // First part of help message is specific to this utility |
| 57 | std::string strUsage = CLIENT_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n"; |
| 58 | |
| 59 | if (args.GetBoolArg("-version", false)) { |
| 60 | strUsage += FormatParagraph(LicenseInfo()); |
| 61 | } else { |
| 62 | strUsage += "\n" |
| 63 | "The bitcoin-util tool provides bitcoin related functionality that does not rely on the ability to access a running node. Available [commands] are listed below.\n" |
| 64 | "\n" |
| 65 | "Usage: bitcoin-util [options] [command]\n" |
| 66 | "or: bitcoin-util [options] grind <hex-block-header>\n"; |
| 67 | strUsage += "\n" + args.GetHelpMessage(); |
| 68 | } |
| 69 | |
| 70 | tfm::format(std::cout, "%s", strUsage); |
| 71 | |
| 72 | if (argc < 2) { |
| 73 | tfm::format(std::cerr, "Error: too few parameters\n"); |
| 74 | return EXIT_FAILURE; |
| 75 | } |
| 76 | return EXIT_SUCCESS; |
| 77 | } |
| 78 | |
| 79 | // Check for chain settings (Params() calls are only valid after this clause) |
| 80 | try { |
| 81 | SelectParams(args.GetChainType()); |
| 82 | } catch (const std::exception& e) { |
| 83 | tfm::format(std::cerr, "Error: %s\n", e.what()); |
| 84 | return EXIT_FAILURE; |
| 85 | } |
| 86 | |
| 87 | return CONTINUE_EXECUTION; |
| 88 | } |
| 89 | |
| 90 | static void grind_task(uint32_t nBits, CBlockHeader header, uint32_t offset, uint32_t step, std::atomic<bool>& found, uint32_t& proposed_nonce) |
| 91 | { |
no test coverage detected