Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 1,755 Lines • ▼ Show 20 Lines | for (std::pair<const TxId, CWalletTx> &item : mapWallet) { | ||||
mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx)); | mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx)); | ||||
} | } | ||||
} | } | ||||
// 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(mempool.cs); | LOCK(g_mempool.cs); | ||||
CValidationState state; | CValidationState state; | ||||
wtx.AcceptToMemoryPool(maxTxFee, state); | wtx.AcceptToMemoryPool(maxTxFee, 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) { | ||||
▲ Show 20 Lines • Show All 186 Lines • ▼ Show 20 Lines | Amount CWalletTx::GetChange() const { | ||||
} | } | ||||
nChangeCached = pwallet->GetChange(*this); | nChangeCached = pwallet->GetChange(*this); | ||||
fChangeCached = true; | fChangeCached = true; | ||||
return nChangeCached; | return nChangeCached; | ||||
} | } | ||||
bool CWalletTx::InMempool() const { | bool CWalletTx::InMempool() const { | ||||
LOCK(mempool.cs); | LOCK(g_mempool.cs); | ||||
if (mempool.exists(GetId())) { | if (g_mempool.exists(GetId())) { | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
bool CWalletTx::IsTrusted() const { | bool CWalletTx::IsTrusted() const { | ||||
// Quick answer in most cases | // Quick answer in most cases | ||||
▲ Show 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | for (const COutput &output : vCoins) { | ||||
const CWalletTx *pcoin = output.tx; | const CWalletTx *pcoin = output.tx; | ||||
if (output.nDepth < | if (output.nDepth < | ||||
(pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs)) { | (pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs)) { | ||||
continue; | continue; | ||||
} | } | ||||
if (!mempool.TransactionWithinChainLimit(pcoin->GetId(), | if (!g_mempool.TransactionWithinChainLimit(pcoin->GetId(), | ||||
nMaxAncestors)) { | nMaxAncestors)) { | ||||
continue; | continue; | ||||
} | } | ||||
int i = output.i; | int i = output.i; | ||||
Amount n = pcoin->tx->vout[i].nValue; | Amount n = pcoin->tx->vout[i].nValue; | ||||
std::pair<Amount, std::pair<const CWalletTx *, unsigned int>> coin = | std::pair<Amount, std::pair<const CWalletTx *, unsigned int>> coin = | ||||
std::make_pair(n, std::make_pair(pcoin, i)); | std::make_pair(n, std::make_pair(pcoin, i)); | ||||
▲ Show 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
// Allow to override the default confirmation target over the | // Allow to override the default confirmation target over the | ||||
// CoinControl instance. | // CoinControl instance. | ||||
int currentConfirmationTarget = nTxConfirmTarget; | int currentConfirmationTarget = nTxConfirmTarget; | ||||
if (coinControl && coinControl->nConfirmTarget > 0) { | if (coinControl && coinControl->nConfirmTarget > 0) { | ||||
currentConfirmationTarget = coinControl->nConfirmTarget; | currentConfirmationTarget = coinControl->nConfirmTarget; | ||||
} | } | ||||
Amount nFeeNeeded = | Amount nFeeNeeded = | ||||
GetMinimumFee(nBytes, currentConfirmationTarget, mempool); | GetMinimumFee(nBytes, currentConfirmationTarget, g_mempool); | ||||
if (coinControl && nFeeNeeded > Amount::zero() && | if (coinControl && nFeeNeeded > Amount::zero() && | ||||
coinControl->nMinimumTotalFee > nFeeNeeded) { | coinControl->nMinimumTotalFee > nFeeNeeded) { | ||||
nFeeNeeded = coinControl->nMinimumTotalFee; | nFeeNeeded = coinControl->nMinimumTotalFee; | ||||
} | } | ||||
if (coinControl && coinControl->fOverrideFeeRate) { | if (coinControl && coinControl->fOverrideFeeRate) { | ||||
nFeeNeeded = coinControl->nFeeRate.GetFeeCeiling(nBytes); | nFeeNeeded = coinControl->nFeeRate.GetFeeCeiling(nBytes); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | if (gArgs.GetBoolArg("-walletrejectlongchains", | ||||
1000; | 1000; | ||||
size_t nLimitDescendants = | size_t nLimitDescendants = | ||||
gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); | gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT); | ||||
size_t nLimitDescendantSize = | size_t nLimitDescendantSize = | ||||
gArgs.GetArg("-limitdescendantsize", | gArgs.GetArg("-limitdescendantsize", | ||||
DEFAULT_DESCENDANT_SIZE_LIMIT) * | DEFAULT_DESCENDANT_SIZE_LIMIT) * | ||||
1000; | 1000; | ||||
std::string errString; | std::string errString; | ||||
if (!mempool.CalculateMemPoolAncestors( | if (!g_mempool.CalculateMemPoolAncestors( | ||||
entry, setAncestors, nLimitAncestors, nLimitAncestorSize, | entry, setAncestors, nLimitAncestors, nLimitAncestorSize, | ||||
nLimitDescendants, nLimitDescendantSize, errString)) { | nLimitDescendants, nLimitDescendantSize, errString)) { | ||||
strFailReason = _("Transaction has too long of a mempool chain"); | strFailReason = _("Transaction has too long of a mempool chain"); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 1,191 Lines • ▼ Show 20 Lines | |||||
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 CMerkleTx::AcceptToMemoryPool(const Amount nAbsurdFee, | bool CMerkleTx::AcceptToMemoryPool(const Amount nAbsurdFee, | ||||
CValidationState &state) { | CValidationState &state) { | ||||
return ::AcceptToMemoryPool(GetConfig(), mempool, state, tx, true, nullptr, | return ::AcceptToMemoryPool(GetConfig(), g_mempool, state, tx, true, | ||||
false, nAbsurdFee); | nullptr, false, nAbsurdFee); | ||||
} | } |