SRD - LOWER_CHANGE match #26871

issue yancyribbens opened this issue on January 11, 2023
  1. yancyribbens commented at 12:34 PM on January 11, 2023: contributor

    I don't fully grok what is going on with LOWER_CHANGE despite the comment. Let's say the target is 1 and I have a UTXO size: 1 + LOWER_CHANGE - .01, IE a UTXO that's greater than the target but less than the target plus LOWER_CHANGE. In that case a selection will not succeed even though the UTXO is greater than the target. I understand not wanting to make a small change output, however, wouldn't the result be no a match when there should be a match?

  2. fanquake commented at 4:44 PM on January 11, 2023: member
  3. fanquake added the label Wallet on Jan 11, 2023
  4. murchandamus commented at 5:22 PM on January 11, 2023: contributor

    You are right, SelectCoinsSRD(…) will fail if you do not have enough funds to add change to your wallet, but that's fine because both Knapsack and BnB find such solutions. Anyway, if you are trying to empty a wallet, you should use sendall.

    In all other cases where your wallet has a balance that exceeds what you are trying to send at least by a bit, SelectCoinsSRD(…) will always find a solution as it will continue selecting inputs until it exceeds target_value+CHANGE_LOWER.

    I'm not sure the Issue Tracker is the best place to ask questions about the Bitcoin Core codebase. It might be better to ask in the #bitcoin-core-pr-reviews channel on Libera Chat (IRC), or on Bitcoin Stack Exchange with the tag [bitcoin-core-development].

  5. yancyribbens commented at 6:12 PM on January 11, 2023: contributor

    @Xekyo ok, so SelectCoinsSRD depends on knowing that other algorithms have already been tried without success. It may be helpful if that was part of the comment. I also couldn't find any accompanying tests for this which would also be helpful.

    As for your comment, I wasn't sure if this was a potential issue or not so I started here. The #bitcoin-core-pr-reviews seems more geared toward reviewing active or recent PR's, right? Wouldn't #bitcoin-core-dev be more appropriate? I didn't want to be intrusive so I'll also consider Bitcoin Stack Exchange in the future.

  6. yancyribbens closed this on Jan 11, 2023

  7. murchandamus commented at 6:43 PM on January 11, 2023: contributor

    Rather than SelectCoinsSRD needing to know about the bigger picture, the coordination is in the purview of its caller ChooseSelectoinResult(…) in spend.cpp. It calls all three different coin selection approaches and then picks the best result. The review club community is open to general questions about Bitcoin Core's codebase, more so than #bitcoin-core-dev. BSE would definitely also work.

  8. yancyribbens commented at 9:29 PM on January 11, 2023: contributor

    Thanks, it's always good to have more avenues to explore. If the review club is more open to questions I'll consider that in the future. That being said, I've lurked on the core-dev channel and read the logs from time to time and they always seem very helpful in that channel as well. I'll try to refrain from opening issues unless I'm more sure it's an issue.

  9. bitcoin locked this on Jan 11, 2024

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:13 UTC

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