Bitcoin-Development

在 BDK(比特幣開發工具包)中創建 Tx 時發送非所有 UTXO 金額

  • April 16, 2022

我正在使用 BDK 使用bdk-cli介面創建事務,研究如何發送 Tx 我拉取了create_tx命令的幫助。當您想從選定的 UTXO 發送少於總(-a, --send_all option)資金時如何創建 Tx 尚不清楚,也不清楚如何處理更改。如果可能的話,有誰知道該怎麼做?謝謝您的幫助。

> 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

由於零錢輸出沒有什麼特別之處可以將其與其他輸出區分開來,我會嘗試多種--to選擇,一種用於主要收件人,另一種將零錢金額發送到您的地址?

實際上,您可以在引用的幫助文本中--to按照省略號的建議在單個地址之後指定多個地址。--to <ADDRESS:SAT>...這似乎更有可能奏效。

引用自:https://bitcoin.stackexchange.com/questions/113334