Browse Source

Merge #9643: [refactor] Remove using namespace <xxx> from wallet/ & util*

a57845c Refactor: Remove using namespace <xxx> from util* (Karl-Johan Alm)
8a52281 Refactor: Remove using namespace <xxx> from wallet/ (Karl-Johan Alm)

Tree-SHA512: cd06b569fee0ce25db753ade5ee694b582733a8883bfd62a27613020266d2a902af079ef23b58a5412f7af4afd7681e689af3c7780e5ea00c77b16d144d72db5
pull/1/head
Wladimir J. van der Laan 6 years ago
parent
commit
c047b1663d
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 38
      src/util.cpp
  2. 8
      src/utilmoneystr.cpp
  3. 50
      src/utilstrencodings.cpp
  4. 2
      src/utiltime.cpp
  5. 37
      src/wallet/db.cpp
  6. 62
      src/wallet/rpcdump.cpp
  7. 240
      src/wallet/rpcwallet.cpp
  8. 8
      src/wallet/test/wallet_tests.cpp
  9. 198
      src/wallet/wallet.cpp
  10. 74
      src/wallet/walletdb.cpp

38
src/util.cpp

@ -97,15 +97,15 @@ namespace boost { @@ -97,15 +97,15 @@ namespace boost {
} // namespace boost
using namespace std;
const char * const BITCOIN_CONF_FILENAME = "bitcoin.conf";
const char * const BITCOIN_PID_FILENAME = "bitcoind.pid";
CCriticalSection cs_args;
map<string, string> mapArgs;
static map<string, vector<string> > _mapMultiArgs;
const map<string, vector<string> >& mapMultiArgs = _mapMultiArgs;
std::map<std::string, std::string> mapArgs;
static std::map<std::string, std::vector<std::string> > _mapMultiArgs;
const std::map<std::string, std::vector<std::string> >& mapMultiArgs = _mapMultiArgs;
bool fDebug = false;
bool fPrintToConsole = false;
bool fPrintToDebugLog = true;
@ -191,7 +191,7 @@ static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; @@ -191,7 +191,7 @@ static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT;
*/
static FILE* fileout = NULL;
static boost::mutex* mutexDebugLog = NULL;
static list<string> *vMsgsBeforeOpenLog;
static std::list<std::string>* vMsgsBeforeOpenLog;
static int FileWriteStr(const std::string &str, FILE *fp)
{
@ -202,7 +202,7 @@ static void DebugPrintInit() @@ -202,7 +202,7 @@ static void DebugPrintInit()
{
assert(mutexDebugLog == NULL);
mutexDebugLog = new boost::mutex();
vMsgsBeforeOpenLog = new list<string>;
vMsgsBeforeOpenLog = new std::list<std::string>;
}
void OpenDebugLog()
@ -238,22 +238,22 @@ bool LogAcceptCategory(const char* category) @@ -238,22 +238,22 @@ bool LogAcceptCategory(const char* category)
// This helps prevent issues debugging global destructors,
// where mapMultiArgs might be deleted before another
// global destructor calls LogPrint()
static boost::thread_specific_ptr<set<string> > ptrCategory;
static boost::thread_specific_ptr<std::set<std::string> > ptrCategory;
if (ptrCategory.get() == NULL)
{
if (mapMultiArgs.count("-debug")) {
const vector<string>& categories = mapMultiArgs.at("-debug");
ptrCategory.reset(new set<string>(categories.begin(), categories.end()));
const std::vector<std::string>& categories = mapMultiArgs.at("-debug");
ptrCategory.reset(new std::set<std::string>(categories.begin(), categories.end()));
// thread_specific_ptr automatically deletes the set when the thread ends.
} else
ptrCategory.reset(new set<string>());
ptrCategory.reset(new std::set<std::string>());
}
const set<string>& setCategories = *ptrCategory.get();
const std::set<std::string>& setCategories = *ptrCategory.get();
// if not debugging everything and not debugging specific category, LogPrint does nothing.
if (setCategories.count(string("")) == 0 &&
setCategories.count(string("1")) == 0 &&
setCategories.count(string(category)) == 0)
if (setCategories.count(std::string("")) == 0 &&
setCategories.count(std::string("1")) == 0 &&
setCategories.count(std::string(category)) == 0)
return false;
}
return true;
@ -266,7 +266,7 @@ bool LogAcceptCategory(const char* category) @@ -266,7 +266,7 @@ bool LogAcceptCategory(const char* category)
*/
static std::string LogTimestampStr(const std::string &str, std::atomic_bool *fStartedNewLine)
{
string strStamped;
std::string strStamped;
if (!fLogTimestamps)
return str;
@ -293,7 +293,7 @@ int LogPrintStr(const std::string &str) @@ -293,7 +293,7 @@ int LogPrintStr(const std::string &str)
int ret = 0; // Returns total number of characters written
static std::atomic_bool fStartedNewLine(true);
string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
std::string strTimestamped = LogTimestampStr(str, &fStartedNewLine);
if (fPrintToConsole)
{
@ -561,14 +561,14 @@ void ReadConfigFile(const std::string& confPath) @@ -561,14 +561,14 @@ void ReadConfigFile(const std::string& confPath)
{
LOCK(cs_args);
set<string> setOptions;
std::set<std::string> setOptions;
setOptions.insert("*");
for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it)
{
// Don't overwrite existing settings so command line settings override bitcoin.conf
string strKey = string("-") + it->string_key;
string strValue = it->value[0];
std::string strKey = std::string("-") + it->string_key;
std::string strValue = it->value[0];
InterpretNegativeSetting(strKey, strValue);
if (mapArgs.count(strKey) == 0)
mapArgs[strKey] = strValue;

8
src/utilmoneystr.cpp

@ -9,8 +9,6 @@ @@ -9,8 +9,6 @@
#include "tinyformat.h"
#include "utilstrencodings.h"
using namespace std;
std::string FormatMoney(const CAmount& n)
{
// Note: not using straight sprintf here because we do NOT want
@ -18,7 +16,7 @@ std::string FormatMoney(const CAmount& n) @@ -18,7 +16,7 @@ std::string FormatMoney(const CAmount& n)
int64_t n_abs = (n > 0 ? n : -n);
int64_t quotient = n_abs/COIN;
int64_t remainder = n_abs%COIN;
string str = strprintf("%d.%08d", quotient, remainder);
std::string str = strprintf("%d.%08d", quotient, remainder);
// Right-trim excess zeros before the decimal point:
int nTrim = 0;
@ -33,14 +31,14 @@ std::string FormatMoney(const CAmount& n) @@ -33,14 +31,14 @@ std::string FormatMoney(const CAmount& n)
}
bool ParseMoney(const string& str, CAmount& nRet)
bool ParseMoney(const std::string& str, CAmount& nRet)
{
return ParseMoney(str.c_str(), nRet);
}
bool ParseMoney(const char* pszIn, CAmount& nRet)
{
string strWhole;
std::string strWhole;
int64_t nUnits = 0;
const char* p = pszIn;
while (isspace(*p))

50
src/utilstrencodings.cpp

@ -12,20 +12,18 @@ @@ -12,20 +12,18 @@
#include <errno.h>
#include <limits>
using namespace std;
static const std::string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static const string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static const string SAFE_CHARS[] =
static const std::string SAFE_CHARS[] =
{
CHARS_ALPHA_NUM + " .,;-_/:?@()", // SAFE_CHARS_DEFAULT
CHARS_ALPHA_NUM + " .,;-_?@", // SAFE_CHARS_UA_COMMENT
CHARS_ALPHA_NUM + ".-_", // SAFE_CHARS_FILENAME
};
string SanitizeString(const string& str, int rule)
std::string SanitizeString(const std::string& str, int rule)
{
string strResult;
std::string strResult;
for (std::string::size_type i = 0; i < str.size(); i++)
{
if (SAFE_CHARS[rule].find(str[i]) != std::string::npos)
@ -57,7 +55,7 @@ signed char HexDigit(char c) @@ -57,7 +55,7 @@ signed char HexDigit(char c)
return p_util_hexdigit[(unsigned char)c];
}
bool IsHex(const string& str)
bool IsHex(const std::string& str)
{
for(std::string::const_iterator it(str.begin()); it != str.end(); ++it)
{
@ -67,10 +65,10 @@ bool IsHex(const string& str) @@ -67,10 +65,10 @@ bool IsHex(const string& str)
return (str.size() > 0) && (str.size()%2 == 0);
}
vector<unsigned char> ParseHex(const char* psz)
std::vector<unsigned char> ParseHex(const char* psz)
{
// convert hex dump to vector
vector<unsigned char> vch;
std::vector<unsigned char> vch;
while (true)
{
while (isspace(*psz))
@ -88,16 +86,16 @@ vector<unsigned char> ParseHex(const char* psz) @@ -88,16 +86,16 @@ vector<unsigned char> ParseHex(const char* psz)
return vch;
}
vector<unsigned char> ParseHex(const string& str)
std::vector<unsigned char> ParseHex(const std::string& str)
{
return ParseHex(str.c_str());
}
string EncodeBase64(const unsigned char* pch, size_t len)
std::string EncodeBase64(const unsigned char* pch, size_t len)
{
static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
string strRet="";
std::string strRet = "";
strRet.reserve((len+2)/3*4);
int mode=0, left=0;
@ -139,12 +137,12 @@ string EncodeBase64(const unsigned char* pch, size_t len) @@ -139,12 +137,12 @@ string EncodeBase64(const unsigned char* pch, size_t len)
return strRet;
}
string EncodeBase64(const string& str)
std::string EncodeBase64(const std::string& str)
{
return EncodeBase64((const unsigned char*)str.c_str(), str.size());
}
vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
std::vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
{
static const int decode64_table[256] =
{
@ -166,7 +164,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid) @@ -166,7 +164,7 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
if (pfInvalid)
*pfInvalid = false;
vector<unsigned char> vchRet;
std::vector<unsigned char> vchRet;
vchRet.reserve(strlen(p)*3/4);
int mode = 0;
@ -227,17 +225,17 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid) @@ -227,17 +225,17 @@ vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid)
return vchRet;
}
string DecodeBase64(const string& str)
std::string DecodeBase64(const std::string& str)
{
vector<unsigned char> vchRet = DecodeBase64(str.c_str());
return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
std::vector<unsigned char> vchRet = DecodeBase64(str.c_str());
return (vchRet.size() == 0) ? std::string() : std::string((const char*)&vchRet[0], vchRet.size());
}
string EncodeBase32(const unsigned char* pch, size_t len)
std::string EncodeBase32(const unsigned char* pch, size_t len)
{
static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567";
string strRet="";
std::string strRet="";
strRet.reserve((len+4)/5*8);
int mode=0, left=0;
@ -292,12 +290,12 @@ string EncodeBase32(const unsigned char* pch, size_t len) @@ -292,12 +290,12 @@ string EncodeBase32(const unsigned char* pch, size_t len)
return strRet;
}
string EncodeBase32(const string& str)
std::string EncodeBase32(const std::string& str)
{
return EncodeBase32((const unsigned char*)str.c_str(), str.size());
}
vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
std::vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
{
static const int decode32_table[256] =
{
@ -319,7 +317,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid) @@ -319,7 +317,7 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
if (pfInvalid)
*pfInvalid = false;
vector<unsigned char> vchRet;
std::vector<unsigned char> vchRet;
vchRet.reserve((strlen(p))*5/8);
int mode = 0;
@ -414,10 +412,10 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid) @@ -414,10 +412,10 @@ vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid)
return vchRet;
}
string DecodeBase32(const string& str)
std::string DecodeBase32(const std::string& str)
{
vector<unsigned char> vchRet = DecodeBase32(str.c_str());
return (vchRet.size() == 0) ? string() : string((const char*)&vchRet[0], vchRet.size());
std::vector<unsigned char> vchRet = DecodeBase32(str.c_str());
return (vchRet.size() == 0) ? std::string() : std::string((const char*)&vchRet[0], vchRet.size());
}
static bool ParsePrechecks(const std::string& str)

2
src/utiltime.cpp

@ -12,8 +12,6 @@ @@ -12,8 +12,6 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread.hpp>
using namespace std;
static int64_t nMockTime = 0; //!< For unit testing
int64_t GetTime()

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;