@@ -173,7 +173,7 @@ static UniValue getnetworkhashps(const JSONRPCRequest& request)
173
173
" \n Arguments:\n "
174
174
" 1. nblocks (numeric, optional, default=120) The number of blocks, or -1 for blocks since last difficulty change.\n "
175
175
" 2. height (numeric, optional, default=-1) To estimate at the time of the given height.\n "
176
- " 3. algo (numeric , optional, default=" +GetMiningType (GetMiningAlgorithm (), false , false )+" ) Algo to calculate [randomx, sha256d, progpow, xr16t, PoS].\n "
176
+ " 3. algo (string , optional, default=" +GetMiningType (GetMiningAlgorithm (), false , false )+" ) Algo to calculate [randomx, sha256d, progpow, xr16t, PoS].\n "
177
177
" \n Result:\n "
178
178
" x (numeric) Hashes per second estimated\n "
179
179
" \n Examples:\n "
@@ -346,6 +346,7 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
346
346
" \" blocks\" : nnn, (numeric) The current block\n "
347
347
" \" currentblockweight\" : nnn, (numeric) The last block weight\n "
348
348
" \" currentblocktx\" : nnn, (numeric) The last block transaction\n "
349
+ " \" algorithm\" : \" xxxx\" , (string) Algorithm set to mine (progpow, randomx, sha256d)\n "
349
350
" \" difficulty\" : xxx.xxxxx (numeric) The current difficulty\n "
350
351
" \" networkhashps\" : nnn, (numeric) The network hashes per second\n "
351
352
" \" pooledtx\" : n (numeric) The size of the mempool\n "
@@ -384,6 +385,39 @@ static UniValue getmininginfo(const JSONRPCRequest& request)
384
385
return obj;
385
386
}
386
387
388
+ static UniValue setminingalgo (const JSONRPCRequest& request)
389
+ {
390
+ if (request.fHelp || request.params .size () != 1 )
391
+ throw std::runtime_error (
392
+ " setminingalgo algorithm\n "
393
+ " \n Changes your mining algorithm to [algorithm]. Note that mining must be turned off when command is used.\n "
394
+ " \n Arguments:\n "
395
+ " 1. algorithm (string, required) Algorithm to mine [progpow, randomx, sha256d].\n "
396
+ " \n Result:\n "
397
+ " {\n "
398
+ " \" success\" : true|false, (boolean) Status of the switch\n "
399
+ " \" message\" : \" text\" , (text) Informational message about the switch\n "
400
+ " }\n "
401
+ " \n Examples:\n "
402
+ + HelpExampleCli (" setminingalgo" , " sha256d" )
403
+ + HelpExampleRpc (" setminingalgo" , " sha256d" )
404
+ );
405
+
406
+ if (GenerateActive ())
407
+ throw JSONRPCError (RPC_INVALID_PARAMETER, " mining must be stopped to change algorithm" );
408
+
409
+ std::string sOldAlgo = GetMiningType (GetMiningAlgorithm (), false , false );
410
+ std::string sNewAlgo = request.params [0 ].get_str ();
411
+ // Check if it's a mining algorithm
412
+ if (!SetMiningAlgorithm (sNewAlgo )) {
413
+ throw JSONRPCError (RPC_INVALID_PARAMETER, strprintf (" %s is not a supported mining type" , sNewAlgo ));
414
+ }
415
+ UniValue result (UniValue::VOBJ);
416
+ result.pushKV (" success" , true );
417
+ result.pushKV (" message" , strprintf (" Mining algorithm changed from %s to %s" , sOldAlgo , sNewAlgo ));
418
+ return result;
419
+
420
+ }
387
421
388
422
// NOTE: Unlike wallet RPC (which use VEIL values), mining RPCs follow GBT (BIP 22) in using satoshi amounts
389
423
static UniValue prioritisetransaction (const JSONRPCRequest& request)
@@ -1246,20 +1280,19 @@ static UniValue estimaterawfee(const JSONRPCRequest& request)
1246
1280
static const CRPCCommand commands[] =
1247
1281
{ // category name actor (function) argNames
1248
1282
// --------------------- ------------------------ ----------------------- ----------
1249
- { " mining" , " getnetworkhashps " , &getnetworkhashps , {" nblocks " , " height " , " algo " } },
1283
+ { " mining" , " getblocktemplate " , &getblocktemplate , {" template_request " } },
1250
1284
{ " mining" , " getmininginfo" , &getmininginfo, {} },
1285
+ { " mining" , " getnetworkhashps" , &getnetworkhashps, {" nblocks" ," height" ," algo" } },
1251
1286
{ " mining" , " prioritisetransaction" , &prioritisetransaction, {" txid" ," dummy" ," fee_delta" } },
1252
- { " mining" , " getblocktemplate" , &getblocktemplate, {" template_request" } },
1253
- { " mining" , " submitblock" , &submitblock, {" hexdata" ," dummy" } },
1254
1287
{ " mining" , " pprpcsb" , &pprpcsb, {" header_hash" , " mix_hash" , " nonce" } },
1255
-
1288
+ { " mining" , " setminingalgo" , &setminingalgo, {" algo" } },
1289
+ { " mining" , " submitblock" , &submitblock, {" hexdata" ," dummy" } },
1256
1290
1257
1291
{ " generating" , " generatetoaddress" , &generatetoaddress, {" nblocks" ," address" ," maxtries" } },
1258
- { " hidden" , " estimatefee" , &estimatefee, {} },
1259
-
1260
- { " util" , " estimatesmartfee" , &estimatesmartfee, {" conf_target" , " estimate_mode" } },
1261
1292
1293
+ { " hidden" , " estimatefee" , &estimatefee, {} },
1262
1294
{ " hidden" , " estimaterawfee" , &estimaterawfee, {" conf_target" , " threshold" } },
1295
+ { " util" , " estimatesmartfee" , &estimatesmartfee, {" conf_target" , " estimate_mode" } },
1263
1296
};
1264
1297
1265
1298
void RegisterMiningRPCCommands (CRPCTable &t)
0 commit comments