Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto restore from keys #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM python:3.6-alpine

ARG BUILD_DATE
ARG VCS_REF
ARG VERSION
ARG VERSION=3.1.1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This not needed, because actual version taken from VERSION file in root dir by Makefile.

LABEL maintainer="[email protected]" \
org.label-schema.build-date=$BUILD_DATE \
org.label-schema.name="Electrum wallet" \
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ curl --data-binary '{"id":"1","method":"listaddresses"}' http://electrum:electru

Always link electrum daemon to containers or bind to localhost directly and not expose 7000 port for security reasons.

### 12 Factor

You may also restore the wallet from a Master Private Key or Master Public Key by setting `ELECTRUM_MASTER_PRIVATE_KEY` or `ELECTRUM_MASTER_PUBLIC_KEY` env vars. This is useful in a setup like Kubernetes. If a wallet already exists, the master private key or the master public key will not be restored.

## API

* [Electrum protocol specs](http://docs.electrum.org/en/latest/protocol.html)
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ services:
environment:
ELECTRUM_USER: electrum
ELECTRUM_PASSWORD: changeme
ELECTRUM_MASTER_PRIVATE_KEY: xprv9s21ZrQH143K2qhNXjGPHr6Rdz3h2N5dnt4sFspFnDqP8rPCXi5YPHq6hqQ2jSJb6XM4qwbfwMqxP5qsFRFRBKMPnE3WiAhFsBkVcMv2rYX
ELECTRUM_MASTER_PUBLIC_KEY: xpub661MyMwAqRbcFKmqdkoPez3AC1tBRpoVA6zU4GDsLZNN1eiM5FPnw69aZ6NbpahyLMsKeyjf2eqS64xSqYfsj9YWFWUpKtzbXmkLiAsRyCF
27 changes: 27 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,33 @@ electrum setconfig rpcport 7000
# Run application
electrum daemon start

echo "checking status"
electrum daemon status
echo "Done"

# Restore from keys if available
if [ -n "$ELECTRUM_MASTER_PRIVATE_KEY" ];
then
echo "Restoring and loading wallet from Master Private Key"
{
# && - do not stop script if command fails
echo | electrum restore $ELECTRUM_MASTER_PRIVATE_KEY
} || { # catch
echo "Wallet already exists; skipping..."
}
electrum daemon load_wallet
elif [ -n "$ELECTRUM_MASTER_PUBLIC_KEY" ];
then
echo "Restoring and loading wallet from Master Public Key"
{
# && - do not stop script if command fails
electrum restore $ELECTRUM_MASTER_PUBLIC_KEY
} || {
echo "Wallet already exists; skipping..."
}
electrum daemon load_wallet
fi

# Wait forever
while true; do
tail -f /dev/null & wait ${!}
Expand Down