Skip to content

Instantly share code, notes, and snippets.

@t4sk
Last active January 2, 2017 21:25
Show Gist options
  • Save t4sk/372be9a8baf1bc47457f92b3aa8eff34 to your computer and use it in GitHub Desktop.
Save t4sk/372be9a8baf1bc47457f92b3aa8eff34 to your computer and use it in GitHub Desktop.
Bitcoin transaction using bitcoin-qt console

How to create transaction using bitcoin-qt console

  • Example of a transaction with single input and output

Start bitcoin-qt (on testnet)

bitcoin-qt -testnet

Open console

Help > Debug window > Console

Inside the console...

listunspent 0
> [
    {
      "txid": "TXID",
      "vout": VOUT,
      "address": "PUB_KEY_HASH",
      "scriptPubKey": "SCRIPT_PUB_KEY",
      "amount": AMOUNT,
      ...
    }
  ]

dumpprivkey PUB_KEY_HASH
> PRIV_KEY

createrawtransaction '[{"txid": "TXID", "vout": VOUT}]' '{"SEND_TO_PUB_KEY_HASH": AMOUNT}'
> RAW_TX

signrawtransaction 'RAW_TX' '[{"txid": "TXID", "vout": VOUT, "scriptPubKey": "SCRIPT_PUB_KEY"}]' '["PRIV_KEY"]'
> { "hex": "SIGNED_TX", ...}

-- check transaction before sending
decoderawtransaction SIGNED_TX

sendtransaction SIGNED_TX
> NEW_TX_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment