#include "walletdb.h"
#include "bitcoinrpc.h"
#include "init.h"
+#include "timedata.h"
#include "util.h"
#include "ntp.h"
#include "base58.h"
extern int64_t nReserveBalance;
extern void TxToJSON(const CTransaction& tx, const uint256& hashBlock, json_spirit::Object& entry);
-std::string HelpRequiringPassphrase()
+string HelpRequiringPassphrase()
{
return pwalletMain->IsCrypted()
? "\n\nRequires wallet passphrase to be set with walletpassphrase first"
auto nNtpOffset = GetNtpOffset(),
nP2POffset = GetNodesOffset();
- timestamping.push_back(Pair("ntpoffset", nNtpOffset != INT64_MAX ? nNtpOffset : Value::null));
- timestamping.push_back(Pair("p2poffset", nP2POffset != INT64_MAX ? nP2POffset : Value::null));
+ timestamping.push_back(Pair("ntpoffset", nNtpOffset != numeric_limits<int64_t>::max() ? nNtpOffset : Value::null));
+ timestamping.push_back(Pair("p2poffset", nP2POffset != numeric_limits<int64_t>::max() ? nP2POffset : Value::null));
obj.push_back(Pair("timestamping", timestamping));
obj.push_back(Pair("moneysupply", ValueFromAmount(pindexBest->nMoneySupply)));
obj.push_back(Pair("connections", (int)vNodes.size()));
- obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string())));
+ obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.ToStringIPPort() : string())));
obj.push_back(Pair("ip", addrSeenByPeer.ToStringIP()));
diff.push_back(Pair("proof-of-work", GetDifficulty()));
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid NovaCoin address");
string strAccount;
- map<CBitcoinAddress, string>::iterator mi = pwalletMain->mapAddressBook.find(address);
+ auto mi = pwalletMain->mapAddressBook.find(address);
if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty())
strAccount = (*mi).second;
return strAccount;
totalAmount += nAmount;
- vecSend.push_back(make_pair(scriptPubKey, nAmount));
+ vecSend.push_back({ scriptPubKey, nAmount });
}
EnsureWalletIsUnlocked();
"(got %" PRIszu " keys, but need at least %d to redeem)", keys.size(), nRequired));
if (keys.size() > 16)
throw runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number");
- std::vector<CPubKey> pubkeys;
+ vector<CPubKey> pubkeys;
pubkeys.resize(keys.size());
for (unsigned int i = 0; i < keys.size(); i++)
{
- const std::string& ks = keys[i].get_str();
+ const auto& ks = keys[i].get_str();
// Case 1: Bitcoin address and we have full public key:
CBitcoinAddress address(ks);
strprintf("redeemScript exceeds size limit: %" PRIszu " > %d", inner.size(), MAX_SCRIPT_ELEMENT_SIZE));
pwalletMain->AddCScript(inner);
- CBitcoinAddress address(inner.GetID());
+ CBitcoinAddress address{ CScriptID(inner) }; // "most vexing parse"
pwalletMain->SetAddressBookName(address, strAccount);
return address.ToString();
strAccount = AccountFromValue(params[1]);
// Construct using pay-to-script-hash:
- vector<unsigned char> innerData = ParseHexV(params[0], "redeemScript");
+ auto innerData = ParseHexV(params[0], "redeemScript");
CScript inner(innerData.begin(), innerData.end());
pwalletMain->AddCScript(inner);
- CBitcoinAddress address(inner.GetID());
+ CBitcoinAddress address{ CScriptID(inner) }; // "most vexing parse"
pwalletMain->SetAddressBookName(address, strAccount);
return address.ToString();
tallyitem()
{
nAmount = 0;
- nConf = std::numeric_limits<int>::max();
+ nConf = numeric_limits<int>::max();
}
};
// Tally
map<CBitcoinAddress, tallyitem> mapTally;
- for (auto it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it)
+ for (const auto &wit : pwalletMain->mapWallet)
{
- const CWalletTx& wtx = (*it).second;
+ const auto& wtx = wit.second;
if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal())
continue;
if (nDepth < nMinDepth)
continue;
- for(const CTxOut& txout : wtx.vout)
+ for(const auto& txout : wtx.vout)
{
CTxDestination address;
if (!ExtractDestination(txout.scriptPubKey, address) || !IsMine(*pwalletMain, address))
map<string, tallyitem> mapAccountTally;
for(const auto& item : pwalletMain->mapAddressBook)
{
- const CBitcoinAddress& address = item.first;
- const string& strAccount = item.second;
+ const auto& address = item.first;
+ const auto& strAccount = item.second;
auto it = mapTally.find(address);
if (it == mapTally.end() && !fIncludeEmpty)
continue;
int64_t nAmount = 0;
- int nConf = std::numeric_limits<int>::max();
+ int nConf = numeric_limits<int>::max();
if (it != mapTally.end())
{
nAmount = (*it).second.nAmount;
obj.push_back(Pair("address", address.ToString()));
obj.push_back(Pair("account", strAccount));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
- obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
+ obj.push_back(Pair("confirmations", (nConf == numeric_limits<int>::max() ? 0 : nConf)));
ret.push_back(obj);
}
}
if (fByAccounts)
{
- for (auto it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it)
+ for (const auto &acc : mapAccountTally)
{
- auto nAmount = (*it).second.nAmount;
- int nConf = (*it).second.nConf;
+ auto nAmount = acc.second.nAmount;
+ int nConf = acc.second.nConf;
Object obj;
- obj.push_back(Pair("account", (*it).first));
+ obj.push_back(Pair("account", acc.first));
obj.push_back(Pair("amount", ValueFromAmount(nAmount)));
- obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf)));
+ obj.push_back(Pair("confirmations", (nConf == numeric_limits<int>::max() ? 0 : nConf)));
ret.push_back(obj);
}
}
Array ret;
- std::list<CAccountingEntry> acentries;
+ list<CAccountingEntry> acentries;
auto txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount);
// iterate backwards until we have nCount items to return:
if ((nFrom + nCount) > (int)ret.size())
nCount = ret.size() - nFrom;
auto first = ret.begin();
- std::advance(first, nFrom);
+ advance(first, nFrom);
auto last = ret.begin();
- std::advance(last, nFrom+nCount);
+ advance(last, nFrom+nCount);
if (last != ret.end()) ret.erase(last, ret.end());
if (first != ret.begin()) ret.erase(ret.begin(), first);
- std::reverse(ret.begin(), ret.end()); // Return oldest to newest
+ reverse(ret.begin(), ret.end()); // Return oldest to newest
return ret;
}
else
{
entry.push_back(Pair("blockhash", hashBlock.GetHex()));
- map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock);
+ auto mi = mapBlockIndex.find(hashBlock);
if (mi != mapBlockIndex.end() && (*mi).second)
{
- CBlockIndex* pindex = (*mi).second;
+ auto pindex = (*mi).second;
if (pindex->IsInMainChain())
entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight));
else
if (mine == MINE_SPENDABLE) {
CScript subscript;
pwalletMain->GetCScript(scriptID, subscript);
- std::vector<CTxDestination> addresses;
+ vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired);
auto currentAddress = address.ToString();
auto dest = address.Get();
ret.push_back(Pair("address", currentAddress));
- auto mine = pwalletMain ? IsMine(*pwalletMain, address) : MINE_NO;
+ auto mine = IsMine(*pwalletMain, address);
ret.push_back(Pair("ismine", mine != MINE_NO));
if (mine != MINE_NO) {
ret.push_back(Pair("watchonly", mine == MINE_WATCH_ONLY));
LOCK2(cs_main, pwalletMain->cs_wallet);
- std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime());
+ auto txids = pwalletMain->ResendWalletTransactionsBefore(GetTime());
Array result;
- for(const uint256& txid : txids)
+ for(const auto& txid : txids)
{
result.push_back(txid.ToString());
}
"listmalleableviews\n"
"Get list of views for generated malleable keys.\n");
- std::list<CMalleableKeyView> keyViewList;
+ list<CMalleableKeyView> keyViewList;
pwalletMain->ListMalleableViews(keyViewList);
Array result;