Avoid creating unnecessary change #892

pull dooglus wants to merge 0 commits into bitcoin:master from dooglus:master changing 0 files +0 −0
  1. dooglus commented at 10:31 PM on February 24, 2012: contributor

    If we have three 50BTC outputs and try to spend 100BTC, we should use only two of the outputs. Previously we were using all three. Similarly if we have outputs of 50, 50, and 0.01 and want to spend 100BTC, we shouldn't include the 0.01 in the transaction.

    http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf shows a transaction where MtGox was trying to consolidate ten 50k outputs into a single 500k output. The wallet had at least 11 50k outputs in it. Because of this code in wallet.cpp: if (nTotalLower >= nTargetValue + CENT) nTargetValue += CENT; the target value was increased from 500k to 500k plus a cent, which couldn't be found using just ten 50k outputs, and so an eleventh 50k output became involved, to avoid sub-cent change. There was no need for any change at all. (I notice the 50k change hasn't yet been redeemed. I hope it isn't lost!)

    These transactions show other common cases where extra 0.01 coins are tacked on to both sides of transactions for no good reason:

    http://blockexplorer.com/tx/a9d50d41be42beb278f5830d75aee06216b0a9c93d5eb5a62b6d30bec8c272f3 http://blockexplorer.com/tx/a2f748139f90b5063aace9ab18cb0ceb011a440a5a51888e0ec6c7b71a12aed6

  2. dooglus merged this on Feb 25, 2012
  3. dooglus closed this on Feb 25, 2012

  4. dooglus commented at 6:34 PM on February 27, 2012: contributor

    User error on my part. I made the change on my master branch which seemed to cause problems. See above where it says:

    "dooglus merged commit da9ab62 into bitcoin:master from dooglus:master"

    I don't have write access to bitcoin:master, so I don't know why it thinks I did that.

    I opened a new pull request, 898, for the same issue.

  5. destenson referenced this in commit a38d983b18 on Jun 26, 2016
  6. ptschip referenced this in commit 2024e7bf29 on Jan 9, 2018
  7. DrahtBot locked this on Sep 8, 2021
Contributors

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-16 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me