Repository navigation
wallet: Use correct effective value when checking target - #26203
Conversation
|
@1440000bytes could you check if this fixes your issue? Thanks. |
Generally, we avoid throwing "quick refactors" into bug fixes. Especially if they are going to be backported. Or, at least the refactor should be a separate commit, so if it doesn't need backporting, it doesn't have to be. |
0e6dd3d to
f560f6b
Compare
Alright, removed. |
|
Added a unit test. |
|
@aureleoules I want to clarify one thing: Is this a bug only on Windows or other platforms? If its a bug on some linux distro as well it will be easier for me to test |
Or maybe that should be job of testers.. Give me one day I will test it. |
|
This is a logic bug in the wallet. It's entirely platform independent. |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
I don't understand whats happening in this issue. I compiled PR branch and tested it on Windows, it fixes the previous error and bitcoind or bitcoin-qt does not crash. However, returns "insufficient funds". @sipa said this is platform independent but I tried to run the same command on Fedora with v24.0rc1 and it returns PSBT with a change: Windows (PR Branch): Fedora (v24.0rc1): |
|
@1440000bytes So IIUC you have 1 coin worth 0.001 BTC (as shown by your bitcoin/src/wallet/rpc/spend.cpp Lines 1659 to 1663 in f59e915 This needs to fund the payment and the fees for the transaction, including the cost to spend the coin. 0.001 covers the payment and non-input fees, but not the cost to spend. So it is indeed the case that the wallet has insufficient funds. cause of the crash and why the fix works:
Line 584 in f59e915 bitcoin/src/wallet/coinselection.cpp Lines 441 to 445 in f59e915 GetSelectedValue() is 0.001 and GetSelectedEffectiveValue() is something less than 0.0009.So this condition doesn't hit: Line 585 in f59e915 But the assertion does, since selected_effective_value is something less than 0.0009.
|
@1440000bytes: I missed this at first, but could you confirm that the first output you posted is resulting from running |
|
Concept ACK. The assert can also be reproduced by adjusting the amount in the psbt just between the regimes where it succeeds and the regime with insufficient funds. E.g. on an empty regtest datadir: will lead to a crash on master (which is fixed by this PR). |
What is cost to spend?
Yes and both have same config: |
murchandamus
left a comment
There was a problem hiding this comment.
Concept ACK, have a couple small improvement suggestions:
721db50 to
0af938b
Compare
0af938b to
d0d9cf7
Compare
|
Thank you @xekyo @glozow @mzumsande for the reviews, I addressed your comments. Thanks @1440000bytes for testing. |
|
Overall the change looks correct to me. I was trying to backport the test to see where the bug was introduced, but didn't succeed due to too many refactors. Is it a regression from 23.0 or not? |
…g target 2730ed2 test: Check external coin effective value is used in CoinSelection (Aurèle Oulès) 21f96f4 wallet: Use correct effective value when checking target (Aurèle Oulès) Pull request description: backport of #26203 ACKs for top commit: jarolrod: ACK 2730ed2 Tree-SHA512: ce84ac8d47861f290a26d572512467e89ec6ac27973d954d76245b6c6fdea01e36f2e0bce41599abfe14d0014335ebd17b990177771803de39406097973186ca
|
Post merge ACK d0d9cf7 |
Fixes #26185. The following assert failed because it was not checked in the parent function.
bitcoin/src/wallet/coinselection.cpp
Line 391 in 2bd9aa5