message: Disable Zerocoin mint RPC when it almost not accepted by network
diff: @@ -37,6 +37,23 @@ using namespace std;
  int64_t nWalletUnlockTime;
  static CCriticalSection cs_nWalletUnlockTime;
  +static void EnsureZerocoinMintIsAllowed()
  +{
  + // We want to make sure the new mint still accept by network when we broadcast.
  + // So we will not allow users to use this RPC anymore 10 blocks before it completely
  + // disabled at consensus level. We don't need this for spend because it does not make sense
  + // since users still lost their mints when it completely disable.
  + auto& consensus = Params().GetConsensus();
  + constexpr int threshold = 10; // 10 blocks should be enough for mints to get mined.
  + int disableHeight = consensus.nSigmaStartBlock + consensus.nZerocoinV2MintMempoolGracefulPeriod - threshold;
  +
  + LOCK(cs_main);
  +
  + if (chainActive.Height() > disableHeight) {
  + throw JSONRPCError(RPC_WALLET_ERROR, "Zerocoin mint is not allowed on network anymore");
  + }
  +}
  +
  std::string HelpRequiringPassphrase()
  {
  return pwalletMain && pwalletMain->IsCrypted()
  @@ -2742,6 +2759,7 @@ UniValue mint(const UniValue& params, bool fHelp)
  UniValue mintzerocoin(const UniValue& params, bool fHelp)
  {
  + EnsureZerocoinMintIsAllowed();
  if (fHelp || params.size() != 1)
  throw runtime_error("mintzerocoin <amount>(1,10,25,50,100)\n" + HelpRequiringPassphrase());
  @@ -2897,6 +2915,8 @@ UniValue mintzerocoinV3(const UniValue& params, bool fHelp)
  UniValue mintmanyzerocoin(const UniValue& params, bool fHelp)
  {
  + EnsureZerocoinMintIsAllowed();
  +
  if (fHelp || params.size() == 0 || params.size() % 2 != 0 || params.size() > 10)
  throw runtime_error(
  "mintmanyzerocoin <denomination>(1,10,25,50,100), numberOfMints, <denomination>(1,10,25,50,100), numberOfMints, ... }\n"
  