Skip to content

Commit

Permalink
refactor: a new constant with Tx Version
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Mar 24, 2024
1 parent 9d429f4 commit 8b6c96d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ class CTransaction
public:
// Default transaction version.
static const int32_t CURRENT_VERSION=2;
// Special transaction version
static const int32_t SPECIAL_VERSION = 3;

// Changing the default transaction version requires a two step process: first
// adapting relay policy by bumping MAX_STANDARD_VERSION, and then later date
// bumping the default CURRENT_VERSION at which point both CURRENT_VERSION and
// MAX_STANDARD_VERSION will be equal.
static const int32_t MAX_STANDARD_VERSION=3;
static const int32_t MAX_STANDARD_VERSION = SPECIAL_VERSION;

// The local variables are made const to prevent unintended modification
// without updating the cached hash value. However, CTransaction is not
Expand Down Expand Up @@ -268,7 +270,7 @@ class CTransaction

bool IsSpecialTxVersion() const noexcept
{
return nVersion >= 3;
return nVersion >= SPECIAL_VERSION;
}

bool HasExtraPayloadField() const noexcept
Expand Down Expand Up @@ -298,7 +300,7 @@ struct CMutableTransaction
SER_READ(obj, obj.nVersion = (int16_t) (n32bitVersion & 0xffff));
SER_READ(obj, obj.nType = (uint16_t) ((n32bitVersion >> 16) & 0xffff));
READWRITE(obj.vin, obj.vout, obj.nLockTime);
if (obj.nVersion >= 3 && obj.nType != TRANSACTION_NORMAL) {
if (obj.nVersion >= CTransaction::SPECIAL_VERSION && obj.nType != TRANSACTION_NORMAL) {
READWRITE(obj.vExtraPayload);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ class CTransactionSignatureSerializer
SerializeOutput(s, nOutput);
// Serialize nLockTime
::Serialize(s, txTo.nLockTime);
if (txTo.nVersion >= 3 && txTo.nType != TRANSACTION_NORMAL)
if (txTo.nVersion >= CTransaction::SPECIAL_VERSION && txTo.nType != TRANSACTION_NORMAL)
::Serialize(s, txTo.vExtraPayload);
}
};
Expand Down

0 comments on commit 8b6c96d

Please sign in to comment.