Author

Topic: Getting started with Command Line Electrum on Ubuntu Linux (Read 230 times)

member
Activity: 239
Merit: 59
a young loner on a crusade
I don't like using Electrum from the command line because it is quite a pain in the ass to make a transaction and also to make sure that you don't leave any traces of your wallet password inside the terminal, whereas with the GUI version I can be confident that the password is getting scrubbed after the dialog is closed.
When manually making a transaction, the GUI of course is preferred. The command line is for transactions without manual input.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
I don't like using Electrum from the command line because it is quite a pain in the ass to make a transaction and also to make sure that you don't leave any traces of your wallet password inside the terminal, whereas with the GUI version I can be confident that the password is getting scrubbed after the dialog is closed.

I've tried using Electrum in Ubuntu Mate 18.04 (with updated kernel and all software) the other way by just executing the electrum-4.4.6-x86_64.AppImage file; and I've got this error:

"
/tmp/.mount_electrNc0scn/usr/bin/python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /tmp/.mount_electrNc0scn/usr/lib/libpython3.9.so.1.0) "


How this could be solved?

Your Glibc is too new and your distro is very old and does not ship with such a new Glibc.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
How this could be solved?
This is related to that issue (check OP, 1st and last replies): github.com/spesmilo/electrum/issues/7997

Unfortunately, the main solution to use the AppImage is to upgrade your OS since the developer didn't included the said dependency in the AppImage.
The issue was closed by the OP for being solved by updating his OS.
newbie
Activity: 17
Merit: 1
I've tried using Electrum in Ubuntu Mate 18.04 (with updated kernel and all software) the other way by just executing the electrum-4.4.6-x86_64.AppImage file; and I've got this error:

"
/tmp/.mount_electrNc0scn/usr/bin/python3: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /tmp/.mount_electrNc0scn/usr/lib/libpython3.9.so.1.0) "


How this could be solved?
member
Activity: 239
Merit: 59
a young loner on a crusade
To avoid this error
Code:
Daemon not running; try 'electrum daemon -d'
wallet not loaded
Wait a few seconds after starting the daemon and before loading the wallet.
Code:
electrum daemon -d
Wait
Code:
electrum load_wallet -w $wallet
member
Activity: 239
Merit: 59
a young loner on a crusade
Install Electrum
Code:
sudo apt-get install python3-pyqt5 libsecp256k1-dev python3-cryptography python3-setuptools python3-pip jq
wget download.electrum.org/4.4.6/Electrum-4.4.6.tar.gz
wget download.electrum.org/4.4.6/Electrum-4.4.6.tar.gz.asc
gpg --verify Electrum-4.4.6.tar.gz.asc
python3 -m pip install --user Electrum-4.4.6.tar.gz
Installed in /home/michael/.local/bin/electrum
When I followed your procedure, I ended up getting this error. I am not sure what caused the error, but maybe it's because of some incompatibilities with the python installation and the newer versions of Linux distros.
I posted a shortened version of the apt-get lines on Electrum.org. Are you on Debian?

--Knight Hider
copper member
Activity: 2198
Merit: 1837
🌀 Cosmic Casino
Install Electrum
Code:
sudo apt-get install python3-pyqt5 libsecp256k1-dev python3-cryptography python3-setuptools python3-pip jq
wget download.electrum.org/4.4.6/Electrum-4.4.6.tar.gz
wget download.electrum.org/4.4.6/Electrum-4.4.6.tar.gz.asc
gpg --verify Electrum-4.4.6.tar.gz.asc
python3 -m pip install --user Electrum-4.4.6.tar.gz
Installed in /home/michael/.local/bin/electrum
When I followed your procedure, I ended up getting this error. I am not sure what caused the error, but maybe it's because of some incompatibilities with the python installation and the newer versions of Linux distros.

Code:
This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

