pull down to refresh

@tech5, I got it to work on testnet. Here is a guide for you.

Pre-amble

The instructions are written to target testnet. You can get testnet bitcoins from a faucet on google. Remove --testnet from all commands after you have something functioning on your machine.
I tested it with 1, 2 and 3 funded addresses on testnet. Note that the fee is static. I'm sure it'll work with infinite addresses.

1 Setup Server

  1. Install your fav linux distro (I did this on Ubuntu).
  2. Install python 3, optionally in a virtual environment
  3. Install electrum
  4. Install jq (Eg. sudo apt-get install jq)
Hopefully the above is easy enough for you. There are plenty of guides online for these.
Depending on your build, you may need to run the following.
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
Electrum will give you errors if you need this.

2 Configure Electrum

2 B - Daemon

Use Electrum docs & CLI to configure the daemon.
This will involve at the very least, setting a static port. Choose ports that aren't in use. No need to expose these ports externally, unless you know what you're doing.
electrum setconfig rpcport 7776 --offline --testnet
And mainnet, change the port to 7777.

2 - B Use Electrum UI to Setup your Wallet

electrum --testnet
Follow the prompts to setup your wallet with a password. Import the private keys you have into the wallet using the UI. Shut down the UI.

3 Run the Daemon

electrum daemon -d --testnet

4 Configure your Environment

export FEE=0.00001 # in BTC export DEST_ADDRESS=tb1qun6lw4f6mdqy97q373gs75m00etdklyrjjs2h2 export PASSWORD=pass export WALLET=~/.electrum/testnet/wallets/default_wallet_testnet

5 Load the wallet

electrum load_wallet -w $WALLET -W $PASSWORD --testnet

6 Get Addresses with Balances, Sweep & Broadcast

Run the following. It will list the addresses with balances, pull out the private keys, format them ready for the sweep command, prepare and sign a transaction, then broadcast it.
electrum listaddresses --funded -w $WALLET --testnet | electrum getprivatekeys - -w $WALLET -W $PASSWORD --testnet | jq -c | sed 's/[^a-zA-Z0-9:]/ /g' | electrum sweep - $DEST_ADDRESS --testnet -f $FEE | electrum signtransaction - -w $WALLET -W $PASSWORD --testnet | electrum broadcast - --testnet

7 Schedule

Add the command in step 5 to a cron schedule. So long as the electrum daemon and the wallet is unlocked the command will work.

8 Reboot

Run the commands from 3, 4 and 5 on startup of the server. Alternatively, you can run them before each command, but you would need to shut down the daemon if you did that.
Wow that’s awesome!! I will give it a try. Thank you for sharing!
reply