diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 84e4c0846..367355419 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -257,14 +257,18 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) event_base_dispatch(base.get()); if (response.status == 0) { + // Report the port we ACTUALLY dialled. ASSETCHAINS_RPCPORT is a separate global that is + // initialised to the mainnet default at the top of this file and never assigned here, so + // using it made every failure claim port 21769 no matter what -rpcport was given -- which + // reads as "your -rpcport was ignored" and sends you chasing a config bug that isn't there. throw CConnectionFailed(strprintf("couldn't connect to server at port %d : %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", - ASSETCHAINS_RPCPORT, http_errorstring(response.error), response.error)); + port, http_errorstring(response.error), response.error)); } else if (response.status == HTTP_UNAUTHORIZED) { throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)"); } else if (response.status >= 400 && response.status != HTTP_BAD_REQUEST && response.status != HTTP_NOT_FOUND && response.status != HTTP_INTERNAL_SERVER_ERROR) { throw std::runtime_error(strprintf("server returned HTTP error %d", response.status)); } else if (response.body.empty()) { - throw std::runtime_error(strprintf("no response from server at port %d", ASSETCHAINS_RPCPORT )); + throw std::runtime_error(strprintf("no response from server at port %d", port)); } // Parse reply