Fortunately, DireWolfM14's version works flawlessly, with no errors on my side.
member
Activity: 239
Merit: 59
a young loner on a crusade
Install Electrum
Code:
sudo apt-get install python3-pyqt5 libsecp256k1-dev python3-cryptography python3-setuptools python3-pip jq
wget download.electrum.org/4.4.6/Electrum-4.4.6.tar.gz
wget download.electrum.org/4.4.6/Electrum-4.4.6.tar.gz.asc
gpg --verify Electrum-4.4.6.tar.gz.asc
python3 -m pip install --user Electrum-4.4.6.tar.gz
Installed in /home/michael/.local/bin/electrum

Use Electrum on testnet instead of real Bitcoin
Code:
alias electrum='electrum --testnet'

Electrum uses paths relative to the path of the running daemon instead of your current path. Use absolute paths for wallets.
Code:
wallets=~/.electrum/testnet/wallets

Start Electrum daemon:
Code:
electrum daemon -d

You can create and load as many wallets as you want
Code:
electrum -w $wallets/bob.wallet create >> bob.seed
electrum -w $wallets/alice.wallet create >> alice.seed
electrum load_wallet -w $wallets/bob.wallet
electrum load_wallet -w $wallets/alice.wallet
For testnet, I store the seed in clear text

List the wallets
Code:
michael@KnightIndustries:~$ electrum list_wallets
[
    {
        "path": "/home/michael/.electrum/testnet/wallets/bob.wallet",
        "synchronized": true
    },
    {
        "path": "/home/michael/.electrum/testnet/wallets/alice.wallet",
        "synchronized": true
    }
]
michael@KnightIndustries:~$

When interacting with a wallet, specify which one of the loaded wallets to use in each command

Get an unused address and store as a variable
Code:
bobaddress=$(electrum -w $wallets/bob.wallet listaddresses | jq .[-1])
echo $bobaddress
aliceaddress=$(electrum -w $wallets/alice.wallet listaddresses | jq .[-1])
echo $aliceaddress

Post the address to get some testnet coins, use a faucet, or sweep a private key (keep reading).

Check the balance
Code:
michael@KnightIndustries:~$ electrum -w $wallets/bob.wallet getbalance
{
    "confirmed": "0",
    "unconfirmed": "0.003274"
}
michael@KnightIndustries:~$

Now send some to Alice
Code:
rawtx=$(electrum -w $wallets/bob.wallet payto $aliceaddress 0.001)
txid=$(electrum broadcast $rawtx)

Check the balances
Code:
michael@KnightIndustries:~$ electrum -w $wallets/bob.wallet getbalance
{
    "confirmed": "0.002271"
}
michael@KnightIndustries:~$ electrum -w $wallets/alice.wallet getbalance
{
    "confirmed": "0.001"
}
michael@KnightIndustries:~$

Pay to many (5 addresses owned by alice)
Code:
michael@KnightIndustries:~$ rawtx=$(electrum -w $wallets/bob.wallet paytomany "[[\"tb1qcnj394993gaevwh33d8xlaag73qjszqr4rfq2c\", 0.001], [\"tb1qrscalt33njp6uq8npk3sxvjcyea37xlt4p9320\", 0.001], [\"tb1qz3x5zn35pm944363wxsh0pmu7lt2xuuwffqq4w\", 0.001], [\"tb1qjlum0r93g23r276my0cfjcf68tuhfsjap08kea\", 0.001], [\"tb1qnvf6he0avvdppd6pnunj2rwa8qmwhpchuc9fh4\", 0.001]]")
michael@KnightIndustries:~/electrumtest$ echo $rawtx
02000000000101ee0171f915201f0d6a3fc131ca6f5803800c9a489087d65e44738b65325b81560000000000fdffffff06a086010000000000160014144d414e340ecb5ac75171a177877cf7d6a3738ea0860100000000001600141c31dfae319c83ae00f30da3033258267b1f1beba08601000000000016001497f9b78cb142a2357b5b23f099613a3af974c25da0860100000000001600149b13abe5fd631a10b7419f27250ddd3836eb8717a086010000000000160014c4e512d4a58a3b963af18b4e6ff7a8f44128080314b810000000000016001485f1f19a76c161d4027ed0af1a76665ef4b9b1500247304402201f68718bca0462bd792e339197d547697caba1fcb7d4189ca23499d4e4668da5022011ab833c1fc1809dc4f019e7f19a64fecee1ff5275f449cf0a13bfbcb4d2decb012103a117002ce5cc83f191a93fdaff89fb0504febc6ad3e68d531173ee4d2a30bbb7a82f2600
michael@KnightIndustries:~/electrumtest$ txid=$(electrum broadcast $rawtx)
michael@KnightIndustries:~/electrumtest$ echo $txid
a8f467e08da549bd89229514e130c59b2e40f742bcad7fe9e19149fbce52abeb
michael@KnightIndustries:~/electrumtest$

