Skip to content
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

wallet: Fix and improve CWallet::CreateTransaction #3668

Merged
merged 22 commits into from
Sep 4, 2020
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
829b037
wallet: Remove unused vecTxDSInTmp in CWallet::CreateTransaction
xdustinface Aug 18, 2020
1a24fd4
wallet: Calculate fees earlier and respect them in change determination
xdustinface Aug 18, 2020
a11a5cb
wallet: Cleanup obsolete code in CreateTransaction
xdustinface Aug 20, 2020
82e253b
wallet: Try to pick other inputs if the selected ones are too small
xdustinface Aug 20, 2020
3583a2f
wallet: Break the loop if the transaction is ready
xdustinface Aug 20, 2020
a49d4ca
wallet: Respect additional amount from previous cycles
xdustinface Aug 22, 2020
b4c2d0b
wallet: Respect available in coin selection, try all coins in last round
xdustinface Aug 22, 2020
1587b03
wallet: Avoid potential infinite loop, just in case..
xdustinface Aug 22, 2020
02c394c
wallet: Fix signing in CreateTransaction
xdustinface Aug 23, 2020
6345c4a
wallet: Fix change calculation if "subtract fee from amount" is enabled
xdustinface Aug 23, 2020
d46cd32
wallet: Return after fee calc if no or not enough amount available
xdustinface Aug 23, 2020
6dc126b
wallet: Fix break logic if available amount is not enough
xdustinface Aug 24, 2020
d8b4a8c
Revert "wallet: Fix signing in CreateTransaction"
UdjinM6 Aug 24, 2020
7e9da41
Use a vector of coins instead of a set in CreateTransaction and sort …
UdjinM6 Aug 24, 2020
b9c7796
wallet: Adjust comment
xdustinface Aug 24, 2020
2da8412
Cleaner usage of nChangePosRequest/InOut
UdjinM6 Aug 24, 2020
7bcc9e2
Simplify some fail/try-again conditions (fixed)
UdjinM6 Aug 24, 2020
3f31d60
Loop through outputs to update change output position only when outpu…
UdjinM6 Aug 24, 2020
ddd6af3
Avoid implicit conversions of int-s into bool-s
UdjinM6 Aug 24, 2020
66216e1
Move `nAmountLeft == nFeeRet` check higher, tweak comments
UdjinM6 Aug 24, 2020
31c137a
wallet: Fix some formatting
xdustinface Aug 30, 2020
a059633
wallet: Improve CTxIn creation in CreateTransaction
xdustinface Sep 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid implicit conversions of int-s into bool-s
  • Loading branch information
UdjinM6 authored and xdustinface committed Sep 1, 2020
commit ddd6af38221b212734ea20db6c745a6d76e439a2
6 changes: 3 additions & 3 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3822,7 +3822,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
CAmount nAmountToSelectAdditional{0};
// Start with nAmountToSelectAdditional=0 and loop until there is enough to cover the request + fees, try it 500 times.
int nMaxTries = 500;
while (--nMaxTries)
while (--nMaxTries > 0)
{
nChangePosInOut = std::numeric_limits<int>::max();
txNew.vin.clear();
Expand Down Expand Up @@ -3953,7 +3953,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
CTxOut newTxOut;
const CAmount nAmountLeft = nValueIn - nValue;
auto getChange = [&]() {
if (nSubtractFeeFromAmount) {
if (nSubtractFeeFromAmount > 0) {
return nAmountLeft;
} else {
return nAmountLeft - nFeeRet;
Expand Down Expand Up @@ -4075,7 +4075,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
}
}

if (!nMaxTries) {
if (nMaxTries == 0) {
strFailReason = _("Exceeded max tries.");
return false;
}
Expand Down