Add RPC call reservebalance
This commit is contained in:
@@ -2095,6 +2095,43 @@ UniValue encryptwallet(const UniValue& params, bool fHelp)
|
||||
return "wallet encrypted; Blackcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.";
|
||||
}
|
||||
|
||||
UniValue reservebalance(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() > 2)
|
||||
throw runtime_error(
|
||||
"reservebalance [<reserve> [amount]]\n"
|
||||
"<reserve> is true or false to turn balance reserve on or off.\n"
|
||||
"<amount> is a real and rounded to cent.\n"
|
||||
"Set reserve amount not participating in network protection.\n"
|
||||
"If no parameters provided current setting is printed.\n");
|
||||
|
||||
if (params.size() > 0)
|
||||
{
|
||||
bool fReserve = params[0].get_bool();
|
||||
if (fReserve)
|
||||
{
|
||||
if (params.size() == 1)
|
||||
throw runtime_error("must provide amount to reserve balance.\n");
|
||||
int64_t nAmount = AmountFromValue(params[1]);
|
||||
nAmount = (nAmount / CENT) * CENT; // round to cent
|
||||
if (nAmount < 0)
|
||||
throw runtime_error("amount cannot be negative.\n");
|
||||
nReserveBalance = nAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (params.size() > 1)
|
||||
throw runtime_error("cannot specify amount to turn off reserve.\n");
|
||||
nReserveBalance = 0;
|
||||
}
|
||||
}
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
result.push_back(Pair("reserve", (nReserveBalance > 0)));
|
||||
result.push_back(Pair("amount", ValueFromAmount(nReserveBalance)));
|
||||
return result;
|
||||
}
|
||||
|
||||
UniValue lockunspent(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (!EnsureWalletIsAvailable(fHelp))
|
||||
@@ -2621,6 +2658,7 @@ static const CRPCCommand commands[] =
|
||||
{ "wallet", "listunspent", &listunspent, false },
|
||||
{ "wallet", "lockunspent", &lockunspent, true },
|
||||
{ "wallet", "move", &movecmd, false },
|
||||
{ "wallet", "reservebalance", &reservebalance, false },
|
||||
{ "wallet", "sendfrom", &sendfrom, false },
|
||||
{ "wallet", "sendmany", &sendmany, false },
|
||||
{ "wallet", "sendtoaddress", &sendtoaddress, false },
|
||||
|
||||
Reference in New Issue
Block a user