Bitcoin Core coin control via RPC (CLI)

5

1

Bitcoin Core introduced nice Coin Control feature accessible via the GUI client. To my surprise though, I don't see any obvious way how to make use of Coin Control via RPC/bitcoin-cli.

How can I pick a particular unspent output when creating a transaction via RPC?

Jozef

Posted 2017-07-07T11:12:23.580

Reputation: 1 374

Answers

1

You can, but the process is broken up into multiple RPCs.

First you use the listunspent RPC to find outputs to spend.

Then you use createrawtransaction with the inputs you want, and the outputs (destinations) you want.

If you didn't select all inputs and outputs already (including change, if necessary - any difference between inputs and outputs goes to fees), you can use fundrawtransaction to add more inputs using the normal coin selection algorithm, or to add change.

Then you use signrawtransaction to sign your inputs.

When all is ready, you can broadcast your transaction using sendrawtransaction.

Pieter Wuille

Posted 2017-07-07T11:12:23.580

Reputation: 54 032

1Thanks, this really seems to be the only way as of now. Perhaps we'll get a more higher level API someday.Jozef 2018-04-27T06:59:19.603