Skip to content

Commit

Permalink
[RPC] Block EVO rpcs before V6 enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed May 4, 2021
1 parent 214dc7f commit a718654
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/rpc/rpcevo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ static CKey GetKeyFromWallet(CWallet* pwallet, const CKeyID& keyID)
}
#endif

static void CheckEvoUpgradeEnforcement()
{
const int nHeight = WITH_LOCK(cs_main, return chainActive.Height(); );
if (!Params().GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_V6_0)) {
throw JSONRPCError(RPC_MISC_ERROR, "Evo upgrade is not active yet");
}
}

// Allows to specify PIVX address or priv key (as strings). In case of PIVX address, the priv key is taken from the wallet
static CKey ParsePrivKey(CWallet* pwallet, const std::string &strKeyOrAddress, bool allowAddresses = true) {
bool isStaking{false}, isShield{false};
Expand Down Expand Up @@ -394,6 +402,7 @@ static UniValue ProTxRegister(const JSONRPCRequest& request, bool fSignAndSend)
)
);
}
if (fSignAndSend) CheckEvoUpgradeEnforcement();

EnsureWallet();
EnsureWalletIsUnlocked();
Expand Down Expand Up @@ -484,6 +493,7 @@ UniValue protx_register_submit(const JSONRPCRequest& request)
+ HelpExampleCli("protx_register_submit", "\"tx\" \"sig\"")
);
}
CheckEvoUpgradeEnforcement();

EnsureWallet();
EnsureWalletIsUnlocked();
Expand Down Expand Up @@ -535,6 +545,7 @@ UniValue protx_register_fund(const JSONRPCRequest& request)
+ HelpExampleCli("protx_register_fund", "...!TODO...")
);
}
CheckEvoUpgradeEnforcement();

EnsureWallet();
EnsureWalletIsUnlocked();
Expand Down Expand Up @@ -672,6 +683,8 @@ UniValue protx_list(const JSONRPCRequest& request)
);
}

CheckEvoUpgradeEnforcement();

#ifdef ENABLE_WALLET
CWallet* const pwallet = pwalletMain;
#else
Expand Down

0 comments on commit a718654

Please sign in to comment.