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

Clean up change computation in CreateTransaction. #5924

Merged
merged 1 commit into from Oct 1, 2015

Conversation

@domob1812
Copy link
Contributor

domob1812 commented Mar 18, 2015

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.

@gavinandresen
Copy link
Contributor

gavinandresen commented Mar 18, 2015

How did you test this?

@domob1812
Copy link
Contributor Author

domob1812 commented Mar 18, 2015

Unit tests and wallet.py (which seems to be the relevant one).

@laanwj laanwj added the Wallet label Mar 20, 2015
@domob1812 domob1812 force-pushed the domob1812:change-cleanup branch from 8f1c7b5 to e9713e9 Mar 27, 2015
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 domob1812 force-pushed the domob1812:change-cleanup branch from e9713e9 to 835c122 May 3, 2015
if (nSubtractFeeFromAmount == 0)
nChange -= nFeeRet;

const CAmount nChange = nValueIn - nValueToSelect;

This comment has been minimized.

Copy link
@laanwj

laanwj Oct 1, 2015

Member

Before

nChange = nValueIn - nValue - nSubtractFeeFromAmount?0:nFeeRet 

After:

nChange = nValueIn - nValueToSelect 
        = nValueIn - (nValue + nSubtractFeeFromAmount?0:nFeeRet) 
        = nValueIn - nValue - nSubtractFeeFromAmount?0:nFeeRet

Looks good to me!

@laanwj
Copy link
Member

laanwj commented Oct 1, 2015

ut/code review ACK

@laanwj laanwj merged commit 835c122 into bitcoin:master Oct 1, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
laanwj added a commit that referenced this pull request Oct 1, 2015
835c122 Clean up change computation in CreateTransaction. (Daniel Kraft)
@domob1812 domob1812 deleted the domob1812:change-cleanup branch Oct 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.