Browse Source

Treat non-version-1 transactions as non-standard

Adds CBlock::CURRENT_VERSION and CTransaction::CURRENT_VERSION
constants, and makes non-CURRENT_VERSION transactions nonstandard.
This will help make future upgrades smoother.
miguelfreitas
Gavin Andresen 13 years ago
parent
commit
dae3e10a5a
  1. 3
      src/main.cpp
  2. 6
      src/main.h

3
src/main.cpp

@ -268,6 +268,9 @@ bool CTransaction::ReadFromDisk(COutPoint prevout)
bool CTransaction::IsStandard() const bool CTransaction::IsStandard() const
{ {
if (nVersion > CTransaction::CURRENT_VERSION)
return false;
BOOST_FOREACH(const CTxIn& txin, vin) BOOST_FOREACH(const CTxIn& txin, vin)
{ {
// Biggest 'standard' txin is a 3-signature 3-of-3 CHECKMULTISIG // Biggest 'standard' txin is a 3-signature 3-of-3 CHECKMULTISIG

6
src/main.h

@ -386,6 +386,7 @@ typedef std::map<uint256, std::pair<CTxIndex, CTransaction> > MapPrevTx;
class CTransaction class CTransaction
{ {
public: public:
static const int CURRENT_VERSION=1;
int nVersion; int nVersion;
std::vector<CTxIn> vin; std::vector<CTxIn> vin;
std::vector<CTxOut> vout; std::vector<CTxOut> vout;
@ -411,7 +412,7 @@ public:
void SetNull() void SetNull()
{ {
nVersion = 1; nVersion = CTransaction::CURRENT_VERSION;
vin.clear(); vin.clear();
vout.clear(); vout.clear();
nLockTime = 0; nLockTime = 0;
@ -817,6 +818,7 @@ class CBlock
{ {
public: public:
// header // header
static const int CURRENT_VERSION=1;
int nVersion; int nVersion;
uint256 hashPrevBlock; uint256 hashPrevBlock;
uint256 hashMerkleRoot; uint256 hashMerkleRoot;
@ -858,7 +860,7 @@ public:
void SetNull() void SetNull()
{ {
nVersion = 1; nVersion = CBlock::CURRENT_VERSION;
hashPrevBlock = 0; hashPrevBlock = 0;
hashMerkleRoot = 0; hashMerkleRoot = 0;
nTime = 0; nTime = 0;

Loading…
Cancel
Save