Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
Lint: Code style violation: '/Users/shammah/repos/bitcoin-abc/src/wallet/wallet.cpp' has code style errors. | |||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include "wallet/wallet.h" | #include "wallet/wallet.h" | ||||
#include "chain.h" | #include "chain.h" | ||||
#include "checkpoints.h" | #include "checkpoints.h" | ||||
▲ Show 20 Lines • Show All 1,801 Lines • ▼ Show 20 Lines | void CWallet::ReacceptWalletTransactions() { | ||||
} | } | ||||
// Try to add wallet transactions to memory pool. | // Try to add wallet transactions to memory pool. | ||||
for (std::pair<const int64_t, CWalletTx *> &item : mapSorted) { | for (std::pair<const int64_t, CWalletTx *> &item : mapSorted) { | ||||
CWalletTx &wtx = *(item.second); | CWalletTx &wtx = *(item.second); | ||||
LOCK(g_mempool.cs); | LOCK(g_mempool.cs); | ||||
CValidationState state; | CValidationState state; | ||||
wtx.AcceptToMemoryPool(maxTxFee, state); | wtx.AcceptToMemoryPool(state); | ||||
} | } | ||||
} | } | ||||
bool CWalletTx::RelayWalletTransaction(CConnman *connman) { | bool CWalletTx::RelayWalletTransaction(CConnman *connman) { | ||||
assert(pwallet->GetBroadcastTransactions()); | assert(pwallet->GetBroadcastTransactions()); | ||||
if (IsCoinBase() || isAbandoned() || GetDepthInMainChain() != 0) { | if (IsCoinBase() || isAbandoned() || GetDepthInMainChain() != 0) { | ||||
return false; | return false; | ||||
} | } | ||||
CValidationState state; | CValidationState state; | ||||
// GetDepthInMainChain already catches known conflicts. | // GetDepthInMainChain already catches known conflicts. | ||||
if (InMempool() || AcceptToMemoryPool(maxTxFee, state)) { | if (InMempool() || AcceptToMemoryPool(state)) { | ||||
LogPrintf("Relaying wtx %s\n", GetId().ToString()); | LogPrintf("Relaying wtx %s\n", GetId().ToString()); | ||||
if (connman) { | if (connman) { | ||||
CInv inv(MSG_TX, GetId()); | CInv inv(MSG_TX, GetId()); | ||||
connman->ForEachNode( | connman->ForEachNode( | ||||
[&inv](CNode *pnode) { pnode->PushInventory(inv); }); | [&inv](CNode *pnode) { pnode->PushInventory(inv); }); | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,422 Lines • ▼ Show 20 Lines | bool CWallet::CommitTransaction( | ||||
mapRequestCount[wtxNew.GetId()] = 0; | mapRequestCount[wtxNew.GetId()] = 0; | ||||
// Get the inserted-CWalletTx from mapWallet so that the | // Get the inserted-CWalletTx from mapWallet so that the | ||||
// fInMempool flag is cached properly | // fInMempool flag is cached properly | ||||
CWalletTx &wtx = mapWallet.at(wtxNew.GetId()); | CWalletTx &wtx = mapWallet.at(wtxNew.GetId()); | ||||
if (fBroadcastTransactions) { | if (fBroadcastTransactions) { | ||||
// Broadcast | // Broadcast | ||||
if (!wtx.AcceptToMemoryPool(maxTxFee, state)) { | if (!wtx.AcceptToMemoryPool(state)) { | ||||
LogPrintf("CommitTransaction(): Transaction cannot be broadcast " | LogPrintf("CommitTransaction(): Transaction cannot be broadcast " | ||||
"immediately, %s\n", | "immediately, %s\n", | ||||
state.GetRejectReason()); | state.GetRejectReason()); | ||||
// TODO: if we expect the failure to be long term or permanent, | // TODO: if we expect the failure to be long term or permanent, | ||||
// instead delete wtx from the wallet and return failure. | // instead delete wtx from the wallet and return failure. | ||||
} else { | } else { | ||||
wtx.RelayWalletTransaction(connman); | wtx.RelayWalletTransaction(connman); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,161 Lines • ▼ Show 20 Lines | int CMerkleTx::GetBlocksToMaturity() const { | ||||
return std::max(0, (COINBASE_MATURITY + 1) - GetDepthInMainChain()); | return std::max(0, (COINBASE_MATURITY + 1) - GetDepthInMainChain()); | ||||
} | } | ||||
bool CMerkleTx::IsImmatureCoinBase() const { | bool CMerkleTx::IsImmatureCoinBase() const { | ||||
// note GetBlocksToMaturity is 0 for non-coinbase tx | // note GetBlocksToMaturity is 0 for non-coinbase tx | ||||
return GetBlocksToMaturity() > 0; | return GetBlocksToMaturity() > 0; | ||||
} | } | ||||
bool CWalletTx::AcceptToMemoryPool(const Amount nAbsurdFee, | bool CWalletTx::AcceptToMemoryPool(CValidationState &state) { | ||||
CValidationState &state) { | |||||
// We must set fInMempool here - while it will be re-set to true by the | // We must set fInMempool here - while it will be re-set to true by the | ||||
// entered-mempool callback, if we did not there would be a race where a | // entered-mempool callback, if we did not there would be a race where a | ||||
// user could call sendmoney in a loop and hit spurious out of funds errors | // user could call sendmoney in a loop and hit spurious out of funds errors | ||||
// because we think that the transaction they just generated's change is | // because we think that the transaction they just generated's change is | ||||
// unavailable as we're not yet aware its in mempool. | // unavailable as we're not yet aware its in mempool. | ||||
const Config &config = GetConfig(); | |||||
bool ret = ::AcceptToMemoryPool( | bool ret = ::AcceptToMemoryPool( | ||||
GetConfig(), g_mempool, state, tx, true /* fLimitFree */, | config, g_mempool, state, tx, true /* fLimitFree */, | ||||
nullptr /* pfMissingInputs */, false /* fOverrideMempoolLimit */, | nullptr /* pfMissingInputs */, false /* fOverrideMempoolLimit */, | ||||
nAbsurdFee); | config.GetMaxFee()); | ||||
fInMempool = ret; | fInMempool = ret; | ||||
return ret; | return ret; | ||||
} | } |
'/Users/shammah/repos/bitcoin-abc/src/wallet/wallet.cpp' has code style errors.