diff --git a/src/CryptoNoteCore/Blockchain.cpp b/src/CryptoNoteCore/Blockchain.cpp index 59774826..8f236a7a 100644 --- a/src/CryptoNoteCore/Blockchain.cpp +++ b/src/CryptoNoteCore/Blockchain.cpp @@ -1,12 +1,16 @@ // Copyright (c) 2011-2017 The Cryptonote developers +// Copyright (c) 2016-2018, The Karbo developers // Copyright (c) 2018 The Circle Foundation + // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "Blockchain.h" #include +#include #include +#include #include #include "Common/Math.h" #include "Common/int-util.h" @@ -16,6 +20,7 @@ #include "Rpc/CoreRpcServerCommandsDefinitions.h" #include "Serialization/BinarySerializationTools.h" #include "CryptoNoteTools.h" +#include "TransactionExtra.h" using namespace Logging; using namespace Common; @@ -1183,6 +1188,13 @@ bool Blockchain::handle_alternative_block(const Block& b, const Crypto::Hash& id return false; } + // Disable merged mining + TransactionExtraMergeMiningTag mmTag; + if (getMergeMiningTagFromExtra(bei.bl.baseTransaction.extra, mmTag) && bei.height >= CryptoNote::parameters::UPGRADE_HEIGHT_V6) { + logger(ERROR, BRIGHT_RED) << "Merge mining tag was found in extra of miner transaction"; + return false; + } + // Always check PoW for alternative blocks m_is_in_checkpoint_zone = false; difficulty_type current_diff = get_next_difficulty_for_alternative_chain(alt_chain, bei); @@ -1918,6 +1930,17 @@ bool Blockchain::pushBlock(const Block& blockData, const std::vector= CryptoNote::parameters::UPGRADE_HEIGHT_V6) { + logger(ERROR, BRIGHT_RED) << "Merge mining tag was found in extra of miner transaction"; + return false; + } + } + + if (blockData.previousBlockHash != getTailId()) { logger(INFO, BRIGHT_WHITE) << "Block " << blockHash << " has wrong previousBlockHash: " << blockData.previousBlockHash << ", expected: " << getTailId(); diff --git a/src/CryptoNoteCore/Checkpoints.cpp b/src/CryptoNoteCore/Checkpoints.cpp index 9c88a1f3..6d595d6a 100644 --- a/src/CryptoNoteCore/Checkpoints.cpp +++ b/src/CryptoNoteCore/Checkpoints.cpp @@ -1,5 +1,7 @@ // Copyright (c) 2011-2017 The Cryptonote developers // Copyright (c) 2018 The Circle Foundation +// Copyright (c) 2016-2018, The Karbo developers + // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/CryptoNoteCore/TransactionExtra.h b/src/CryptoNoteCore/TransactionExtra.h index 89233d4b..58c8d331 100644 --- a/src/CryptoNoteCore/TransactionExtra.h +++ b/src/CryptoNoteCore/TransactionExtra.h @@ -1,5 +1,6 @@ // Copyright (c) 2011-2017 The Cryptonote developers // Copyright (c) 2018 The Circle Foundation + // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -89,6 +90,7 @@ bool appendMergeMiningTagToExtra(std::vector& tx_extra, const Transacti bool append_message_to_extra(std::vector& tx_extra, const tx_extra_message& message); std::vector get_messages_from_extra(const std::vector& extra, const Crypto::PublicKey &txkey, const Crypto::SecretKey *recepient_secret_key); void appendTTLToExtra(std::vector& tx_extra, uint64_t ttl); +bool getMergeMiningTagFromExtra(const std::vector& tx_extra, TransactionExtraMergeMiningTag& mm_tag); bool createTxExtraWithPaymentId(const std::string& paymentIdString, std::vector& extra); //returns false if payment id is not found or parse error