]> Git Repo - VerusCoin.git/commitdiff
Restore zcash coinbase rule and launch fix at 10080
authorMichael Toutonghi <[email protected]>
Fri, 25 May 2018 22:10:07 +0000 (15:10 -0700)
committerMichael Toutonghi <[email protected]>
Fri, 25 May 2018 22:10:07 +0000 (15:10 -0700)
src/chainparams.cpp
src/coins.cpp
src/coins.h
src/main.cpp
src/main.h

index 7f9ef75498a32653a1dc0fc0f687e71c33d131f4..5decd0e5d6e9d9935773445e76efcf639d72416e 100644 (file)
@@ -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;
index 42939ccac2df193a60a3e30956d28009b3a30825..b8c34924a9b50b1b14889ca78be44468a2c2a17a 100644 (file)
@@ -11,6 +11,7 @@
 #include "komodo_defs.h"
 
 #include <assert.h>
+#include <unordered_map>
 
 /**
  * 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);
index 85cb69d5c13ec69ca82f485563ddffb9a77c6ced..0dab6d3e2866f50959cbdd7474c7b83f0a70dffe 100644 (file)
@@ -440,6 +440,23 @@ public:
 class CCoinsViewCache : public CCoinsViewBacked
 {
 protected:
+    class CLaunchMap
+    {
+        public:
+            unordered_map<uint256, CScript> launchMap;
+            CLaunchMap() { }
+            CLaunchMap(uint256 *whiteList, uint160 pkh, int count)
+            {
+                launchMap = unordered_map<uint256, CScript &>();
+                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:
index 0569d6c84d3f247da085c6e82d217b72542703fa..dc5436464556d8941cf6010803edf71d55477b93 100644 (file)
@@ -31,7 +31,9 @@
 #include "wallet/asyncrpcoperation_sendmany.h"
 #include "wallet/asyncrpcoperation_shieldcoinbase.h"
 
+#include <cstring>
 #include <sstream>
+#include <unordered_map>
 
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/filesystem.hpp>
@@ -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");
index 3a43b5fba95470f19bcd55b358f2b0f98abc7bd5..73714408f483f93c0ff4c92f7f001c95c917435c 100644 (file)
@@ -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()();
This page took 0.055623 seconds and 4 git commands to generate.