mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 05:49:11 +01:00
RPC: more EnsureWalletIsAvailable in Dash-specific code
This commit is contained in:
parent
d75d4842ae
commit
70e47f11a0
@ -24,6 +24,8 @@
|
|||||||
#include "wallet/wallet.h"
|
#include "wallet/wallet.h"
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
|
|
||||||
|
bool EnsureWalletIsAvailable(bool avoidException);
|
||||||
|
|
||||||
UniValue gobject(const JSONRPCRequest& request)
|
UniValue gobject(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
std::string strCommand;
|
std::string strCommand;
|
||||||
@ -125,6 +127,9 @@ UniValue gobject(const JSONRPCRequest& request)
|
|||||||
// PREPARE THE GOVERNANCE OBJECT BY CREATING A COLLATERAL TRANSACTION
|
// PREPARE THE GOVERNANCE OBJECT BY CREATING A COLLATERAL TRANSACTION
|
||||||
if(strCommand == "prepare")
|
if(strCommand == "prepare")
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
if (request.params.size() != 5) {
|
if (request.params.size() != 5) {
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject prepare <parent-hash> <revision> <time> <data-hex>'");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject prepare <parent-hash> <revision> <time> <data-hex>'");
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,16 @@
|
|||||||
|
|
||||||
UniValue masternodelist(const JSONRPCRequest& request);
|
UniValue masternodelist(const JSONRPCRequest& request);
|
||||||
|
|
||||||
|
bool EnsureWalletIsAvailable(bool avoidException);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
void EnsureWalletIsUnlocked();
|
void EnsureWalletIsUnlocked();
|
||||||
|
|
||||||
UniValue privatesend(const JSONRPCRequest& request)
|
UniValue privatesend(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
if (request.fHelp || request.params.size() != 1)
|
if (request.fHelp || request.params.size() != 1)
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"privatesend \"command\"\n"
|
"privatesend \"command\"\n"
|
||||||
@ -254,6 +259,9 @@ UniValue masternode(const JSONRPCRequest& request)
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (strCommand == "start-alias")
|
if (strCommand == "start-alias")
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
if (request.params.size() < 2)
|
if (request.params.size() < 2)
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Please specify an alias");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Please specify an alias");
|
||||||
|
|
||||||
@ -303,6 +311,9 @@ UniValue masternode(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
if (strCommand == "start-all" || strCommand == "start-missing" || strCommand == "start-disabled")
|
if (strCommand == "start-all" || strCommand == "start-missing" || strCommand == "start-disabled")
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(pwalletMain->cs_wallet);
|
LOCK(pwalletMain->cs_wallet);
|
||||||
EnsureWalletIsUnlocked();
|
EnsureWalletIsUnlocked();
|
||||||
@ -393,6 +404,9 @@ UniValue masternode(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (strCommand == "outputs") {
|
if (strCommand == "outputs") {
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
// Find possible candidates
|
// Find possible candidates
|
||||||
std::vector<COutput> vPossibleCoins;
|
std::vector<COutput> vPossibleCoins;
|
||||||
pwalletMain->AvailableCoins(vPossibleCoins, true, NULL, false, ONLY_1000);
|
pwalletMain->AvailableCoins(vPossibleCoins, true, NULL, false, ONLY_1000);
|
||||||
@ -646,6 +660,9 @@ UniValue masternodebroadcast(const JSONRPCRequest& request)
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
if (strCommand == "create-alias")
|
if (strCommand == "create-alias")
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
// wait for reindex and/or import to finish
|
// wait for reindex and/or import to finish
|
||||||
if (fImporting || fReindex)
|
if (fImporting || fReindex)
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish");
|
||||||
@ -698,6 +715,9 @@ UniValue masternodebroadcast(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
if (strCommand == "create-all")
|
if (strCommand == "create-all")
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
// wait for reindex and/or import to finish
|
// wait for reindex and/or import to finish
|
||||||
if (fImporting || fReindex)
|
if (fImporting || fReindex)
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish");
|
||||||
|
@ -2406,7 +2406,11 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue keepass(const JSONRPCRequest& request) {
|
UniValue keepass(const JSONRPCRequest& request)
|
||||||
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
std::string strCommand;
|
std::string strCommand;
|
||||||
|
|
||||||
if (request.params.size() >= 1)
|
if (request.params.size() >= 1)
|
||||||
@ -2453,7 +2457,6 @@ UniValue keepass(const JSONRPCRequest& request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "Invalid command";
|
return "Invalid command";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue resendwallettransactions(const JSONRPCRequest& request)
|
UniValue resendwallettransactions(const JSONRPCRequest& request)
|
||||||
@ -2767,6 +2770,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
UniValue setbip69enabled(const JSONRPCRequest& request)
|
UniValue setbip69enabled(const JSONRPCRequest& request)
|
||||||
{
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(request.fHelp))
|
||||||
|
return NullUniValue;
|
||||||
|
|
||||||
if (request.fHelp || request.params.size() != 1)
|
if (request.fHelp || request.params.size() != 1)
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"setbip69enabled enable\n"
|
"setbip69enabled enable\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user