-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Insufficient balance error at 0.0001 BTC, yet available balance says 0.0023 BTC #4505
Comments
We know that the size (and thus fee) of a transaction can increase a lot for every additional input it has. Leather is supposed to select UTXO's based on size so that the largest gets included first (because it is most cost effective). Yet when they this user tries with Leather to send 0.0001 BTC the message is "insufficient balance" if Leather uses the biggest UTXO to cover this... it should be no more expensive to cover the fee than with the other wallet 0.00033390? Using this API to check UTXO's on the address we do see a lot of small ones, likely not cost effective to transfer right now with 200-300 sats/vB fees. https://blockstream.info/api/address/bc1qzl5xt45gazvj2j4su2xdm5tftqkckgst5hhald/utxo but there is atleast one large UTXO in there too: That UTXO alone there (blockstream API) that could cover it the transfer of 0.0001 BTC: that would be an estimated 150-200 kB transaction with a single input and output. |
Another case like the one above: https://blockstream.info/api/address/bc1qy0kfxd896lvujuq4xreuv6xc85t65ljxhs2san/utxo The available balance in the lower right corner looks sufficient. Average network fees for the last five blocks were 30-72 sats/vB. The bigger UTXO's look like enough to cover fee and the transfer for a small amount like 0.00006 BTC, if a single UTXO would be used to cover the fee and transfer, right? |
I wonder if this might just be a bug with the validation as I've ran into this happening illegitimately before. I'd recommend that we try testing this feature with the wallet set to slow 3G emulation, or perhaps it's a react rendering issue where the validator is running behind what the UI is showing. |
@314159265359879 can you perform such a test? |
@markmhendrickson I had a call about this last week with Kyran, I need some dev eyes on this. I can't run these tests. I think it may also require mocking the addresses that were affected (address' balance state has changed since this was first reported, atleast for the first address). |
Another case like this user has a wallet with several small UTXO's but also one big one. This address the largest UTXO is 56177 sats. When the user tried "send max" only 16k was transferrable. A high total fee is expected because currently, send max will include non-economical amounts. Because the wallet should select the biggest UTXO's first it should also be able to send out about 43000 sats without an issue. The transaction fee would be about 12000-13000 sats at a rate of 72 sats/vB. Which means 56177 sats UTXO should be able to cover it on its own without including any small utxo's in the 600 sats range. Left is "sending max" amount. On the right is trying to send 30,000 sats. |
I wonder if you can provide some test cases that'll help us test this logic @314159265359879? Ideally we can have this covered by better unit tests that consider a set of UTXOs and how much the max transferable amount should be? |
Path forward here is to write integration tests for send max |
Test cases. Are we changing the current behavior's or keeping it as it is? Right now it will empty the wallet at whatever cost. Goal of the test is: Are UTXO's excluded from send-max when it is not economic to send them out (based on predefined rule) Lets assume a wallet has these UTXO's on their BTC address (native segwit, P2WPKH) a. 0.00000600 According to this calculator adding an input increases the transaction size by 68 vB (transaction type P2WPKH). at these fee rates .... including one more input will cost: - If the only goal is to test that UTXO's are being excluded when not cost-effective to send and at least 80% of the value is sent (not spend as fee) (aa) the test should determine if at (E.) 400 sats/vB fees, the wallet does excludes UTXO a. through g. and only includes h. as cost-effective. Further testing could help determine if the send-max also excludes part of the UTXO's with varying market fees. For example if aa. is adapted and the market fees average 30 sats/vB. Excluded UTXO should be a. through d. and included should be e. through h. |
@314159265359879 your last comment here seems like a related but different UX question than this issue's original one? In that this issue deals with ensuring that users can send their entire available balance, whereas your last comment deals with providing users with warnings or optionality in regards to using non-cost-effective UTXOs? If so, can we break the latter out into its own issue? |
Also by "writing integrations tests" for this particular issue, we wouldn't aim to change the current UX, but rather fix it (along the lines of ensuring users can send their entire available balance). These automated tests would presumably help identify cases in which the bug arises, fix them, and prevent regressions in the future. |
## [6.26.0](v6.25.0...v6.26.0) (2024-01-26) ### Features * **ui:** adds input element, ref [#4810](#4810) ([e223b0a](e223b0a)) ### Bug Fixes * filter out uneconomical utxos, closes [#4505](#4505) ([a6e116c](a6e116c)) * layout issue when stacking, ref [#4851](#4851) ([ce6c52a](ce6c52a)) * nested button tooltip error, closes [#4835](#4835) ([5b87e3d](5b87e3d)) * onboarding gate in ledger mode ([07729b5](07729b5)) * sign out of the wallet before proceeding with ledger sign in ([aa214c8](aa214c8)) * update psbt warning copy ([988e23f](988e23f)) ### Internal * add BulletSeparator story ([863a128](863a128)) * **deps:** bump vite from 5.0.11 to 5.0.12 ([4ec0cd9](4ec0cd9)) * fix ledger, ref [#4861](#4861) ([62bf0ec](62bf0ec)) * improve styles, try mnemonic ([f6bad6a](f6bad6a)) * post-release merge back ([be0d9a7](be0d9a7)) * remove dupe imports, lint ([b05f731](b05f731))
bc1qzl5xt45gazvj2j4su2xdm5tftqkckgst5hhald
On another wallet it shows
I have always assumed small UTXO's causing it to be non economical to include everything but if that is the case I don't understand why the "available balance" is displayed so much higher.
I am sure the current network fees also play a role
I would love to see this confirmed by a developer who can mock this address. What would be the transaction size, is it that high that the transfer can't be covered by the available balance?
The text was updated successfully, but these errors were encountered: