aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qa/rpc-tests/util.sh8
-rwxr-xr-xqa/rpc-tests/zapwallettxes.sh161
-rw-r--r--src/init.cpp49
-rw-r--r--src/miner.cpp199
-rw-r--r--src/wallet.cpp4
-rw-r--r--src/wallet.h2
-rw-r--r--src/walletdb.cpp10
-rw-r--r--src/walletdb.h4
8 files changed, 320 insertions, 117 deletions
diff --git a/qa/rpc-tests/util.sh b/qa/rpc-tests/util.sh
index 1e7bd6a7ee..b726ef627f 100644
--- a/qa/rpc-tests/util.sh
+++ b/qa/rpc-tests/util.sh
@@ -38,6 +38,10 @@ function AssertEqual {
if (( $( echo "$1 == $2" | bc ) == 0 ))
then
echoerr "AssertEqual: $1 != $2"
+ declare -f CleanUp > /dev/null 2>&1
+ if [[ $? -eq 0 ]] ; then
+ CleanUp
+ fi
exit 1
fi
}
@@ -49,6 +53,10 @@ function CheckBalance {
if (( $( echo "$B == $EXPECT" | bc ) == 0 ))
then
echoerr "bad balance: $B (expected $2)"
+ declare -f CleanUp > /dev/null 2>&1
+ if [[ $? -eq 0 ]] ; then
+ CleanUp
+ fi
exit 1
fi
}
diff --git a/qa/rpc-tests/zapwallettxes.sh b/qa/rpc-tests/zapwallettxes.sh
new file mode 100755
index 0000000000..bc52a7dacd
--- /dev/null
+++ b/qa/rpc-tests/zapwallettxes.sh
@@ -0,0 +1,161 @@
+#!/usr/bin/env bash
+
+# Test -zapwallettxes=<mode>
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 path_to_binaries"
+ echo "e.g. $0 ../../src"
+ exit 1
+fi
+
+set -f
+
+BITCOIND=${1}/bitcoind
+CLI=${1}/bitcoin-cli
+
+DIR="${BASH_SOURCE%/*}"
+SENDANDWAIT="${DIR}/send.sh"
+if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
+. "$DIR/util.sh"
+
+D=$(mktemp -d test.XXXXX)
+
+D1=${D}/node1
+CreateDataDir "$D1" port=11000 rpcport=11001
+B1ARGS="-datadir=$D1"
+$BITCOIND $B1ARGS &
+B1PID=$!
+
+D2=${D}/node2
+CreateDataDir "$D2" port=11010 rpcport=11011
+B2ARGS="-datadir=$D2"
+$BITCOIND $B2ARGS &
+B2PID=$!
+
+function CleanUp {
+$CLI $B2ARGS stop > /dev/null 2>&1
+wait $B2PID
+$CLI $B1ARGS stop > /dev/null 2>&1
+wait $B1PID
+
+rm -rf $D
+}
+
+# 110 blocks, 10 mature == 500 XBT
+$CLI $B1ARGS setgenerate true 110
+$CLI $B2ARGS setgenerate true 110
+
+CheckBalance "$B1ARGS" 500
+CheckBalance "$B2ARGS" 500
+
+# Send 10 XBT
+TXID1_DEFAULT=$($CLI $B1ARGS sendtoaddress "mrhz5ZgSF3C1BSdyCKt3gEdhKoRL5BNfJV" 10)
+TXID2_DEFAULT=$($CLI $B2ARGS sendtoaddress "mrhz5ZgSF3C1BSdyCKt3gEdhKoRL5BNfJV" 10)
+
+CheckBalance $B1ARGS 490
+CheckBalance $B2ARGS 490
+
+# Move 10 XBT to testaccount
+TMP=$($CLI $B1ARGS move "" "testaccount" 10)
+TMP=$($CLI $B2ARGS move "" "testaccount" 10)
+
+CheckBalance $B1ARGS 10 "testaccount"
+CheckBalance $B2ARGS 10 "testaccount"
+
+# Send 1 XBT from testaccount
+TXID1_TESTACCOUNT=$($CLI $B1ARGS sendfrom "testaccount" "mrhz5ZgSF3C1BSdyCKt3gEdhKoRL5BNfJV" 1)
+TXID2_TESTACCOUNT=$($CLI $B2ARGS sendfrom "testaccount" "mrhz5ZgSF3C1BSdyCKt3gEdhKoRL5BNfJV" 1)
+
+CheckBalance $B1ARGS 9 "testaccount"
+CheckBalance $B2ARGS 9 "testaccount"
+
+CheckBalance $B1ARGS 489
+CheckBalance $B2ARGS 489
+
+# Confirm transactions
+$CLI $B1ARGS setgenerate true 1
+$CLI $B2ARGS setgenerate true 1
+
+# Create unconfirmed transaction
+TXID1_UNCONFIRMED=$($CLI $B1ARGS sendtoaddress "mrhz5ZgSF3C1BSdyCKt3gEdhKoRL5BNfJV" 1)
+TXID2_UNCONFIRMED=$($CLI $B2ARGS sendtoaddress "mrhz5ZgSF3C1BSdyCKt3gEdhKoRL5BNfJV" 1)
+
+# check balance (we created another 50 and spent 1 in the meantime)
+CheckBalance $B1ARGS 538
+CheckBalance $B2ARGS 538
+
+# Safety check, if unconfirmed transactions are there
+$CLI $B1ARGS gettransaction $TXID1_UNCONFIRMED > /dev/null 2>&1
+if [[ $? -ne 0 ]] ; then
+ echoerr "gettransaction1_1: $TXID1_UNCONFIRMED failed"
+ CleanUp
+ exit 1
+fi
+$CLI $B2ARGS gettransaction $TXID2_UNCONFIRMED > /dev/null 2>&1
+if [[ $? -ne 0 ]] ; then
+ echoerr "gettransaction2_1: $TXID2_UNCONFIRMED failed"
+ CleanUp
+ exit 1
+fi
+
+# stop nodes
+$CLI $B2ARGS stop > /dev/null 2>&1
+wait $B2PID
+$CLI $B1ARGS stop > /dev/null 2>&1
+wait $B1PID
+
+# restart nodes with -zapwallettxes
+$BITCOIND -zapwallettxes=1 $B1ARGS &
+B1PID=$!
+$BITCOIND -zapwallettxes=2 $B2ARGS &
+B2PID=$!
+
+# check if confirmed transactions are there
+$CLI $B1ARGS gettransaction $TXID1_DEFAULT > /dev/null 2>&1
+if [[ $? -ne 0 ]] ; then
+ echoerr "check confirmed transaction 1: $TXID1_DEFAULT failed"
+ CleanUp
+ exit 1
+fi
+$CLI $B2ARGS gettransaction $TXID2_DEFAULT > /dev/null 2>&1
+if [[ $? -ne 0 ]] ; then
+ echoerr "check confirmed transaction 2: $TXID2_DEFAULT failed"
+ CleanUp
+ exit 1
+fi
+$CLI $B1ARGS gettransaction $TXID1_TESTACCOUNT > /dev/null 2>&1
+if [[ $? -ne 0 ]] ; then
+ echoerr "check confirmed transaction 3: $TXID1_TESTACCOUNT failed"
+ CleanUp
+ exit 1
+fi
+$CLI $B2ARGS gettransaction $TXID2_TESTACCOUNT > /dev/null 2>&1
+if [[ $? -ne 0 ]] ; then
+ echoerr "check confirmed transaction 4: $TXID2_TESTACCOUNT failed"
+ CleanUp
+ exit 1
+fi
+
+# check if unconfirmed transaction is gone
+$CLI $B1ARGS gettransaction $TXID1_UNCONFIRMED > /dev/null 2>&1
+if [[ $? -eq 0 ]] ; then
+ echoerr "check unconfirmed transaction 1: $TXID1_UNCONFIRMED failed"
+ CleanUp
+ exit 1
+fi
+$CLI $B2ARGS gettransaction $TXID2_UNCONFIRMED > /dev/null 2>&1
+if [[ $? -eq 0 ]] ; then
+ echoerr "check unconfirmed transaction 2: $TXID2_UNCONFIRMED failed"
+ CleanUp
+ exit 1
+fi
+
+# check zapwallet mode 1, testaccount balance must be 9 (keeping transaction metadata)
+CheckBalance $B1ARGS 9 "testaccount"
+
+# check zapwallet mode 2, testaccount balance must be 10 (dropping transaction metadata)
+CheckBalance $B2ARGS 10 "testaccount"
+
+echo "Tests successful, cleaning up"
+CleanUp
+exit 0
diff --git a/src/init.cpp b/src/init.cpp
index ff7a9011a5..a03629d07a 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -260,7 +260,8 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + " " + _("on startup") + "\n";
strUsage += " -wallet=<file> " + _("Specify wallet file (within data directory)") + " " + _("(default: wallet.dat)") + "\n";
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
- strUsage += " -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n";
+ strUsage += " -zapwallettxes=<mode> " + _("Delete all wallet transactions and only recover those part of the blockchain through -rescan on startup") + "\n";
+ strUsage += " " + _("(default: 1, 1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)") + "\n";
#endif
strUsage += "\n" + _("Debugging/Testing options:") + "\n";
@@ -536,7 +537,7 @@ bool AppInit2(boost::thread_group& threadGroup)
// -zapwallettx implies a rescan
if (GetBoolArg("-zapwallettxes", false)) {
if (SoftSetBoolArg("-rescan", true))
- LogPrintf("AppInit2 : parameter interaction: -zapwallettxes=1 -> setting -rescan=1\n");
+ LogPrintf("AppInit2 : parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n");
}
// Make sure enough file descriptors are available
@@ -560,6 +561,9 @@ bool AppInit2(boost::thread_group& threadGroup)
// Check for -debugnet (deprecated)
if (GetBoolArg("-debugnet", false))
InitWarning(_("Warning: Deprecated argument -debugnet ignored, use -debug=net"));
+ // Check for -tor - as this is a privacy risk to continue, exit here
+ if (GetBoolArg("-tor", false))
+ return InitError(_("Error: Unsupported argument -tor found, use -onion."));
fBenchmark = GetBoolArg("-benchmark", false);
// Checkmempool defaults to true in regtest mode
@@ -766,19 +770,15 @@ bool AppInit2(boost::thread_group& threadGroup)
}
// -onion can override normal proxy, -noonion disables tor entirely
- // -tor here is a temporary backwards compatibility measure
- if (mapArgs.count("-tor"))
- printf("Notice: option -tor has been replaced with -onion and will be removed in a later version.\n");
if (!(mapArgs.count("-onion") && mapArgs["-onion"] == "0") &&
- !(mapArgs.count("-tor") && mapArgs["-tor"] == "0") &&
- (fProxy || mapArgs.count("-onion") || mapArgs.count("-tor"))) {
+ (fProxy || mapArgs.count("-onion"))) {
CService addrOnion;
- if (!mapArgs.count("-onion") && !mapArgs.count("-tor"))
+ if (!mapArgs.count("-onion"))
addrOnion = addrProxy;
else
- addrOnion = mapArgs.count("-onion")?CService(mapArgs["-onion"], 9050):CService(mapArgs["-tor"], 9050);
+ addrOnion = CService(mapArgs["-onion"], 9050);
if (!addrOnion.IsValid())
- return InitError(strprintf(_("Invalid -onion address: '%s'"), mapArgs.count("-onion")?mapArgs["-onion"]:mapArgs["-tor"]));
+ return InitError(strprintf(_("Invalid -onion address: '%s'"), mapArgs["-onion"]));
SetProxy(NET_TOR, addrOnion, 5);
SetReachable(NET_TOR);
}
@@ -993,11 +993,15 @@ bool AppInit2(boost::thread_group& threadGroup)
pwalletMain = NULL;
LogPrintf("Wallet disabled!\n");
} else {
+
+ // needed to restore wallet transaction meta data after -zapwallettxes
+ std::vector<CWalletTx> vWtx;
+
if (GetBoolArg("-zapwallettxes", false)) {
uiInterface.InitMessage(_("Zapping all transactions from wallet..."));
pwalletMain = new CWallet(strWalletFile);
- DBErrors nZapWalletRet = pwalletMain->ZapWalletTx();
+ DBErrors nZapWalletRet = pwalletMain->ZapWalletTx(vWtx);
if (nZapWalletRet != DB_LOAD_OK) {
uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted"));
return false;
@@ -1092,6 +1096,29 @@ bool AppInit2(boost::thread_group& threadGroup)
LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);
pwalletMain->SetBestChain(chainActive.GetLocator());
nWalletDBUpdated++;
+
+ // Restore wallet transaction metadata after -zapwallettxes=1
+ if (GetBoolArg("-zapwallettxes", false) && GetArg("-zapwallettxes", "1") != "2")
+ {
+ BOOST_FOREACH(const CWalletTx& wtxOld, vWtx)
+ {
+ uint256 hash = wtxOld.GetHash();
+ std::map<uint256, CWalletTx>::iterator mi = pwalletMain->mapWallet.find(hash);
+ if (mi != pwalletMain->mapWallet.end())
+ {
+ const CWalletTx* copyFrom = &wtxOld;
+ CWalletTx* copyTo = &mi->second;
+ copyTo->mapValue = copyFrom->mapValue;
+ copyTo->vOrderForm = copyFrom->vOrderForm;
+ copyTo->nTimeReceived = copyFrom->nTimeReceived;
+ copyTo->nTimeSmart = copyFrom->nTimeSmart;
+ copyTo->fFromMe = copyFrom->fFromMe;
+ copyTo->strFromAccount = copyFrom->strFromAccount;
+ copyTo->nOrderPos = copyFrom->nOrderPos;
+ copyTo->WriteToDisk();
+ }
+ }
+ }
}
} // (!fDisableWallet)
#else // ENABLE_WALLET
diff --git a/src/miner.cpp b/src/miner.cpp
index 63ce125067..6b1f58b229 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -49,7 +49,6 @@ public:
}
};
-
uint64_t nLastBlockTx = 0;
uint64_t nLastBlockSize = 0;
@@ -58,8 +57,10 @@ typedef boost::tuple<double, CFeeRate, const CTransaction*> TxPriority;
class TxPriorityCompare
{
bool byFee;
+
public:
TxPriorityCompare(bool _byFee) : byFee(_byFee) { }
+
bool operator()(const TxPriority& a, const TxPriority& b)
{
if (byFee)
@@ -114,6 +115,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
// Collect memory pool transactions into the block
int64_t nFees = 0;
+
{
LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = chainActive.Tip();
@@ -269,7 +271,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (fPrintPriority)
{
LogPrintf("priority %.1f fee %s txid %s\n",
- dPriority, feeRate.ToString(), tx.GetHash().ToString());
+ dPriority, feeRate.ToString(), tx.GetHash().ToString());
}
// Add transactions that depend on this one to the priority queue
@@ -338,7 +340,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
}
-
#ifdef ENABLE_WALLET
//////////////////////////////////////////////////////////////////////////////
//
@@ -353,7 +354,8 @@ int64_t nHPSTimerStart = 0;
// nonce is 0xffff0000 or above, the block is rebuilt and nNonce starts over at
// zero.
//
-bool static ScanHash(const CBlockHeader *pblock, uint32_t& nNonce, uint256 *phash) {
+bool static ScanHash(const CBlockHeader *pblock, uint32_t& nNonce, uint256 *phash)
+{
// Write the first 76 bytes of the block header to a double-SHA256 state.
CHash256 hasher;
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
@@ -361,7 +363,7 @@ bool static ScanHash(const CBlockHeader *pblock, uint32_t& nNonce, uint256 *phas
assert(ss.size() == 80);
hasher.Write((unsigned char*)&ss[0], 76);
- for (;;) {
+ while (true) {
nNonce++;
// Write the last 4 bytes of the block header (the nonce) to a copy of
@@ -439,114 +441,115 @@ void static BitcoinMiner(CWallet *pwallet)
CReserveKey reservekey(pwallet);
unsigned int nExtraNonce = 0;
- try { while (true) {
- if (Params().MiningRequiresPeers()) {
- // Busy-wait for the network to come online so we don't waste time mining
- // on an obsolete chain. In regtest mode we expect to fly solo.
- while (vNodes.empty())
- MilliSleep(1000);
- }
-
- //
- // Create new block
- //
- unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
- CBlockIndex* pindexPrev = chainActive.Tip();
-
- auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
- if (!pblocktemplate.get())
- return;
- CBlock *pblock = &pblocktemplate->block;
- IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
-
- LogPrintf("Running BitcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
- ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
-
- //
- // Search
- //
- int64_t nStart = GetTime();
- uint256 hashTarget = uint256().SetCompact(pblock->nBits);
- uint256 hash;
- uint32_t nNonce = 0;
- uint32_t nOldNonce = 0;
- while (true)
- {
- bool fFound = ScanHash(pblock, nNonce, &hash);
- uint32_t nHashesDone = nNonce - nOldNonce;
- nOldNonce = nNonce;
+ try {
+ while (true) {
+ if (Params().MiningRequiresPeers()) {
+ // Busy-wait for the network to come online so we don't waste time mining
+ // on an obsolete chain. In regtest mode we expect to fly solo.
+ while (vNodes.empty())
+ MilliSleep(1000);
+ }
- // Check if something found
- if (fFound)
- {
- if (hash <= hashTarget)
+ //
+ // Create new block
+ //
+ unsigned int nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
+ CBlockIndex* pindexPrev = chainActive.Tip();
+
+ auto_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey));
+ if (!pblocktemplate.get())
+ return;
+ CBlock *pblock = &pblocktemplate->block;
+ IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
+
+ LogPrintf("Running BitcoinMiner with %u transactions in block (%u bytes)\n", pblock->vtx.size(),
+ ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
+
+ //
+ // Search
+ //
+ int64_t nStart = GetTime();
+ uint256 hashTarget = uint256().SetCompact(pblock->nBits);
+ uint256 hash;
+ uint32_t nNonce = 0;
+ uint32_t nOldNonce = 0;
+ while (true) {
+ bool fFound = ScanHash(pblock, nNonce, &hash);
+ uint32_t nHashesDone = nNonce - nOldNonce;
+ nOldNonce = nNonce;
+
+ // Check if something found
+ if (fFound)
{
- // Found a solution
- pblock->nNonce = nNonce;
- assert(hash == pblock->GetHash());
+ if (hash <= hashTarget)
+ {
+ // Found a solution
+ pblock->nNonce = nNonce;
+ assert(hash == pblock->GetHash());
- SetThreadPriority(THREAD_PRIORITY_NORMAL);
- CheckWork(pblock, *pwallet, reservekey);
- SetThreadPriority(THREAD_PRIORITY_LOWEST);
+ SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ CheckWork(pblock, *pwallet, reservekey);
+ SetThreadPriority(THREAD_PRIORITY_LOWEST);
- // In regression test mode, stop mining after a block is found.
- if (Params().MineBlocksOnDemand())
- throw boost::thread_interrupted();
+ // In regression test mode, stop mining after a block is found.
+ if (Params().MineBlocksOnDemand())
+ throw boost::thread_interrupted();
- break;
+ break;
+ }
}
- }
- // Meter hashes/sec
- static int64_t nHashCounter;
- if (nHPSTimerStart == 0)
- {
- nHPSTimerStart = GetTimeMillis();
- nHashCounter = 0;
- }
- else
- nHashCounter += nHashesDone;
- if (GetTimeMillis() - nHPSTimerStart > 4000)
- {
- static CCriticalSection cs;
+ // Meter hashes/sec
+ static int64_t nHashCounter;
+ if (nHPSTimerStart == 0)
{
- LOCK(cs);
- if (GetTimeMillis() - nHPSTimerStart > 4000)
+ nHPSTimerStart = GetTimeMillis();
+ nHashCounter = 0;
+ }
+ else
+ nHashCounter += nHashesDone;
+ if (GetTimeMillis() - nHPSTimerStart > 4000)
+ {
+ static CCriticalSection cs;
{
- dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart);
- nHPSTimerStart = GetTimeMillis();
- nHashCounter = 0;
- static int64_t nLogTime;
- if (GetTime() - nLogTime > 30 * 60)
+ LOCK(cs);
+ if (GetTimeMillis() - nHPSTimerStart > 4000)
{
- nLogTime = GetTime();
- LogPrintf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0);
+ dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart);
+ nHPSTimerStart = GetTimeMillis();
+ nHashCounter = 0;
+ static int64_t nLogTime;
+ if (GetTime() - nLogTime > 30 * 60)
+ {
+ nLogTime = GetTime();
+ LogPrintf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0);
+ }
}
}
}
- }
- // Check for stop or if block needs to be rebuilt
- boost::this_thread::interruption_point();
- // Regtest mode doesn't require peers
- if (vNodes.empty() && Params().MiningRequiresPeers())
- break;
- if (nNonce >= 0xffff0000)
- break;
- if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
- break;
- if (pindexPrev != chainActive.Tip())
- break;
-
- // Update nTime every few seconds
- UpdateTime(*pblock, pindexPrev);
- if (Params().AllowMinDifficultyBlocks())
- {
- // Changing pblock->nTime can change work required on testnet:
- hashTarget.SetCompact(pblock->nBits);
+ // Check for stop or if block needs to be rebuilt
+ boost::this_thread::interruption_point();
+ // Regtest mode doesn't require peers
+ if (vNodes.empty() && Params().MiningRequiresPeers())
+ break;
+ if (nNonce >= 0xffff0000)
+ break;
+ if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
+ break;
+ if (pindexPrev != chainActive.Tip())
+ break;
+
+ // Update nTime every few seconds
+ UpdateTime(*pblock, pindexPrev);
+ if (Params().AllowMinDifficultyBlocks())
+ {
+ // Changing pblock->nTime can change work required on testnet:
+ hashTarget.SetCompact(pblock->nBits);
+ }
}
}
- } }
+ }
catch (boost::thread_interrupted)
{
LogPrintf("BitcoinMiner terminated\n");
@@ -581,4 +584,4 @@ void GenerateBitcoins(bool fGenerate, CWallet* pwallet, int nThreads)
minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet));
}
-#endif
+#endif // ENABLE_WALLET
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 7664d6c25c..e74980e9e7 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1514,11 +1514,11 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
}
-DBErrors CWallet::ZapWalletTx()
+DBErrors CWallet::ZapWalletTx(std::vector<CWalletTx>& vWtx)
{
if (!fFileBacked)
return DB_LOAD_OK;
- DBErrors nZapWalletTxRet = CWalletDB(strWalletFile,"cr+").ZapWalletTx(this);
+ DBErrors nZapWalletTxRet = CWalletDB(strWalletFile,"cr+").ZapWalletTx(this, vWtx);
if (nZapWalletTxRet == DB_NEED_REWRITE)
{
if (CDB::Rewrite(strWalletFile, "\x04pool"))
diff --git a/src/wallet.h b/src/wallet.h
index 424799b14e..8494ce9a34 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -341,7 +341,7 @@ public:
void SetBestChain(const CBlockLocator& loc);
DBErrors LoadWallet(bool& fFirstRunRet);
- DBErrors ZapWalletTx();
+ DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx);
bool SetAddressBook(const CTxDestination& address, const std::string& strName, const std::string& purpose);
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 80e9dded5f..3ce2ef019c 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -680,7 +680,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
return result;
}
-DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash)
+DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash, vector<CWalletTx>& vWtx)
{
pwallet->vchDefaultKey = CPubKey();
CWalletScanState wss;
@@ -725,7 +725,11 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash)
uint256 hash;
ssKey >> hash;
+ CWalletTx wtx;
+ ssValue >> wtx;
+
vTxHash.push_back(hash);
+ vWtx.push_back(wtx);
}
}
pcursor->close();
@@ -743,11 +747,11 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash)
return result;
}
-DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet)
+DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
{
// build list of wallet TXs
vector<uint256> vTxHash;
- DBErrors err = FindWalletTx(pwallet, vTxHash);
+ DBErrors err = FindWalletTx(pwallet, vTxHash, vWtx);
if (err != DB_LOAD_OK)
return err;
diff --git a/src/walletdb.h b/src/walletdb.h
index 3bfb436050..8eb716acbb 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -122,8 +122,8 @@ public:
DBErrors ReorderTransactions(CWallet*);
DBErrors LoadWallet(CWallet* pwallet);
- DBErrors FindWalletTx(CWallet* pwallet, std::vector<uint256>& vTxHash);
- DBErrors ZapWalletTx(CWallet* pwallet);
+ DBErrors FindWalletTx(CWallet* pwallet, std::vector<uint256>& vTxHash, std::vector<CWalletTx>& vWtx);
+ DBErrors ZapWalletTx(CWallet* pwallet, std::vector<CWalletTx>& vWtx);
static bool Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys);
static bool Recover(CDBEnv& dbenv, std::string filename);
};