forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement and enforce CbTx with correct block height and deprecate BIP34
- Loading branch information
Showing
8 changed files
with
146 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) 2017 The Dash Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include "cbtx.h" | ||
#include "specialtx.h" | ||
#include "deterministicmns.h" | ||
|
||
#include "validation.h" | ||
#include "univalue.h" | ||
|
||
bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state) | ||
{ | ||
AssertLockHeld(cs_main); | ||
|
||
if (!tx.IsCoinBase()) | ||
return state.DoS(100, false, REJECT_INVALID, "bad-cbtx-invalid"); | ||
|
||
CCbTx cbTx; | ||
if (!GetTxPayload(tx, cbTx)) | ||
return state.DoS(100, false, REJECT_INVALID, "bad-tx-payload"); | ||
|
||
if (cbTx.nVersion > CCbTx::CURRENT_VERSION) | ||
return state.DoS(100, false, REJECT_INVALID, "bad-cbtx-version"); | ||
|
||
if (pindexPrev) { | ||
if (pindexPrev->nHeight + 1 != cbTx.nHeight) | ||
return state.DoS(100, false, REJECT_INVALID, "bad-cbtx-height"); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
std::string CCbTx::ToString() const | ||
{ | ||
return strprintf("CCbTx(nHeight=%d, nVersion=%d, merkleRootMNList=%s)", | ||
nVersion, nHeight, merkleRootMNList.ToString()); | ||
} | ||
|
||
void CCbTx::ToJson(UniValue& obj) const | ||
{ | ||
obj.clear(); | ||
obj.setObject(); | ||
obj.push_back(Pair("version", (int)nVersion)); | ||
obj.push_back(Pair("height", (int)nHeight)); | ||
obj.push_back(Pair("merkleRootMNList", merkleRootMNList.ToString())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) 2017 The Dash Core developers | ||
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef DASH_CBTX_H | ||
#define DASH_CBTX_H | ||
|
||
#include "primitives/transaction.h" | ||
#include "consensus/validation.h" | ||
|
||
class CBlockIndex; | ||
class UniValue; | ||
|
||
// coinbase transaction | ||
class CCbTx | ||
{ | ||
public: | ||
static const uint16_t CURRENT_VERSION = 1; | ||
|
||
public: | ||
uint16_t nVersion{CURRENT_VERSION}; | ||
int32_t nHeight{0}; | ||
uint256 merkleRootMNList; | ||
|
||
public: | ||
ADD_SERIALIZE_METHODS; | ||
|
||
template <typename Stream, typename Operation> | ||
inline void SerializationOp(Stream& s, Operation ser_action) | ||
{ | ||
READWRITE(nVersion); | ||
READWRITE(nHeight); | ||
READWRITE(merkleRootMNList); | ||
} | ||
|
||
std::string ToString() const; | ||
void ToJson(UniValue& obj) const; | ||
}; | ||
|
||
bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CValidationState& state); | ||
|
||
#endif//DASH_CBTX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters