aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-04-08 12:08:17 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-04-08 12:09:21 +0200
commit7efc9cf672acd752521a79c1547d232b2ca3486b (patch)
treec451fcaa14dd993b8dadfd6ef39c0fe573093a4e /src/wallet/wallet.cpp
parenteb87f84d1820292548102314796422eb6edd92a6 (diff)
parent77650cc9f4646787e843b2922730d8cba5af36a1 (diff)
Merge pull request #5951
77650cc add -walletbroadcast=0 rpc test (Jonas Schnelli) 6f25262 wallet: make it possible to disable transaction broadcast (Wladimir J. van der Laan)
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp21
1 files changed, 14 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;
}