Leading Bitcoin Wallet

Using cold storage with the command line

This guide explains how to sign Bitcoin transactions using an offline Electrum wallet through the command line interface.

Preparing an Unsigned Transaction

First, use your online (watching-only) wallet to create a transaction without signing it:

electrum payto 1Lb9YaqiKdaPYQPFVRjmy1sZcSsVajaNQA 0.1 --unsigned > unsigned.txn

This command saves the unsigned transaction in a file called unsigned.txn. If you’re using a watching-only wallet, you can omit the --unsigned option.

To check the contents of the unsigned transaction, use this command:

cat unsigned.txn | electrum deserialize -

Signing the Transaction

Electrum’s serialization format includes the necessary master public key and derivation information. This allows the offline wallet to sign the transaction without additional data. To sign the transaction:

cat unsigned.txn | electrum signtransaction - > signed.txn

This command reads the unsigned transaction, prompts for your wallet password, and creates a new file named signed.txn containing the signed transaction.

Broadcasting the Transaction

After signing, you need to send your transaction to the Bitcoin network. Use the following command:

cat signed.txn | electrum broadcast -

If the broadcast is successful, Electrum will display the transaction ID.

Remember, once broadcast, Bitcoin transactions are irreversible. Always double-check the transaction details before broadcasting.

Table of Contents