Browse Source

Refactor: Remove using namespace <xxx> from wallet/

pull/1/head
Karl-Johan Alm 6 years ago
parent
commit
8a5228197c
No known key found for this signature in database
GPG Key ID: 57AF762DB3353322
  1. 37
      src/wallet/db.cpp
  2. 62
      src/wallet/rpcdump.cpp
  3. 240
      src/wallet/rpcwallet.cpp
  4. 8
      src/wallet/test/wallet_tests.cpp
  5. 198
      src/wallet/wallet.cpp
  6. 74
      src/wallet/walletdb.cpp

37
src/wallet/db.cpp

@ -22,9 +22,6 @@ @@ -22,9 +22,6 @@
#include <boost/thread.hpp>
#include <boost/version.hpp>
using namespace std;
//
// CDB
//
@ -117,7 +114,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn) @@ -117,7 +114,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
void CDBEnv::MakeMock()
{
if (fDbEnvInit)
throw runtime_error("CDBEnv::MakeMock: Already initialized");
throw std::runtime_error("CDBEnv::MakeMock: Already initialized");
boost::this_thread::interruption_point();
@ -140,7 +137,7 @@ void CDBEnv::MakeMock() @@ -140,7 +137,7 @@ void CDBEnv::MakeMock()
DB_PRIVATE,
S_IRUSR | S_IWUSR);
if (ret > 0)
throw runtime_error(strprintf("CDBEnv::MakeMock: Error %d opening database environment.", ret));
throw std::runtime_error(strprintf("CDBEnv::MakeMock: Error %d opening database environment.", ret));
fDbEnvInit = true;
fMockDb = true;
@ -214,7 +211,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco @@ -214,7 +211,7 @@ bool CDB::Recover(const std::string& filename, void *callbackDataIn, bool (*reco
{
CDataStream ssKey(row.first, SER_DISK, CLIENT_VERSION);
CDataStream ssValue(row.second, SER_DISK, CLIENT_VERSION);
string strType, strErr;
std::string strType, strErr;
if (!(*recoverKVcallback)(callbackDataIn, ssKey, ssValue))
continue;
}
@ -301,7 +298,7 @@ bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<C @@ -301,7 +298,7 @@ bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<C
if (fAggressive)
flags |= DB_AGGRESSIVE;
stringstream strDump;
std::stringstream strDump;
Db db(dbenv, 0);
int result = db.verify(strFile.c_str(), NULL, &strDump, flags);
@ -325,7 +322,7 @@ bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<C @@ -325,7 +322,7 @@ bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<C
// ... repeated
// DATA=END
string strLine;
std::string strLine;
while (!strDump.eof() && strLine != HEADER_END)
getline(strDump, strLine); // Skip past header
@ -378,7 +375,7 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose @@ -378,7 +375,7 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose
{
LOCK(bitdb.cs_db);
if (!bitdb.Open(GetDataDir()))
throw runtime_error("CDB: Failed to open database environment.");
throw std::runtime_error("CDB: Failed to open database environment.");
strFile = strFilename;
++bitdb.mapFileUseCount[strFile];
@ -391,7 +388,7 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose @@ -391,7 +388,7 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose
DbMpoolFile* mpf = pdb->get_mpf();
ret = mpf->set_flags(DB_MPOOL_NOFILE, 1);
if (ret != 0)
throw runtime_error(strprintf("CDB: Failed to configure for no temp file backing for database %s", strFile));
throw std::runtime_error(strprintf("CDB: Failed to configure for no temp file backing for database %s", strFile));
}
ret = pdb->open(NULL, // Txn pointer
@ -406,10 +403,10 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose @@ -406,10 +403,10 @@ CDB::CDB(const std::string& strFilename, const char* pszMode, bool fFlushOnClose
pdb = NULL;
--bitdb.mapFileUseCount[strFile];
strFile = "";
throw runtime_error(strprintf("CDB: Error %d, can't open database %s", ret, strFilename));
throw std::runtime_error(strprintf("CDB: Error %d, can't open database %s", ret, strFilename));
}
if (fCreate && !Exists(string("version"))) {
if (fCreate && !Exists(std::string("version"))) {
bool fTmp = fReadOnly;
fReadOnly = false;
WriteVersion(CLIENT_VERSION);
@ -452,7 +449,7 @@ void CDB::Close() @@ -452,7 +449,7 @@ void CDB::Close()
}
}
void CDBEnv::CloseDb(const string& strFile)
void CDBEnv::CloseDb(const std::string& strFile)
{
{
LOCK(cs_db);
@ -466,7 +463,7 @@ void CDBEnv::CloseDb(const string& strFile) @@ -466,7 +463,7 @@ void CDBEnv::CloseDb(const string& strFile)
}
}
bool CDBEnv::RemoveDb(const string& strFile)
bool CDBEnv::RemoveDb(const std::string& strFile)
{
this->CloseDb(strFile);
@ -475,7 +472,7 @@ bool CDBEnv::RemoveDb(const string& strFile) @@ -475,7 +472,7 @@ bool CDBEnv::RemoveDb(const string& strFile)
return (rc == 0);
}
bool CDB::Rewrite(const string& strFile, const char* pszSkip)
bool CDB::Rewrite(const std::string& strFile, const char* pszSkip)
{
while (true) {
{
@ -488,7 +485,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip) @@ -488,7 +485,7 @@ bool CDB::Rewrite(const string& strFile, const char* pszSkip)
bool fSuccess = true;
LogPrintf("CDB::Rewrite: Rewriting %s...\n", strFile);
string strFileRes = strFile + ".rewrite";
std::string strFileRes = strFile + ".rewrite";
{ // surround usage of db with extra {}
CDB db(strFile.c_str(), "r");
Db* pdbCopy = new Db(bitdb.dbenv, 0);
@ -568,9 +565,9 @@ void CDBEnv::Flush(bool fShutdown) @@ -568,9 +565,9 @@ void CDBEnv::Flush(bool fShutdown)
return;
{
LOCK(cs_db);
map<string, int>::iterator mi = mapFileUseCount.begin();
std::map<std::string, int>::iterator mi = mapFileUseCount.begin();
while (mi != mapFileUseCount.end()) {
string strFile = (*mi).first;
std::string strFile = (*mi).first;
int nRefCount = (*mi).second;
LogPrint("db", "CDBEnv::Flush: Flushing %s (refcount = %d)...\n", strFile, nRefCount);
if (nRefCount == 0) {
@ -607,7 +604,7 @@ bool CDB::PeriodicFlush(std::string strFile) @@ -607,7 +604,7 @@ bool CDB::PeriodicFlush(std::string strFile)
{
// Don't do this if any databases are in use
int nRefCount = 0;
map<string, int>::iterator mi = bitdb.mapFileUseCount.begin();
std::map<std::string, int>::iterator mi = bitdb.mapFileUseCount.begin();
while (mi != bitdb.mapFileUseCount.end())
{
nRefCount += (*mi).second;
@ -617,7 +614,7 @@ bool CDB::PeriodicFlush(std::string strFile) @@ -617,7 +614,7 @@ bool CDB::PeriodicFlush(std::string strFile)
if (nRefCount == 0)
{
boost::this_thread::interruption_point();
map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
std::map<std::string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
if (mi != bitdb.mapFileUseCount.end())
{
LogPrint("db", "Flushing %s\n", strFile);

62
src/wallet/rpcdump.cpp

@ -29,8 +29,6 @@ @@ -29,8 +29,6 @@
#include <boost/assign/list_of.hpp>
#include <boost/foreach.hpp>
using namespace std;
std::string static EncodeDumpTime(int64_t nTime) {
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);
}
@ -82,7 +80,7 @@ UniValue importprivkey(const JSONRPCRequest& request) @@ -82,7 +80,7 @@ UniValue importprivkey(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error(
throw std::runtime_error(
"importprivkey \"bitcoinprivkey\" ( \"label\" ) ( rescan )\n"
"\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
"\nArguments:\n"
@ -106,8 +104,8 @@ UniValue importprivkey(const JSONRPCRequest& request) @@ -106,8 +104,8 @@ UniValue importprivkey(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet);
string strSecret = request.params[0].get_str();
string strLabel = "";
std::string strSecret = request.params[0].get_str();
std::string strLabel = "";
if (request.params.size() > 1)
strLabel = request.params[1].get_str();
@ -156,8 +154,8 @@ UniValue importprivkey(const JSONRPCRequest& request) @@ -156,8 +154,8 @@ UniValue importprivkey(const JSONRPCRequest& request)
return NullUniValue;
}
void ImportAddress(CWallet*, const CBitcoinAddress& address, const string& strLabel);
void ImportScript(CWallet * const pwallet, const CScript& script, const string& strLabel, bool isRedeemScript)
void ImportAddress(CWallet*, const CBitcoinAddress& address, const std::string& strLabel);
void ImportScript(CWallet* const pwallet, const CScript& script, const std::string& strLabel, bool isRedeemScript)
{
if (!isRedeemScript && ::IsMine(*pwallet, script) == ISMINE_SPENDABLE) {
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
@ -182,7 +180,7 @@ void ImportScript(CWallet * const pwallet, const CScript& script, const string& @@ -182,7 +180,7 @@ void ImportScript(CWallet * const pwallet, const CScript& script, const string&
}
}
void ImportAddress(CWallet * const pwallet, const CBitcoinAddress& address, const string& strLabel)
void ImportAddress(CWallet* const pwallet, const CBitcoinAddress& address, const std::string& strLabel)
{
CScript script = GetScriptForDestination(address.Get());
ImportScript(pwallet, script, strLabel, false);
@ -199,7 +197,7 @@ UniValue importaddress(const JSONRPCRequest& request) @@ -199,7 +197,7 @@ UniValue importaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error(
throw std::runtime_error(
"importaddress \"address\" ( \"label\" rescan p2sh )\n"
"\nAdds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend.\n"
"\nArguments:\n"
@ -221,7 +219,7 @@ UniValue importaddress(const JSONRPCRequest& request) @@ -221,7 +219,7 @@ UniValue importaddress(const JSONRPCRequest& request)
);
string strLabel = "";
std::string strLabel = "";
if (request.params.size() > 1)
strLabel = request.params[1].get_str();
@ -269,7 +267,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request) @@ -269,7 +267,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 2)
throw runtime_error(
throw std::runtime_error(
"importprunedfunds\n"
"\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n"
"\nArguments:\n"
@ -288,8 +286,8 @@ UniValue importprunedfunds(const JSONRPCRequest& request) @@ -288,8 +286,8 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
ssMB >> merkleBlock;
//Search partial merkle tree in proof for our transaction and index in valid block
vector<uint256> vMatch;
vector<unsigned int> vIndex;
std::vector<uint256> vMatch;
std::vector<unsigned int> vIndex;
unsigned int txnIndex = 0;
if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) == merkleBlock.header.hashMerkleRoot) {
@ -298,7 +296,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request) @@ -298,7 +296,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
if (!mapBlockIndex.count(merkleBlock.header.GetHash()) || !chainActive.Contains(mapBlockIndex[merkleBlock.header.GetHash()]))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found in chain");
vector<uint256>::const_iterator it;
std::vector<uint256>::const_iterator it;
if ((it = std::find(vMatch.begin(), vMatch.end(), hashTx))==vMatch.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction given doesn't exist in proof");
}
@ -330,7 +328,7 @@ UniValue removeprunedfunds(const JSONRPCRequest& request) @@ -330,7 +328,7 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"removeprunedfunds \"txid\"\n"
"\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will effect wallet balances.\n"
"\nArguments:\n"
@ -345,9 +343,9 @@ UniValue removeprunedfunds(const JSONRPCRequest& request) @@ -345,9 +343,9 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
uint256 hash;
hash.SetHex(request.params[0].get_str());
vector<uint256> vHash;
std::vector<uint256> vHash;
vHash.push_back(hash);
vector<uint256> vHashOut;
std::vector<uint256> vHashOut;
if (pwallet->ZapSelectTx(vHash, vHashOut) != DB_LOAD_OK) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not properly delete the transaction.");
@ -368,7 +366,7 @@ UniValue importpubkey(const JSONRPCRequest& request) @@ -368,7 +366,7 @@ UniValue importpubkey(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error(
throw std::runtime_error(
"importpubkey \"pubkey\" ( \"label\" rescan )\n"
"\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend.\n"
"\nArguments:\n"
@ -386,7 +384,7 @@ UniValue importpubkey(const JSONRPCRequest& request) @@ -386,7 +384,7 @@ UniValue importpubkey(const JSONRPCRequest& request)
);
string strLabel = "";
std::string strLabel = "";
if (request.params.size() > 1)
strLabel = request.params[1].get_str();
@ -428,7 +426,7 @@ UniValue importwallet(const JSONRPCRequest& request) @@ -428,7 +426,7 @@ UniValue importwallet(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"importwallet \"filename\"\n"
"\nImports keys from a wallet dump file (see dumpwallet).\n"
"\nArguments:\n"
@ -449,7 +447,7 @@ UniValue importwallet(const JSONRPCRequest& request) @@ -449,7 +447,7 @@ UniValue importwallet(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet);
ifstream file;
std::ifstream file;
file.open(request.params[0].get_str().c_str(), std::ios::in | std::ios::ate);
if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
@ -536,7 +534,7 @@ UniValue dumpprivkey(const JSONRPCRequest& request) @@ -536,7 +534,7 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"dumpprivkey \"address\"\n"
"\nReveals the private key corresponding to 'address'.\n"
"Then the importprivkey can be used with this output\n"
@ -554,7 +552,7 @@ UniValue dumpprivkey(const JSONRPCRequest& request) @@ -554,7 +552,7 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet);
string strAddress = request.params[0].get_str();
std::string strAddress = request.params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
@ -577,7 +575,7 @@ UniValue dumpwallet(const JSONRPCRequest& request) @@ -577,7 +575,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"dumpwallet \"filename\"\n"
"\nDumps all wallet keys in a human-readable format.\n"
"\nArguments:\n"
@ -591,7 +589,7 @@ UniValue dumpwallet(const JSONRPCRequest& request) @@ -591,7 +589,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet);
ofstream file;
std::ofstream file;
file.open(request.params[0].get_str().c_str());
if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
@ -675,16 +673,16 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6 @@ -675,16 +673,16 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
}
// Optional fields.
const string& strRedeemScript = data.exists("redeemscript") ? data["redeemscript"].get_str() : "";
const std::string& strRedeemScript = data.exists("redeemscript") ? data["redeemscript"].get_str() : "";
const UniValue& pubKeys = data.exists("pubkeys") ? data["pubkeys"].get_array() : UniValue();
const UniValue& keys = data.exists("keys") ? data["keys"].get_array() : UniValue();
const bool& internal = data.exists("internal") ? data["internal"].get_bool() : false;
const bool& watchOnly = data.exists("watchonly") ? data["watchonly"].get_bool() : false;
const string& label = data.exists("label") && !internal ? data["label"].get_str() : "";
const std::string& label = data.exists("label") && !internal ? data["label"].get_str() : "";
bool isScript = scriptPubKey.getType() == UniValue::VSTR;
bool isP2SH = strRedeemScript.length() > 0;
const string& output = isScript ? scriptPubKey.get_str() : scriptPubKey["address"].get_str();
const std::string& output = isScript ? scriptPubKey.get_str() : scriptPubKey["address"].get_str();
// Parse the output.
CScript script;
@ -774,7 +772,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6 @@ -774,7 +772,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
// Import private keys.
if (keys.size()) {
for (size_t i = 0; i < keys.size(); i++) {
const string& privkey = keys[i].get_str();
const std::string& privkey = keys[i].get_str();
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(privkey);
@ -814,7 +812,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6 @@ -814,7 +812,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
} else {
// Import public keys.
if (pubKeys.size() && keys.size() == 0) {
const string& strPubKey = pubKeys[0].get_str();
const std::string& strPubKey = pubKeys[0].get_str();
if (!IsHex(strPubKey)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey must be a hex string");
@ -882,7 +880,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6 @@ -882,7 +880,7 @@ UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, const int6
// Import private keys.
if (keys.size()) {
const string& strPrivkey = keys[0].get_str();
const std::string& strPrivkey = keys[0].get_str();
// Checks.
CBitcoinSecret vchSecret;
@ -1001,7 +999,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest) @@ -1001,7 +999,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
// clang-format off
if (mainRequest.fHelp || mainRequest.params.size() < 1 || mainRequest.params.size() > 2)
throw runtime_error(
throw std::runtime_error(
"importmulti \"requests\" \"options\"\n\n"
"Import addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options).\n\n"
"Arguments:\n"

240
src/wallet/rpcwallet.cpp

@ -27,8 +27,6 @@ @@ -27,8 +27,6 @@
#include <univalue.h>
using namespace std;
CWallet *GetWalletForJSONRPCRequest(const JSONRPCRequest& request)
{
return pwalletMain;
@ -94,13 +92,13 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) @@ -94,13 +92,13 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
}
entry.push_back(Pair("bip125-replaceable", rbfStatus));
BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue)
BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, wtx.mapValue)
entry.push_back(Pair(item.first, item.second));
}
string AccountFromValue(const UniValue& value)
std::string AccountFromValue(const UniValue& value)
{
string strAccount = value.get_str();
std::string strAccount = value.get_str();
if (strAccount == "*")
throw JSONRPCError(RPC_WALLET_INVALID_ACCOUNT_NAME, "Invalid account name");
return strAccount;
@ -114,7 +112,7 @@ UniValue getnewaddress(const JSONRPCRequest& request) @@ -114,7 +112,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 1)
throw runtime_error(
throw std::runtime_error(
"getnewaddress ( \"account\" )\n"
"\nReturns a new Bitcoin address for receiving payments.\n"
"If 'account' is specified (DEPRECATED), it is added to the address book \n"
@ -131,7 +129,7 @@ UniValue getnewaddress(const JSONRPCRequest& request) @@ -131,7 +129,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
// Parse the account first so we don't generate a key if there's an error
string strAccount;
std::string strAccount;
if (request.params.size() > 0)
strAccount = AccountFromValue(request.params[0]);
@ -152,7 +150,7 @@ UniValue getnewaddress(const JSONRPCRequest& request) @@ -152,7 +150,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
}
CBitcoinAddress GetAccountAddress(CWallet * const pwallet, string strAccount, bool bForceNew=false)
CBitcoinAddress GetAccountAddress(CWallet* const pwallet, std::string strAccount, bool bForceNew=false)
{
CPubKey pubKey;
if (!pwallet->GetAccountPubkey(pubKey, strAccount, bForceNew)) {
@ -170,7 +168,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request) @@ -170,7 +168,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"getaccountaddress \"account\"\n"
"\nDEPRECATED. Returns the current Bitcoin address for receiving payments to this account.\n"
"\nArguments:\n"
@ -187,7 +185,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request) @@ -187,7 +185,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
// Parse the account first so we don't generate a key if there's an error
string strAccount = AccountFromValue(request.params[0]);
std::string strAccount = AccountFromValue(request.params[0]);
UniValue ret(UniValue::VSTR);
@ -204,7 +202,7 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request) @@ -204,7 +202,7 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 1)
throw runtime_error(
throw std::runtime_error(
"getrawchangeaddress\n"
"\nReturns a new Bitcoin address, for receiving change.\n"
"This is for use with raw transactions, NOT normal use.\n"
@ -242,7 +240,7 @@ UniValue setaccount(const JSONRPCRequest& request) @@ -242,7 +240,7 @@ UniValue setaccount(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error(
throw std::runtime_error(
"setaccount \"address\" \"account\"\n"
"\nDEPRECATED. Sets the account associated with the given address.\n"
"\nArguments:\n"
@ -259,7 +257,7 @@ UniValue setaccount(const JSONRPCRequest& request) @@ -259,7 +257,7 @@ UniValue setaccount(const JSONRPCRequest& request)
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
string strAccount;
std::string strAccount;
if (request.params.size() > 1)
strAccount = AccountFromValue(request.params[1]);
@ -267,7 +265,7 @@ UniValue setaccount(const JSONRPCRequest& request) @@ -267,7 +265,7 @@ UniValue setaccount(const JSONRPCRequest& request)
if (IsMine(*pwallet, address.Get())) {
// Detect when changing the account of an address that is the 'unused current key' of another account:
if (pwallet->mapAddressBook.count(address.Get())) {
string strOldAccount = pwallet->mapAddressBook[address.Get()].name;
std::string strOldAccount = pwallet->mapAddressBook[address.Get()].name;
if (address == GetAccountAddress(pwallet, strOldAccount)) {
GetAccountAddress(pwallet, strOldAccount, true);
}
@ -289,7 +287,7 @@ UniValue getaccount(const JSONRPCRequest& request) @@ -289,7 +287,7 @@ UniValue getaccount(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"getaccount \"address\"\n"
"\nDEPRECATED. Returns the account associated with the given address.\n"
"\nArguments:\n"
@ -307,8 +305,8 @@ UniValue getaccount(const JSONRPCRequest& request) @@ -307,8 +305,8 @@ UniValue getaccount(const JSONRPCRequest& request)
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
string strAccount;
map<CTxDestination, CAddressBookData>::iterator mi = pwallet->mapAddressBook.find(address.Get());
std::string strAccount;
std::map<CTxDestination, CAddressBookData>::iterator mi = pwallet->mapAddressBook.find(address.Get());
if (mi != pwallet->mapAddressBook.end() && !(*mi).second.name.empty()) {
strAccount = (*mi).second.name;
}
@ -324,7 +322,7 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request) @@ -324,7 +322,7 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"getaddressesbyaccount \"account\"\n"
"\nDEPRECATED. Returns the list of addresses for the given account.\n"
"\nArguments:\n"
@ -341,13 +339,13 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request) @@ -341,13 +339,13 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
string strAccount = AccountFromValue(request.params[0]);
std::string strAccount = AccountFromValue(request.params[0]);
// Find all addresses that have the given account
UniValue ret(UniValue::VARR);
for (const std::pair<CBitcoinAddress, CAddressBookData>& item : pwallet->mapAddressBook) {
const CBitcoinAddress& address = item.first;
const string& strName = item.second.name;
const std::string& strName = item.second.name;
if (strName == strAccount)
ret.push_back(address.ToString());
}
@ -376,7 +374,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA @@ -376,7 +374,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
CReserveKey reservekey(pwallet);
CAmount nFeeRequired;
std::string strError;
vector<CRecipient> vecSend;
std::vector<CRecipient> vecSend;
int nChangePosRet = -1;
CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount};
vecSend.push_back(recipient);
@ -400,7 +398,7 @@ UniValue sendtoaddress(const JSONRPCRequest& request) @@ -400,7 +398,7 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 2 || request.params.size() > 5)
throw runtime_error(
throw std::runtime_error(
"sendtoaddress \"address\" amount ( \"comment\" \"comment_to\" subtractfeefromamount )\n"
"\nSend an amount to a given address.\n"
+ HelpRequiringPassphrase(pwallet) +
@ -460,7 +458,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request) @@ -460,7 +458,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
}
if (request.fHelp)
throw runtime_error(
throw std::runtime_error(
"listaddressgroupings\n"
"\nLists groups of addresses which have had their common ownership\n"
"made public by common use as inputs or as the resulting change\n"
@ -485,8 +483,8 @@ UniValue listaddressgroupings(const JSONRPCRequest& request) @@ -485,8 +483,8 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
UniValue jsonGroupings(UniValue::VARR);
map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances();
for (set<CTxDestination> grouping : pwallet->GetAddressGroupings()) {
std::map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances();
for (std::set<CTxDestination> grouping : pwallet->GetAddressGroupings()) {
UniValue jsonGrouping(UniValue::VARR);
BOOST_FOREACH(CTxDestination address, grouping)
{
@ -513,7 +511,7 @@ UniValue signmessage(const JSONRPCRequest& request) @@ -513,7 +511,7 @@ UniValue signmessage(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 2)
throw runtime_error(
throw std::runtime_error(
"signmessage \"address\" \"message\"\n"
"\nSign a message with the private key of an address"
+ HelpRequiringPassphrase(pwallet) + "\n"
@ -537,8 +535,8 @@ UniValue signmessage(const JSONRPCRequest& request) @@ -537,8 +535,8 @@ UniValue signmessage(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet);
string strAddress = request.params[0].get_str();
string strMessage = request.params[1].get_str();
std::string strAddress = request.params[0].get_str();
std::string strMessage = request.params[1].get_str();
CBitcoinAddress addr(strAddress);
if (!addr.IsValid())
@ -557,7 +555,7 @@ UniValue signmessage(const JSONRPCRequest& request) @@ -557,7 +555,7 @@ UniValue signmessage(const JSONRPCRequest& request)
ss << strMessageMagic;
ss << strMessage;
vector<unsigned char> vchSig;
std::vector<unsigned char> vchSig;
if (!key.SignCompact(ss.GetHash(), vchSig))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed");
@ -572,7 +570,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request) @@ -572,7 +570,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error(
throw std::runtime_error(
"getreceivedbyaddress \"address\" ( minconf )\n"
"\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n"
"\nArguments:\n"
@ -632,7 +630,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request) @@ -632,7 +630,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error(
throw std::runtime_error(
"getreceivedbyaccount \"account\" ( minconf )\n"
"\nDEPRECATED. Returns the total amount received by addresses with <account> in transactions with at least [minconf] confirmations.\n"
"\nArguments:\n"
@ -659,8 +657,8 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request) @@ -659,8 +657,8 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
nMinDepth = request.params[1].get_int();
// Get the set of pub keys assigned to account
string strAccount = AccountFromValue(request.params[0]);
set<CTxDestination> setAddress = pwallet->GetAccountAddresses(strAccount);
std::string strAccount = AccountFromValue(request.params[0]);
std::set<CTxDestination> setAddress = pwallet->GetAccountAddresses(strAccount);
// Tally
CAmount nAmount = 0;
@ -691,7 +689,7 @@ UniValue getbalance(const JSONRPCRequest& request) @@ -691,7 +689,7 @@ UniValue getbalance(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 3)
throw runtime_error(
throw std::runtime_error(
"getbalance ( \"account\" minconf include_watchonly )\n"
"\nIf account is not specified, returns the server's total available balance.\n"
"If account is specified (DEPRECATED), returns the balance in the account.\n"
@ -750,9 +748,9 @@ UniValue getbalance(const JSONRPCRequest& request) @@ -750,9 +748,9 @@ UniValue getbalance(const JSONRPCRequest& request)
continue;
CAmount allFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
std::string strSentAccount;
std::list<COutputEntry> listReceived;
std::list<COutputEntry> listSent;
wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter);
if (wtx.GetDepthInMainChain() >= nMinDepth)
{
@ -766,7 +764,7 @@ UniValue getbalance(const JSONRPCRequest& request) @@ -766,7 +764,7 @@ UniValue getbalance(const JSONRPCRequest& request)
return ValueFromAmount(nBalance);
}
string strAccount = AccountFromValue(request.params[0]);
std::string strAccount = AccountFromValue(request.params[0]);
CAmount nBalance = pwallet->GetAccountBalance(strAccount, nMinDepth, filter);
@ -781,7 +779,7 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request) @@ -781,7 +779,7 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
}
if (request.fHelp || request.params.size() > 0)
throw runtime_error(
throw std::runtime_error(
"getunconfirmedbalance\n"
"Returns the server's total unconfirmed balance\n");
@ -799,7 +797,7 @@ UniValue movecmd(const JSONRPCRequest& request) @@ -799,7 +797,7 @@ UniValue movecmd(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 3 || request.params.size() > 5)
throw runtime_error(
throw std::runtime_error(
"move \"fromaccount\" \"toaccount\" amount ( minconf \"comment\" )\n"
"\nDEPRECATED. Move a specified amount from one account in your wallet to another.\n"
"\nArguments:\n"
@ -821,15 +819,15 @@ UniValue movecmd(const JSONRPCRequest& request) @@ -821,15 +819,15 @@ UniValue movecmd(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
string strFrom = AccountFromValue(request.params[0]);
string strTo = AccountFromValue(request.params[1]);
std::string strFrom = AccountFromValue(request.params[0]);
std::string strTo = AccountFromValue(request.params[1]);
CAmount nAmount = AmountFromValue(request.params[2]);
if (nAmount <= 0)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
if (request.params.size() > 3)
// unused parameter, used to be nMinDepth, keep type-checking it though
(void)request.params[3].get_int();
string strComment;
std::string strComment;
if (request.params.size() > 4)
strComment = request.params[4].get_str();
@ -849,7 +847,7 @@ UniValue sendfrom(const JSONRPCRequest& request) @@ -849,7 +847,7 @@ UniValue sendfrom(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 3 || request.params.size() > 6)
throw runtime_error(
throw std::runtime_error(
"sendfrom \"fromaccount\" \"toaddress\" amount ( minconf \"comment\" \"comment_to\" )\n"
"\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a bitcoin address."
+ HelpRequiringPassphrase(pwallet) + "\n"
@ -879,7 +877,7 @@ UniValue sendfrom(const JSONRPCRequest& request) @@ -879,7 +877,7 @@ UniValue sendfrom(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
string strAccount = AccountFromValue(request.params[0]);
std::string strAccount = AccountFromValue(request.params[0]);
CBitcoinAddress address(request.params[1].get_str());
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
@ -918,7 +916,7 @@ UniValue sendmany(const JSONRPCRequest& request) @@ -918,7 +916,7 @@ UniValue sendmany(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 2 || request.params.size() > 5)
throw runtime_error(
throw std::runtime_error(
"sendmany \"fromaccount\" {\"address\":amount,...} ( minconf \"comment\" [\"address\",...] )\n"
"\nSend multiple times. Amounts are double-precision floating point numbers."
+ HelpRequiringPassphrase(pwallet) + "\n"
@ -959,7 +957,7 @@ UniValue sendmany(const JSONRPCRequest& request) @@ -959,7 +957,7 @@ UniValue sendmany(const JSONRPCRequest& request)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
}
string strAccount = AccountFromValue(request.params[0]);
std::string strAccount = AccountFromValue(request.params[0]);
UniValue sendTo = request.params[1].get_obj();
int nMinDepth = 1;
if (request.params.size() > 2)
@ -974,19 +972,19 @@ UniValue sendmany(const JSONRPCRequest& request) @@ -974,19 +972,19 @@ UniValue sendmany(const JSONRPCRequest& request)
if (request.params.size() > 4)
subtractFeeFromAmount = request.params[4].get_array();
set<CBitcoinAddress> setAddress;
vector<CRecipient> vecSend;
std::set<CBitcoinAddress> setAddress;
std::vector<CRecipient> vecSend;
CAmount totalAmount = 0;
vector<string> keys = sendTo.getKeys();
BOOST_FOREACH(const string& name_, keys)
std::vector<std::string> keys = sendTo.getKeys();
BOOST_FOREACH(const std::string& name_, keys)
{
CBitcoinAddress address(name_);
if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+name_);
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ")+name_);
if (setAddress.count(address))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+name_);
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ")+name_);
setAddress.insert(address);
CScript scriptPubKey = GetScriptForDestination(address.Get());
@ -1017,7 +1015,7 @@ UniValue sendmany(const JSONRPCRequest& request) @@ -1017,7 +1015,7 @@ UniValue sendmany(const JSONRPCRequest& request)
CReserveKey keyChange(pwallet);
CAmount nFeeRequired = 0;
int nChangePosRet = -1;
string strFailReason;
std::string strFailReason;
bool fCreated = pwallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, nChangePosRet, strFailReason);
if (!fCreated)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
@ -1042,7 +1040,7 @@ UniValue addmultisigaddress(const JSONRPCRequest& request) @@ -1042,7 +1040,7 @@ UniValue addmultisigaddress(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
{
string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n"
std::string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n"
"\nAdd a nrequired-to-sign multisignature address to the wallet.\n"
"Each key is a Bitcoin address or hex-encoded public key.\n"
"If 'account' is specified (DEPRECATED), assign address to that account.\n"
@ -1065,12 +1063,12 @@ UniValue addmultisigaddress(const JSONRPCRequest& request) @@ -1065,12 +1063,12 @@ UniValue addmultisigaddress(const JSONRPCRequest& request)
"\nAs json rpc call\n"
+ HelpExampleRpc("addmultisigaddress", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
;
throw runtime_error(msg);
throw std::runtime_error(msg);
}
LOCK2(cs_main, pwallet->cs_wallet);
string strAccount;
std::string strAccount;
if (request.params.size() > 2)
strAccount = AccountFromValue(request.params[2]);
@ -1140,7 +1138,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request) @@ -1140,7 +1138,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
if (request.fHelp || request.params.size() < 1 || request.params.size() > 1)
{
string msg = "addwitnessaddress \"address\"\n"
std::string msg = "addwitnessaddress \"address\"\n"
"\nAdd a witness address for a script (with pubkey or redeemscript known).\n"
"It returns the witness script.\n"
@ -1151,7 +1149,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request) @@ -1151,7 +1149,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
"\"witnessaddress\", (string) The value of the new address (P2SH of witness script).\n"
"}\n"
;
throw runtime_error(msg);
throw std::runtime_error(msg);
}
{
@ -1181,7 +1179,7 @@ struct tallyitem @@ -1181,7 +1179,7 @@ struct tallyitem
{
CAmount nAmount;
int nConf;
vector<uint256> txids;
std::vector<uint256> txids;
bool fIsWatchonly;
tallyitem()
{
@ -1209,7 +1207,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA @@ -1209,7 +1207,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
filter = filter | ISMINE_WATCH_ONLY;
// Tally
map<CBitcoinAddress, tallyitem> mapTally;
std::map<CBitcoinAddress, tallyitem> mapTally;
for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;
@ -1232,7 +1230,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA @@ -1232,7 +1230,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
tallyitem& item = mapTally[address];
item.nAmount += txout.nValue;
item.nConf = min(item.nConf, nDepth);
item.nConf = std::min(item.nConf, nDepth);
item.txids.push_back(wtx.GetHash());
if (mine & ISMINE_WATCH_ONLY)
item.fIsWatchonly = true;
@ -1241,11 +1239,11 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA @@ -1241,11 +1239,11 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
// Reply
UniValue ret(UniValue::VARR);
map<string, tallyitem> mapAccountTally;
std::map<std::string, tallyitem> mapAccountTally;
for (const std::pair<CBitcoinAddress, CAddressBookData>& item : pwallet->mapAddressBook) {
const CBitcoinAddress& address = item.first;
const string& strAccount = item.second.name;
map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address);
const std::string& strAccount = item.second.name;
std::map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address);
if (it == mapTally.end() && !fIncludeEmpty)
continue;
@ -1263,7 +1261,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA @@ -1263,7 +1261,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
{
tallyitem& _item = mapAccountTally[strAccount];
_item.nAmount += nAmount;
_item.nConf = min(_item.nConf, nConf);
_item.nConf = std::min(_item.nConf, nConf);
_item.fIsWatchonly = fIsWatchonly;
}
else
@ -1292,7 +1290,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA @@ -1292,7 +1290,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
if (fByAccounts)
{
for (map<string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
for (std::map<std::string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
{
CAmount nAmount = (*it).second.nAmount;
int nConf = (*it).second.nConf;
@ -1317,7 +1315,7 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request) @@ -1317,7 +1315,7 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 3)
throw runtime_error(
throw std::runtime_error(
"listreceivedbyaddress ( minconf include_empty include_watchonly)\n"
"\nList balances by receiving address.\n"
"\nArguments:\n"
@ -1361,7 +1359,7 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request) @@ -1361,7 +1359,7 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 3)
throw runtime_error(
throw std::runtime_error(
"listreceivedbyaccount ( minconf include_empty include_watchonly)\n"
"\nDEPRECATED. List balances by account.\n"
"\nArguments:\n"
@ -1399,16 +1397,16 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest) @@ -1399,16 +1397,16 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
entry.push_back(Pair("address", addr.ToString()));
}
void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
void ListTransactions(CWallet* const pwallet, const CWalletTx& wtx, const std::string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter)
{
CAmount nFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
std::string strSentAccount;
std::list<COutputEntry> listReceived;
std::list<COutputEntry> listSent;
wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter);
bool fAllAccounts = (strAccount == string("*"));
bool fAllAccounts = (strAccount == std::string("*"));
bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY);
// Sent
@ -1441,7 +1439,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin @@ -1441,7 +1439,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
{
BOOST_FOREACH(const COutputEntry& r, listReceived)
{
string account;
std::string account;
if (pwallet->mapAddressBook.count(r.destination)) {
account = pwallet->mapAddressBook[r.destination].name;
}
@ -1479,9 +1477,9 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin @@ -1479,9 +1477,9 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
}
}
void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, UniValue& ret)
void AcentryToJSON(const CAccountingEntry& acentry, const std::string& strAccount, UniValue& ret)
{
bool fAllAccounts = (strAccount == string("*"));
bool fAllAccounts = (strAccount == std::string("*"));
if (fAllAccounts || acentry.strAccount == strAccount)
{
@ -1504,7 +1502,7 @@ UniValue listtransactions(const JSONRPCRequest& request) @@ -1504,7 +1502,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 4)
throw runtime_error(
throw std::runtime_error(
"listtransactions ( \"account\" count skip include_watchonly)\n"
"\nReturns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'.\n"
"\nArguments:\n"
@ -1565,7 +1563,7 @@ UniValue listtransactions(const JSONRPCRequest& request) @@ -1565,7 +1563,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
string strAccount = "*";
std::string strAccount = "*";
if (request.params.size() > 0)
strAccount = request.params[0].get_str();
int nCount = 10;
@ -1607,11 +1605,11 @@ UniValue listtransactions(const JSONRPCRequest& request) @@ -1607,11 +1605,11 @@ UniValue listtransactions(const JSONRPCRequest& request)
if ((nFrom + nCount) > (int)ret.size())
nCount = ret.size() - nFrom;
vector<UniValue> arrTmp = ret.getValues();
std::vector<UniValue> arrTmp = ret.getValues();
vector<UniValue>::iterator first = arrTmp.begin();
std::vector<UniValue>::iterator first = arrTmp.begin();
std::advance(first, nFrom);
vector<UniValue>::iterator last = arrTmp.begin();
std::vector<UniValue>::iterator last = arrTmp.begin();
std::advance(last, nFrom+nCount);
if (last != arrTmp.end()) arrTmp.erase(last, arrTmp.end());
@ -1634,7 +1632,7 @@ UniValue listaccounts(const JSONRPCRequest& request) @@ -1634,7 +1632,7 @@ UniValue listaccounts(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 2)
throw runtime_error(
throw std::runtime_error(
"listaccounts ( minconf include_watchonly)\n"
"\nDEPRECATED. Returns Object that has account names as keys, account balances as values.\n"
"\nArguments:\n"
@ -1666,7 +1664,7 @@ UniValue listaccounts(const JSONRPCRequest& request) @@ -1666,7 +1664,7 @@ UniValue listaccounts(const JSONRPCRequest& request)
if(request.params[1].get_bool())
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY;
map<string, CAmount> mapAccountBalances;
std::map<std::string, CAmount> mapAccountBalances;
for (const std::pair<CTxDestination, CAddressBookData>& entry : pwallet->mapAddressBook) {
if (IsMine(*pwallet, entry.first) & includeWatchonly) { // This address belongs to me
mapAccountBalances[entry.second.name] = 0;
@ -1676,9 +1674,9 @@ UniValue listaccounts(const JSONRPCRequest& request) @@ -1676,9 +1674,9 @@ UniValue listaccounts(const JSONRPCRequest& request)
for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
const CWalletTx& wtx = pairWtx.second;
CAmount nFee;
string strSentAccount;
list<COutputEntry> listReceived;
list<COutputEntry> listSent;
std::string strSentAccount;
std::list<COutputEntry> listReceived;
std::list<COutputEntry> listSent;
int nDepth = wtx.GetDepthInMainChain();
if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0)
continue;
@ -1697,12 +1695,12 @@ UniValue listaccounts(const JSONRPCRequest& request) @@ -1697,12 +1695,12 @@ UniValue listaccounts(const JSONRPCRequest& request)
}
}
const list<CAccountingEntry> & acentries = pwallet->laccentries;
const std::list<CAccountingEntry>& acentries = pwallet->laccentries;
BOOST_FOREACH(const CAccountingEntry& entry, acentries)
mapAccountBalances[entry.strAccount] += entry.nCreditDebit;
UniValue ret(UniValue::VOBJ);
BOOST_FOREACH(const PAIRTYPE(string, CAmount)& accountBalance, mapAccountBalances) {
BOOST_FOREACH(const PAIRTYPE(std::string, CAmount)& accountBalance, mapAccountBalances) {
ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second)));
}
return ret;
@ -1716,7 +1714,7 @@ UniValue listsinceblock(const JSONRPCRequest& request) @@ -1716,7 +1714,7 @@ UniValue listsinceblock(const JSONRPCRequest& request)
}
if (request.fHelp)
throw runtime_error(
throw std::runtime_error(
"listsinceblock ( \"blockhash\" target_confirmations include_watchonly)\n"
"\nGet all transactions in blocks since block [blockhash], or all transactions if omitted\n"
"\nArguments:\n"
@ -1823,7 +1821,7 @@ UniValue gettransaction(const JSONRPCRequest& request) @@ -1823,7 +1821,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error(
throw std::runtime_error(
"gettransaction \"txid\" ( include_watchonly )\n"
"\nGet detailed information about in-wallet transaction <txid>\n"
"\nArguments:\n"
@ -1898,7 +1896,7 @@ UniValue gettransaction(const JSONRPCRequest& request) @@ -1898,7 +1896,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
ListTransactions(pwallet, wtx, "*", 0, false, details, filter);
entry.push_back(Pair("details", details));
string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags());
std::string strHex = EncodeHexTx(static_cast<CTransaction>(wtx), RPCSerializationFlags());
entry.push_back(Pair("hex", strHex));
return entry;
@ -1912,7 +1910,7 @@ UniValue abandontransaction(const JSONRPCRequest& request) @@ -1912,7 +1910,7 @@ UniValue abandontransaction(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"abandontransaction \"txid\"\n"
"\nMark in-wallet transaction <txid> as abandoned\n"
"This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n"
@ -1951,7 +1949,7 @@ UniValue backupwallet(const JSONRPCRequest& request) @@ -1951,7 +1949,7 @@ UniValue backupwallet(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() != 1)
throw runtime_error(
throw std::runtime_error(
"backupwallet \"destination\"\n"
"\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n"
"\nArguments:\n"
@ -1963,7 +1961,7 @@ UniValue backupwallet(const JSONRPCRequest& request) @@ -1963,7 +1961,7 @@ UniValue backupwallet(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet);
string strDest = request.params[0].get_str();
std::string strDest = request.params[0].get_str();
if (!pwallet->BackupWallet(strDest)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!");
}
@ -1980,7 +1978,7 @@ UniValue keypoolrefill(const JSONRPCRequest& request) @@ -1980,7 +1978,7 @@ UniValue keypoolrefill(const JSONRPCRequest& request)
}
if (request.fHelp || request.params.size() > 1)
throw runtime_error(
throw std::runtime_error(
"keypoolrefill ( newsize )\n"
"\nFills the keypool."
+ HelpRequiringPassphrase(pwallet) + "\n"
@ -2027,7 +2025,7 @@ UniValue walletpassphrase(const JSONRPCRequest& request) @@ -2027,7 +2025,7 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
}
if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) {
throw runtime_error(
throw std::runtime_error(
"walletpassphrase \"passphrase\" timeout\n"
"\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
"This is needed prior to performing transactions related to private keys such as sending bitcoins\n"
@ -2069,7 +2067,7 @@ UniValue walletpassphrase(const JSONRPCRequest& request) @@ -2069,7 +2067,7 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
}
}
else
throw runtime_error(
throw std::runtime_error(
"walletpassphrase <passphrase> <timeout>\n"
"Stores the wallet decryption key in memory for <timeout> seconds.");
@ -2091,7 +2089,7 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request) @@ -2091,7 +2089,7 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
}
if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) {
throw runtime_error(
throw std::runtime_error(
"walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n"
"\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n"
"\nArguments:\n"
@ -2122,7 +2120,7 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request) @@ -2122,7 +2120,7 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
strNewWalletPass = request.params[1].get_str().c_str();
if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1)
throw runtime_error(
throw std::runtime_error(
"walletpassphrasechange <oldpassphrase> <newpassphrase>\n"
"Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>.");
@ -2142,7 +2140,7 @@ UniValue walletlock(const JSONRPCRequest& request) @@ -2142,7 +2140,7 @@ UniValue walletlock(const JSONRPCRequest& request)
}
if (pwallet->IsCrypted() && (request.fHelp || request.params