dcrwallet icon indicating copy to clipboard operation
dcrwallet copied to clipboard

Implement spendoutputs JSON-RPC method

Open jrick opened this issue 2 years ago • 1 comments

This method provides greater coin control when creating and sending transactions. Rather than the wallet performing UTXO selection on its own, only the specified inputs and outputs (with the exception of wallet change) will be used.

This is intended to be a more ergonomic and easier to use alternative to the raw transaction RPCs (createrawtransaction, signrawtransaction, and sendrawtransaction).

jrick avatar Sep 28 '23 16:09 jrick

Conceptually, I'm super excited about this. Dealing with raw transactions manually is a pain.

matthawkins90 avatar Sep 28 '23 17:09 matthawkins90

An example on how this can be used:

$ cat spendoutputs.sh                                                                                                                 
#!/bin/ksh

exec ./dcrctl --testnet --wallet spendoutputs default - - <<EOF
$(jq -M -c < spendoutputs-previousoutpoints.txt)
$(jq -M -c < spendoutputs-outputs.txt)
EOF
$ cat spendoutputs-previousoutpoints.txt                                                                                              
[
  "952d607bfabf524bef523ec08bb743ede8618864fe8ae1418d6020286150dfc9:4",
  "c90939f5e0eeab4cb296c84b6883fa692892b60c0e0e60bec1cf0193e1372c3c:3"
]
$ cat spendoutputs-outputs.txt                                                                                                        
[
  {"address": "TsXVzz2xrAxEMUYGj7wRfFvEnEqsTJ2RARB", "amount": 1.23},
  {"address": "TsYFYPAJaApn2pGEkziHJ9VuHuhXWoRLGKw", "amount": 4.56}
]
$ ./spendoutputs.sh
e0456b1f52bc8db0ceab33fe34cb9206a9f685349a9fff2f8ea8291ce16eb891

jrick avatar Apr 17 '24 13:04 jrick