Compute the change directly as difference between the "requested" and the actual value returned by SelectCoins. This removes a duplication of the fee logic code.
Clean up change computation in CreateTransaction. #5924
pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:change-cleanup changing 1 files +4 −7-
domob1812 commented at 6:28 PM on March 18, 2015: contributor
-
gavinandresen commented at 6:30 PM on March 18, 2015: contributor
How did you test this?
-
domob1812 commented at 6:55 PM on March 18, 2015: contributor
Unit tests and
wallet.py(which seems to be the relevant one). - laanwj added the label Wallet on Mar 20, 2015
- domob1812 force-pushed on Mar 27, 2015
-
835c12291e
Clean up change computation in CreateTransaction.
Compute the change directly as difference between the "requested" and the actual value returned by SelectCoins. This removes a duplication of the fee logic code.
- domob1812 force-pushed on May 3, 2015
-
in src/wallet/wallet.cpp:None in 835c12291e
1813 | @@ -1814,10 +1814,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, 1814 | dPriority += (double)nCredit * age; 1815 | } 1816 | 1817 | - CAmount nChange = nValueIn - nValue; 1818 | - if (nSubtractFeeFromAmount == 0) 1819 | - nChange -= nFeeRet; 1820 | - 1821 | + const CAmount nChange = nValueIn - nValueToSelect;
laanwj commented at 9:09 AM on October 1, 2015:Before
nChange = nValueIn - nValue - nSubtractFeeFromAmount?0:nFeeRetAfter:
nChange = nValueIn - nValueToSelect = nValueIn - (nValue + nSubtractFeeFromAmount?0:nFeeRet) = nValueIn - nValue - nSubtractFeeFromAmount?0:nFeeRetLooks good to me!
laanwj commented at 9:12 AM on October 1, 2015: memberut/code review ACK
laanwj merged this on Oct 1, 2015laanwj closed this on Oct 1, 2015laanwj referenced this in commit 12a7712abd on Oct 1, 2015domob1812 deleted the branch on Oct 1, 2015MarcoFalke locked this on Sep 8, 2021ContributorsLabels
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 15:15 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-21 15:15 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me