Electrum

From Bitcoin Wiki
Jump to navigation Jump to search

Electrum is a lightweight Bitcoin client, based on a client-server protocol. It was released on november 5, 2011.

screenshot of Electrum with its Qt gui
screenshot of Electrum with its Qt gui

Main features:

  • Encrypted wallet
  • Deterministic key generation. If you lose your wallet, you can recover it from its seed.
  • No blockchain download; the client requests that information from a server
  • Private keys are not shared with the server.
  • Firewall friendly: The client does not need to open a port, it simply polls the server for updates.
  • No single point of failure: The server code is open source, anyone can run a server.
  • Python. Very compact code, easy to contribute.

Graphical User Interfaces

Electrum has two GUIs: one that is based on Gtk, and a newer one based on Qt. The Qt GUI is enabled by default. To use the gtk interface, type:

$ ./electrum -g gtk

In addition, Electrum has a rich set of commands for the command line interface.

Brain Wallet

Electrum uses a type 2 deterministic key generation algorithm. This means that all the keys are derived from a seed.

Typical seeds have 128 bits of entropy. Electrum provides mnemonic code in order to represent the seed.

Example:

  • hexadecimal: 431a62f1c86555d3c45e5c4d9e10c8c7
  • mnemonic: "constant forest adore false green weave stop guy fur freeze giggle clock"

You can display the seed with the command line interface. Example:

$ ./electrum seed
Password:
431a62f1c86555d3c45e5c4d9e10c8c7 "constant forest adore false green weave stop guy fur freeze giggle clock"

Multiple wallets

Electrum uses one single file per wallet. Your default wallet is located in your user account. If you want to use another wallet, use the -w option followed by the wallet path and name:

$ ./electrum -w /path/to/my/wallet/wallet_name

Export and import addresses

You can export your private keys using the 'addresses' command:

$ ./electrum addresses -ak
Password:
1LGoehbyeX4QBEPK1a6dhyaoMQZfqg5LKX:5JBSttEGhjEcPidSovW66Rin2EZ6LEHZ2qx8Pu2RqqNaDTBVWaF   
1KcsBJa2cCxVkGJfSsg5bUeXN7Y5uLa8mP:5KiP4uiNT6KG8jnXbainCM8rDWRrgxt3PAyut4FFpDoCo1Rh6VM   
1PXsn7LVXTccGhJPTUL8r2EGB4fF9kvex3:5Kj8mvBJReyk8xEBMx5cTnciQCxto5JmudiTPkqwMcd61Kf1Jqc   
1KteSFTAphyByLTtUfFiVQ9s7fMVmx7c2h:5JeZ3FTbWcksLt3PKydd5U9p952UQRHwv3LoxzCA9LZ7V2bku5p   
1GE5ZChAobeTEPLHDCDDKTSg3XvLkcQFjS:5JwtGEygTwF2nouhRVzW3w5DWZd1sCgxLtnd1v51wjkbUrp5sqH   
12YNehfAoYTiwjTXULwaZqTCauu2D61fq6:5Jvcq19ePCXKcVun4n7US99CsrEByUK2kgxXBA3rBVBqYZjhfwD  [change] 

There are two options in this example:

  • option -a means: 'list all addresses'. if you don't use it, change addresses are not listed.
  • option -k means: display the private keys

You can also import addresses into an electrum wallet, with the 'import' command:

$ ./electrum import 1LGoehbyeX4QBEPK1a6dhyaoMQZfqg5LKX:5JBSttEGhjEcPidSovW66Rin2EZ6LEHZ2qx8Pu2RqqNaDTBVWaF
keypair imported

Note that imported keys do not belong to the deterministic sequence of your wallet; if you import keys in a wallet, you must back it up!

Offline wallet

It is possible to create a transaction on an offline computer, and to broadcast them from another computer, with a wallet that does not have the seed or private keys.

How to prepare an offline wallet

  • step 1: create a wallet on your offline computer
$ ./electrum -w wallet create
  • step 2: save the seed of your wallet to a file that will remain on the offline computer:
./electrum -w wallet seed | awk '{print $1}'> seedfile
  • step 3: blank the seed in your wallet file.

For example, under linux, you may type:

$ cat w | sed "s/`cat seedfile`/trololololo/g" > wallet.no_seed

or you can open the file in an editor and do it manually. After this step you may remove the wallet file:

rm wallet
  • step 4: transfer the wallet.no_seed file to the online computer.

For example, copy the wallet file to a usb stick:

$ cp wallet.no_seed /my/usb/wallet.no_seed

and once you have plugged the usb key to the online computer:

$ cp /my/usb/wallet.no_seed ./wallet.no_seed
  • step 5: run electrum on the online computer; this will synchronize your wallet with the bitcoin network, and you will be able to monitor incoming transactions:
./electrum -w wallet.no_seed

How to send a transaction with an offline wallet

  • step 1: copy the synchronized wallet file to your offline computer
$ cp wallet.no_seed /usb/stick/wallet.no_seed
  • step 2: edit the wallet file and restore the seed :
$ cat w | sed "s/trololololo/`cat seedfile`/g" > wallet.seed

you may also do this manually with a file editor if you do not know how to use sed.

  • step 3: create the transaction
./electrum -w wallet.seed mktx <recipient> <amount>  >  tx_file
  • step 4: with the usb stick, copy the transaction to the online computer:
$cp tx_file /usb/tx_file

and, on the online computer:

$cp /usb/tx_file tx_file
  • step 5: broadcast the transaction:
./electrum sendtx <transaction> `cat tx_file`

List of commands

command description syntax requires password needs to be online
help display the help for a command help [command] no no
validateaddress check is the argument is a valid bitcoin address validateaddress <address> no no
balance shows the balance of your wallet or of an address balance [address] no yes
contacts print your list of contacts contacts no no
create create a new wallet create no no
restore restore a wallet from seed restore no yes
payto create and broadcast a transaction payto <address> <amount> yes yes
mktx create a transaction and dump it mktx <address> <amount> yes no
sendtx broadcast a transaction sendtx <tx> no yes
password update your password password yes no
addresses show your list of addresses, optionally with private keys. addresses [-abk] / no
history print the transaction history history no yes
label change the label of a transaction or address label <label> no no
seed print your seed seed yes no
import import a keypair import address:private_key yes no
signmessage sign a message (as in bitcoind) signmessage address message yes no
verifymessage verify a message (as in bitcoind) verifymessage address sig message no no
eval call python eval eval expression no no

Security

See Thin Client Security

links