adds rpc calls for setprivatesendrounds
and setprivatesendamount
(#2230)
* adds rpc calls for `setprivatesendrounds` and `setprivatesendamount` * tabs -> spaces * @gladcow change request * Whops tab -> spaces * @Udjin changes, not the CAmount -> int * int stuff * Throw error when rounds / amount isn't within range
This commit is contained in:
parent
2e06f8133f
commit
98ed90cbb4
@ -139,6 +139,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "setban", 3, "absolute" },
|
{ "setban", 3, "absolute" },
|
||||||
{ "setbip69enabled", 0, "enabled" },
|
{ "setbip69enabled", 0, "enabled" },
|
||||||
{ "setnetworkactive", 0, "state" },
|
{ "setnetworkactive", 0, "state" },
|
||||||
|
{ "setprivatesendrounds", 0, "rounds" },
|
||||||
|
{ "setprivatesendamount", 0, "amount" },
|
||||||
{ "getmempoolancestors", 1, "verbose" },
|
{ "getmempoolancestors", 1, "verbose" },
|
||||||
{ "getmempooldescendants", 1, "verbose" },
|
{ "getmempooldescendants", 1, "verbose" },
|
||||||
{ "spork", 1, "value" },
|
{ "spork", 1, "value" },
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "wallet.h"
|
#include "wallet.h"
|
||||||
#include "walletdb.h"
|
#include "walletdb.h"
|
||||||
#include "keepass.h"
|
#include "keepass.h"
|
||||||
|
#include "privatesend-client.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -2364,6 +2365,60 @@ UniValue settxfee(const JSONRPCRequest& request)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UniValue setprivatesendrounds(const JSONRPCRequest& request)
|
||||||
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
|
if (request.fHelp || request.params.size() != 1)
|
||||||
|
throw std::runtime_error(
|
||||||
|
"setprivatesendrounds rounds\n"
|
||||||
|
"\nSet the number of rounds for PrivateSend mixing.\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. rounds (numeric, required) The default number of rounds is " + std::to_string(DEFAULT_PRIVATESEND_ROUNDS) +
|
||||||
|
" Cannot be more than " + std::to_string(MAX_PRIVATESEND_ROUNDS) + " nor less than " + std::to_string(MIN_PRIVATESEND_ROUNDS) +
|
||||||
|
"\nExamples:\n"
|
||||||
|
+ HelpExampleCli("setprivatesendrounds", "4")
|
||||||
|
+ HelpExampleRpc("setprivatesendrounds", "16")
|
||||||
|
);
|
||||||
|
|
||||||
|
int nRounds = request.params[0].get_int();
|
||||||
|
|
||||||
|
if (nRounds > MAX_PRIVATESEND_ROUNDS || nRounds < MIN_PRIVATESEND_ROUNDS)
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid number of rounds");
|
||||||
|
|
||||||
|
privateSendClient.nPrivateSendRounds = nRounds;
|
||||||
|
|
||||||
|
return NullUniValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
UniValue setprivatesendamount(const JSONRPCRequest& request)
|
||||||
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
|
if (request.fHelp || request.params.size() != 1)
|
||||||
|
throw std::runtime_error(
|
||||||
|
"setprivatesendamount amount\n"
|
||||||
|
"\nSet the goal amount in " + CURRENCY_UNIT + " for PrivateSend mixing.\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"1. amount (numeric, required) The default amount is " + std::to_string(DEFAULT_PRIVATESEND_AMOUNT) +
|
||||||
|
" Cannot be more than " + std::to_string(MAX_PRIVATESEND_AMOUNT) + " nor less than " + std::to_string(MIN_PRIVATESEND_AMOUNT) +
|
||||||
|
"\nExamples:\n"
|
||||||
|
+ HelpExampleCli("setprivatesendamount", "500")
|
||||||
|
+ HelpExampleRpc("setprivatesendamount", "208")
|
||||||
|
);
|
||||||
|
|
||||||
|
int nAmount = request.params[0].get_int();
|
||||||
|
|
||||||
|
if (nAmount > MAX_PRIVATESEND_AMOUNT || nAmount < MIN_PRIVATESEND_AMOUNT)
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount of " + CURRENCY_UNIT + " as mixing goal amount");
|
||||||
|
|
||||||
|
privateSendClient.nPrivateSendAmount = nAmount;
|
||||||
|
|
||||||
|
return NullUniValue;
|
||||||
|
}
|
||||||
|
|
||||||
UniValue getwalletinfo(const JSONRPCRequest& request)
|
UniValue getwalletinfo(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
if (!EnsureWalletIsAvailable(request.fHelp))
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
@ -2887,6 +2942,8 @@ static const CRPCCommand commands[] =
|
|||||||
{ "wallet", "sendtoaddress", &sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} },
|
{ "wallet", "sendtoaddress", &sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} },
|
||||||
{ "wallet", "setaccount", &setaccount, true, {"address","account"} },
|
{ "wallet", "setaccount", &setaccount, true, {"address","account"} },
|
||||||
{ "wallet", "settxfee", &settxfee, true, {"amount"} },
|
{ "wallet", "settxfee", &settxfee, true, {"amount"} },
|
||||||
|
{ "wallet", "setprivatesendrounds", &setprivatesendrounds, true, {"rounds"} },
|
||||||
|
{ "wallet", "setprivatesendamount", &setprivatesendamount, true, {"amount"} },
|
||||||
{ "wallet", "signmessage", &signmessage, true, {"address","message"} },
|
{ "wallet", "signmessage", &signmessage, true, {"address","message"} },
|
||||||
{ "wallet", "walletlock", &walletlock, true, {} },
|
{ "wallet", "walletlock", &walletlock, true, {} },
|
||||||
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} },
|
{ "wallet", "walletpassphrasechange", &walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} },
|
||||||
|
Loading…
Reference in New Issue
Block a user