@@ -263,9 +263,9 @@ Value signmnbroadcast(const Array& params, bool fHelp)
263263
264264Value setupmasternode (const Array& params, bool fHelp )
265265{
266- if (fHelp || params.size () < 5 || params.size () > 6 )
266+ if (fHelp || params.size () < 5 || params.size () > 7 )
267267 throw std::runtime_error (
268- " setupmasternode alias txhash outputIndex collateralPubKey ip_address\n "
268+ " setupmasternode alias txhash outputIndex collateralPubKey ip_address (reward_address) \n "
269269 " \n Starts escrows funds for some purpose.\n "
270270
271271 " \n Arguments:\n "
@@ -274,6 +274,7 @@ Value setupmasternode(const Array& params, bool fHelp)
274274 " 3. outputIndex (string, required) Output index transaction. \n "
275275 " 4. collateralPubkey (string, required) collateral pubkey. \n "
276276 " 5. ip_address (string, required) Local ip address of this node\n "
277+ " 6. reward_address (string, optional) A custom reward address, defaults to the collateral address\n "
277278 " \n Result:\n "
278279 " \" protocol_version\" (string) Protocol version used for serialization.\n "
279280 " \" message_to_sign\" (string) Hex-encoded msg requiring collateral signature.\n "
@@ -307,7 +308,7 @@ Value setupmasternode(const Array& params, bool fHelp)
307308 if (ipAndPort.find (' :' ) == std::string::npos)
308309 ipAndPort += " :" + std::to_string (Params ().GetDefaultPort ());
309310
310- CMasternodeConfig::CMasternodeEntry config (alias,ipAndPort," " ,txHash,outputIndex, " " );
311+ CMasternodeConfig::CMasternodeEntry config (alias,ipAndPort," " ,txHash,outputIndex);
311312
312313 CMasternodeBroadcast mnb;
313314 std::string errorMsg;
@@ -316,6 +317,17 @@ Value setupmasternode(const Array& params, bool fHelp)
316317 throw JSONRPCError (RPC_INVALID_PARAMS,errorMsg);
317318 }
318319
320+ /* If we have a custom reward address, override the one from the broadcast.
321+ This is fine, as it would only invalidate the broadcast signature and
322+ the broadcast created is not yet signed anyway. */
323+ if (params.size () >= 6 && !params[5 ].get_str ().empty ())
324+ {
325+ const CBitcoinAddress addr (params[5 ].get_str ());
326+ if (!addr.IsValid ())
327+ throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, " Invalid reward address" );
328+ mnb.rewardScript = GetScriptForDestination (addr.Get ());
329+ }
330+
319331 CDataStream ss (SER_NETWORK,PROTOCOL_VERSION);
320332 result.push_back (Pair (" protocol_version" , PROTOCOL_VERSION ));
321333 result.push_back (Pair (" message_to_sign" , HexStr (mnb.getMessageToSign ()) ));
0 commit comments