Skip to content

Commit 829510c

Browse files
committed
merge bitcoin#15596: Ignore sendmany::minconf as dummy value
includes: - faa3a24 Continuation of 393f455 from dash#4604
1 parent a3d6db6 commit 829510c

File tree

1 file changed

+53
-49
lines changed

1 file changed

+53
-49
lines changed

src/wallet/wallet.cpp

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,25 +2537,27 @@ CWallet::Balance CWallet::GetBalance(const int min_depth, const bool avoid_reuse
25372537
{
25382538
LOCK(cs_wallet);
25392539
std::set<uint256> trusted_parents;
2540-
for (auto pcoin : GetSpendableTXs()) {
2541-
const bool is_trusted{IsTrusted(*pcoin, trusted_parents)};
2542-
const int tx_depth{pcoin->GetDepthInMainChain()};
2543-
const CAmount tx_credit_mine{pcoin->GetAvailableCredit(/* fUseCache */ true, ISMINE_SPENDABLE | reuse_filter)};
2544-
const CAmount tx_credit_watchonly{pcoin->GetAvailableCredit(/* fUseCache */ true, ISMINE_WATCH_ONLY | reuse_filter)};
2545-
if (is_trusted && ((tx_depth >= min_depth) || (fAddLocked && pcoin->IsLockedByInstantSend()))) {
2540+
for (const auto* pcoin : GetSpendableTXs()) {
2541+
const auto& wtx{*pcoin};
2542+
2543+
const bool is_trusted{IsTrusted(wtx, trusted_parents)};
2544+
const int tx_depth{wtx.GetDepthInMainChain()};
2545+
const CAmount tx_credit_mine{wtx.GetAvailableCredit(/* fUseCache */ true, ISMINE_SPENDABLE | reuse_filter)};
2546+
const CAmount tx_credit_watchonly{wtx.GetAvailableCredit(/* fUseCache */ true, ISMINE_WATCH_ONLY | reuse_filter)};
2547+
if (is_trusted && ((tx_depth >= min_depth) || (fAddLocked && wtx.IsLockedByInstantSend()))) {
25462548
ret.m_mine_trusted += tx_credit_mine;
25472549
ret.m_watchonly_trusted += tx_credit_watchonly;
25482550
}
2549-
if (!is_trusted && tx_depth == 0 && pcoin->InMempool()) {
2551+
if (!is_trusted && tx_depth == 0 && wtx.InMempool()) {
25502552
ret.m_mine_untrusted_pending += tx_credit_mine;
25512553
ret.m_watchonly_untrusted_pending += tx_credit_watchonly;
25522554
}
2553-
ret.m_mine_immature += pcoin->GetImmatureCredit();
2554-
ret.m_watchonly_immature += pcoin->GetImmatureWatchOnlyCredit();
2555+
ret.m_mine_immature += wtx.GetImmatureCredit();
2556+
ret.m_watchonly_immature += wtx.GetImmatureWatchOnlyCredit();
25552557
if (CCoinJoinClientOptions::IsEnabled()) {
2556-
ret.m_anonymized += pcoin->GetAnonymizedCredit(coinControl);
2557-
ret.m_denominated_trusted += pcoin->GetDenominatedCredit(false);
2558-
ret.m_denominated_untrusted_pending += pcoin->GetDenominatedCredit(true);
2558+
ret.m_anonymized += wtx.GetAnonymizedCredit(coinControl);
2559+
ret.m_denominated_trusted += wtx.GetDenominatedCredit(false);
2560+
ret.m_denominated_untrusted_pending += wtx.GetDenominatedCredit(true);
25592561
}
25602562
}
25612563
}
@@ -2661,23 +2663,25 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, const CCoinControl* c
26612663
const bool only_safe = {coinControl ? !coinControl->m_include_unsafe_inputs : true};
26622664

26632665
std::set<uint256> trusted_parents;
2664-
for (auto pcoin : GetSpendableTXs()) {
2665-
const uint256& wtxid = pcoin->GetHash();
2666+
for (const auto* pcoin : GetSpendableTXs()) {
2667+
const auto& wtx{*pcoin};
26662668

2667-
if (!chain().checkFinalTx(*pcoin->tx))
2669+
const uint256& wtxid = wtx.GetHash();
2670+
2671+
if (!chain().checkFinalTx(*wtx.tx))
26682672
continue;
26692673

2670-
if (pcoin->IsImmatureCoinBase())
2674+
if (wtx.IsImmatureCoinBase())
26712675
continue;
26722676

2673-
int nDepth = pcoin->GetDepthInMainChain();
2677+
int nDepth = wtx.GetDepthInMainChain();
26742678

26752679
// We should not consider coins which aren't at least in our mempool
26762680
// It's possible for these to be conflicted via ancestors which we may never be able to detect
2677-
if (nDepth == 0 && !pcoin->InMempool())
2681+
if (nDepth == 0 && !wtx.InMempool())
26782682
continue;
26792683

2680-
bool safeTx = IsTrusted(*pcoin, trusted_parents);
2684+
bool safeTx = IsTrusted(wtx, trusted_parents);
26812685

26822686
if (only_safe && !safeTx) {
26832687
continue;
@@ -2687,31 +2691,31 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, const CCoinControl* c
26872691
continue;
26882692
}
26892693

2690-
for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++) {
2694+
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++) {
26912695
bool found = false;
26922696
switch (nCoinType) {
26932697
case CoinType::ONLY_FULLY_MIXED: {
2694-
found = CoinJoin::IsDenominatedAmount(pcoin->tx->vout[i].nValue) &&
2698+
found = CoinJoin::IsDenominatedAmount(wtx.tx->vout[i].nValue) &&
26952699
IsFullyMixed(COutPoint(wtxid, i));
26962700
break;
26972701
}
26982702
case CoinType::ONLY_READY_TO_MIX: {
2699-
found = CoinJoin::IsDenominatedAmount(pcoin->tx->vout[i].nValue) &&
2703+
found = CoinJoin::IsDenominatedAmount(wtx.tx->vout[i].nValue) &&
27002704
!IsFullyMixed(COutPoint(wtxid, i));
27012705
break;
27022706
}
27032707
case CoinType::ONLY_NONDENOMINATED: {
27042708
// NOTE: do not use collateral amounts
2705-
found = !CoinJoin::IsCollateralAmount(pcoin->tx->vout[i].nValue) &&
2706-
!CoinJoin::IsDenominatedAmount(pcoin->tx->vout[i].nValue);
2709+
found = !CoinJoin::IsCollateralAmount(wtx.tx->vout[i].nValue) &&
2710+
!CoinJoin::IsDenominatedAmount(wtx.tx->vout[i].nValue);
27072711
break;
27082712
}
27092713
case CoinType::ONLY_MASTERNODE_COLLATERAL: {
2710-
found = dmn_types::IsCollateralAmount(pcoin->tx->vout[i].nValue);
2714+
found = dmn_types::IsCollateralAmount(wtx.tx->vout[i].nValue);
27112715
break;
27122716
}
27132717
case CoinType::ONLY_COINJOIN_COLLATERAL: {
2714-
found = CoinJoin::IsCollateralAmount(pcoin->tx->vout[i].nValue);
2718+
found = CoinJoin::IsCollateralAmount(wtx.tx->vout[i].nValue);
27152719
break;
27162720
}
27172721
case CoinType::ALL_COINS: {
@@ -2726,7 +2730,7 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, const CCoinControl* c
27262730
continue;
27272731
}
27282732

2729-
if (pcoin->tx->vout[i].nValue < nMinimumAmount || pcoin->tx->vout[i].nValue > nMaximumAmount)
2733+
if (wtx.tx->vout[i].nValue < nMinimumAmount || wtx.tx->vout[i].nValue > nMaximumAmount)
27302734
continue;
27312735

27322736
if (coinControl && coinControl->HasSelected() && !coinControl->fAllowOtherInputs && !coinControl->IsSelected(COutPoint(wtxid, i)))
@@ -2738,7 +2742,7 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, const CCoinControl* c
27382742
if (IsSpent(wtxid, i))
27392743
continue;
27402744

2741-
isminetype mine = IsMine(pcoin->tx->vout[i]);
2745+
isminetype mine = IsMine(wtx.tx->vout[i]);
27422746

27432747
if (mine == ISMINE_NO) {
27442748
continue;
@@ -2748,16 +2752,16 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, const CCoinControl* c
27482752
continue;
27492753
}
27502754

2751-
std::unique_ptr<SigningProvider> provider = GetSolvingProvider(pcoin->tx->vout[i].scriptPubKey);
2755+
std::unique_ptr<SigningProvider> provider = GetSolvingProvider(wtx.tx->vout[i].scriptPubKey);
27522756

2753-
bool solvable = provider ? IsSolvable(*provider, pcoin->tx->vout[i].scriptPubKey) : false;
2757+
bool solvable = provider ? IsSolvable(*provider, wtx.tx->vout[i].scriptPubKey) : false;
27542758
bool spendable = ((mine & ISMINE_SPENDABLE) != ISMINE_NO) || (((mine & ISMINE_WATCH_ONLY) != ISMINE_NO) && (coinControl && coinControl->fAllowWatchOnly && solvable));
27552759

2756-
vCoins.push_back(COutput(pcoin, i, nDepth, spendable, solvable, safeTx, (coinControl && coinControl->fAllowWatchOnly)));
2760+
vCoins.push_back(COutput(&wtx, i, nDepth, spendable, solvable, safeTx, (coinControl && coinControl->fAllowWatchOnly)));
27572761

27582762
// Checks the sum amount of all UTXO's.
27592763
if (nMinimumSumAmount != MAX_MONEY) {
2760-
nTotal += pcoin->tx->vout[i].nValue;
2764+
nTotal += wtx.tx->vout[i].nValue;
27612765

27622766
if (nTotal >= nMinimumSumAmount) {
27632767
return;
@@ -2947,9 +2951,9 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
29472951
std::map<uint256, CWalletTx>::const_iterator it = mapWallet.find(outpoint.hash);
29482952
if (it != mapWallet.end())
29492953
{
2950-
const CWalletTx* pcoin = &it->second;
2954+
const CWalletTx& wtx = it->second;
29512955
// Clearly invalid input, fail
2952-
if (pcoin->tx->vout.size() <= outpoint.n) {
2956+
if (wtx.tx->vout.size() <= outpoint.n) {
29532957
return false;
29542958
}
29552959
if (nCoinType == CoinType::ONLY_FULLY_MIXED) {
@@ -2958,7 +2962,7 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm
29582962
if (!IsFullyMixed(outpoint)) continue;
29592963
}
29602964
// Just to calculate the marginal byte size
2961-
CInputCoin coin(pcoin->tx, outpoint.n, pcoin->GetSpendSize(outpoint.n, false));
2965+
CInputCoin coin(wtx.tx, outpoint.n, wtx.GetSpendSize(outpoint.n, false));
29622966
nValueFromPresetInputs += coin.txout.nValue;
29632967
if (coin.m_input_bytes <= 0) {
29642968
return false; // Not solvable, can't estimate size for fee
@@ -4251,27 +4255,27 @@ std::map<CTxDestination, CAmount> CWallet::GetAddressBalances() const
42514255
std::set<uint256> trusted_parents;
42524256
for (const auto& walletEntry : mapWallet)
42534257
{
4254-
const CWalletTx *pcoin = &walletEntry.second;
4258+
const CWalletTx& wtx = walletEntry.second;
42554259

4256-
if (!IsTrusted(*pcoin, trusted_parents))
4260+
if (!IsTrusted(wtx, trusted_parents))
42574261
continue;
42584262

4259-
if (pcoin->IsImmatureCoinBase())
4263+
if (wtx.IsImmatureCoinBase())
42604264
continue;
42614265

4262-
int nDepth = pcoin->GetDepthInMainChain();
4263-
if ((nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? 0 : 1)) && !pcoin->IsLockedByInstantSend())
4266+
int nDepth = wtx.GetDepthInMainChain();
4267+
if ((nDepth < (wtx.IsFromMe(ISMINE_ALL) ? 0 : 1)) && !wtx.IsLockedByInstantSend())
42644268
continue;
42654269

4266-
for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++)
4270+
for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
42674271
{
42684272
CTxDestination addr;
4269-
if (!IsMine(pcoin->tx->vout[i]))
4273+
if (!IsMine(wtx.tx->vout[i]))
42704274
continue;
4271-
if(!ExtractDestination(pcoin->tx->vout[i].scriptPubKey, addr))
4275+
if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr))
42724276
continue;
42734277

4274-
CAmount n = IsSpent(walletEntry.first, i) ? 0 : pcoin->tx->vout[i].nValue;
4278+
CAmount n = IsSpent(walletEntry.first, i) ? 0 : wtx.tx->vout[i].nValue;
42754279

42764280
balances[addr] += n;
42774281
}
@@ -4289,13 +4293,13 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() const
42894293

42904294
for (const auto& walletEntry : mapWallet)
42914295
{
4292-
const CWalletTx *pcoin = &walletEntry.second;
4296+
const CWalletTx& wtx = walletEntry.second;
42934297

4294-
if (pcoin->tx->vin.size() > 0)
4298+
if (wtx.tx->vin.size() > 0)
42954299
{
42964300
bool any_mine = false;
42974301
// group all input addresses with each other
4298-
for (const CTxIn& txin : pcoin->tx->vin)
4302+
for (const CTxIn& txin : wtx.tx->vin)
42994303
{
43004304
CTxDestination address;
43014305
if(!IsMine(txin)) /* If this input isn't mine, ignore it */
@@ -4309,7 +4313,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() const
43094313
// group change with input addresses
43104314
if (any_mine)
43114315
{
4312-
for (const CTxOut& txout : pcoin->tx->vout)
4316+
for (const CTxOut& txout : wtx.tx->vout)
43134317
if (IsChange(txout))
43144318
{
43154319
CTxDestination txoutAddr;
@@ -4326,7 +4330,7 @@ std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() const
43264330
}
43274331

43284332
// group lone addrs by themselves
4329-
for (const auto& txout : pcoin->tx->vout)
4333+
for (const auto& txout : wtx.tx->vout)
43304334
if (IsMine(txout))
43314335
{
43324336
CTxDestination address;

0 commit comments

Comments
 (0)