Yet another simpler way with some extra fundrawtransaction
. Docs say us what inputs and output all required fields. But don’t forget empty list is object too:
Step 1)
$ bitcoin-cli createrawtransaction '[]' \
'{"mxh3H416KCRoBDiweSESew5YJyAk1nxLrN": 0.025}'
Step 2)
$ bitcoin-cli fundrawtransaction <hex_createrawtransaction> \
'{"changeAddress": "mkrzDhhZtzQm8zgckSs4fMNrvtNJ66zaFe"}'
After second step you can look at the fee generated by your wallet. And change it with feeRate
option of fundrawtransaction
command. This all can be done before sign and send to network your transaction.