]> Untitled Git - bdk/commit
Restrict `drain_to` usage
authorDaniela Brozzoni <danielabrozzoni@protonmail.com>
Mon, 6 Jun 2022 19:45:13 +0000 (21:45 +0200)
committerDaniela Brozzoni <danielabrozzoni@protonmail.com>
Tue, 28 Jun 2022 08:32:48 +0000 (10:32 +0200)
commit6a150368674046f796f5c37755896f16d8345fbc
tree3c878d6c140a2818e79b2955e0c8c9f44a7e4e54
parent17d0ae0f712ee86a99b96ba393acc572f047a5e7
Restrict `drain_to` usage

Before this commit, you could create a transaction with `drain_to` set
without specifying recipients, nor `drain_wallet`, nor `utxos`. What would
happen is that BDK would pick one input from the wallet and send
that one to `drain_to`, which is quite weird.
This PR restricts the usage of `drain_to`: if you want to use it as a
change output, you need to set recipients as well. If you want to send
a specific utxo to the `drain_to` address, you specify it through
`add_utxos`. If you want to drain the whole wallet, you set
`drain_wallet`. In any other case, if `drain_to` is set, we return a
`NoRecipients` error.

Fixes #620
src/wallet/mod.rs
src/wallet/tx_builder.rs