1 /********************************************************************
2 * (C) 2018 Michael Toutonghi
4 * Distributed under the MIT software license, see the accompanying
5 * file COPYING or http://www.opensource.org/licenses/mit-license.php.
7 * This supports code to catch nothing at stake cheaters who stake
12 #ifndef CHEATCATCHER_H
13 #define CHEATCATCHER_H
18 #include "primitives/transaction.h"
19 #include "script/script.h"
31 CTxHolder(const CTransaction &_tx, uint32_t _height) : height(_height), tx(_tx) {
32 CVerusHashWriter hw = CVerusHashWriter(SER_GETHASH, PROTOCOL_VERSION);
34 hw << tx.vin[0].prevout.hash;
35 hw << tx.vin[0].prevout.n;
39 CTxHolder& operator=(const CTxHolder& txh)
52 std::multimap<const int32_t, CTxHolder> orderedCheatCandidates;
53 std::multimap<const uint256, CTxHolder *> indexedCheatCandidates;
54 CCriticalSection cs_cheat;
59 // prune all transactions in the list below height
60 uint32_t Prune(uint32_t height);
62 // check to see if a transaction that could be a cheat for the passed transaction is in our list
63 bool IsCheatInList(const CTransaction &tx, CTransaction *pcheatTx);
65 // checks if the out point is in the list
66 bool IsUTXOInList(COutPoint _utxo, uint32_t height);
68 // check to see if there are cheat candidates of the same or greater block height in list
69 bool IsHeightOrGreaterInList(uint32_t height);
71 // add a potential cheat transaction to the list. we do this for all stake transactions from orphaned stakes
72 void Add(const CTxHolder &txh);
74 // remove a transaction from the the list
75 void Remove(const CTxHolder &txh);
79 extern CCheatList cheatList;
80 extern boost::optional<libzcash::SaplingPaymentAddress> defaultSaplingDest;