# HG changeset patch # User Wladimir J. van der Laan # Date 1346685096 25200 # Node ID 83b24f40896fa345f7c23d7ec336450c9c9c94b9 # Parent 9b67399e93a315c2a4f5f28792fff192451f4e12# Parent 1a08d5de36c438ee0caef0385405239a2067c98d Merge pull request #1743 from xanatos/patch-14 Changed nprev->pprev diff --git a/bitcoin-qt.pro b/bitcoin-qt.pro --- a/bitcoin-qt.pro +++ b/bitcoin-qt.pro @@ -75,12 +75,12 @@ # or: qmake "USE_IPV6=0" (disabled by default) # or: qmake "USE_IPV6=-" (not supported) contains(USE_IPV6, -) { - message(Building without IPv6 support) + message(Building without IPv6 support) } else { - count(USE_IPV6, 0) { - USE_IPV6=1 - } - DEFINES += USE_IPV6=$$USE_IPV6 + count(USE_IPV6, 0) { + USE_IPV6=1 + } + DEFINES += USE_IPV6=$$USE_IPV6 } contains(BITCOIN_NEED_QT_PLUGINS, 1) { @@ -92,7 +92,7 @@ # for extra security against potential buffer overflows QMAKE_CXXFLAGS += -fstack-protector QMAKE_LFLAGS += -fstack-protector - # do not enable this on windows, as it will result in a non-working executable! + # do not enable this on windows cross compile with mingw 4.2.x, as it will result in a non-working executable! } # regenerate src/build.h @@ -176,7 +176,8 @@ src/allocators.h \ src/ui_interface.h \ src/qt/rpcconsole.h \ - src/version.h + src/version.h \ + src/netbase.h SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/qt/transactiontablemodel.cpp \ @@ -202,9 +203,6 @@ src/addrman.cpp \ src/db.cpp \ src/walletdb.cpp \ - src/json/json_spirit_writer.cpp \ - src/json/json_spirit_value.cpp \ - src/json/json_spirit_reader.cpp \ src/qt/clientmodel.cpp \ src/qt/guiutil.cpp \ src/qt/transactionrecord.cpp \ diff --git a/doc/release-notes.txt b/doc/release-notes.txt --- a/doc/release-notes.txt +++ b/doc/release-notes.txt @@ -43,6 +43,7 @@ * Rework gettransaction, getblock calls. 'gettransaction' responds for non-wallet TXs now. * Remove deprecated RPC 'getblocknumber' +* Remove superceded RPC 'getmemorypool' (see BIP 22, above) * New blockchain checkpoint at block 193,000 * listtransactions output now displays "smart" times for transactions, and 'blocktime' and 'timereceived' fields were added @@ -57,8 +58,8 @@ file containing peer address data. * Lower default send buffer from 10MB to 1MB * proxy: SOCKS5 by default -* Support connecting by hostnames passed to proxy (-proxydns) -* Add -seednode connections, and use this for -dnsseed + -proxydns +* Support connecting by hostnames passed to proxy +* Add -seednode connections, and use this instead of DNS seeds when proxied * Added -externalip and -discover * Add -onlynet to connect only to a given network (IPv4, IPv6, or Tor) * Separate listening sockets, -bind= diff --git a/src/db.cpp b/src/db.cpp --- a/src/db.cpp +++ b/src/db.cpp @@ -195,10 +195,7 @@ { delete pdb; pdb = NULL; - { - LOCK(bitdb.cs_db); - --bitdb.mapFileUseCount[strFile]; - } + --bitdb.mapFileUseCount[strFile]; strFile = ""; throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", pszFile, ret)); } diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -225,7 +225,7 @@ " -datadir= " + _("Specify data directory") + "\n" + " -dbcache= " + _("Set database cache size in megabytes (default: 25)") + "\n" + " -dblogsize= " + _("Set database disk log size in megabytes (default: 100)") + "\n" + - " -timeout= " + _("Specify connection timeout (in milliseconds)") + "\n" + + " -timeout= " + _("Specify connection timeout in milliseconds (default: 5000))") + "\n" + " -proxy= " + _("Connect through socks proxy") + "\n" + " -socks= " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" + " -tor= " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n" diff --git a/src/irc.cpp b/src/irc.cpp --- a/src/irc.cpp +++ b/src/irc.cpp @@ -207,16 +207,22 @@ void ThreadIRCSeed2(void* parg) { - /* Don't advertise on IRC if we don't allow incoming connections */ - if (mapArgs.count("-connect") || fNoListen) + // Don't connect to IRC if we won't use IPv4 connections. + if (IsLimited(NET_IPV4)) return; + // ... or if we won't make outbound connections and won't accept inbound ones. + if (mapArgs.count("-connect") && fNoListen) + return; + + // ... or if IRC is not enabled. if (!GetBoolArg("-irc", false)) return; printf("ThreadIRCSeed started\n"); int nErrorWait = 10; int nRetryWait = 10; + int nNameRetry = 0; while (!fShutdown) { @@ -251,7 +257,9 @@ CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses CService addrLocal; string strMyName; - if (GetLocal(addrLocal, &addrIPv4)) + // Don't use our IP as our nick if we're not listening + // or if it keeps failing because the nick is already in use. + if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3) strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); if (strMyName == "") strMyName = strprintf("x%u", GetRand(1000000000)); @@ -267,6 +275,7 @@ if (nRet == 2) { printf("IRC name already in use\n"); + nNameRetry++; Wait(10); continue; } @@ -276,6 +285,7 @@ else return; } + nNameRetry = 0; Sleep(500); // Get our external IP from the IRC server and re-nick before joining the channel @@ -283,7 +293,8 @@ if (GetIPFromIRC(hSocket, strMyName, addrFromIRC)) { printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str()); - if (addrFromIRC.IsRoutable()) + // Don't use our IP as our nick if we're not listening + if (!fNoListen && addrFromIRC.IsRoutable()) { // IRC lets you to re-nick AddLocal(addrFromIRC, LOCAL_IRC); @@ -291,7 +302,7 @@ Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); } } - + if (fTestNet) { Send(hSocket, "JOIN #bitcoinTEST3\r"); Send(hSocket, "WHO #bitcoinTEST3\r"); diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -33,6 +33,7 @@ DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE DEBUGFLAGS=-g CFLAGS=-O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) @@ -93,7 +94,7 @@ i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< bitcoind.exe: $(OBJS:obj/%=obj/%) - i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) + i586-mingw32msvc-g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) @@ -101,7 +102,7 @@ i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework-mt-s $(LIBS) + i586-mingw32msvc-g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework-mt-s $(LIBS) clean: diff --git a/src/makefile.mingw b/src/makefile.mingw --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -28,6 +28,7 @@ DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE DEBUGFLAGS=-g CFLAGS=-mthreads -O2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) +LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) @@ -85,7 +86,7 @@ g++ -c $(CFLAGS) -o $@ $< bitcoind.exe: $(OBJS:obj/%=obj/%) - g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) + g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) @@ -93,7 +94,7 @@ g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< test_bitcoin.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) + g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) clean: -del /Q bitcoind test_bitcoin diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -233,8 +233,8 @@ bool fAlready = mapLocalHost.count(addr) > 0; LocalServiceInfo &info = mapLocalHost[addr]; if (!fAlready || nScore >= info.nScore) { - info.nScore = nScore; - info.nPort = addr.GetPort() + (fAlready ? 1 : 0); + info.nScore = nScore + (fAlready ? 1 : 0); + info.nPort = addr.GetPort(); } SetReachable(addr.GetNetwork()); } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -273,8 +273,7 @@ optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this); optionsAction->setToolTip(tr("Modify configuration options for Bitcoin")); optionsAction->setMenuRole(QAction::PreferencesRole); - toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("Show/Hide &Bitcoin"), this); - toggleHideAction->setToolTip(tr("Show or hide the Bitcoin window")); + toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this); exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this); exportAction->setToolTip(tr("Export the data in the current tab to a file")); encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this); @@ -463,7 +462,7 @@ { if(reason == QSystemTrayIcon::Trigger) { - // Click on system tray icon triggers "show/hide Bitcoin" + // Click on system tray icon triggers show/hide of the main window toggleHideAction->trigger(); } } diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -92,6 +92,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command"), QT_TRANSLATE_NOOP("bitcoin-core", "How many blocks to check at startup (default: 2500, 0 = all)"), QT_TRANSLATE_NOOP("bitcoin-core", "How thorough the block verification is (0-6, default: 1)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Importing blocks..."), QT_TRANSLATE_NOOP("bitcoin-core", "Imports blocks from external blk000?.dat file"), QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"), QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address: '%s'"), diff --git a/src/qt/forms/aboutdialog.ui b/src/qt/forms/aboutdialog.ui --- a/src/qt/forms/aboutdialog.ui +++ b/src/qt/forms/aboutdialog.ui @@ -65,9 +65,6 @@ 0.3.666-beta - - Qt::RichText - Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse @@ -89,13 +86,25 @@ + + + IBeamCursor + + + Copyright © 2009-2012 The Bitcoin developers + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + IBeamCursor - Copyright © 2009-2012 Bitcoin Developers - + This is experimental software. Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -15,9 +15,13 @@ - - Copyright © 2009-2012 Bitcoin Developers - + + Copyright © 2009-2012 The Bitcoin developers + + + + + This is experimental software. Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -286,22 +290,17 @@ BitcoinGUI - + Sign &message... - - Show/Hide &Bitcoin - - - - + Synchronizing with network... - + &Overview @@ -376,7 +375,7 @@ - + &Encrypt Wallet... @@ -409,7 +408,7 @@ - + Send coins to a Bitcoin address @@ -434,12 +433,7 @@ - - Show or hide the Bitcoin window - - - - + Export the data in the current tab to a file @@ -469,12 +463,12 @@ - + &Verify message... - + Bitcoin @@ -484,12 +478,17 @@ - + &About Bitcoin - + + &Show / Hide + + + + &File @@ -657,7 +656,7 @@ - + A fatal error occurred. Bitcoin can no longer continue safely and will quit. @@ -741,7 +740,7 @@ GUIUtil::HelpMessageBox - + Bitcoin-Qt @@ -960,7 +959,7 @@ - + Warning @@ -1256,7 +1255,7 @@ SendCoinsDialog - + @@ -2106,7 +2105,7 @@ - + Usage: @@ -2121,12 +2120,12 @@ - + Get help for a command - + Options: @@ -2141,7 +2140,7 @@ - + Generate coins @@ -2151,7 +2150,7 @@ - + Specify data directory @@ -2181,27 +2180,27 @@ - + Connect to a node to retrieve peer addresses, and disconnect - + Specify your own public address - + Bind to given address. Use [host]:port notation for IPv6 - + Threshold for disconnecting misbehaving peers (default: 100) - + Number of seconds to keep misbehaving peers from reconnecting (default: 86400) @@ -2216,7 +2215,7 @@ - + Run in the background as a daemon and accept commands @@ -2226,7 +2225,7 @@ - + Accept connections from outside (default: 1 if no -proxy or -connect) @@ -2281,7 +2280,12 @@ - + + Importing blocks... + + + + Invalid -tor address: '%s' @@ -2391,22 +2395,22 @@ - + Allow JSON-RPC connections from specified IP address - + Send commands to node running on <ip> (default: 127.0.0.1) - + Execute command when the best block changes (%s in cmd is replaced by block hash) - + Upgrade wallet to latest format @@ -2421,7 +2425,7 @@ - + How many blocks to check at startup (default: 2500, 0 = all) @@ -2431,7 +2435,7 @@ - + Imports blocks from external blk000?.dat file @@ -2451,17 +2455,17 @@ - + Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH) - + This help message - + Cannot obtain a lock on data directory %s. Bitcoin is probably already running. @@ -2471,12 +2475,12 @@ - + Unable to bind to %s on this computer (bind returned error %d, %s) - + Connect through socks proxy @@ -2486,12 +2490,12 @@ - + Loading addresses... - + Error loading blkindex.dat @@ -2506,17 +2510,17 @@ - + Wallet needed to be rewritten: restart Bitcoin to complete - + Error loading wallet.dat - + Invalid -proxy address: '%s' @@ -2531,7 +2535,7 @@ - + Cannot resolve -bind address: '%s' @@ -2541,12 +2545,12 @@ - + Invalid amount for -paytxfee=<amount>: '%s' - + Error: could not start node @@ -2566,17 +2570,17 @@ - + Sending... - + Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here. - + Invalid amount @@ -2591,7 +2595,7 @@ - + Add a node to connect to and attempt to keep the connection open @@ -2611,12 +2615,12 @@ - + Loading wallet... - + Cannot downgrade wallet @@ -2631,22 +2635,22 @@ - + Rescanning... - + Done loading - + To use the %s option - + %s, you must set a rpcpassword in the configuration file: %s It is recommended you use the following random password: diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -13,7 +13,6 @@ #include #include -#include #include // TODO: make it possible to filter out categories (esp debug messages when implemented) @@ -54,34 +53,108 @@ // Nothing to do } +/** + * Split shell command line into a list of arguments. Aims to emulate \c bash and friends. + * + * - Arguments are delimited with whitespace + * - Extra whitespace at the beginning and end and between arguments will be ignored + * - Text can be "double" or 'single' quoted + * - The backslash \c \ is used as escape character + * - Outside quotes, any character can be escaped + * - Within double quotes, only escape \c " and backslashes before a \c " or another backslash + * - Within single quotes, no escaping is possible and no special interpretation takes place + * + * @param[out] args Parsed arguments will be appended to this list + * @param[in] strCommand Command line to split + */ +bool parseCommandLine(std::vector &args, const std::string &strCommand) +{ + enum CmdParseState + { + STATE_EATING_SPACES, + STATE_ARGUMENT, + STATE_SINGLEQUOTED, + STATE_DOUBLEQUOTED, + STATE_ESCAPE_OUTER, + STATE_ESCAPE_DOUBLEQUOTED + } state = STATE_EATING_SPACES; + std::string curarg; + foreach(char ch, strCommand) + { + switch(state) + { + case STATE_ARGUMENT: // In or after argument + case STATE_EATING_SPACES: // Handle runs of whitespace + switch(ch) + { + case '"': state = STATE_DOUBLEQUOTED; break; + case '\'': state = STATE_SINGLEQUOTED; break; + case '\\': state = STATE_ESCAPE_OUTER; break; + case ' ': case '\n': case '\t': + if(state == STATE_ARGUMENT) // Space ends argument + { + args.push_back(curarg); + curarg.clear(); + } + state = STATE_EATING_SPACES; + break; + default: curarg += ch; state = STATE_ARGUMENT; + } + break; + case STATE_SINGLEQUOTED: // Single-quoted string + switch(ch) + { + case '\'': state = STATE_ARGUMENT; break; + default: curarg += ch; + } + break; + case STATE_DOUBLEQUOTED: // Double-quoted string + switch(ch) + { + case '"': state = STATE_ARGUMENT; break; + case '\\': state = STATE_ESCAPE_DOUBLEQUOTED; break; + default: curarg += ch; + } + break; + case STATE_ESCAPE_OUTER: // '\' outside quotes + curarg += ch; state = STATE_ARGUMENT; + break; + case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text + if(ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself + curarg += ch; state = STATE_DOUBLEQUOTED; + break; + } + } + switch(state) // final state + { + case STATE_EATING_SPACES: + return true; + case STATE_ARGUMENT: + args.push_back(curarg); + return true; + default: // ERROR to end in one of the other states + return false; + } +} + void RPCExecutor::request(const QString &command) { - // Parse shell-like command line into separate arguments - std::string strMethod; - std::vector strParams; - try { - boost::escaped_list_separator els('\\',' ','\"'); - std::string strCommand = command.toStdString(); - boost::tokenizer > tok(strCommand, els); - - int n = 0; - for(boost::tokenizer >::iterator beg=tok.begin(); beg!=tok.end();++beg,++n) - { - if(n == 0) // First parameter is the command - strMethod = *beg; - else - strParams.push_back(*beg); - } - } - catch(boost::escaped_list_error &e) + std::vector args; + if(!parseCommandLine(args, command.toStdString())) { - emit reply(RPCConsole::CMD_ERROR, QString("Parse error")); + emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \"")); return; } - - try { + if(args.empty()) + return; // Nothing to do + try + { std::string strPrint; - json_spirit::Value result = tableRPC.execute(strMethod, RPCConvertValues(strMethod, strParams)); + // Convert argument list to JSON objects in method-dependent way, + // and pass it along with the method name to the dispatcher. + json_spirit::Value result = tableRPC.execute( + args[0], + RPCConvertValues(args[0], std::vector(args.begin() + 1, args.end()))); // Format result reply if (result.type() == json_spirit::null_type) @@ -95,7 +168,16 @@ } catch (json_spirit::Object& objError) { - emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false))); + try // Nice formatting for standard-format error + { + int code = find_value(objError, "code").get_int(); + std::string message = find_value(objError, "message").get_str(); + emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")"); + } + catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message + { // Show raw JSON object + emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false))); + } } catch (std::exception& e) { diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -225,6 +225,10 @@ const Value& modeval = find_value(oparam, "mode"); if (modeval.type() == str_type) strMode = modeval.get_str(); + else if (modeval.type() == null_type) + { + /* Do nothing */ + } else throw JSONRPCError(-8, "Invalid mode"); } diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -1006,7 +1006,8 @@ Array ret; - CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(strAccount); + std::list acentries; + CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount); // iterate backwards until we have nCount items to return: for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) diff --git a/src/wallet.cpp b/src/wallet.cpp --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -291,8 +291,7 @@ return true; } -CWallet::TxItems -CWallet::OrderedTxItems(std::string strAccount) +CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, std::string strAccount) { CWalletDB walletdb(strWalletFile); @@ -306,7 +305,7 @@ CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); } - list acentries; + acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); BOOST_FOREACH(CAccountingEntry& entry, acentries) { @@ -375,7 +374,8 @@ { // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future int64 latestTolerated = latestNow + 300; - TxItems txOrdered = OrderedTxItems(); + std::list acentries; + TxItems txOrdered = OrderedTxItems(acentries); for (TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; diff --git a/src/wallet.h b/src/wallet.h --- a/src/wallet.h +++ b/src/wallet.h @@ -146,7 +146,12 @@ typedef std::pair TxPair; typedef std::multimap TxItems; - TxItems OrderedTxItems(std::string strAccount = ""); + + /** Get the wallet's activity log + @return multimap of ordered transactions and accounting entries + @warning Returned pointers are *only* valid within the scope of passed acentries + */ + TxItems OrderedTxItems(std::list& acentries, std::string strAccount = ""); void MarkDirty(); bool AddToWallet(const CWalletTx& wtxIn);