From 89a4226965d42f6a297fadef3bfba340701b9014 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 5 Aug 2021 15:55:34 -0400 Subject: [PATCH] Report rpc port in error when unable to connect --- src/bitcoin-cli.cpp | 18 ++++++++++++------ src/chainparamsbase.cpp | 8 +++----- src/init.cpp | 4 ++-- src/wallet-utility.cpp | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index b804e26bc..e9623f9bd 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -28,9 +28,13 @@ #include #include #include "support/events.h" + +uint16_t ASSETCHAINS_RPCPORT = 18031; uint16_t BITCOIND_RPCPORT = 18031; char SMART_CHAIN_SYMBOL[65]; +extern uint16_t ASSETCHAINS_RPCPORT; + #include using namespace std; @@ -252,14 +256,16 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) event_base_dispatch(base.get()); - if (response.status == 0) - throw CConnectionFailed(strprintf("couldn't connect to server: %s (code %d)\n(make sure server is running and you are connecting to the correct RPC port)", http_errorstring(response.error), response.error)); - else if (response.status == HTTP_UNAUTHORIZED) + if (response.status == 0) { + 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)); + } 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) + } 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("no response from server"); + } else if (response.body.empty()) { + throw std::runtime_error(strprintf("no response from server at port %d", ASSETCHAINS_RPCPORT )); + } // Parse reply UniValue valReply(UniValue::VSTR); diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 2c15f8ffc..1f0eb7740 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -1,8 +1,8 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2016-2021 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -19,9 +19,7 @@ ******************************************************************************/ #include "chainparamsbase.h" - #include "util.h" - #include /** @@ -32,7 +30,7 @@ class CBaseMainParams : public CBaseChainParams public: CBaseMainParams() { - nRPCPort = 7771; + nRPCPort = 18031; } }; static CBaseMainParams mainParams; @@ -45,7 +43,7 @@ class CBaseTestNetParams : public CBaseChainParams public: CBaseTestNetParams() { - nRPCPort = 17771; + nRPCPort = 28031; strDataDir = "testnet3"; } }; diff --git a/src/init.cpp b/src/init.cpp index 3e699a7cf..faa1a9f5f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -568,7 +568,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-rpcbind=", _("Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)")); strUsage += HelpMessageOpt("-rpcuser=", _("Username for JSON-RPC connections")); strUsage += HelpMessageOpt("-rpcpassword=", _("Password for JSON-RPC connections")); - strUsage += HelpMessageOpt("-rpcport=", strprintf(_("Listen for JSON-RPC connections on (default: %u or testnet: %u)"), 7771, 17771)); + strUsage += HelpMessageOpt("-rpcport=", strprintf(_("Listen for JSON-RPC connections on (default: %u or testnet: %u)"), ASSETCHAINS_RPCPORT, 10000 + ASSETCHAINS_RPCPORT)); strUsage += HelpMessageOpt("-rpcallowip=", _("Allow JSON-RPC connections from specified source. Valid for are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times")); strUsage += HelpMessageOpt("-rpcthreads=", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS)); if (showDebug) { @@ -583,7 +583,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600)); } strUsage += HelpMessageGroup(_("Hush Smart Chain options:")); - strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash")); + strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash (200,9)")); strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60")); strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0")); strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration")); diff --git a/src/wallet-utility.cpp b/src/wallet-utility.cpp index 32dad9c42..a82dfa3b7 100644 --- a/src/wallet-utility.cpp +++ b/src/wallet-utility.cpp @@ -13,7 +13,7 @@ char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN]; int64_t MAX_MONEY = 200000000 * 100000000LL; uint64_t ASSETCHAINS_SUPPLY; -uint16_t BITCOIND_RPCPORT = 7771; +uint16_t BITCOIND_RPCPORT = 18031; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC; uint32_t ASSETCHAINS_MAGIC = 2387029918;