Browse Source

Reorganize params, add "-defaultzaddr", "-privatechange", prepare for their use

pull/283/head
miketout 4 years ago
parent
commit
6e62f83702
  1. 2
      src/chainparams.cpp
  2. 2
      src/cheatcatcher.cpp
  3. 2
      src/cheatcatcher.h
  4. 29
      src/init.cpp
  5. 2
      src/key_io.cpp
  6. 4
      src/key_io.h
  7. 2
      src/komodo-tx.cpp
  8. 2
      src/komodo_globals.h
  9. 2
      src/komodo_utils.h
  10. 32
      src/miner.cpp
  11. 2
      src/net.cpp
  12. 2
      src/wallet-utility.cpp
  13. 27
      src/wallet/wallet.cpp
  14. 1
      src/wallet/wallet.h

2
src/chainparams.cpp

@ -82,7 +82,7 @@ extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAIN_INIT, ASSETCHAINS_MAGIC, ASSETCHAINS_ALGO, ASSETCHAINS_EQUIHASH, ASSETCHAINS_VERUSHASH;
extern int32_t VERUS_BLOCK_POSUNITS, ASSETCHAINS_LWMAPOS, ASSETCHAINS_SAPLING, ASSETCHAINS_OVERWINTER;
extern int64_t ASSETCHAINS_SUPPLY;
extern std::string VERUS_CHEATCATCHER;
extern std::string VERUS_DEFAULT_ZADDR;
const arith_uint256 maxUint = UintToArith256(uint256S("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));

2
src/cheatcatcher.cpp

@ -19,7 +19,7 @@
using namespace std;
CCheatList cheatList;
boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
boost::optional<libzcash::SaplingPaymentAddress> defaultSaplingDest;
uint32_t CCheatList::Prune(uint32_t height)
{

2
src/cheatcatcher.h

@ -77,6 +77,6 @@ class CCheatList
extern CCheatList cheatList;
extern boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
extern boost::optional<libzcash::SaplingPaymentAddress> defaultSaplingDest;
#endif

29
src/init.cpp

@ -77,7 +77,7 @@ using namespace std;
extern void ThreadSendAlert();
extern int32_t KOMODO_LOADINGBLOCKS;
extern bool VERUS_MINTBLOCKS;
extern std::string VERUS_CHEATCATCHER;
extern std::string VERUS_DEFAULT_ZADDR;
ZCJoinSplit* pzcashParams = NULL;
@ -1233,12 +1233,30 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
}
}
// get default IDs and addresses
auto defaultIDDest = DecodeDestination(GetArg("-defaultid", ""));
VERUS_DEFAULTID = defaultIDDest.which() == COptCCParams::ADDRTYPE_ID ? CIdentityID(GetDestinationID(defaultIDDest)) : CIdentityID();
VERUS_DEFAULT_ZADDR = GetArg("-cheatcatcher", "");
VERUS_DEFAULT_ZADDR = GetArg("-defaultzaddr", VERUS_DEFAULT_ZADDR);
// if we are supposed to catch stake cheaters, there must be a valid sapling parameter, we need it at
// initialization, and this is the first time we can get it. store the Sapling address here
extern boost::optional<libzcash::SaplingPaymentAddress> defaultSaplingDest;
libzcash::PaymentAddress addr = DecodePaymentAddress(VERUS_DEFAULT_ZADDR);
if (VERUS_DEFAULT_ZADDR.size() > 0 && IsValidPaymentAddress(addr))
{
try
{
defaultSaplingDest = boost::get<libzcash::SaplingPaymentAddress>(addr);
}
catch (...)
{
}
}
VERUS_PRIVATECHANGE = GetBoolArg("-privatechange", defaultSaplingDest == boost::none);
// Sanity check
if (!InitSanityCheck())
return InitError(_("Initialization sanity check failed. Komodo is shutting down."));
return InitError(_("Initialization sanity check failed. Verus is shutting down."));
std::string strDataDir = GetDataDir().string();
#ifdef ENABLE_WALLET
@ -1254,9 +1272,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
try {
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
if (!lock.try_lock())
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Komodo is probably already running."), strDataDir));
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Verus is probably already running."), strDataDir));
} catch(const boost::interprocess::interprocess_exception& e) {
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Komodo is probably already running.") + " %s.", strDataDir, e.what()));
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Verus is probably already running.") + " %s.", strDataDir, e.what()));
}
#ifndef _WIN32
@ -1265,7 +1283,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (GetBoolArg("-shrinkdebugfile", !fDebug))
ShrinkDebugFile();
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
LogPrintf("Komodo version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
LogPrintf("Verus version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
if (fPrintToDebugLog)
OpenDebugLog();
@ -2008,7 +2026,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
StartNode(threadGroup, scheduler);
VERUS_CHEATCATCHER = GetArg("-cheatcatcher", "");
bool gen = GetBoolArg("-gen", false);
#ifdef ENABLE_MINING

2
src/key_io.cpp

@ -25,6 +25,8 @@ extern uint160 VERUS_CHAINID;
extern std::string VERUS_CHAINNAME;
CIdentityID VERUS_DEFAULTID;
bool VERUS_PRIVATECHANGE;
std::string VERUS_DEFAULT_ZADDR;
namespace
{

4
src/key_io.h

@ -15,6 +15,10 @@
#include <string>
extern CIdentityID VERUS_DEFAULTID;
extern bool VERUS_PRIVATECHANGE;
extern std::string VERUS_DEFAULT_ZADDR;
std::string TrimLeading(const std::string &Name, unsigned char ch);
std::string TrimTrailing(const std::string &Name, unsigned char ch);
std::string TrimSpaces(const std::string &Name);

2
src/komodo-tx.cpp

@ -45,7 +45,7 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256
static bool fCreateBlank;
static std::map<std::string,UniValue> registers;
static const int CONTINUE_EXECUTION=-1;
boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
boost::optional<libzcash::SaplingPaymentAddress> defaultSaplingDest;
//
// This function returns either one of EXIT_ codes when it's expected to stop the process or

2
src/komodo_globals.h

@ -46,7 +46,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
int32_t KOMODO_MININGTHREADS = 0,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
std::string VERUS_CHEATCATCHER, NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
bool VERUS_MINTBLOCKS;

2
src/komodo_utils.h

@ -1694,7 +1694,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
}
extern int64_t MAX_MONEY;
extern std::string VERUS_CHEATCATCHER;
extern std::string VERUS_DEFAULT_ZADDR;
bool SetThisChain(const UniValue &chainDefinition);
const uint256 &CurrencyDefHash();

32
src/miner.cpp

@ -594,7 +594,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& _
CBlockIndex *ppast;
CTransaction cb;
int cheatHeight = nHeight - COINBASE_MATURITY < 1 ? 1 : nHeight - COINBASE_MATURITY;
if (cheatCatcher &&
if (defaultSaplingDest &&
sapling && chainActive.Height() > 100 &&
(ppast = chainActive[cheatHeight]) &&
ppast->IsVerusPOSBlock() &&
@ -650,7 +650,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& _
ovk = ovkForShieldingFromTaddr(seed);
// send everything to Sapling address
tb.SendChangeTo(cheatCatcher.value(), ovk);
tb.SendChangeTo(defaultSaplingDest.value(), ovk);
tb.AddOpRet(mtx.vout[mtx.vout.size() - 1].scriptPubKey);
@ -3426,39 +3426,23 @@ void static BitcoinMiner(CWallet *pwallet)
return;
}
// if we are supposed to catch stake cheaters, there must be a valid sapling parameter, we need it at
// initialization, and this is the first time we can get it. store the Sapling address here
extern boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
extern std::string VERUS_CHEATCATCHER;
libzcash::PaymentAddress addr = DecodePaymentAddress(VERUS_CHEATCATCHER);
if (VERUS_CHEATCATCHER.size() > 0 && IsValidPaymentAddress(addr))
{
try
{
cheatCatcher = boost::get<libzcash::SaplingPaymentAddress>(addr);
}
catch (...)
{
}
}
VERUS_MINTBLOCKS = (VERUS_MINTBLOCKS && ASSETCHAINS_LWMAPOS != 0);
if (fGenerate == true || VERUS_MINTBLOCKS)
{
mapArgs["-gen"] = "1";
if (VERUS_CHEATCATCHER.size() > 0)
if (VERUS_DEFAULT_ZADDR.size() > 0)
{
if (cheatCatcher == boost::none)
if (defaultSaplingDest == boost::none)
{
LogPrintf("ERROR: -cheatcatcher parameter is invalid Sapling payment address\n");
fprintf(stderr, "-cheatcatcher parameter is invalid Sapling payment address\n");
LogPrintf("ERROR: -defaultzaddr parameter is invalid Sapling payment address\n");
fprintf(stderr, "-defaultzaddr parameter is invalid Sapling payment address\n");
}
else
{
LogPrintf("StakeGuard searching for double stakes on %s\n", VERUS_CHEATCATCHER.c_str());
fprintf(stderr, "StakeGuard searching for double stakes on %s\n", VERUS_CHEATCATCHER.c_str());
LogPrintf("StakeGuard searching for double stakes on %s\n", VERUS_DEFAULT_ZADDR.c_str());
fprintf(stderr, "StakeGuard searching for double stakes on %s\n", VERUS_DEFAULT_ZADDR.c_str());
}
}
}

2
src/net.cpp

@ -443,6 +443,8 @@ void CNode::PushVersion()
else
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
//printf("net send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString().c_str(), id);
if (PROTOCOL_VERSION >= MIN_PBAAS_VERSION)
{
CKeyID nodePaymentAddress;

2
src/wallet-utility.cpp

@ -27,8 +27,6 @@ int32_t ASSETCHAINS_LWMAPOS = 0;
int32_t VERUS_BLOCK_POSUNITS = 1000;
int32_t ASSETCHAINS_OVERWINTER = 227520;
int32_t ASSETCHAINS_SAPLING = 227520;
boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
std::string VERUS_CHEATCATCHER = "";
unsigned int MAX_BLOCK_SIGOPS = 20000;

27
src/wallet/wallet.cpp

@ -1677,7 +1677,8 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
return false;
}
uint32_t solutionVersion = CConstVerusSolutionVector::activationHeight.ActiveVersion(nHeight);
uint32_t solutionVersion = CConstVerusSolutionVector::GetVersionByHeight(nHeight);
bool extendedStake = solutionVersion >= CActivationHeight::ACTIVATE_EXTENDEDSTAKE;
// we get these sources of entropy to prove all sources in the header
int posHeight = -1, powHeight = -1, altHeight = -1;
@ -1685,7 +1686,7 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
{
LOCK(cs_main);
pastHash = chainActive.GetVerusEntropyHash(nHeight, &posHeight, &powHeight, &altHeight);
if (altHeight == -1 && (powHeight == -1 || posHeight == -1))
if (extendedStake && (altHeight == -1 && (powHeight == -1 || posHeight == -1)))
{
printf("Error retrieving entropy hash at height %d, posHeight: %d, powHeight: %d, altHeight: %d\n", nHeight, posHeight, powHeight, altHeight);
LogPrintf("Error retrieving entropy hash at height %d, posHeight: %d, powHeight: %d, altHeight: %d\n", nHeight, posHeight, powHeight, altHeight);
@ -1693,10 +1694,25 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
}
}
int secondBlockHeight = altHeight != -1 ? altHeight : (posHeight > powHeight ? powHeight : posHeight);
// secondBlockHeight is either less than first or -1 if there isn't one
int secondBlockHeight = altHeight != -1 ?
altHeight :
posHeight == -1 ?
posHeight :
powHeight == -1 ?
powHeight :
(posHeight > powHeight ?
powHeight :
posHeight);
int proveBlockHeight = posHeight > secondBlockHeight ? posHeight : powHeight;
if (proveBlockHeight != -1)
if (proveBlockHeight == -1)
{
printf("No block suitable for proof for height %d, posHeight: %d, powHeight: %d, altHeight: %d\n", nHeight, posHeight, powHeight, altHeight);
LogPrintf("No block suitable for proof for height %d, posHeight: %d, powHeight: %d, altHeight: %d\n", nHeight, posHeight, powHeight, altHeight);
}
else
{
CPOSNonce curNonce;
uint32_t srcIndex;
@ -1705,7 +1721,6 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
CMutableTransaction checkStakeTx = CreateNewContextualCMutableTransaction(consensusParams, nHeight);
std::vector<CTxDestination> addressRet;
int nRequiredRet;
bool extendedStake = CConstVerusSolutionVector::GetVersionByHeight(nHeight) >= CActivationHeight::ACTIVATE_EXTENDEDSTAKE;
BOOST_FOREACH(COutput &txout, vecOutputs)
{
@ -1752,7 +1767,7 @@ bool CWallet::VerusSelectStakeOutput(CBlock *pBlock, arith_uint256 &hashResult,
voutNum = pwinner->i;
pBlock->nNonce = curNonce;
if (solutionVersion >= CActivationHeight::ACTIVATE_PBAAS)
if (solutionVersion >= CActivationHeight::ACTIVATE_EXTENDEDSTAKE)
{
CDataStream headerStream = CDataStream(SER_NETWORK, PROTOCOL_VERSION);

1
src/wallet/wallet.h

@ -47,7 +47,6 @@ extern unsigned int nTxConfirmTarget;
extern bool bSpendZeroConfChange;
extern bool fSendFreeTransactions;
extern bool fPayAtLeastCustomFee;
extern CIdentityID VERUS_DEFAULTID;
//! -paytxfee default
static const CAmount DEFAULT_TRANSACTION_FEE = 0.0001 * COIN;

Loading…
Cancel
Save