message: Add mining address rpc call
diff: @@ -202,6 +202,59 @@ static UniValue getnewbasecoinaddress(const JSONRPCRequest& request)
  return EncodeDestination(dest, fBech32);
  }
  +static UniValue getnewminingaddress(const JSONRPCRequest& request)
  +{
  + std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
  + CWallet* const pwallet = wallet.get();
  +
  + if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
  + return NullUniValue;
  + }
  +
  + if (request.fHelp || request.params.size() > 1)
  + throw std::runtime_error(
  + "getnewminingaddress\n"
  + "\nReturns a new Veil address to be used to as a mining address.\n"
  + "If 'label' is specified, it is added to the address book \n"
  + "so mining payments received with the address will be associated with 'label'.\n"
  + "\nArguments:\n"
  + "1. \"label\" (string, optional) The label name for the address to be linked to. If not provided, the default label \"\" is used. It can also be set to the empty string \"\" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.\n"
  + "\nResult:\n"
  + "\"address\" (string) The new veil address\n"
  + "\nExamples:\n"
  + + HelpExampleCli("getnewminingaddress", "")
  + + HelpExampleRpc("getnewminingaddress", "")
  + );
  +
  + if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
  + throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
  + }
  +
  + LOCK2(cs_main, pwallet->cs_wallet);
  +
  + // Parse the label first so we don't generate a key if there's an error
  + std::string label;
  + if (!request.params[0].isNull())
  + label = LabelFromValue(request.params[0]);
  +
  + if (!pwallet->IsLocked()) {
  + pwallet->TopUpKeyPool();
  + }
  +
  + // Generate a new key that is added to wallet
  + CPubKey newKey;
  + if (!pwallet->GetKeyFromPool(newKey)) {
  + throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
  + }
  +
  + CKeyID dest = newKey.GetID();
  +
  + pwallet->SetAddressBook(dest, label, "receive");
  +
  + bool fBech32 = false;
  + return EncodeDestination(dest, fBech32);
  +}
  +
  static UniValue getrawchangeaddress(const JSONRPCRequest& request)
  {
  std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
  @@ -4752,6 +4805,7 @@ static const CRPCCommand commands[] =
  { "wallet", "getaddressinfo", &getaddressinfo, {"address"} },
  { "wallet", "getbalance", &getbalance, {"account|dummy","minconf","include_watchonly"} },
  { "wallet", "getnewbasecoinaddress", &getnewbasecoinaddress, {"label|account","address_type"} },
  + { "wallet", "getnewminingaddress", &getnewminingaddress, {"label"} },
  { "wallet", "getrawchangeaddress", &getrawchangeaddress, {"address_type"} },
  { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, {"address","minconf"} },
  { "wallet", "gettransaction", &gettransaction, {"txid","include_watchonly"} },
  