Alice now has 5 addresses with 0.001 tBTC.
Code:
michael@KnightIndustries:~/electrumtest$ electrum -w $wallets/alice.wallet listaddresses --funded
[
    "tb1qnvf6he0avvdppd6pnunj2rwa8qmwhpchuc9fh4",
    "tb1qjlum0r93g23r276my0cfjcf68tuhfsjap08kea",
    "tb1qz3x5zn35pm944363wxsh0pmu7lt2xuuwffqq4w",
    "tb1qrscalt33njp6uq8npk3sxvjcyea37xlt4p9320",
    "tb1qcnj394993gaevwh33d8xlaag73qjszqr4rfq2c"
]
michael@KnightIndustries:~/electrumtest$

Export the private keys (this is testnet, never share your real keys)
Code:
michael@KnightIndustries:~/electrumtest$ electrum -w $wallets/alice.wallet listaddresses --funded | electrum -w $wallets/alice.wallet getprivatekeys -
WARNING: ALL your private keys are secret.
Exposing a single private key can compromise your entire wallet!
In particular, DO NOT use 'redeem private key' services proposed by third parties.
[
    "p2wpkh:cP1yoUtpAqPzTR2rAZvtkSv393ZDTor5LiFKWtAiEwoVJeGXbVHt",
    "p2wpkh:cVSGSq4e3oxuC7WfXZ3dX8SUTX4D5YsDTD696Xr8pnV2NL3MnyAt",
    "p2wpkh:cVjXBuPe17bPrVDvEwSXZnRuMTc3gS6mXjTnZnfRbSWFD1ChtGJ9",
    "p2wpkh:cSuYboBWX1zBn59rtnYW3k13VTA2KC5T8T2V8B8RvpAukng1X2Mt",
    "p2wpkh:cUevsVbV6A5aE8KzkVcRNufnfVrWPUBF8Zq82kBAm2QqsGxMKGvJ"
]
michael@KnightIndustries:~/electrumtest$
Sweep one if you need testnet coins, but only take one and post which one you used. Leave some testnet coins for someone else.
Code:
michael@KnightIndustries:~/electrumtest$ electrum -w $wallets/alice.wallet sweep p2wpkh:cP1yoUtpAqPzTR2rAZvtkSv393ZDTor5LiFKWtAiEwoVJeGXbVHt tb1qnvf6he0avvdppd6pnunj2rwa8qmwhpchuc9fh4
02000000000101ebab52cefb4991e1e97fadbc42f7402e9bc530e114952289bd49a58de067f4a80300000000fdffffff0132860100000000001600149b13abe5fd631a10b7419f27250ddd3836eb871702473044022008cee487e951b3fd29ce57d7931a16393ce9613cf67c4c68f77f303bc928e18402203d429543630ef4ce394d403f7732ca45d53a1dc0335573e26fb8476741ce3741012103e97d0573b173ab174702b1da812aa1adf7f6edc6940f5ec5b96914fd3fc8a5b81d312600
michael@KnightIndustries:~/electrumtest$
I did not broadcast this transaction, but you can!

