aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2018-03-09 17:21:27 -0500
committerAndrew Chow <achow101-github@achow101.com>2018-03-13 12:39:26 -0400
commitce7435cf1ef36109595be9a3a3955afdff1d63e4 (patch)
treead93d328576d4d2f2f8e3bcbf46483bf4100e6ec /src/wallet/wallet.cpp
parent0185939be6f7c5554b864e33657ce610fd434e18 (diff)
downloadbitcoin-ce7435cf1ef36109595be9a3a3955afdff1d63e4.tar.xz
Move output eligibility to a separate function
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index e797a63dd8..639e00f2bc 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2484,6 +2484,20 @@ static void ApproximateBestSubset(const std::vector<CInputCoin>& vValue, const C
}
}
+bool CWallet::OutputEligibleForSpending(const COutput& output, const int nConfMine, const int nConfTheirs, const uint64_t nMaxAncestors) const
+{
+ if (!output.fSpendable)
+ return false;
+
+ if (output.nDepth < (output.tx->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs))
+ return false;
+
+ if (!mempool.TransactionWithinChainLimit(output.tx->GetHash(), nMaxAncestors))
+ return false;
+
+ return true;
+}
+
bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMine, const int nConfTheirs, const uint64_t nMaxAncestors, std::vector<COutput> vCoins,
std::set<CInputCoin>& setCoinsRet, CAmount& nValueRet) const
{
@@ -2499,20 +2513,10 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, const int nConfMin
for (const COutput &output : vCoins)
{
- if (!output.fSpendable)
- continue;
-
- const CWalletTx *pcoin = output.tx;
-
- if (output.nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? nConfMine : nConfTheirs))
- continue;
-
- if (!mempool.TransactionWithinChainLimit(pcoin->GetHash(), nMaxAncestors))
+ if (!OutputEligibleForSpending(output, nConfMine, nConfTheirs, nMaxAncestors))
continue;
- int i = output.i;
-
- CInputCoin coin = CInputCoin(pcoin, i);
+ CInputCoin coin = CInputCoin(output.tx, output.i);
if (coin.txout.nValue == nTargetValue)
{