Y
Published on

Send Bitcoin with Bitcoin Core

Authors
  • avatar
    Name
    Yinhuan Yuan
    Twitter

Here's how to split transaction creation, signing, and broadcasting across different computers: You need to start bitcoind.

bitcoind -conf="C:\Users\<UserName>\AppData\Local\Bitcoin\bitcoin.conf" -datadir="D:\Bitcoin" -printtoconsole
  1. On Computer 1 (Create unsigned transaction): You need to check the transaction with YOUR_TXID has not been spent. The total of bitcoin in transations is smaller than the amount to be sent. The diference will be paided to miner.
bitcoin-cli -conf="C:\Users\<UserName>\AppData\Local\Bitcoin\bitcoin.conf" createrawtransaction '[{"txid":"YOUR_TXID","vout":0}]' '{"RECIPIENT_ADDRESS":0.1}'

It will generate a Unsigned Hex string.

  1. On Computer 2 (Sign transaction): In cold wallet machine, you also need to start bitcoind. It is fine that you failed with synchronize with the main net.
bitcoind -conf="C:\Users\<UserName>\AppData\Local\Bitcoin\bitcoin.conf" -datadir="D:\Bitcoin" -printtoconsole

Create a json string with transactions and append as the last parameter to sign the transation. PRIVATE_KEY is in WIF format.

bitcoin-cli -conf="C:\Users\<UserName>\AppData\Local\Bitcoin\bitcoin.conf" signrawtransactionwithkey "UNSIGNED_HEX" '["PRIVATE_KEY"]' '[{"txid":"YOUR_TXID","vout":0,"scriptPubKey":"76a9......","amount":0.1016}]'

It will create a hex string and a complete sign to show whether the signing is successful or not.

{
  "hex": "0200000001b........",
  "complete": true
}
  1. On Computer 1 (Broadcast):

Go back the machine which is connected with mainnet and use the following method to send out the transation.

bitcoin-cli -conf="C:\Users\<UserName>\AppData\Local\Bitcoin\bitcoin.conf" sendrawtransaction "SIGNED_HEX"

Key points:

  • Computer 2 needs private keys
  • Copy hex strings between computers securely
  • Verify transaction details before broadcasting
  • Fees must be included in createrawtransaction