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.
| 114 | // CONTINUE_EXECUTION when it's expected to continue further. |
| 115 | // |
| 116 | static int AppInitRPC(int argc, char* argv[]) |
| 117 | { |
| 118 | // |
| 119 | // Parameters |
| 120 | // |
| 121 | SetupCliArgs(); |
| 122 | std::string error; |
| 123 | if (!gArgs.ParseParameters(argc, argv, error)) { |
| 124 | fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str()); |
| 125 | return EXIT_FAILURE; |
| 126 | } |
| 127 | if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { |
| 128 | std::string strUsage = PACKAGE_NAME " RPC client version " + FormatFullVersion() + "\n"; |
| 129 | if (!gArgs.IsArgSet("-version")) { |
| 130 | strUsage += "\n" |
| 131 | "Usage: bgold-cli [options] <command> [params] Send command to " PACKAGE_NAME "\n" |
| 132 | "or: bgold-cli [options] -named <command> [name=value]... Send command to " PACKAGE_NAME " (with named arguments)\n" |
| 133 | "or: bgold-cli [options] help List commands\n" |
| 134 | "or: bgold-cli [options] help <command> Get help for a command\n"; |
| 135 | strUsage += "\n" + gArgs.GetHelpMessage(); |
| 136 | } |
| 137 | |
| 138 | fprintf(stdout, "%s", strUsage.c_str()); |
| 139 | if (argc < 2) { |
| 140 | fprintf(stderr, "Error: too few parameters\n"); |
| 141 | return EXIT_FAILURE; |
| 142 | } |
| 143 | return EXIT_SUCCESS; |
| 144 | } |
| 145 | if (!fs::is_directory(GetDataDir(false))) { |
| 146 | fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str()); |
| 147 | return EXIT_FAILURE; |
| 148 | } |
| 149 | if (!gArgs.ReadConfigFiles(error, true)) { |
| 150 | fprintf(stderr, "Error reading configuration file: %s\n", error.c_str()); |
| 151 | return EXIT_FAILURE; |
| 152 | } |
| 153 | // Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause) |
| 154 | try { |
| 155 | SelectBaseParams(gArgs.GetChainName()); |
| 156 | } catch (const std::exception& e) { |
| 157 | fprintf(stderr, "Error: %s\n", e.what()); |
| 158 | return EXIT_FAILURE; |
| 159 | } |
| 160 | if (gArgs.GetBoolArg("-rpcssl", false)) |
| 161 | { |
| 162 | fprintf(stderr, "Error: SSL mode for RPC (-rpcssl) is no longer supported.\n"); |
| 163 | return EXIT_FAILURE; |
| 164 | } |
| 165 | bool convert_addr_to_btg = gArgs.IsArgSet("-convertaddrtobtg"); |
| 166 | bool convert_addr_to_btc = gArgs.IsArgSet("-convertaddrtobtc"); |
| 167 | if (convert_addr_to_btg || convert_addr_to_btc) { |
| 168 | std::string chain_name = gArgs.GetChainName(); |
| 169 | if (chain_name != CBaseChainParams::MAIN) { |
| 170 | fprintf(stderr, "Error: Only the address format of mainnet can be converted. You selected: %s\n", |
| 171 | chain_name.c_str()); |
| 172 | return EXIT_FAILURE; |
| 173 | } |
no test coverage detected