Is there a way to run coin selection on a subset of coins? #1080
-
I wanted to run Use-case here is to coin select only within coins that have been selected (or previously tagged) by the user. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The https://docs.rs/bdk/latest/bdk/wallet/tx_builder/struct.TxBuilder.html#method.add_unspendable Going forward for new BDK APIs this sounds like a good feature to add to let you specify your allowed subset directly. Would this make sense for /// Add a list of outpoints to the internal list of UTXOs that are allowed to be spent. If not set then all "spendable"
/// UTXOs are allowed.
///
/// If an error occurs while adding any of the UTXOs then none of them are added and the error is returned.
///
/// The “unspendable” UTXOs have priority over the allowed UTXOs, meaning that if a UTXO is present both in the
/// “allowed” and the “unspendable” list, it will not be spent. UTXOs added with the `add_utxo` or `add_utxos`
/// functions will be added whether they are in the "allowed" list or not.
TxBuilder::allow_utxos(&mut self, outpoints: [OutPoint]) -> Result<&mut Self, Error> /// Add an outpoint to the internal list of UTXOs that are allowed to be spent. If not set then all "spendable"
/// UTXOs are allowed.
///
/// If an error occurs while adding the UTXO then the error is returned.
///
/// The “unspendable” UTXOs have priority over the allowed UTXOs, meaning that if a UTXO is present both in the
/// “allowed” and the “unspendable” list, it will not be spent. UTXOs added with the `add_utxo` or `add_utxos`
/// functions will be added whether they are in the "allowed" list or not.
TxBuilder::allow_utxo(&mut self, outpoint: OutPoint) -> Result<&mut Self, Error> |
Beta Was this translation helpful? Give feedback.
-
@notmandatory going forward it looks like a fine API indeed. But why not allow user to do coin selection directly? User might want to tweak the results of whatever coins are returned by the algo hereself? In that case |
Beta Was this translation helpful? Give feedback.
The
TxBuilder
allows you to specify which UTXOs must NOT be used in coin-selection. It's a bit awkward but if you give it all the UTXOs but the user selected subset then coin-selection will only use your selected subset. The assumption is that you'll usually only have a few UTXOs (such as from dusting attacks) that you want to exclude from coin-selection and the rest are fair game.https://docs.rs/bdk/latest/bdk/wallet/tx_builder/struct.TxBuilder.html#method.add_unspendable
Going forward for new BDK APIs this sounds like a good feature to add to let you specify your allowed subset directly. Would this make sense for
TxBuilder
functions to specify "allowed" UTXOs?/// Add a list of outpoin…