I'm using BDK to create a transaction using bdk-cli interface, researching how to send a Tx I pulled the help for the create_tx command. It's not clear how to create a Tx when you want to send less than the total (-a, --send_all option) of funds from the selected UTXO, it is also not clear how to deal with the change. Does anyone know how to do it, if possible? Thanks for the help.
> bdk-cli wallet create_tx -h
bdk-cli-wallet-create_tx 0.4.0
Creates a new unsigned transaction
USAGE:
bdk-cli wallet --descriptor <DESCRIPTOR> create_tx [FLAGS] [OPTIONS] --to <ADDRESS:SAT>...
FLAGS:
-r, --enable_rbf Enables Replace-By-Fee (BIP125)
-h, --help Prints help information
--offline_signer Make a PSBT that can be signed by offline signers and hardware wallets. Forces the addition
of `non_witness_utxo` and more details to let the signer identify the change output
-a, --send_all Sends all the funds (or all the selected utxos). Requires only one recipients of value 0
-V, --version Prints version information
OPTIONS:
--to <ADDRESS:SAT>... Adds a recipient to the transaction
--unspendable <CANT_SPEND_TXID:VOUT>... Marks a utxo as unspendable
--external_policy <EXT_POLICY>
Selects which policy should be used to satisfy the external descriptor
--internal_policy <INT_POLICY>
Selects which policy should be used to satisfy the internal descriptor
--utxos <MUST_SPEND_TXID:VOUT>... Selects which utxos *must* be spent
-f, --fee_rate <SATS_VBYTE> Fee rate to use in sat/vbyte