coldstorage – How to send bitcoin from an offline Bitcoin Core that does not have a synchronized balance?

The easiest way to do this is by importing the address that you generated in the Bitcoin Core offline client in a fully synchronized Bitcoin-Core online. The command is: bitcoin-cli importaddress

. The benefit of importing this address into the synchronized Bitcoin-Core machine is that you can use it as an observation-only address that will allow you to see all the UTXOs related to it. Then you can use the command bitcoin-cli listunspent to show you all the UTXO and then you can use those related to the address in question.

Note: below txids and the quantities are composed.
Now, using the UTXO that were shown in the listunspent output can create a transaction in the online customer using the createrawtransaction I send. I deliberately used two UTXO to show how this can be done for multiple UTXOs and also to show what other commands will look like if one of the exit points in the entries belongs to an inherited address and the other exit point belongs to a P2SH address -P2WPKH.

bitcoin-cli createrawtransaction '({"txid":"27893ad827ddd94c442c561b1d3bf3d0f60571d6518e4941698e5778b25e1991","vout":0},{"txid":"776be22ff789a86283b247f99f7b2c6f7f53185cb765570bc65c6e6bb7ed8558","vout":1})' '{"12WJykFa1hqJUJ65QbFB8dS5XNJaR22w2S":0.1}' 

This would give you the following hexadecimal string that you can copy to your machine offline.

output: 020000000291195eb278578e6941498e51d67105f6d0f33b1d1b562c444cd9dd27d83a89270000000000ffffffff5885edb76b6e5cc60b5765b75c18537f6f2c7b9ff947b28362a889f72fe26b770100000000ffffffff0180969800000000001976a9141083323e89f0f734c448cd16d5a5513afb841b1788ac00000000

Copy that output to the machine offline to sign the transaction. Now signrawtransaction The command was deprecated in v0.17 and removed since v0.18. Instead we now have signrawtransactionwithwallet Y signrawtransactionwithkey. You will use the first one when you want to sign the transaction from a key that belongs to your wallet in Bitcoin Core and will use the last one when you want to sign a transaction with a key that is not in your wallet by passing the private key along with the command.

As your address was generated from a key in the wallet, we will use the first command. After copying on the output of createrawtransaction command we had on the online client, we also need to provide the sciptPubKey Y redeemScript. This is done so that the offline client knows what the blocking script is for the exit points and what key he needs to use, since he does not have access to the transactions (since he is offline).

Now, use the command:

bitcoin-cli signrawtransactionwithwallet "020000000291195eb278578e6941498e51d67105f6d0f33b1d1b562c444cd9dd27d83a89270000000000ffffffff5885edb76b6e5cc60b5765b75c18537f6f2c7b9ff947b28362a889f72fe26b770100000000ffffffff0180969800000000001976a9141083323e89f0f734c448cd16d5a5513afb841b1788ac00000000" 
'({"txid":"27893ad827ddd94c442c561b1d3bf3d0f60571d6518e4941698e5778b25e1991","vout":0,"scriptPubKey":"76a914623ff66fb88ff802fe1b8eaff666ba52307eecb088ac","amount":0.09},
{"txid":"776be22ff789a86283b247f99f7b2c6f7f53185cb765570bc65c6e6bb7ed8558","vout":1, "scriptPubKey":"a914de7dad83bb2d6e9638d347dcb3c53fe238773c9387","redeemScript":"0014df7bcc159ade813e6bd6290d97ed0bc8987dc084", "amount":0.011})' 
"ALL"

This would give you a signed transaction as an exit. Let's call it hexoutput. A couple of things to write down. If you pay close attention, you will see that the second exit point used in the entry contains redeemScript. This is because it belonged to a P2SH-P2WPKH transaction and, therefore, must provide the redeemScript next to scriptPubKey countryside. For more information, you can check the documentation here.

Now copy this hexoutput to your Bitcoin-core client online and use the following command to relay it over the network.

bitcoin-cli sendrawtransaction hexoutput

This will give you a txid of the transaction as an exit that you can use to monitor your transaction.