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?
Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI 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?
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
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 '19 at 6:20