Parse UniValue error to update the message to print to std::cerr and the code to return. */
| 1331 | |
| 1332 | /** Parse UniValue error to update the message to print to std::cerr and the code to return. */ |
| 1333 | static void ParseError(const UniValue& error, std::string& strPrint, int& nRet) |
| 1334 | { |
| 1335 | if (error.isObject()) { |
| 1336 | const UniValue& err_code = error.find_value("code"); |
| 1337 | const UniValue& err_msg = error.find_value("message"); |
| 1338 | if (!err_code.isNull()) { |
| 1339 | strPrint = "error code: " + err_code.getValStr() + "\n"; |
| 1340 | } |
| 1341 | if (err_msg.isStr()) { |
| 1342 | strPrint += ("error message:\n" + err_msg.get_str()); |
| 1343 | } |
| 1344 | if (err_code.isNum() && err_code.getInt<int>() == RPC_WALLET_NOT_SPECIFIED) { |
| 1345 | strPrint += " Or for the CLI, specify the \"-rpcwallet=<walletname>\" option before the command"; |
| 1346 | strPrint += " (run \"bitcoin-cli -h\" for help or \"bitcoin-cli listwallets\" to see which wallets are currently loaded)."; |
| 1347 | } |
| 1348 | } else { |
| 1349 | strPrint = "error: " + error.write(); |
| 1350 | } |
| 1351 | nRet = abs(error["code"].getInt<int>()); |
| 1352 | } |
| 1353 | |
| 1354 | /** |
| 1355 | * GetWalletBalances calls listwallets; if more than one wallet is loaded, it then |