|
3 | 3 | // file COPYING or https://www.opensource.org/licenses/mit-license.php. |
4 | 4 | #include "legacy/validation_zerocoin_legacy.h" |
5 | 5 |
|
| 6 | +#include "consensus/zerocoin_verify.h" |
6 | 7 | #include "libzerocoin/CoinSpend.h" |
7 | 8 | #include "wallet/wallet.h" |
8 | 9 | #include "zpivchain.h" |
9 | 10 |
|
| 11 | +bool AcceptToMemoryPoolZerocoin(const CTransaction& tx, CAmount& nValueIn, int chainHeight, CValidationState& state, const Consensus::Params& consensus) |
| 12 | +{ |
| 13 | + nValueIn = tx.GetZerocoinSpent(); |
| 14 | + |
| 15 | + //Check that txid is not already in the chain |
| 16 | + int nHeightTx = 0; |
| 17 | + if (IsTransactionInChain(tx.GetHash(), nHeightTx)) |
| 18 | + return state.Invalid(error("%s : zPIV spend tx %s already in block %d", __func__, tx.GetHash().GetHex(), nHeightTx), |
| 19 | + REJECT_DUPLICATE, "bad-txns-inputs-spent"); |
| 20 | + |
| 21 | + //Check for double spending of serial #'s |
| 22 | + for (const CTxIn& txIn : tx.vin) { |
| 23 | + // Only allow for public zc spends inputs |
| 24 | + if (!txIn.IsZerocoinPublicSpend()) |
| 25 | + return state.Invalid(false, REJECT_INVALID, "bad-zc-spend-notpublic"); |
| 26 | + |
| 27 | + libzerocoin::ZerocoinParams* params = consensus.Zerocoin_Params(false); |
| 28 | + PublicCoinSpend publicSpend(params); |
| 29 | + if (!ZPIVModule::ParseZerocoinPublicSpend(txIn, tx, state, publicSpend)){ |
| 30 | + return false; |
| 31 | + } |
| 32 | + if (!ContextualCheckZerocoinSpend(tx, &publicSpend, chainHeight, UINT256_ZERO)) |
| 33 | + return state.Invalid(false, REJECT_INVALID, "bad-zc-spend-contextcheck"); |
| 34 | + |
| 35 | + // Check that the version matches the one enforced with SPORK_18 |
| 36 | + if (!CheckPublicCoinSpendVersion(publicSpend.getVersion())) { |
| 37 | + return state.Invalid(false, REJECT_INVALID, "bad-zc-spend-version"); |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + return true; |
| 42 | +} |
| 43 | + |
10 | 44 | bool DisconnectZerocoinTx(const CTransaction& tx, CAmount& nValueIn, CZerocoinDB* zerocoinDB) |
11 | 45 | { |
12 | 46 | /** UNDO ZEROCOIN DATABASING |
|
0 commit comments