5

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?

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.

  • 1
    Thanks, this really seems to be the only way as of now. Perhaps we'll get a more higher level API someday. – Jozef Apr 27 '18 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.