MCPcopy Create free account
hub / github.com/ElementsProject/elements / AppInitUtil

Function AppInitUtil

src/bitcoin-util.cpp:44–83  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

42// This function returns either one of EXIT_ codes when it's expected to stop the process or
43// CONTINUE_EXECUTION when it's expected to continue further.
44static int AppInitUtil(ArgsManager& args, int argc, char* argv[])
45{
46 SetupBitcoinUtilArgs(args);
47 std::string error;
48 if (!args.ParseParameters(argc, argv, error)) {
49 tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
50 return EXIT_FAILURE;
51 }
52
53 if (HelpRequested(args) || args.IsArgSet("-version")) {
54 // First part of help message is specific to this utility
55 std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n";
56
57 if (args.IsArgSet("-version")) {
58 strUsage += FormatParagraph(LicenseInfo());
59 } else {
60 strUsage += "\n"
61 "Usage: bitcoin-util [options] [commands] Do stuff\n";
62 strUsage += "\n" + args.GetHelpMessage();
63 }
64
65 tfm::format(std::cout, "%s", strUsage);
66
67 if (argc < 2) {
68 tfm::format(std::cerr, "Error: too few parameters\n");
69 return EXIT_FAILURE;
70 }
71 return EXIT_SUCCESS;
72 }
73
74 // Check for chain settings (Params() calls are only valid after this clause)
75 try {
76 SelectParams(args.GetChainName());
77 } catch (const std::exception& e) {
78 tfm::format(std::cerr, "Error: %s\n", e.what());
79 return EXIT_FAILURE;
80 }
81
82 return CONTINUE_EXECUTION;
83}
84
85static void grind_task(uint32_t nBits, CBlockHeader& header_orig, uint32_t offset, uint32_t step, std::atomic<bool>& found)
86{

Callers 1

bitcoin-util.cppFile · 0.85

Calls 11

SetupBitcoinUtilArgsFunction · 0.85
HelpRequestedFunction · 0.85
FormatFullVersionFunction · 0.85
FormatParagraphFunction · 0.85
LicenseInfoFunction · 0.85
SelectParamsFunction · 0.85
ParseParametersMethod · 0.80
IsArgSetMethod · 0.80
GetHelpMessageMethod · 0.80
GetChainNameMethod · 0.80
formatFunction · 0.70

Tested by

no test coverage detected