Merge branch 'duke' into dev
This commit is contained in:
@@ -28,9 +28,13 @@
|
|||||||
#include <event2/buffer.h>
|
#include <event2/buffer.h>
|
||||||
#include <event2/keyvalq_struct.h>
|
#include <event2/keyvalq_struct.h>
|
||||||
#include "support/events.h"
|
#include "support/events.h"
|
||||||
|
|
||||||
|
uint16_t ASSETCHAINS_RPCPORT = 18031;
|
||||||
uint16_t BITCOIND_RPCPORT = 18031;
|
uint16_t BITCOIND_RPCPORT = 18031;
|
||||||
char SMART_CHAIN_SYMBOL[65];
|
char SMART_CHAIN_SYMBOL[65];
|
||||||
|
|
||||||
|
extern uint16_t ASSETCHAINS_RPCPORT;
|
||||||
|
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -252,14 +256,16 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params)
|
|||||||
|
|
||||||
event_base_dispatch(base.get());
|
event_base_dispatch(base.get());
|
||||||
|
|
||||||
if (response.status == 0)
|
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));
|
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)",
|
||||||
else if (response.status == HTTP_UNAUTHORIZED)
|
ASSETCHAINS_RPCPORT, http_errorstring(response.error), response.error));
|
||||||
|
} else if (response.status == HTTP_UNAUTHORIZED) {
|
||||||
throw std::runtime_error("incorrect rpcuser or rpcpassword (authorization failed)");
|
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));
|
throw std::runtime_error(strprintf("server returned HTTP error %d", response.status));
|
||||||
else if (response.body.empty())
|
} else if (response.body.empty()) {
|
||||||
throw std::runtime_error("no response from server");
|
throw std::runtime_error(strprintf("no response from server at port %d", ASSETCHAINS_RPCPORT ));
|
||||||
|
}
|
||||||
|
|
||||||
// Parse reply
|
// Parse reply
|
||||||
UniValue valReply(UniValue::VSTR);
|
UniValue valReply(UniValue::VSTR);
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Copyright (c) 2010 Satoshi Nakamoto
|
// Copyright (c) 2010 Satoshi Nakamoto
|
||||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||||
|
// Copyright (c) 2016-2021 The Hush developers
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright © 2014-2019 The SuperNET Developers. *
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
||||||
* *
|
* *
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "chainparamsbase.h"
|
#include "chainparamsbase.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +30,7 @@ class CBaseMainParams : public CBaseChainParams
|
|||||||
public:
|
public:
|
||||||
CBaseMainParams()
|
CBaseMainParams()
|
||||||
{
|
{
|
||||||
nRPCPort = 7771;
|
nRPCPort = 18031;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static CBaseMainParams mainParams;
|
static CBaseMainParams mainParams;
|
||||||
@@ -45,7 +43,7 @@ class CBaseTestNetParams : public CBaseChainParams
|
|||||||
public:
|
public:
|
||||||
CBaseTestNetParams()
|
CBaseTestNetParams()
|
||||||
{
|
{
|
||||||
nRPCPort = 17771;
|
nRPCPort = 28031;
|
||||||
strDataDir = "testnet3";
|
strDataDir = "testnet3";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -157,6 +157,16 @@ public:
|
|||||||
boost::unique_lock<boost::mutex> lock(cs);
|
boost::unique_lock<boost::mutex> lock(cs);
|
||||||
return queue.size();
|
return queue.size();
|
||||||
}
|
}
|
||||||
|
size_t MaxDepth()
|
||||||
|
{
|
||||||
|
boost::unique_lock<boost::mutex> lock(cs);
|
||||||
|
return maxDepth;
|
||||||
|
}
|
||||||
|
int NumThreads()
|
||||||
|
{
|
||||||
|
boost::unique_lock<boost::mutex> lock(cs);
|
||||||
|
return numThreads;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HTTPPathHandler
|
struct HTTPPathHandler
|
||||||
@@ -186,6 +196,22 @@ std::vector<HTTPPathHandler> pathHandlers;
|
|||||||
//! Bound listening sockets
|
//! Bound listening sockets
|
||||||
std::vector<evhttp_bound_socket *> boundSockets;
|
std::vector<evhttp_bound_socket *> boundSockets;
|
||||||
|
|
||||||
|
|
||||||
|
int getWorkQueueDepth()
|
||||||
|
{
|
||||||
|
return workQueue->Depth();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getWorkQueueMaxDepth()
|
||||||
|
{
|
||||||
|
return workQueue->MaxDepth();
|
||||||
|
}
|
||||||
|
|
||||||
|
int getWorkQueueNumThreads()
|
||||||
|
{
|
||||||
|
return workQueue->NumThreads();
|
||||||
|
}
|
||||||
|
|
||||||
/** Check if a network address is allowed to access the HTTP server */
|
/** Check if a network address is allowed to access the HTTP server */
|
||||||
static bool ClientAllowed(const CNetAddr& netaddr)
|
static bool ClientAllowed(const CNetAddr& netaddr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ struct event_base;
|
|||||||
class CService;
|
class CService;
|
||||||
class HTTPRequest;
|
class HTTPRequest;
|
||||||
|
|
||||||
|
int getWorkQueueDepth();
|
||||||
|
int getWorkQueueMaxDepth();
|
||||||
|
int getWorkQueueNumThreads();
|
||||||
|
|
||||||
/** Initialize HTTP server.
|
/** Initialize HTTP server.
|
||||||
* Call this before RegisterHTTPHandler or EventBase().
|
* Call this before RegisterHTTPHandler or EventBase().
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||||||
strUsage += HelpMessageOpt("-rpcbind=<addr>", _("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("-rpcbind=<addr>", _("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=<user>", _("Username for JSON-RPC connections"));
|
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
|
||||||
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
||||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), 7771, 17771));
|
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), ASSETCHAINS_RPCPORT, 10000 + ASSETCHAINS_RPCPORT));
|
||||||
strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> 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("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> 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=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
|
strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
|
||||||
if (showDebug) {
|
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 += 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 += 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_blocktime", _("Block time in seconds, default is 60"));
|
||||||
strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0"));
|
strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0"));
|
||||||
strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration"));
|
strUsage += HelpMessageOpt("-ac_beam", _("BEAM integration"));
|
||||||
|
|||||||
@@ -1553,12 +1553,12 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio
|
|||||||
//fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase);
|
//fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase);
|
||||||
if (iscoinbase == 0 && txout.nValue > 0)
|
if (iscoinbase == 0 && txout.nValue > 0)
|
||||||
{
|
{
|
||||||
// TODO: if we are upgraded to Sapling, we can allow Sprout sourced funds to sit in a transparent address
|
|
||||||
char destaddr[65];
|
char destaddr[65];
|
||||||
Getscriptaddress(destaddr,txout.scriptPubKey);
|
Getscriptaddress(destaddr,txout.scriptPubKey);
|
||||||
if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
|
if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
|
||||||
{
|
{
|
||||||
invalid_private_taddr = 1;
|
invalid_private_taddr = 1;
|
||||||
|
fprintf(stderr,"%s: invalid taddr %s on private chain!\n", __func__, destaddr);
|
||||||
//return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain");
|
//return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,28 @@ UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& m
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern int getWorkQueueDepth();
|
||||||
|
extern int getWorkQueueMaxDepth();
|
||||||
|
extern int getWorkQueueNumThreads();
|
||||||
|
|
||||||
|
UniValue rpcinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
|
{
|
||||||
|
UniValue result(UniValue::VOBJ);
|
||||||
|
if (fHelp || params.size() != 0) {
|
||||||
|
throw runtime_error(
|
||||||
|
"rpcinfo\n"
|
||||||
|
"Returns an object containing various RPC state info.\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
LOCK(cs_main);
|
||||||
|
int depth = getWorkQueueDepth();
|
||||||
|
|
||||||
|
result.push_back(Pair("work_queue_depth", depth));
|
||||||
|
result.push_back(Pair("work_queue_max_depth", getWorkQueueMaxDepth() ));
|
||||||
|
result.push_back(Pair("work_queue_num_threads", getWorkQueueNumThreads() ));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
|
||||||
{
|
{
|
||||||
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,hushnotarized_height,txid_height;
|
uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height,longestchain,hushnotarized_height,txid_height;
|
||||||
@@ -1556,6 +1578,7 @@ static const CRPCCommand commands[] =
|
|||||||
{ "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */
|
{ "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */
|
||||||
{ "util", "createmultisig", &createmultisig, true },
|
{ "util", "createmultisig", &createmultisig, true },
|
||||||
{ "util", "verifymessage", &verifymessage, true },
|
{ "util", "verifymessage", &verifymessage, true },
|
||||||
|
{ "util", "rpcinfo", &rpcinfo, true },
|
||||||
|
|
||||||
/* Not shown in help */
|
/* Not shown in help */
|
||||||
{ "hidden", "setmocktime", &setmocktime, true },
|
{ "hidden", "setmocktime", &setmocktime, true },
|
||||||
|
|||||||
60
src/util.cpp
60
src/util.cpp
@@ -512,17 +512,27 @@ boost::filesystem::path GetDefaultDataDir()
|
|||||||
// ~/.hush was actually used by the original 1.x version of Hush, but we will
|
// ~/.hush was actually used by the original 1.x version of Hush, but we will
|
||||||
// only make subdirectories inside of it, so we won't be able to overwrite
|
// only make subdirectories inside of it, so we won't be able to overwrite
|
||||||
// an old wallet.dat from the Ice Ages :)
|
// an old wallet.dat from the Ice Ages :)
|
||||||
|
|
||||||
|
fs::path pathRet;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Windows
|
// Windows
|
||||||
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol;
|
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol;
|
||||||
|
// Always use .hush/HUSH3, if it exists (even if .komodo/HUSH3 exists)
|
||||||
if(fs::is_directory(pathRet)) {
|
if(fs::is_directory(pathRet)) {
|
||||||
// legacy directory, use that
|
return pathRet;
|
||||||
} else {
|
} else {
|
||||||
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol;
|
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Komodo" / symbol;
|
||||||
|
if(fs::is_directory(pathRet)) {
|
||||||
|
// existing legacy directory, use that for backward compat
|
||||||
|
return pathRet;
|
||||||
|
} else {
|
||||||
|
// For new clones, use Hush/HUSH3
|
||||||
|
pathRet = GetSpecialFolderPath(CSIDL_APPDATA) / "Hush" / symbol;
|
||||||
|
return pathRet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return pathRet;
|
return pathRet;
|
||||||
#else
|
#else
|
||||||
fs::path pathRet;
|
|
||||||
char* pszHome = getenv("HOME");
|
char* pszHome = getenv("HOME");
|
||||||
if (pszHome == NULL || strlen(pszHome) == 0)
|
if (pszHome == NULL || strlen(pszHome) == 0)
|
||||||
pathRet = fs::path("/");
|
pathRet = fs::path("/");
|
||||||
@@ -534,27 +544,45 @@ boost::filesystem::path GetDefaultDataDir()
|
|||||||
TryCreateDirectory(pathRet);
|
TryCreateDirectory(pathRet);
|
||||||
fs::path tmppath;
|
fs::path tmppath;
|
||||||
tmppath = pathRet;
|
tmppath = pathRet;
|
||||||
tmppath /= "Komodo";
|
tmppath /= "Hush";
|
||||||
if(fs::is_directory(pathRet)) {
|
|
||||||
//legacy directory, use that
|
// create Library/Application Support/Hush if it doesn't exist
|
||||||
TryCreateDirectory(tmppath);
|
TryCreateDirectory(tmppath);
|
||||||
|
|
||||||
|
// Always use Hush/HUSH3 if it exists
|
||||||
|
if(fs::is_directory(tmppath / symbol)) {
|
||||||
return tmppath / symbol;
|
return tmppath / symbol;
|
||||||
} else {
|
} else {
|
||||||
// New directory :)
|
// Check for legacy dir
|
||||||
tmppath = pathRet;
|
tmppath = pathRet;
|
||||||
tmppath /= "Hush";
|
tmppath /= "Komodo";
|
||||||
TryCreateDirectory(tmppath);
|
//TryCreateDirectory(tmppath);
|
||||||
return tmppath / symbol;
|
if(fs::is_directory( tmppath / symbol) {
|
||||||
|
// Found legacy dir, use that
|
||||||
|
return tmppath / symbol;
|
||||||
|
} else {
|
||||||
|
// For new clones, use Hush/HUSH3
|
||||||
|
tmppath = pathRet / "Hush" / HUSH3;
|
||||||
|
}
|
||||||
|
return tmppath;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Unix
|
// Unix
|
||||||
fs::path tmppath = pathRet / ".komodo" / symbol;
|
// New directory :)
|
||||||
|
fs::path tmppath = pathRet / ".hush" / symbol;
|
||||||
|
// Always use .hush/HUSH3, if it exists (even if .komodo/HUSH3 exists)
|
||||||
if(fs::is_directory(tmppath)) {
|
if(fs::is_directory(tmppath)) {
|
||||||
// legacy directory, use that for backward compat
|
|
||||||
return tmppath;
|
return tmppath;
|
||||||
} else {
|
} else {
|
||||||
// New directory :)
|
// This is the legacy location
|
||||||
tmppath = pathRet / ".hush" / symbol;
|
tmppath = pathRet / ".komodo" / symbol;
|
||||||
|
if(fs::is_directory(tmppath)) {
|
||||||
|
// existing legacy directory, use that for backward compat
|
||||||
|
return tmppath;
|
||||||
|
} else {
|
||||||
|
// For new clones, use .hush/HUSH3
|
||||||
|
tmppath = pathRet / ".hush" / symbol;
|
||||||
|
}
|
||||||
return tmppath;
|
return tmppath;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
|
char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN];
|
||||||
int64_t MAX_MONEY = 200000000 * 100000000LL;
|
int64_t MAX_MONEY = 200000000 * 100000000LL;
|
||||||
uint64_t ASSETCHAINS_SUPPLY;
|
uint64_t ASSETCHAINS_SUPPLY;
|
||||||
uint16_t BITCOIND_RPCPORT = 7771;
|
uint16_t BITCOIND_RPCPORT = 18031;
|
||||||
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||||
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
|
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC;
|
||||||
uint32_t ASSETCHAINS_MAGIC = 2387029918;
|
uint32_t ASSETCHAINS_MAGIC = 2387029918;
|
||||||
|
|||||||
Reference in New Issue
Block a user