0

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
Murch
  • 71,155
  • 33
  • 180
  • 600
Bitcoin_1o1
  • 343
  • 1
  • 12

1 Answers1

0

Since there is nothing special about a change output that distinguishes it from other output I would try multiple --to options, one for main recipient and one sending a change amount to an address of yours?

Actually you can probably specify multiple addresses after a single --to as suggested by the ellipsis after --to <ADDRESS:SAT>... in the help text you quoted. That seems more likely to work.

RedGrittyBrick
  • 24,039
  • 3
  • 23
  • 47