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?
-
yancyribbens commented at 12:34 PM on January 11, 2023: contributor
- fanquake added the label Wallet on Jan 11, 2023
-
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 usesendall.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 exceedstarget_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].
-
yancyribbens commented at 6:12 PM on January 11, 2023: contributor
@Xekyo ok, so
SelectCoinsSRDdepends 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-reviewsseems more geared toward reviewing active or recent PR's, right? Wouldn't#bitcoin-core-devbe more appropriate? I didn't want to be intrusive so I'll also consider Bitcoin Stack Exchange in the future. - yancyribbens closed this on Jan 11, 2023
-
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. -
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.
- bitcoin locked this on Jan 11, 2024