Skip to content

Commit 7c87241

Browse files
random-zebraFuzzbawls
authored andcommitted
[Consensus] Bump TxVersion::SAPLING to 3
Github-Pull: #2051 Rebased-From: 3dfd813
1 parent 05fe877 commit 7c87241

File tree

6 files changed

+12
-8
lines changed

6 files changed

+12
-8
lines changed

src/consensus/upgrades.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const struct NUInfo NetworkUpgradeInfo[Consensus::MAX_NETWORK_UPGRADES] = {
5151
},
5252
{
5353
/*.strName =*/ "v5_shield",
54-
/*.strInfo =*/ "Sapling Shield - start block v8 - start transaction v2",
54+
/*.strInfo =*/ "Sapling Shield - start block v8 - start transaction v3",
5555
},
5656
{
5757
/*.strName =*/ "Test_dummy",

src/init.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,9 +1465,6 @@ bool AppInit2()
14651465

14661466
fReindex = gArgs.GetBoolArg("-reindex", false);
14671467

1468-
// Assume sapling active during reindex for proper v2 deserialization when loading the wallet
1469-
if (fReindex) g_IsSaplingActive = true;
1470-
14711468
// Create blocks directory if it doesn't already exist
14721469
fs::create_directories(GetDataDir() / "blocks");
14731470

src/primitives/transaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class CTransaction
235235
/** Transaction Versions */
236236
enum TxVersion: int16_t {
237237
LEGACY = 1,
238-
SAPLING = 2,
238+
SAPLING = 3,
239239
TOOHIGH
240240
};
241241

src/sapling/sapling_validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState& state, CAmount&
3232
return true;
3333
}
3434

35-
// From here, all of the checks are done in +v2 transactions.
35+
// From here, all of the checks are done in v3+ transactions.
3636

3737
// if the tx has shielded data, cannot be a coinstake, coinbase, zcspend and zcmint
3838
if (tx.IsCoinStake() || tx.IsCoinBase() || tx.HasZerocoinSpendInputs() || tx.HasZerocoinMintOutputs())
@@ -53,7 +53,7 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
5353
{
5454
// Basic checks that don't depend on any context
5555
const Consensus::Params& consensus = Params().GetConsensus();
56-
// If the tx got to this point, must be +v2.
56+
// If the tx got to this point, must be v3+.
5757
assert(tx.isSaplingVersion());
5858

5959
// Check for non-zero valueBalance when there are no Sapling inputs or outputs

src/sapling/sapling_validation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CValidationState;
1414
namespace SaplingValidation {
1515

1616
/** Context-independent validity checks */
17-
// Note: for +v2, if the tx has no shielded data, this method returns true.
17+
// Note: for v3+, if the tx has no shielded data, this method returns true.
1818
// Note2: This function only performs shielded data related checks, it does NOT checks regular inputs and outputs.
1919
bool CheckTransaction(const CTransaction& tx, CValidationState& state, CAmount& nValueOut, bool fIsSaplingActive);
2020
bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state, CAmount& nValueOut);

src/wallet/wallet.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4130,6 +4130,11 @@ bool CWallet::InitLoadWallet()
41304130
return true;
41314131
}
41324132

4133+
// Assume sapling active during initialization of the wallet for proper v3 deserialization
4134+
// before reindex/resync
4135+
const bool wasSaplingActive = g_IsSaplingActive;
4136+
if (!wasSaplingActive) g_IsSaplingActive = true;
4137+
41334138
std::string walletFile = gArgs.GetArg("-wallet", DEFAULT_WALLET_DAT);
41344139

41354140
CWallet * const pwallet = CreateWalletFromFile(walletFile);
@@ -4138,6 +4143,8 @@ bool CWallet::InitLoadWallet()
41384143
}
41394144
pwalletMain = pwallet;
41404145

4146+
// restore global flag to previous state
4147+
g_IsSaplingActive = wasSaplingActive;
41414148
return true;
41424149
}
41434150

0 commit comments

Comments
 (0)