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

Transfer all BTC without the change output #273

Open
ShookLyngs opened this issue Aug 8, 2024 · 1 comment
Open

Transfer all BTC without the change output #273

ShookLyngs opened this issue Aug 8, 2024 · 1 comment

Comments

@ShookLyngs
Copy link
Collaborator

ShookLyngs commented Aug 8, 2024

In the current implementation of the btc lib, all imbalanced transactions without non-fixed outputs, should generate a change output. This means that if there are satoshi left in the inputs, they should be returned as a change output. This can be inappropriate in some scenarios, for example, when a user wants to transfer the entire balance to another address, a change output is redundant.

Overall, the feature has two key points to be resolved:

  1. What is the available balance for the transfer-all action?
  2. How can the redundant change output be removed from the transaction?

Related Issues

@ShookLyngs
Copy link
Collaborator Author

ShookLyngs commented Aug 8, 2024

What is the available balance for the transfer-all action?

If an address holds normal BTC UTXOs, RGBPP UTXOs and dust UTXOs, we should only transfer the normal BTC UTXOs and exclude the others. In this case, the sendBtc API is not suitable and we might wanna implement a new API for it.

Ideally, we can fetch the Utxo[] list of the address, and then add all BTC UTXOs to the transaction inputs, while doing this, we should also calculate the total value of the inputs. And then, we can generate an output in the transaction that it contains all the value of the transaction inputs.

How can the redundant change output be removed from the transaction?

The current logic supports:

By setting the output with fixed: false and protected: true should prevent a redundant change output.

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

No branches or pull requests

1 participant