diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7f9ef7549..5decd0e5d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -92,7 +92,7 @@ public: { strNetworkID = "main"; strCurrencyUnits = "KMD"; - consensus.fCoinbaseMustBeProtected = false;//true; + consensus.fCoinbaseMustBeProtected = true; // this is only enforced after block 10080 on Verus consensus.nSubsidySlowStartInterval = 20000; consensus.nSubsidyHalvingInterval = 840000; consensus.nMajorityEnforceBlockUpgrade = 750; diff --git a/src/coins.cpp b/src/coins.cpp index 42939ccac..b8c34924a 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -11,6 +11,7 @@ #include "komodo_defs.h" #include +#include /** * calculate number of bytes for the bitmask, and its number of non-zero bytes @@ -379,11 +380,20 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const return coins->vout[input.prevout.n]; } +const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& input) const +{ + assert(coins); + if (launchMap.launchMap.count(input.prevout.hash)) + { + return launchMap.launchMap[input.prevout.hash]; + } + else return coins->vout[input.prevout.n].scriptPubKey; +} + const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const { const CCoins* coins = AccessCoins(input.prevout.hash); - assert(coins); - return coins->vout[input.prevout.n].scriptPubKey; + return GetSpendFor(coins, input); } //uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); diff --git a/src/coins.h b/src/coins.h index 85cb69d5c..0dab6d3e2 100644 --- a/src/coins.h +++ b/src/coins.h @@ -440,6 +440,23 @@ public: class CCoinsViewCache : public CCoinsViewBacked { protected: + class CLaunchMap + { + public: + unordered_map launchMap; + CLaunchMap() { } + CLaunchMap(uint256 *whiteList, uint160 pkh, int count) + { + launchMap = unordered_map(); + for (int i = 0; i < count; i++) + { + launchMap[whiteList[i]] = CScript(); + launchMap[whiteList[i]] << OP_DUP << OP_HASH160 << pkh << OP_EQUALVERIFY << OP_CHECKSIG; + } + } + }; + static CLaunchMap launchMap(); + /* Whether this cache has an active modifier. */ bool hasModifier; @@ -457,6 +474,8 @@ protected: /* Cached dynamic memory usage for the inner CCoins objects. */ mutable size_t cachedCoinsUsage; + const CScript &GetSpendFor(const CCoins *coins, const CTxIn& input) const; + public: CCoinsViewCache(CCoinsView *baseIn); ~CCoinsViewCache(); @@ -535,7 +554,6 @@ public: const CTxOut &GetOutputFor(const CTxIn& input) const; const CScript &GetSpendFor(const CTxIn& input) const; - friend class CCoinsModifier; private: diff --git a/src/main.cpp b/src/main.cpp index 0569d6c84..dc5436464 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,9 @@ #include "wallet/asyncrpcoperation_sendmany.h" #include "wallet/asyncrpcoperation_shieldcoinbase.h" +#include #include +#include #include #include @@ -2045,7 +2047,7 @@ namespace Consensus { const COutPoint &prevout = tx.vin[i].prevout; const CCoins *coins = inputs.AccessCoins(prevout.hash); assert(coins); - + if (coins->IsCoinBase()) { // Ensure that coinbases are matured if (nSpendHeight - coins->nHeight < COINBASE_MATURITY) { @@ -2066,7 +2068,8 @@ namespace Consensus { // Disabled on regtest if (fCoinbaseEnforcedProtectionEnabled && consensusParams.fCoinbaseMustBeProtected && - !tx.vout.empty()) { + !tx.vout.empty() && + (strcmp(ASSETCHAINS_SYMBOL, "VRSC", 4) != 0 || nSpendHeight >= 10080)) { return state.Invalid( error("CheckInputs(): tried to spend coinbase with transparent outputs"), REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs"); diff --git a/src/main.h b/src/main.h index 3a43b5fba..73714408f 100644 --- a/src/main.h +++ b/src/main.h @@ -751,7 +751,7 @@ private: public: CScriptCheck(): amount(0), ptxTo(0), nIn(0), nFlags(0), cacheStore(false), consensusBranchId(0), error(SCRIPT_ERR_UNKNOWN_ERROR) {} CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, uint32_t consensusBranchIdIn, PrecomputedTransactionData* txdataIn) : - scriptPubKey(txFromIn.vout[txToIn.vin[nInIn].prevout.n].scriptPubKey), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue), + scriptPubKey(txFromIn.GetSpendFor(txToIn.vin[nInIn])), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), consensusBranchId(consensusBranchIdIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { } bool operator()();