diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 83c85e551..28091b957 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -24,7 +24,7 @@ so you can pay to a pubkey, or to its hash. or to a script's hash. the last is h all of the above are the standard bitcoin vout types and there should be plenty of materials about it Encrypted by a verified device what I did with the CC contracts is created a fourth type of vout, the CC vout. this is using the cryptoconditions standard and it is even a different signature mechanism. ed25519 instead of secp256k1. it is basically a big extension to the bitcoin script. There is a special opcode that is added that says it is a CC script. - + but it gets more interesting each CC script has an evalcode this is just an arbitrary number. but what it does is allows to create a self-contained universe of CC utxo that all have the same evalcode and that is how a faucet CC differentiates itself from a dice CC, the eval code is different @@ -73,7 +73,7 @@ struct CC_utxo // these are the parameters stored after Verus crypto-condition vouts. new versions may change // the format -struct CC_meta +struct CC_meta { std::vector version; uint8_t evalCode; @@ -110,7 +110,7 @@ int32_t komodo_nextheight(); static const uint256 zeroid; bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock); int32_t is_hexstr(char *str,int32_t n); -bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL); +bool myAddtomempool(CTransaction &tx, CValidationState *pstate = NULL, bool fSkipExpiry = false); //uint64_t myGettxout(uint256 hash,int32_t n); bool myIsutxo_spentinmempool(uint256 txid,int32_t vout); bool mytxid_inmempool(uint256 txid); diff --git a/src/main.cpp b/src/main.cpp index c811fa65f..3cee45552 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1599,7 +1599,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF } -bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel) +bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel, bool fSkipExpiry) { AssertLockHeld(cs_main); if (pfMissingInputs) @@ -1636,7 +1636,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // DoS level set to 10 to be more forgiving. // Check transaction contextually against the set of consensus rules which apply in the next block to be mined. - if (!ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) + if (!fSkipExpiry && !ContextualCheckTransaction(tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel)) { return error("AcceptToMemoryPool: ContextualCheckTransaction failed"); } @@ -1733,7 +1733,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (pfMissingInputs) *pfMissingInputs = true; //fprintf(stderr,"missing inputs\n"); - //return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); + return state.DoS(0, error("AcceptToMemoryPool: tx inputs not found"),REJECT_INVALID, "bad-txns-inputs-missing"); return(false); } } @@ -1975,14 +1975,14 @@ bool GetAddressUnspent(uint160 addressHash, int type, else return(coins.vout[n].nValue); }*/ -bool myAddtomempool(CTransaction &tx, CValidationState *pstate) +bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry) { CValidationState state; if (!pstate) pstate = &state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) - return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees)); + return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees, -1, fSkipExpiry)); else return(true); } @@ -4686,7 +4686,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { const CTransaction &tx = e.GetTx(); const uint256 &hash = tx.GetHash(); - if ( tx.vjoinsplit.size() == 0 ) { + if ( tx.vjoinsplit.empty() && tx.vShieldedSpend.empty()) { transactionsToRemove.push_back(tx); tmpmempool.addUnchecked(hash,e,true); } @@ -4705,10 +4705,10 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C CValidationState state; CTransaction Tx; const CTransaction &tx = (CTransaction)block.vtx[i]; - if (tx.IsCoinBase() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) + if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) continue; Tx = tx; - if ( myAddtomempool(Tx, &state) == false ) // happens with out of order tx in block on resync + if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync { //LogPrintf("Rejected by mempool, reason: .%s.\n", state.GetRejectReason().c_str()); // take advantage of other checks, but if we were only rejected because it is a valid staking @@ -4773,9 +4773,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { const CTransaction &tx = e.GetTx(); const uint256 &hash = tx.GetHash(); - if ( tx.vjoinsplit.size() == 0 ) { - mempool.addUnchecked(hash,e,true); - } + mempool.addUnchecked(hash,e,true); } //fprintf(stderr, "finished adding back. mempoolsize.%ld\n",mempool.size()); // empty the temp mempool for next time. diff --git a/src/main.h b/src/main.h index 00055b39c..fdd9fcae8 100644 --- a/src/main.h +++ b/src/main.h @@ -274,7 +274,7 @@ void PruneAndFlush(); /** (try to) add transaction to memory pool **/ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, - bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1); + bool* pfMissingInputs, bool fRejectAbsurdFee=false, int dosLevel=-1, bool fSkipExpiry=false); struct CNodeStateStats {