We assert that the change_cost must be positive so we should document it in the function's docs
doc: Clarify that change_cost cannot be negative in GetSelectionWaste #22892
pull benthecarman wants to merge 1 commits into bitcoin:master from benthecarman:doc-change-cost-not-negative changing 1 files +3 −1-
benthecarman commented at 3:13 AM on September 5, 2021: contributor
- fanquake added the label Docs on Sep 5, 2021
-
in src/wallet/coinselection.h:177 in 2af5a46782 outdated
173 | @@ -174,7 +174,7 @@ struct OutputGroup 174 | * change_cost = effective_feerate * change_output_size + long_term_feerate * change_spend_size 175 | * 176 | * @param[in] inputs The selected inputs 177 | - * @param[in] change_cost The cost of creating change and spending it in the future. Only used if there is change. Must be 0 if there is no change. 178 | + * @param[in] change_cost The cost of creating change and spending it in the future. Must be positive if there is change. Must be 0 if there is no change.
jonatack commented at 11:22 AM on September 5, 2021:maybe keep both the "Only used if" and "must be positive" info
- * [@param](/bitcoin-bitcoin/contributor/param/)[in] change_cost The cost of creating change and spending it in the future. Only used if there is change. Must be 0 if there is no change. + * [@param](/bitcoin-bitcoin/contributor/param/)[in] change_cost The cost of creating change and spending it in the future. + * Only used if there is change, in which case it must be positive. + * Must be 0 if there is no change.
benthecarman commented at 5:56 PM on September 5, 2021:done
jonatack commented at 11:23 AM on September 5, 2021: memberConcept ACK
practicalswift commented at 11:44 AM on September 5, 2021: contributorConcept ACK: preconditions should be documented
doc: Clarify that change_cost cannot be negative in GetSelectionWaste d2eccacd18benthecarman force-pushed on Sep 5, 2021jonatack commented at 6:11 PM on September 5, 2021: memberACK d2eccacd188959c5aed661d0d5b39c119e7c7a32
fanquake requested review from achow101 on Sep 10, 2021fanquake requested review from meshcollider on Sep 10, 2021jarolrod commented at 7:02 AM on September 13, 2021: memberACK d2eccacd188959c5aed661d0d5b39c119e7c7a32
This should be documented properly. 🥃
shaavan approvedshaavan commented at 1:51 PM on September 16, 2021: contributorACK d2eccacd188959c5aed661d0d5b39c119e7c7a32
It makes sense to document the condition that is later asserted in the code.
laanwj merged this on Sep 27, 2021laanwj closed this on Sep 27, 2021bitcoin locked this on Oct 30, 2022benthecarman deleted the branch on Oct 10, 2025
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-22 18:14 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-22 18:14 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