]> Git Repo - VerusCoin.git/commitdiff
Commit for Michael's testing
authormiketout <[email protected]>
Sun, 7 Jun 2020 21:47:49 +0000 (14:47 -0700)
committermiketout <[email protected]>
Sun, 7 Jun 2020 21:47:49 +0000 (14:47 -0700)
src/init.cpp
src/main.cpp
src/wallet/wallet.cpp

index f72e42718ab06959049a610ccf76bfe5b89a1361..62b0d4788c504cdae0048ed5561ff0489454bcfc 100644 (file)
@@ -1223,8 +1223,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
             CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV2, 1);
             CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV3, 1);
             CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV4, 1);
-            CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV5, 155);
-            CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV6, 1600);
+            CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV5, 1);
+            CConstVerusSolutionVector::activationHeight.SetActivationHeight(CActivationHeight::SOLUTION_VERUSV6, 1);
         }
         else
         {
index ce0d9ca54f68f3e18fe03a697c07c306bcf83177..b5f99befdd06995d10fcfe0b636abb51888a2d2f 100644 (file)
@@ -2057,6 +2057,7 @@ bool AcceptToMemoryPoolInt(CTxMemPool& pool, CValidationState &state, const CTra
         }
         if (!ContextualCheckInputs(tx, state, view, nextBlockHeight, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
         {
+            ContextualCheckInputs(tx, state, view, nextBlockHeight, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId);
             if ( flag != 0 )
                 KOMODO_CONNECTING = -1;
             return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
@@ -4725,7 +4726,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
             pindexIter = pindexIter->pprev;
         }
         nHeight = nTargetHeight;
-        
+
         // Connect new blocks
         BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) {
             if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) {
index 80c8b54e96c1d52c8ffe67c7b1e396dd7f48dd46..f7d0e0badf8fa08cf3e3523cc85bb0f5d0ccd5ef 100644 (file)
@@ -2433,6 +2433,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
 {
     {
         AssertLockHeld(cs_wallet);
+        AssertLockHeld(cs_main);
         uint256 txHash = tx.GetHash();
         bool fExisted = mapWallet.count(txHash) != 0;
         if (fExisted && !fUpdate) return false;
@@ -2446,9 +2447,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
             }
         }
 
-        bool canSign = false;
-        bool isMine = false;
-
         for (auto output : tx.vout)
         {
             bool canSpend = false;
@@ -2456,10 +2454,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
 
             if (output.scriptPubKey.IsPayToCryptoCondition(p) && p.IsValid() && p.version >= p.VERSION_V3)
             {
-                // assert and fix if we find any spot where this wouldn't be held, rather than
-                // creating a deadlock by attempting to take the cs out of order
-                AssertLockHeld(cs_main);
-
                 uint32_t nHeight = 0;
                 if (pblock)
                 {
@@ -2470,7 +2464,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                     }
                     else
                     {
-                        // doesn't seem like this should ever happen
+                        // this should never happen
                         assert(false);
                     }
                 }
@@ -2479,7 +2473,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
 
                 if (p.evalCode == EVAL_IDENTITY_PRIMARY && p.vData.size() && (*(CIdentity *)&identity = CIdentity(p.vData[0])).IsValid())
                 {
-                    identity.txid = tx.GetHash();
+                    identity.txid = txHash;
                     CIdentityMapKey idMapKey = CIdentityMapKey(identity.GetID(), 
                                                                nHeight, 
                                                                1, 
@@ -2492,15 +2486,16 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
 
                     std::pair<CIdentityMapKey, CIdentityMapValue> idHistory;
 
-                    // if we are deleting, current identity is what it was, idHistory is what it will be, if adding, current is what it will be, idHistory is what it was
+                    // if adding, current is what it will be, idHistory is what it was
+                    // if we are deleting, current identity is what it was, idHistory is what it will be
                     std::pair<bool, bool> wasCanSignCanSpend({false, false});
                     std::pair<bool, bool> canSignCanSpend(CheckAuthority(identity));
 
-                    // if it is revoked, consider the recovery authority in the can sign/can spend decision
+                    // if the new identity is revoked, the recovery identity holds can sign/can spend authority
                     if (identity.IsRevoked())
                     {
-                        // if it's revoked, default will be no authority, and we will only have authority if
-                        // we have recovery identity in this wallet
+                        // if it's revoked, default is no authority for primary addresses, but we will have authority if
+                        // we have control over the recovery identity
                         std::pair<CIdentityMapKey, CIdentityMapValue> recoveryAuthority;
                         if (GetIdentity(identity.recoveryAuthority, recoveryAuthority, nHeight ? nHeight : INT_MAX))
                         {
@@ -2513,7 +2508,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                     {
                         wasCanSignCanSpend = CheckAuthority(idHistory.second);
 
-                        if (idHistory.second.IsRevoked() && !(wasCanSignCanSpend.first && wasCanSignCanSpend.second))
+                        if (idHistory.second.IsRevoked())
                         {
                             std::pair<CIdentityMapKey, CIdentityMapValue> oldRecoveryAuthority;
                             std::pair<bool, bool> auxCSCS;
@@ -2528,17 +2523,27 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                             }
                         }
 
-                        // if this is the initial registration, delete all other instances of the ID
+                        // if this is an add of the initial registration, delete all other instances of the ID
                         if (CNameReservation(tx).IsValid())
                         {
                             while (GetIdentity(idID, idHistory))
                             {
+                                // any definition of this identity in this wallet must be
+                                // invalid now
                                 RemoveIdentity(idHistory.first, idHistory.second.txid);
+                                if (idHistory.second.txid != txHash)
+                                {
+                                    // any definition of this ID in this wallet that is not this definition
+                                    // must also be on an invalid transaction
+                                    EraseFromWallet(idHistory.second.txid);
+                                }
                                 // set wasCanSignCanSpend to true, true to delete any dependent transactions
                                 wasCanSignCanSpend = {true, true};
                             }
                             idHistory = std::pair<CIdentityMapKey, CIdentityMapValue>();
+                            wasCanSignCanSpend = std::pair<bool, bool>({false, false});
                         }
+
                         else if (nHeight && idHistory.first.blockHeight == nHeight && idHistory.second.txid != identity.txid)
                         {
                             // this is one of more than one identity records in the same block
@@ -2692,7 +2697,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                             {
                                 if (canSignCanSpend.first)
                                 {
-                                    // add all UTXOs that are sent to this address to this wallet
+                                    // add all UTXOs sent to this address to this wallet
                                     std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue>> unspentOutputs;
                                     if (GetAddressUnspent(idID, CScript::P2ID, unspentOutputs))
                                     {
@@ -2718,25 +2723,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                                 CTransaction newTx;
                                                 if (myGetTransaction(newOut.first.txhash, newTx, blkHash))
                                                 {
-                                                    auto sprNoteData = FindMySproutNotes(newTx);
-                                                    auto sapNoteDataAndAddressesToAdd = FindMySaplingNotes(newTx);
-                                                    auto sapNoteData = sapNoteDataAndAddressesToAdd.first;
-                                                    auto addrsToAdd = sapNoteDataAndAddressesToAdd.second;
-                                                    for (const auto &addressToAdd : addrsToAdd)
-                                                    {
-                                                        AddSaplingIncomingViewingKey(addressToAdd.second, addressToAdd.first);
-                                                    }
-
                                                     CWalletTx wtx(this, newTx);
 
-                                                    if (sprNoteData.size() > 0) {
-                                                        wtx.SetSproutNoteData(sprNoteData);
-                                                    }
-
-                                                    if (sapNoteData.size() > 0) {
-                                                        wtx.SetSaplingNoteData(sapNoteData);
-                                                    }
-
                                                     // Get merkle branch if transaction was found in a block
                                                     CBlock block;
                                                     auto blkIndexIt = mapBlockIndex.find(blkHash);
@@ -2787,20 +2775,28 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                             continue;
                                         }
 
-                                        // if the tx is from this wallet, we will not erase it
-                                        if (IsFromMe(txidAndWtx.second))
-                                        {
-                                            continue;
-                                        }
-
                                         txnouttype txType;
                                         std::vector<CTxDestination> addresses;
                                         int minSigs;
                                         bool eraseTx = true;
-                                        std::vector<CIdentityID> oneTxIDs;
                                         int i = 0;
                                         uint256 hashTx = txidAndWtx.second.GetHash();
 
+                                        // if we still have z-address notes on the transaction, don't delete
+                                        auto sprNoteData = FindMySproutNotes(txidAndWtx.second);
+                                        auto sapNoteDataAndAddressesToAdd = FindMySaplingNotes(txidAndWtx.second);
+                                        if (sprNoteData.size() || sapNoteDataAndAddressesToAdd.first.size())
+                                        {
+                                            // don't erase the tx, but check to erase IDs
+                                            eraseTx = false;
+                                        }
+
+                                        // if the tx is from this wallet, we will not erase it
+                                        if (IsFromMe(txidAndWtx.second))
+                                        {
+                                            eraseTx = false;
+                                        }
+
                                         // look for a reason not to delete this tx
                                         for (auto txout : txidAndWtx.second.vout)
                                         {
@@ -2811,7 +2807,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                                 if (IsMine(txout))
                                                 {
                                                     eraseTx = false;
-                                                    break;
                                                 }
                                                 continue;
                                             }
@@ -2824,14 +2819,14 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                                 {
                                                     // we should keep this transaction anyhow, check next
                                                     eraseTx = false;
-                                                    break;
+                                                    continue;
                                                 }
                                                 
                                                 for (auto &dest : addresses)
                                                 {
                                                     if (dest.which() == COptCCParams::ADDRTYPE_ID)
                                                     {
-                                                        oneTxIDs.push_back(GetDestinationID(dest));
+                                                        idsToCheck.insert(GetDestinationID(dest));
                                                     }
                                                 }
                                             }
@@ -2841,11 +2836,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
                                         if (eraseTx)
                                         {
                                             txesToErase.push_back(txidAndWtx.first);
-
-                                            for (auto &checkID : oneTxIDs)
-                                            {
-                                                idsToCheck.insert(checkID);
-                                            }
                                         }
                                     }
 
@@ -2938,9 +2928,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
             }
         }
 
-        isMine = IsMine(tx);
-
-        if (fExisted || isMine || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0)
+        if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0)
         {
             CWalletTx wtx(this, tx);
 
This page took 0.064163 seconds and 4 git commands to generate.