]> Git Repo - VerusCoin.git/commitdiff
Smart transaction staking fixes
authormiketout <[email protected]>
Sat, 6 Jun 2020 20:24:04 +0000 (13:24 -0700)
committermiketout <[email protected]>
Sat, 6 Jun 2020 20:24:04 +0000 (13:24 -0700)
src/cc/StakeGuard.cpp
src/miner.cpp

index 6aabc460528ac048dc8364874c29cf44ca04fb08..3154073a90f39df6fecc27f66e666f7412222da1 100644 (file)
@@ -165,20 +165,25 @@ bool ValidateStakeTransaction(const CTransaction &stakeTx, CStakeParams &stakePa
             if (it != mapBlockIndex.end() && (pindex = it->second) != NULL && chainActive.Contains(pindex))
             {
                 std::vector<std::vector<unsigned char>> vAddr = std::vector<std::vector<unsigned char>>();
+                bool extendedStake = CConstVerusSolutionVector::GetVersionByHeight(stakeParams.blkHeight) >= CActivationHeight::ACTIVATE_EXTENDEDSTAKE;
+                COptCCParams p;
 
                 if (stakeParams.srcHeight == pindex->GetHeight() && 
                     (stakeParams.blkHeight - stakeParams.srcHeight >= VERUS_MIN_STAKEAGE) &&
-                    Solver(srcTx.vout[stakeTx.vin[0].prevout.n].scriptPubKey, txType, vAddr))
+                    ((srcTx.vout[stakeTx.vin[0].prevout.n].scriptPubKey.IsPayToCryptoCondition(p) &&
+                      extendedStake && 
+                      p.IsValid() &&
+                      srcTx.vout[stakeTx.vin[0].prevout.n].scriptPubKey.IsSpendableOutputType(p)) ||
+                    (!p.IsValid() && Solver(srcTx.vout[stakeTx.vin[0].prevout.n].scriptPubKey, txType, vAddr))))
                 {
-                    bool extendedStake = CConstVerusSolutionVector::GetVersionByHeight(stakeParams.blkHeight) >= CActivationHeight::ACTIVATE_EXTENDEDSTAKE;
-                    if (txType == TX_PUBKEY && !stakeParams.pk.IsValid())
+                    if (!p.IsValid() && txType == TX_PUBKEY && !stakeParams.pk.IsValid())
                     {
                         stakeParams.pk = CPubKey(vAddr[0]);
                     }
                     // once extended stake hits, we only accept extended form of staking
                     if (!(extendedStake && stakeParams.Version() < stakeParams.VERSION_EXTENDED_STAKE) &&
                         !(!extendedStake && stakeParams.Version() >= stakeParams.VERSION_EXTENDED_STAKE) &&
-                        ((extendedStake && txType == TX_CRYPTOCONDITION) || (txType == TX_PUBKEY) || (txType == TX_PUBKEYHASH && (extendedStake || stakeParams.pk.IsFullyValid()))))
+                        ((extendedStake && p.IsValid()) || (txType == TX_PUBKEY) || (txType == TX_PUBKEYHASH && (extendedStake || stakeParams.pk.IsFullyValid()))))
                     {
                         auto consensusBranchId = CurrentEpochBranchId(stakeParams.blkHeight, Params().GetConsensus());
 
index 3efaf4710b62be1b7f310feaecc9704b86a97e40..fbf2fc37ba60fe76d3bc65d35b287c8c0e4b2595 100644 (file)
@@ -854,7 +854,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& _
                     return NULL;
                 }
                 COptCCParams optP;
-                if (!coinbaseTx.vout.back().scriptPubKey.IsPayToCryptoCondition(optP) || !p.IsValid())
+                if (!coinbaseTx.vout.back().scriptPubKey.IsPayToCryptoCondition(optP) || !optP.IsValid())
                 {
                     MakeGuardedOutput(1, p.pk, stakeTx, coinbaseTx.vout.back());
                     LogPrintf("%s: created invalid staking coinbase\n", __func__);
This page took 0.036834 seconds and 4 git commands to generate.