Learn more
Code:
michael@KnightIndustries:~/electrumtest$ electrum commands
add_peer add_request addtransaction broadcast bumpfee changegaplimit clear_invoices clear_ln_blacklist clear_requests close_channel close_wallet commands convert_currency convert_xkey create createmultisig createnewaddress decode_invoice decrypt delete_invoice delete_request deserialize dumpgraph dumpprivkeys enable_htlc_settle encrypt export_channel_backup freeze freeze_utxo get get_channel_ctx get_invoice get_request get_ssl_domain get_tx_status get_watchtower_ctn getaddressbalance getaddresshistory getaddressunspent getalias getbalance getconfig getfeerate getinfo getmasterprivate getmerkle getminacceptablegap getmpk getprivatekeyforpath getprivatekeys getpubkeys getseed getservers gettransaction getunusedaddress help import_channel_backup importprivkey inject_fees is_synchronized ismine lightning_history list_channels list_invoices list_peers list_requests list_wallets listaddresses listcontacts listunspent lnpay load_wallet make_seed nodeid normal_swap notify onchain_history open_channel password payto paytomany rebalance_channels removelocaltx request_force_close reset_liquidity_hints restore reverse_swap searchcontacts serialize setconfig setlabel signmessage signtransaction signtransaction_with_privkey stop sweep unfreeze unfreeze_utxo validateaddress verifymessage version version_info
michael@KnightIndustries:~/electrumtest$
Code:
michael@KnightIndustries:~/electrumtest$ electrum help
[
    "add_peer",
    "add_request",
    "addtransaction",
    "broadcast",
    "bumpfee",
    "changegaplimit",
    "clear_invoices",
    "clear_ln_blacklist",
    "clear_requests",
    "close_channel",
    "close_wallet",
    "commands",
    "convert_currency",
    "convert_xkey",
    "create",
    "createmultisig",
    "createnewaddress",
    "decode_invoice",
    "decrypt",
    "delete_invoice",
    "delete_request",
    "deserialize",
    "dumpgraph",
    "dumpprivkeys",
    "enable_htlc_settle",
    "encrypt",
    "export_channel_backup",
    "freeze",
    "freeze_utxo",
    "get",
    "get_channel_ctx",
    "get_invoice",
    "get_request",
    "get_ssl_domain",
    "get_tx_status",
    "get_watchtower_ctn",
    "getaddressbalance",
    "getaddresshistory",
    "getaddressunspent",
    "getalias",
    "getbalance",
    "getconfig",
    "getfeerate",
    "getinfo",
    "getmasterprivate",
    "getmerkle",
    "getminacceptablegap",
    "getmpk",
    "getprivatekeyforpath",
    "getprivatekeys",
    "getpubkeys",
    "getseed",
    "getservers",
    "gettransaction",
    "getunusedaddress",
    "help",
    "import_channel_backup",
    "importprivkey",
    "inject_fees",
    "is_synchronized",
    "ismine",
    "lightning_history",
    "list_channels",
    "list_invoices",
    "list_peers",
    "list_requests",
    "list_wallets",
    "listaddresses",
    "listcontacts",
    "listunspent",
    "lnpay",
    "load_wallet",
    "make_seed",
    "nodeid",
    "normal_swap",
    "notify",
    "onchain_history",
    "open_channel",
    "password",
    "payto",
    "paytomany",
    "rebalance_channels",
    "removelocaltx",
    "request_force_close",
    "reset_liquidity_hints",
    "restore",
    "reverse_swap",
    "searchcontacts",
    "serialize",
    "setconfig",
    "setlabel",
    "signmessage",
    "signtransaction",
    "signtransaction_with_privkey",
    "stop",
    "sweep",
    "unfreeze",
    "unfreeze_utxo",
    "validateaddress",
    "verifymessage",
    "version",
    "version_info"
]
michael@KnightIndustries:~/electrumtest$

Stop the Electrum daemon
Code:
electrum stop
This closes all wallets

References:
https://electrum.readthedocs.io/en/latest/cmdline.html
https://bitzuma.com/posts/an-introduction-to-the-electrum-python-console/

--Knight Hider
Jump to: