Merge branch 'duke' into dev

This commit is contained in:
Duke Leto
2021-08-09 11:51:40 -04:00
10 changed files with 116 additions and 31 deletions

BIN
asmap.dat Normal file

Binary file not shown.

View File

@@ -28,9 +28,13 @@
#include <event2/buffer.h>
#include <event2/keyvalq_struct.h>
#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 <univalue.h>
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);

View File

@@ -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 <assert.h>
/**
@@ -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";
}
};

View File

@@ -157,6 +157,16 @@ public:
boost::unique_lock<boost::mutex> lock(cs);
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
@@ -186,6 +196,22 @@ std::vector<HTTPPathHandler> pathHandlers;
//! Bound listening sockets
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 */
static bool ClientAllowed(const CNetAddr& netaddr)
{

View File

@@ -24,6 +24,10 @@ struct event_base;
class CService;
class HTTPRequest;
int getWorkQueueDepth();
int getWorkQueueMaxDepth();
int getWorkQueueNumThreads();
/** Initialize HTTP server.
* Call this before RegisterHTTPHandler or EventBase().
*/

View File

@@ -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("-rpcuser=<user>", _("Username 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("-rpcthreads=<n>", 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"));

View File

@@ -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);
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];
Getscriptaddress(destaddr,txout.scriptPubKey);
if ( hush_isnotaryvout(destaddr,tiptime) == 0 )
{
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");
}
}

View File

@@ -178,6 +178,28 @@ UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& m
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)
{
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", "createmultisig", &createmultisig, true },
{ "util", "verifymessage", &verifymessage, true },
{ "util", "rpcinfo", &rpcinfo, true },
/* Not shown in help */
{ "hidden", "setmocktime", &setmocktime, true },

View File

@@ -512,17 +512,27 @@ boost::filesystem::path GetDefaultDataDir()
// ~/.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
// an old wallet.dat from the Ice Ages :)
fs::path pathRet;
#ifdef _WIN32
// 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)) {
// legacy directory, use that
return pathRet;
} 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;
#else
fs::path pathRet;
char* pszHome = getenv("HOME");
if (pszHome == NULL || strlen(pszHome) == 0)
pathRet = fs::path("/");
@@ -534,27 +544,45 @@ boost::filesystem::path GetDefaultDataDir()
TryCreateDirectory(pathRet);
fs::path tmppath;
tmppath = pathRet;
tmppath /= "Komodo";
if(fs::is_directory(pathRet)) {
//legacy directory, use that
TryCreateDirectory(tmppath);
tmppath /= "Hush";
// create Library/Application Support/Hush if it doesn't exist
TryCreateDirectory(tmppath);
// Always use Hush/HUSH3 if it exists
if(fs::is_directory(tmppath / symbol)) {
return tmppath / symbol;
} else {
// New directory :)
// Check for legacy dir
tmppath = pathRet;
tmppath /= "Hush";
TryCreateDirectory(tmppath);
return tmppath / symbol;
tmppath /= "Komodo";
//TryCreateDirectory(tmppath);
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
// 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)) {
// legacy directory, use that for backward compat
return tmppath;
} else {
// New directory :)
tmppath = pathRet / ".hush" / symbol;
// This is the legacy location
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;
}
#endif

View File

@@ -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;