Skip to content

Commit 64a913d

Browse files
UdjinM6codablock
andauthored
Allow empty strings in protx update_registrar as an option to re-use current values (#3177)
* Allow empty strings in `protx update_registrar` as an option to re-use current values * Update src/rpc/rpcevo.cpp Co-Authored-By: Alexander Block <ablock84@gmail.com>
1 parent 3c21d25 commit 64a913d

File tree

1 file changed

+42
-22
lines changed

1 file changed

+42
-22
lines changed

src/rpc/rpcevo.cpp

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,15 @@ std::string GetHelpString(int nParamNum, std::string strParamName)
6666
" Only allowed when the ProRegTx had a non-zero operatorReward value.\n"
6767
" If set to an empty string, the currently active payout address is reused.\n"
6868
},
69-
{"operatorPubKey",
69+
{"operatorPubKey_register",
7070
"%d. \"operatorPubKey\" (string, required) The operator BLS public key. The private key does not have to be known.\n"
7171
" It has to match the private key which is later used when operating the masternode.\n"
7272
},
73+
{"operatorPubKey_update",
74+
"%d. \"operatorPubKey\" (string, required) The operator BLS public key. The private key does not have to be known.\n"
75+
" It has to match the private key which is later used when operating the masternode.\n"
76+
" If set to an empty string, the currently active operator BLS public key is reused.\n"
77+
},
7378
{"operatorReward",
7479
"%d. \"operatorReward\" (numeric, required) The fraction in %% to share with the operator. The value must be\n"
7580
" between 0.00 and 100.00.\n"
@@ -79,20 +84,29 @@ std::string GetHelpString(int nParamNum, std::string strParamName)
7984
" The private key belonging to this address must be known in your wallet. The address must\n"
8085
" be unused and must differ from the collateralAddress\n"
8186
},
82-
{"payoutAddress",
87+
{"payoutAddress_register",
8388
"%d. \"payoutAddress\" (string, required) The dash address to use for masternode reward payments.\n"
8489
},
90+
{"payoutAddress_update",
91+
"%d. \"payoutAddress\" (string, required) The dash address to use for masternode reward payments.\n"
92+
" If set to an empty string, the currently active payout address is reused.\n"
93+
},
8594
{"proTxHash",
8695
"%d. \"proTxHash\" (string, required) The hash of the initial ProRegTx.\n"
8796
},
8897
{"reason",
8998
"%d. reason (numeric, optional) The reason for masternode service revocation.\n"
9099
},
91-
{"votingAddress",
100+
{"votingAddress_register",
92101
"%d. \"votingAddress\" (string, required) The voting key address. The private key does not have to be known by your wallet.\n"
93102
" It has to match the private key which is later used when voting on proposals.\n"
94103
" If set to an empty string, ownerAddress will be used.\n"
95104
},
105+
{"votingAddress_update",
106+
"%d. \"votingAddress\" (string, required) The voting key address. The private key does not have to be known by your wallet.\n"
107+
" It has to match the private key which is later used when voting on proposals.\n"
108+
" If set to an empty string, the currently active voting key address is reused.\n"
109+
},
96110
};
97111

98112
auto it = mapParamHelp.find(strParamName);
@@ -304,10 +318,10 @@ void protx_register_fund_help(CWallet* const pwallet)
304318
+ GetHelpString(1, "collateralAddress")
305319
+ GetHelpString(2, "ipAndPort")
306320
+ GetHelpString(3, "ownerAddress")
307-
+ GetHelpString(4, "operatorPubKey")
308-
+ GetHelpString(5, "votingAddress")
321+
+ GetHelpString(4, "operatorPubKey_register")
322+
+ GetHelpString(5, "votingAddress_register")
309323
+ GetHelpString(6, "operatorReward")
310-
+ GetHelpString(7, "payoutAddress")
324+
+ GetHelpString(7, "payoutAddress_register")
311325
+ GetHelpString(8, "fundAddress") +
312326
"\nResult:\n"
313327
"\"txid\" (string) The transaction id.\n"
@@ -329,10 +343,10 @@ void protx_register_help(CWallet* const pwallet)
329343
+ GetHelpString(2, "collateralIndex")
330344
+ GetHelpString(3, "ipAndPort")
331345
+ GetHelpString(4, "ownerAddress")
332-
+ GetHelpString(5, "operatorPubKey")
333-
+ GetHelpString(6, "votingAddress")
346+
+ GetHelpString(5, "operatorPubKey_register")
347+
+ GetHelpString(6, "votingAddress_register")
334348
+ GetHelpString(7, "operatorReward")
335-
+ GetHelpString(8, "payoutAddress")
349+
+ GetHelpString(8, "payoutAddress_register")
336350
+ GetHelpString(9, "feeSourceAddress") +
337351
"\nResult:\n"
338352
"\"txid\" (string) The transaction id.\n"
@@ -353,10 +367,10 @@ void protx_register_prepare_help()
353367
+ GetHelpString(2, "collateralIndex")
354368
+ GetHelpString(3, "ipAndPort")
355369
+ GetHelpString(4, "ownerAddress")
356-
+ GetHelpString(5, "operatorPubKey")
357-
+ GetHelpString(6, "votingAddress")
370+
+ GetHelpString(5, "operatorPubKey_register")
371+
+ GetHelpString(6, "votingAddress_register")
358372
+ GetHelpString(7, "operatorReward")
359-
+ GetHelpString(8, "payoutAddress")
373+
+ GetHelpString(8, "payoutAddress_register")
360374
+ GetHelpString(9, "feeSourceAddress") +
361375
"\nResult:\n"
362376
"{ (json object)\n"
@@ -682,9 +696,9 @@ void protx_update_registrar_help(CWallet* const pwallet)
682696
+ HelpRequiringPassphrase(pwallet) + "\n"
683697
"\nArguments:\n"
684698
+ GetHelpString(1, "proTxHash")
685-
+ GetHelpString(2, "operatorPubKey")
686-
+ GetHelpString(3, "votingAddress")
687-
+ GetHelpString(4, "payoutAddress")
699+
+ GetHelpString(2, "operatorPubKey_update")
700+
+ GetHelpString(3, "votingAddress_update")
701+
+ GetHelpString(4, "payoutAddress_update")
688702
+ GetHelpString(5, "feeSourceAddress") +
689703
"\nResult:\n"
690704
"\"txid\" (string) The transaction id.\n"
@@ -724,11 +738,16 @@ UniValue protx_update_registrar(const JSONRPCRequest& request)
724738
ptx.keyIDVoting = ParsePubKeyIDFromAddress(request.params[3].get_str(), "voting address");
725739
}
726740

727-
CBitcoinAddress payoutAddress(request.params[4].get_str());
728-
if (!payoutAddress.IsValid()) {
729-
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("invalid payout address: %s", request.params[4].get_str()));
741+
CTxDestination payoutDest;
742+
ExtractDestination(ptx.scriptPayout, payoutDest);
743+
if (request.params[4].get_str() != "") {
744+
CBitcoinAddress payoutAddress(request.params[4].get_str());
745+
if (!payoutAddress.IsValid()) {
746+
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("invalid payout address: %s", request.params[4].get_str()));
747+
}
748+
payoutDest = payoutAddress.Get();
749+
ptx.scriptPayout = GetScriptForDestination(payoutDest);
730750
}
731-
ptx.scriptPayout = GetScriptForDestination(payoutAddress.Get());
732751

733752
CKey keyOwner;
734753
if (!pwallet->GetKey(dmn->pdmnState->keyIDOwner, keyOwner)) {
@@ -742,14 +761,15 @@ UniValue protx_update_registrar(const JSONRPCRequest& request)
742761
// make sure we get anough fees added
743762
ptx.vchSig.resize(65);
744763

745-
CBitcoinAddress feeSourceAddress = payoutAddress;
764+
CTxDestination feeSourceDest = payoutDest;
746765
if (request.params.size() > 5) {
747-
feeSourceAddress = CBitcoinAddress(request.params[5].get_str());
766+
CBitcoinAddress feeSourceAddress = CBitcoinAddress(request.params[5].get_str());
748767
if (!feeSourceAddress.IsValid())
749768
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Dash address: ") + request.params[5].get_str());
769+
feeSourceDest = feeSourceAddress.Get();
750770
}
751771

752-
FundSpecialTx(pwallet, tx, ptx, feeSourceAddress.Get());
772+
FundSpecialTx(pwallet, tx, ptx, feeSourceDest);
753773
SignSpecialTxPayloadByHash(tx, ptx, keyOwner);
754774
SetTxPayload(tx, ptx);
755775

0 commit comments

Comments
 (0)