[wallet] Split send_all into set_single_recipient and drain_wallet

Previously `send_all` was particularly confusing, because when used on a
`create_tx` it implied two things:
- spend everything that's in the wallet (if no utxos are specified)
- don't create a change output

But when used on a `bump_fee` it only meant to not add a change output
and instead reduce the only existing output to increase the fee.

This has now been split into two separate options that should hopefully
make it more clear to use, as described in #142.

Additionally, `TxBuilder` now has a "context", that basically allows to
make some flags available only when they are actually meaningful, either
for `create_tx` or `bump_fee`.

Closes #142.
This commit is contained in:
Alekos Filini
2020-10-28 10:37:47 +01:00
parent f67bfe7bfc
commit 36c5a4dc0c
4 changed files with 426 additions and 216 deletions

View File

@@ -34,8 +34,10 @@ pub enum Error {
InvalidU32Bytes(Vec<u8>),
Generic(String),
ScriptDoesntHaveAddressForm,
SendAllMultipleOutputs,
NoAddressees,
SingleRecipientMultipleOutputs,
SingleRecipientNoInputs,
NoRecipients,
NoUtxosSelected,
OutputBelowDustLimit(usize),
InsufficientFunds,
InvalidAddressNetwork(Address),