-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Gradually bump fee when trying to select coins for PS spending tx #2361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2861,26 +2861,36 @@ bool CWallet::SelectCoins(const std::vector<COutput>& vAvailableCoins, const CAm | |
| } | ||
|
|
||
| //if we're doing only denominated, we need to round up to the nearest smallest denomination | ||
| if(nCoinType == ONLY_DENOMINATED) { | ||
| if (nCoinType == ONLY_DENOMINATED) { | ||
| std::vector<CAmount> vecPrivateSendDenominations = CPrivateSend::GetStandardDenominations(); | ||
| CAmount nSmallestDenom = vecPrivateSendDenominations.back(); | ||
| // Make outputs by looping through denominations, from large to small | ||
| for (const auto& nDenom : vecPrivateSendDenominations) | ||
| { | ||
| for (const auto& out : vCoins) | ||
| { | ||
| //make sure it's the denom we're looking for, round the amount up to smallest denom | ||
| if(out.tx->tx->vout[out.i].nValue == nDenom && nValueRet + nDenom < nTargetValue + nSmallestDenom) { | ||
| COutPoint outpoint = COutPoint(out.tx->GetHash(),out.i); | ||
| int nRounds = GetCappedOutpointPrivateSendRounds(outpoint); | ||
| // make sure it's actually anonymized | ||
| if(nRounds < privateSendClient.nPrivateSendRounds) continue; | ||
| nValueRet += nDenom; | ||
| setCoinsRet.insert(std::make_pair(out.tx, out.i)); | ||
| std::vector<CAmount> vecDenominationsAsAFee = vecPrivateSendDenominations; | ||
| std::reverse(vecDenominationsAsAFee.begin(), vecDenominationsAsAFee.end()); | ||
|
|
||
| // Try to fit into fee that matches one of denominations, from small to large | ||
| for (const auto& nDenomAsAFee : vecDenominationsAsAFee) { | ||
| CAmount nMaxPSFee = std::min(nDenomAsAFee, maxTxFee); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does validation.h#L61 need to be changed (maxTxFee)?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm.. we should've probably reverted #737 (i.e. changed this to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #2362 |
||
| // Make outputs by looping through denominations, from large to small | ||
| for (const auto& nDenom : vecPrivateSendDenominations) { | ||
| for (const auto& out : vCoins) { | ||
| // Make sure it's the denom we're looking for, round the amount up to current max fee | ||
| if (out.tx->tx->vout[out.i].nValue == nDenom && nValueRet + nDenom < nTargetValue + nMaxPSFee) { | ||
| COutPoint outpoint = COutPoint(out.tx->GetHash(),out.i); | ||
| int nRounds = GetRealOutpointPrivateSendRounds(outpoint); | ||
| // Make sure it's actually anonymized | ||
| if (nRounds < privateSendClient.nPrivateSendRounds) continue; | ||
| nValueRet += nDenom; | ||
| setCoinsRet.insert(std::make_pair(out.tx, out.i)); | ||
| if (nValueRet >= nTargetValue) return true; // Done, no need to look any further | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm worried that as we are adding inputs it doesn't appear we are increasing the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking about this and no, technically, this should be good. But then I realised that even in this case we are probably doing it wrong (it's not the job of |
||
| } | ||
| } | ||
| } | ||
| // No luck, try next denom as current max fee | ||
| setCoinsRet.clear(); | ||
| // but only if current denom doesn't exceed the global max fee already | ||
| if (nDenomAsAFee >= maxTxFee) return false; | ||
| } | ||
| return (nValueRet >= nTargetValue); | ||
| // should never get here, just in case denom vector is empty for some reason | ||
| return false; | ||
| } | ||
| // calculate value from preset inputs and store them | ||
| std::set<std::pair<const CWalletTx*, uint32_t> > setPresetCoins; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixing formatting with code changes? Disappointed... 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, shame on me :)