diff options
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 21 | ||||
-rw-r--r-- | src/wallet/wallet.h | 7 |
2 files changed, 21 insertions, 7 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a10123002e..2566b2712b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1096,6 +1096,9 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) void CWallet::ReacceptWalletTransactions() { + // If transcations aren't broadcasted, don't let them into local mempool either + if (!fBroadcastTransactions) + return; LOCK2(cs_main, cs_wallet); BOOST_FOREACH(PAIRTYPE(const uint256, CWalletTx)& item, mapWallet) { @@ -1116,6 +1119,7 @@ void CWallet::ReacceptWalletTransactions() bool CWalletTx::RelayWalletTransaction() { + assert(pwallet->GetBroadcastTransactions()); if (!IsCoinBase()) { if (GetDepthInMainChain() == 0) { @@ -1354,7 +1358,7 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime) { // Do this infrequently and randomly to avoid giving away // that these are our transactions. - if (GetTime() < nNextResend) + if (GetTime() < nNextResend || !fBroadcastTransactions) return; bool fFirst = (nNextResend == 0); nNextResend = GetTime() + GetRand(30 * 60); @@ -1979,14 +1983,17 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) // Track how many getdata requests our transaction gets mapRequestCount[wtxNew.GetHash()] = 0; - // Broadcast - if (!wtxNew.AcceptToMemoryPool(false)) + if (fBroadcastTransactions) { - // This must not fail. The transaction has already been signed and recorded. - LogPrintf("CommitTransaction(): Error: Transaction not valid"); - return false; + // Broadcast + if (!wtxNew.AcceptToMemoryPool(false)) + { + // This must not fail. The transaction has already been signed and recorded. + LogPrintf("CommitTransaction(): Error: Transaction not valid"); + return false; + } + wtxNew.RelayWalletTransaction(); } - wtxNew.RelayWalletTransaction(); } return true; } diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 6ae1c87b1d..4dbb0e2e57 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -455,6 +455,7 @@ private: int64_t nNextResend; int64_t nLastResend; + bool fBroadcastTransactions; /** * Used to keep track of spent outpoints, and @@ -518,6 +519,7 @@ public: nNextResend = 0; nLastResend = 0; nTimeFirstKey = 0; + fBroadcastTransactions = false; } std::map<uint256, CWalletTx> mapWallet; @@ -723,6 +725,11 @@ public: /** Watch-only address added */ boost::signals2::signal<void (bool fHaveWatchOnly)> NotifyWatchonlyChanged; + + /** Inquire whether this wallet broadcasts transactions. */ + bool GetBroadcastTransactions() const { return fBroadcastTransactions; } + /** Set whether this wallet broadcasts transactions. */ + void SetBroadcastTransactions(bool broadcast) { fBroadcastTransactions = broadcast; } }; /** A key allocated from the key pool. */ |