@@ -46,6 +46,7 @@ enum ProRegParam {
4646 proTxHash,
4747 payoutAddress_register,
4848 payoutAddress_update,
49+ revocationReason,
4950 votingAddress_register,
5051 votingAddress_update,
5152};
@@ -114,6 +115,10 @@ static const std::map<ProRegParam, std::string> mapParamHelp = {
114115 {proTxHash,
115116 " %d. \" proTxHash\" (string, required) The hash of the initial ProRegTx.\n "
116117 },
118+ {revocationReason,
119+ " %d. reason (numeric, optional) The reason for masternode service revocation. Default: 0.\n "
120+ " 0=not_specified, 1=service_termination, 2=compromised_keys, 3=keys_change.\n "
121+ },
117122 {votingAddress_register,
118123 " %d. \" votingAddress\" (string, required) The voting key address. The private key does not have to be known by your wallet.\n "
119124 " It has to match the private key which is later used when voting on proposals.\n "
@@ -896,6 +901,73 @@ UniValue protx_update_registrar(const JSONRPCRequest& request)
896901
897902 return SignAndSendSpecialTx (pwallet, tx, pl);
898903}
904+
905+ UniValue protx_revoke (const JSONRPCRequest& request)
906+ {
907+ CWallet * const pwallet = GetWalletForJSONRPCRequest (request);
908+
909+ if (!EnsureWalletIsAvailable (pwallet, request.fHelp ))
910+ return NullUniValue;
911+
912+ if (request.fHelp || request.params .size () < 1 || request.params .size () > 3 ) {
913+ throw std::runtime_error (
914+ " protx_update_revoke \" proTxHash\" (\" operatorKey\" reason)\n "
915+ " \n Creates and sends a ProUpRevTx to the network. This will revoke the operator key of the masternode and\n "
916+ " put it into the PoSe-banned state. It will also set the service field of the masternode\n "
917+ " to zero. Use this in case your operator key got compromised or you want to stop providing your service\n "
918+ " to the masternode owner.\n "
919+ + HelpRequiringPassphrase (pwallet) + " \n "
920+ " \n Arguments:\n "
921+ + GetHelpString (1 , proTxHash)
922+ + GetHelpString (2 , operatorKey)
923+ + GetHelpString (3 , revocationReason) +
924+ " \n Result:\n "
925+ " \" txid\" (string) The transaction id.\n "
926+ " \n Examples:\n "
927+ + HelpExampleCli (" protx_revoke" , " ...!TODO..." )
928+ );
929+ }
930+ CheckEvoUpgradeEnforcement ();
931+
932+ EnsureWalletIsUnlocked (pwallet);
933+ // Make sure the results are valid at least up to the most recent block
934+ // the user could have gotten from another RPC command prior to now
935+ pwallet->BlockUntilSyncedToCurrentChain ();
936+
937+ ProUpRevPL pl;
938+ pl.nVersion = ProUpServPL::CURRENT_VERSION;
939+ pl.proTxHash = ParseHashV (request.params [0 ], " proTxHash" );
940+
941+ auto dmn = deterministicMNManager->GetListAtChainTip ().GetMN (pl.proTxHash );
942+ if (!dmn) {
943+ throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" masternode with hash %s not found" , pl.proTxHash .ToString ()));
944+ }
945+
946+ const std::string& strOpKey = request.params .size () > 1 ? request.params [1 ].get_str () : " " ;
947+ const CKey& operatorKey = strOpKey.empty () ? GetKeyFromWallet (pwallet, dmn->pdmnState ->keyIDOperator )
948+ : ParsePrivKey (pwallet, strOpKey, false );
949+
950+ pl.nReason = ProUpRevPL::RevocationReason::REASON_NOT_SPECIFIED;
951+ if (request.params .size () > 2 ) {
952+ int nReason = request.params [2 ].get_int ();
953+ if (nReason < 0 || nReason > ProUpRevPL::RevocationReason::REASON_LAST) {
954+ throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" invalid reason %d, must be between 0 and %d" ,
955+ nReason, ProUpRevPL::RevocationReason::REASON_LAST));
956+ }
957+ pl.nReason = (uint16_t )nReason;
958+ }
959+
960+ CMutableTransaction tx;
961+ tx.nVersion = CTransaction::TxVersion::SAPLING;
962+ tx.nType = CTransaction::TxType::PROUPREV;
963+
964+ // make sure fee calculation works
965+ pl.vchSig .resize (CPubKey::COMPACT_SIGNATURE_SIZE);
966+ FundSpecialTx (pwallet, tx, pl);
967+ SignSpecialTxPayloadByHash (tx, pl, operatorKey);
968+
969+ return SignAndSendSpecialTx (pwallet, tx, pl);
970+ }
899971#endif
900972
901973static const CRPCCommand commands[] =
@@ -907,6 +979,7 @@ static const CRPCCommand commands[] =
907979 { " evo" , " protx_register_fund" , &protx_register_fund, true , {" collateralAddress" ," ipAndPort" ," ownerAddress" ," operatorAddress" ," votingAddress" ," payoutAddress" ," operatorReward" ," operatorPayoutAddress" } },
908980 { " evo" , " protx_register_prepare" , &protx_register_prepare, true , {" collateralHash" ," collateralIndex" ," ipAndPort" ," ownerAddress" ," operatorAddress" ," votingAddress" ," payoutAddress" ," operatorReward" ," operatorPayoutAddress" } },
909981 { " evo" , " protx_register_submit" , &protx_register_submit, true , {" tx" ," sig" } },
982+ { " evo" , " protx_revoke" , &protx_revoke, true , {" proTxHash" ," operatorKey" ," reason" } },
910983 { " evo" , " protx_update_registrar" , &protx_update_registrar, true , {" proTxHash" ," operatorAddress" ," votingAddress" ," payoutAddress" ," ownerKey" } },
911984 { " evo" , " protx_update_service" , &protx_update_service, true , {" proTxHash" ," ipAndPort" ," operatorPayoutAddress" ," operatorKey" } },
912985#endif // ENABLE_WALLET
0 commit comments