Install
Electrumsudo 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
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.
wallets=~/.electrum/testnet/wallets
Start Electrum daemon:
You can create and load as many wallets as you want
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
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
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
michael@KnightIndustries:~$ electrum -w $wallets/bob.wallet getbalance
{
"confirmed": "0",
"unconfirmed": "0.003274"
}
michael@KnightIndustries:~$
Now send some to Alice
rawtx=$(electrum -w $wallets/bob.wallet payto $aliceaddress 0.001)
txid=$(electrum broadcast $rawtx)
Check the balances
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)
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.
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)
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.
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
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$
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
This closes all wallets
References:
https://electrum.readthedocs.io/en/latest/cmdline.htmlhttps://bitzuma.com/posts/an-introduction-to-the-electrum-python-console/--Knight Hider