Skip to content

Clean up change computation in CreateTransaction.#5924

Merged
laanwj merged 1 commit intobitcoin:masterfrom
domob1812:change-cleanup
Oct 1, 2015
Merged

Clean up change computation in CreateTransaction.#5924
laanwj merged 1 commit intobitcoin:masterfrom
domob1812:change-cleanup

Conversation

@domob1812
Copy link
Contributor

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

How did you test this?

@domob1812
Copy link
Contributor Author

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

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
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 change-cleanup branch October 1, 2015 09:46
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants