Skip to content
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

Not accounting for non-RGB inputs in coin selection #113

Open
nicbus opened this issue Jan 26, 2024 · 7 comments
Open

Not accounting for non-RGB inputs in coin selection #113

nicbus opened this issue Jan 26, 2024 · 7 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@nicbus
Copy link
Contributor

nicbus commented Jan 26, 2024

Trying to execute a few transfers using this branch of rgb-sandbox I run into the following error:

Error: not enough funds to pay fee of 400 sats; all inputs contain 2000 sats and outputs spends 2000 sats out of them.

The wallet should have enough bitcoins as the unspents come up as:

Height     Amount, ṩ    Outpoint                                                                                                                                                                                                                                                                                               
bcrt1q06vjlq89kufjgzenwusm99l6hv5ygxhur8qun8    &9/0                                                                                                                                                                                                                                                                           
107             2000    e6cfb776a1e03165f6e739a6452231ac9d30fb20cbde0ae130ed7b10d20dc7b1:0                                                                                                                                                                                                                                     
106             2000    7a39dd007218bdbf3d6d1a2b919700d9a144a1d2cab20cace5a8ad57df2395b7:0                                                                                                                                                                                                                                     
                                                                                                                                                                                                                                                                                                                               
bcrt1qwke7jgvxuwcwk8q4m4mglgmltyfzasde5c4nsj    &0/0                                                                                                                                                                                                                                                                           
105        100000000    2a0bd1672cfb051c7c0627d1295c07325974b53048a87169c80b44f8698c949e:0                                                                                                                                                                                                                                     

I guess this happens because the input selection is not adding more inputs if needed to cover fees (or outputs), but I haven't dug deeper than this.

@dr-orlovsky
Copy link
Member

Yes, you are right in your assumption. I remember writing that logic, but it seems somehow it is skipped. We need to move the issue into BP wallet since it happens there.

@shuimuliang
Copy link

Suppose Alice has one UTXO with 2000 sats.
2000 -> 1600 -> 1200 -> 800 -> 400 (it won't be able to broadcast anymore)

@dr-orlovsky
Copy link
Member

Suppose Alice has one UTXO with 2000 sats.
2000 -> 1600 -> 1200 -> 800 -> 400 (it won't be able to broadcast anymore)

It would - you just need to add more tx inputs and feed additional sats into the witness transaction

@dr-orlovsky dr-orlovsky changed the title not enough funds Not accounting for non-RGB inputs in coin selection Mar 26, 2024
@dr-orlovsky
Copy link
Member

Re-opening and changing the name as explained in BP-WG/bp-wallet#13 (comment)

@dr-orlovsky dr-orlovsky reopened this Mar 26, 2024
@dr-orlovsky dr-orlovsky self-assigned this Mar 26, 2024
@dr-orlovsky dr-orlovsky added the question Further information is requested label Mar 26, 2024
@dr-orlovsky dr-orlovsky added this to the v0.11.0 milestone Mar 26, 2024
@dr-orlovsky
Copy link
Member

Now, there is the question: when and how should we use non-RGB inputs for moving some BTCs to RGB outputs.

In other words, this situation is not a bug but a feature - however possibly bad UX. I just do not know how to make it better: I assume many wallets will differenciate BTC and RGB balances, and if some BTC are "disappearing" after RGB transactions it would be even worse UX...

@nicbus
Copy link
Contributor Author

nicbus commented Mar 29, 2024

I agree that using funds from the "BTC balance" without prior user consent would be bad UX.

I propose doing something similar to what rgb-lib does to handle this. Specifically, I would:

  • add a command that lets the user spend some "BTC balance" (i.e. keychains 0 or 1) to create new RGB UTXOs
    • with default number and size of the UTXOs (e.g. 5 / 5000 sat)
    • with options to specify custom values
  • automatically use RGB UTXOs with 0 allocations to pay for fee or witness transfers (or blind them to allocate assets)
  • return an informative error in case funds (a.k.a. UTXOs) are needed but none are available, hinting at the command to create RGB UTXOs

@dr-orlovsky
Copy link
Member

This is a large feature request, and since rgb cli is not a mainstream wallet I propose to postpone this for v0.12. End-users will be able to do that anyway with proper mobile and web wallets build with rgb-lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants