Skip to content

Commit ac88244

Browse files
committed
Validation: guard v2 shielded transaction serialization for pre-v5 upgrade window.
1 parent c613b4f commit ac88244

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,7 @@ void FlushStateToDisk()
26502650
void static UpdateTip(CBlockIndex* pindexNew)
26512651
{
26522652
chainActive.SetTip(pindexNew);
2653+
g_IsSaplingActive = Params().GetConsensus().NetworkUpgradeActive(pindexNew->nHeight, Consensus::UPGRADE_V5_DUMMY);
26532654

26542655
// New best block
26552656
nTimeBestReceived = GetTime();

src/primitives/transaction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
extern bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow);
1919

20+
// contextual flag to guard the serialization for v5 upgrade.
21+
// can be removed once v5 enforcement is activated.
22+
std::atomic<bool> g_IsSaplingActive{false};
2023

2124
std::string BaseOutPoint::ToStringShort() const
2225
{

src/primitives/transaction.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616

1717
#include "sapling/sapling_transaction.h"
1818

19+
#include <atomic>
1920
#include <list>
2021

2122
class CTransaction;
2223

24+
// contextual flag to guard the serialization for v5 upgrade.
25+
// can be removed once v5 enforcement is activated.
26+
extern std::atomic<bool> g_IsSaplingActive;
27+
2328
/** An outpoint - a combination of a transaction hash and an index n into its vout */
2429
class BaseOutPoint
2530
{
@@ -276,7 +281,7 @@ class CTransaction
276281
READWRITE(*const_cast<std::vector<CTxOut>*>(&vout));
277282
READWRITE(*const_cast<uint32_t*>(&nLockTime));
278283

279-
if (nVersion == CTransaction::SAPLING_VERSION) {
284+
if (g_IsSaplingActive && nVersion == CTransaction::SAPLING_VERSION) {
280285
READWRITE(*const_cast<Optional<SaplingTxData>*>(&sapData));
281286
}
282287

0 commit comments

Comments
 (0)