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

Add TxBuilder control coin selection methods #131

Closed
notmandatory opened this issue Apr 5, 2022 · 4 comments · Fixed by #164
Closed

Add TxBuilder control coin selection methods #131

notmandatory opened this issue Apr 5, 2022 · 4 comments · Fixed by #164
Assignees
Milestone

Comments

@notmandatory
Copy link
Member

notmandatory commented Apr 5, 2022

Add methods to TxBuilder to allow users to control coin selection.

Note this issue requires Wallet.list_unspent() to be implemented first to get some OutPoints for testing.

See https://docs.rs/bdk/latest/bdk/wallet/tx_builder/struct.TxBuilder.html for docs on what the functions do.


interface TxBuilder {
  ... 
  TxBuilder add_unspendable(OutPoint unspendable);
  TxBuilder add_utxo(OutPoint outpoint);
  TxBuilder add_utxos(sequence<OutPoint>);
  TxBuilder do_not_spend_change();
  TxBuilder manually_selected_only();
  TxBuilder only_spend_change();
  TxBuilder unspendable(sequence<OutPoint>);
}

@notmandatory notmandatory moved this to Todo in BDK-Bindings Apr 5, 2022
@notmandatory notmandatory changed the title Add methods to TxBuilder to allow users to control coin selection Add TxBuilder control coin selection methods Apr 5, 2022
@artfuldev artfuldev self-assigned this Apr 5, 2022
@zoedberg
Copy link
Contributor

Really interested in this feature!

I was wondering if manually selecting UTXOs and setting manually_selected_only will be enough in order to set an absolute fee (that will be equal to the total input amount minus the total output amount) or if the fee_absolute method will be necessary in order to do that. Could you clarify this, please?

@notmandatory
Copy link
Member Author

notmandatory commented May 23, 2022

I believe that even if you use add_utxo and manually_selected_only you will also need to use fee_absolute to get an absolute fee since the coin selection will only use the specified utxos it needs to pay the outputs and some given fee or fee rate. You can see the rust docs here: https://docs.rs/bdk/latest/bdk/wallet/tx_builder/struct.TxBuilder.html#method.add_utxo

And if you want to test it out you can use the bdk-cli tool, the bdk-ffi behavior will be the same as bdk-cli. See the options with:

bdk-cli wallet -d <descriptor> help create_tx

@zoedberg
Copy link
Contributor

I've implemented all the requested methods plus the fee_absolute one. Since this depends on the list unspent PR I think I should wait for that to be merged before opening a PR for this but feel free to assign me this issue in the meanwhile :)

@notmandatory notmandatory assigned zoedberg and unassigned artfuldev Jun 10, 2022
@notmandatory notmandatory moved this from Todo to In Progress in BDK-Bindings Jun 10, 2022
@notmandatory
Copy link
Member Author

You're also welcome to open a draft PR for some early feedback, but fine to wait until #158 is merged too.

@notmandatory notmandatory added this to the Release 0.8.0 milestone Jul 20, 2022
@notmandatory notmandatory moved this from In Progress to Ready to Review in BDK-Bindings Jul 20, 2022
Repository owner moved this from Ready to Review to Done in BDK-Bindings Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants