std::string HelpRequiringPassphrase()
{
return pwalletMain->IsCrypted()
- ? "\nrequires wallet passphrase to be set with walletpassphrase first"
+ ? "\n\nRequires wallet passphrase to be set with walletpassphrase first"
: "";
}
+static void accountingAllowed()
+{
+ if (!GetBoolArg("-accounts", false))
+ throw runtime_error(
+ "Accounting API is deprecated and its removal is planned in the future.\n"
+ "It can easily result in negative or odd balances if misused or misunderstood.\n"
+ "If you still want to enable it then add accounts=1 to your options.\n");
+}
+
void EnsureWalletIsUnlocked()
{
if (pwalletMain->IsLocked())
"getaccountaddress <account>\n"
"Returns the current NovaCoin address for receiving payments to this account.");
+ // Deprecation check
+ accountingAllowed();
+
// Parse the account first so we don't generate a key if there's an error
string strAccount = AccountFromValue(params[0]);
"getreceivedbyaccount <account> [minconf=1]\n"
"Returns the total amount received by addresses with <account> in transactions with at least [minconf] confirmations.");
+ // Deprecation check
+ accountingAllowed();
+
// Minimum confirmations
int nMinDepth = 1;
if (params.size() > 1)
return ValueFromAmount(nBalance);
}
+ // Deprecation check
+ accountingAllowed();
+
string strAccount = AccountFromValue(params[0]);
int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, filter);
"move <fromaccount> <toaccount> <amount> [minconf=1] [comment]\n"
"Move from one account in your wallet to another.");
+ // Deprecation check
+ accountingAllowed();
+
string strFrom = AccountFromValue(params[0]);
string strTo = AccountFromValue(params[1]);
int64_t nAmount = AmountFromValue(params[2]);
"<amount> is a real and is rounded to the nearest " + FormatMoney(MIN_TXOUT_AMOUNT)
+ HelpRequiringPassphrase());
+ // Deprecation check
+ accountingAllowed();
+
string strAccount = AccountFromValue(params[0]);
CBitcoinAddress address(params[1].get_str());
if (!address.IsValid())
"amounts are double-precision floating point numbers"
+ HelpRequiringPassphrase());
+ // Deprecation check
+ accountingAllowed();
+
string strAccount = AccountFromValue(params[0]);
Object sendTo = params[1].get_obj();
int nMinDepth = 1;
EnsureWalletIsUnlocked();
- // Check funds
- int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
- if (totalAmount > nBalance)
- throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
+ if (GetBoolArg("-accounts", false))
+ {
+ // Check funds
+ int64_t nBalance = GetAccountBalance(strAccount, nMinDepth, MINE_SPENDABLE);
+ if (totalAmount > nBalance)
+ throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds");
+ }
// Send
CReserveKey keyChange(pwalletMain);
" \"amount\" : total amount received by addresses with this account\n"
" \"confirmations\" : number of confirmations of the most recent transaction included");
+ // Deprecation check
+ accountingAllowed();
+
return ListReceived(params, true);
}
"listaccounts [minconf=1]\n"
"Returns Object that has account names as keys, account balances as values.");
+ // Deprecation check
+ accountingAllowed();
+
int nMinDepth = 1;
if (params.size() > 0)
nMinDepth = params[0].get_int();
if (fHelp || params.size() > 1)
throw runtime_error(
"keypoolrefill [new-size]\n"
- "Fills the keypool."
+ "Fills the keypool.\n"
+ "IMPORTANT: Any previous backups you have made of your wallet file "
+ "should be replaced with the newly generated one."
+ HelpRequiringPassphrase());
unsigned int nSize = max<unsigned int>(GetArg("-keypool", 100), 0);
return Value::null;
}
+Value keypoolreset(const Array& params, bool fHelp)
+{
+ if (fHelp || params.size() > 1)
+ throw runtime_error(
+ "keypoolreset [new-size]\n"
+ "Resets the keypool.\n"
+ "IMPORTANT: Any previous backups you have made of your wallet file "
+ "should be replaced with the newly generated one."
+ + HelpRequiringPassphrase());
+
+ unsigned int nSize = max<unsigned int>(GetArg("-keypool", 100), 0);
+ if (params.size() > 0) {
+ if (params[0].get_int() < 0)
+ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size");
+ nSize = (unsigned int) params[0].get_int();
+ }
+
+ EnsureWalletIsUnlocked();
+
+ pwalletMain->NewKeyPool(nSize);
+
+ if (pwalletMain->GetKeyPoolSize() < nSize)
+ throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
+
+ return Value::null;
+}
+
void ThreadTopUpKeyPool(void* parg)
{