diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 1ae4e59f92..1371a0d07e 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -36,6 +36,7 @@ static const unsigned int MAX_BLOCK_BASE_SIZE = 2000000; static const int64_t MAX_BLOCK_SIGOPS_COST = 400000; /** The maximum allowed size of version 3 extra payload */ static const unsigned int MAX_TX_EXTRA_PAYLOAD = 150000; +static const unsigned int NEW_MAX_TX_EXTRA_PAYLOAD = 230000; /** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */ static const int COINBASE_MATURITY = 100; diff --git a/src/lelantus.cpp b/src/lelantus.cpp index 95e45e2fab..af4fd8ffd7 100644 --- a/src/lelantus.cpp +++ b/src/lelantus.cpp @@ -421,6 +421,13 @@ bool CheckLelantusJoinSplitTransaction( "CTransaction::CheckLelantusJoinSplitTransaction() : Error: incorrect joinsplit transaction verion"); } + if (joinsplit->isSigmaToLelantus() && height >= params.stage4StartBlock) { + return state.DoS(100, + false, + NSEQUENCE_INCORRECT, + "CTransaction::CheckLelantusJoinSplitTransaction() : Sigma pool already closed."); + } + uint256 txHashForMetadata; // Obtain the hash of the transaction sans the zerocoin part diff --git a/src/validation.cpp b/src/validation.cpp index 5cba58e368..cbc8b6b258 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -662,7 +662,7 @@ bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fChe // Size limits (this doesn't take the witness into account, as that hasn't been checked for malleability) if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) > MAX_BLOCK_BASE_SIZE) return state.DoS(100, false, REJECT_INVALID, "bad-txns-oversize"); - if (tx.vExtraPayload.size() > MAX_TX_EXTRA_PAYLOAD) + if ((tx.vExtraPayload.size() > MAX_TX_EXTRA_PAYLOAD && nHeight < ::Params().GetConsensus().stage4StartBlock) || tx.vExtraPayload.size() > NEW_MAX_TX_EXTRA_PAYLOAD) return state.DoS(100, false, REJECT_INVALID, "bad-txns-payload-oversize"); // Check for negative or overflow output values @@ -964,6 +964,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C const std::vector &ids = joinsplit->getCoinGroupIds(); const std::vector& serials = joinsplit->getCoinSerialNumbers(); + if (joinsplit->isSigmaToLelantus() && chainActive.Height() >= consensus.stage4StartBlock) { + return state.DoS(100, error("Sigma pool already closed."), + REJECT_INVALID, "txn-invalid-lelantus-joinsplit"); + } + if (serials.size() != ids.size()) return state.Invalid(false, REJECT_CONFLICT, "txn-invalid-lelantus-joinsplit"); diff --git a/src/wallet/lelantusjoinsplitbuilder.cpp b/src/wallet/lelantusjoinsplitbuilder.cpp index eba439524c..c6ef7363eb 100644 --- a/src/wallet/lelantusjoinsplitbuilder.cpp +++ b/src/wallet/lelantusjoinsplitbuilder.cpp @@ -193,6 +193,9 @@ CWalletTx LelantusJoinSplitBuilder::Build( std::vector denomChanges; try { + if (chainActive.Height() >= Params().GetConsensus().stage4StartBlock) + throw std::runtime_error(_("Sigma pool already closed.")); + CAmount availableBalance(0); for (auto coin : sigmaCoins) { availableBalance += coin.get_denomination_value();