0

I am looking into being able to send coins from specific addresses to a single output address using bitcoin-cli

Is this possible? What RPC command would I use? Any chance of an example?

1

Yes that possible:

you need to know the txid and Vout index for those particular addresses when they were funded

for example here i have used 3 addressees to send some BTC to single addresses 2N6V6Ko17CPWaZZf6YrGKeq8R1fzbqrTKLF and if know the txid and vout of those addresses when they were funded i will do:

1)create raw tranaction

syntax: createrawtransaction   [{"txid":txid,"vout":n},...] {address:amount,...} 

 bitcoin-cli -regtest createrawtransaction '[{"txid":"582283c5f2293a2cdb27173c3118ff59863d9ff2be5c3b48fa8e66509e9a7d0d","vout":1},{"txid":"3126fc2864fbf780460734dd1512b98e86f72f8e5b8b59047beae9dd859ac33a","vout":0},{"txid":"94a6701b68e38b3f980c9bf2b0e905dd7e479c7ed01590eeee20b1753c29d6af","vout":1}]' '{"2N6V6Ko17CPWaZZf6YrGKeq8R1fzbqrTKLF":"2"}'

2) Sign raw transaction:

syntax: signrawtransaction  <hexstring> [] [<privatekey1>,...] 

bitcoin-cli -regtest  Signrawtransaction hexstring_from_createRawtransaction '[]'["pvtkey_add1","pvtkey_add2","pvtkey_add3"]

3) send raw transaction

syntax: sendrawtransaction hexString

bitcoin-cli -regtest hexString_from_signrawTransction
  • Very cool stuff, Thank you... I have a couple of questions, 1) How do I find the vout number, is there a command to get that information? 2) The private keys used in the sign transaction command, those would be the private keys of the addresses associated with those transactions? – Jeffrey L. Roberts Sep 17 at 4:54
  • 2
    @cryptoKTM signrawtransaction was deprecated in v0.17 and was removed from v0.18. The alternatives are signrawtransactionwithkey and signrawtransactionwithwallet. In the above example, since you are explicitly mentioning the keys you would use the former one. – Ugam Kamat Sep 17 at 6:20
  • 1
    @JeffreyL.Roberts you should know the txid when the address was funded, by simple rpc i.e getrawtransaction on particular txid you can find the vout index , yes they are pvt key associated with addresses also please refer to letest comment for upgraded versions – cryptoKTM Sep 17 at 11:30

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.