How to use the command 'electrum' (with examples)
Electrum is an ergonomic Bitcoin wallet and private key management tool. It provides users with the ability to create new wallets, restore existing wallets, create signed transactions offline, display wallet receiving addresses, sign and verify messages, and connect to specific electrum-server instances.
Use case 1: Create a new wallet
Code:
electrum -w new_wallet.dat create
Motivation: Creating a new wallet is essential for users who want to start using Electrum for Bitcoin transactions. This use case allows users to generate a new wallet file with the specified name (’new_wallet.dat’).
Explanation:
electrum
- the command itself.-w new_wallet.dat
- specifies the name of the wallet file to be created.create
- the command to create the new wallet.
Example output: None (the command will create a new wallet file without any output).
Use case 2: Restore an existing wallet from seed offline
Code:
electrum -w recovery_wallet.dat restore -o
Motivation: Restoring an existing wallet from seed is useful for users who want to access their Bitcoin funds using Electrum on a different device or after a wallet loss. The -o
option ensures that the restoration process is performed offline, adding an extra layer of security.
Explanation:
electrum
- the command itself.-w recovery_wallet.dat
- specifies the name of the wallet file to be restored.restore
- the command to restore the wallet.-o
- specifies that the restoration process should be performed offline.
Example output: None (the command will restore the specified wallet file without any output).
Use case 3: Create a signed transaction offline
Code:
electrum mktx recipient amount -f 0.0000001 -F from -o
Motivation: Creating a signed transaction offline provides an additional layer of security when performing Bitcoin transactions. This use case allows users to specify the recipient, transfer amount, fee rate, and source of funds to create a signed transaction that can later be broadcasted to the Bitcoin network.
Explanation:
electrum
- the command itself.mktx recipient amount
- specifies the recipient’s address and the transfer amount.-f 0.0000001
- sets the fee rate for the transaction to 0.0000001 BTC.-F from
- specifies the source of funds for the transaction.-o
- specifies that the transaction should be created offline.
Example output: None (the command will create a signed transaction without any output).
Use case 4: Display all wallet receiving addresses
Code:
electrum listaddresses -a
Motivation: Displaying all wallet receiving addresses is useful for users who want to view all the addresses associated with their Electrum wallet. This use case allows users to check the addresses where they can receive Bitcoin funds.
Explanation:
electrum
- the command itself.listaddresses
- the command to display all wallet receiving addresses.-a
- specifies that all addresses (including change addresses) should be listed.
Example output:
Address 1: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
Address 2: 1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF
Address 3: 1HQ3EZuVSJ2Z8Lk2K8hKzDgLVwJhxXtXBU
Use case 5: Sign a message
Code:
electrum signmessage address message
Motivation: Signing a message allows users to prove ownership of a Bitcoin address and verify the authenticity of a message. This use case enables users to sign a message using their Electrum wallet.
Explanation:
electrum
- the command itself.signmessage address message
- specifies the Bitcoin address and the message to be signed.
Example output:
Signature: H9cjt5YYunkDcAyMQo0DZ7yHmN4QYTCvHviuxblcrrinwvZtxozmX2EpTFkJE7xMiYnef2UqLQQhhvqyjaF6nB8=
Use case 6: Verify a message
Code:
electrum verifymessage address signature message
Motivation: Verifying a message allows users to ensure the authenticity and integrity of a message that was signed using a Bitcoin address. This use case enables users to check whether a message was indeed signed by a specific address.
Explanation:
electrum
- the command itself.verifymessage address signature message
- specifies the Bitcoin address, signature, and the message to be verified.
Example output:
Verified: True
Use case 7: Connect only to a specific electrum-server instance
Code:
electrum -p socks5:127.0.0.1:9050 -s 56ckl5obj37gypcu.onion:50001:t -1
Motivation: Connecting only to a specific electrum-server instance can be useful for users who want to ensure reliability and privacy by using trusted servers. This use case allows users to specify the server address and port number to establish a connection.
Explanation:
electrum
- the command itself.-p socks5:127.0.0.1:9050
- specifies the proxy configuration (SOCKS5) with the IP address and port number.-s 56ckl5obj37gypcu.onion:50001:t
- specifies the server address and port number to connect (-t for SSL/TLS).-1
- sets the timeout for the connection in seconds (negative value indicates no timeout).
Example output: None (the command will connect to the specified electrum-server instance without any output).
Conclusion:
The ’electrum’ command provides a wide range of functions for Bitcoin wallet management and private key operations. By following the provided examples, users can create new wallets, restore existing wallets, create signed transactions offline, display wallet receiving addresses, sign and verify messages, and connect to specific electrum-server instances. These functionalities make Electrum a powerful tool for secure Bitcoin transactions and key management.