Electrum-RVN-SIG / electrum-ravencoin

Electrum-Ravencoin Wallet Client. Forked from the Electrum Bitcoin base client.
https://ravencoin.org
MIT License
48 stars 22 forks source link

Dockerized Wallet and Seed Generation #16

Open pipersniper opened 3 years ago

pipersniper commented 3 years ago

Overview

As a proof of concept, I put together a Dockerfile that uses noVNC to make the GUI available, so one can start the wallet container, browse to localhost:8080, and interact with the wallet as if it were installed locally.

TODO: Add dependencies for using a ledger; volumes so a wallet can be backed up externally, and stop being lazy by using the root user.

The pertinent issue for this repo is seed generation - when I reach the verification step, the application segfaults after entering the final word. No logs appear to be generated. Running the wallet in a container (or at least, in this particular configuration) might just be a bad idea, but it was concerning to see seed generation causing a segfault.

Usage

docker-compose up -d then browse to localhost:8080, then click Connect.

The container that results from the code below is running a minimally configured openbox - right click the desktop and use the Electrum - Ravencoin link, or use the Terminal link and execute ./run_electrum from /opt/rvn.

docker-compose.yml

version: '3.7'

services:
  wallet:
    build:
      context: ./docker
      dockerfile: Dockerfile
    restart: always
    ports:
      - 8080:8080

docker/Dockerfile

FROM golang:1.14-buster AS novnc_builder

# Install noVNC in builder image
WORKDIR /src
RUN go mod init build && \
    go get github.com/geek1011/easy-novnc@v1.1.0 && \
    go build -o /bin/easy-novnc github.com/geek1011/easy-novnc

FROM debian:buster

ENV VERSION=v0.4.0 \
    version=0.4.0

# Install dependencies
RUN apt-get update -y && \
    apt-get install -y \
        openbox \
        tigervnc-standalone-server \
        supervisor && \
    rm -rf /var/lib/apt/lists && \
    mkdir -p /usr/share/desktop-directories && \
    apt-get update -y && \
    apt-get install -y \
        lxterminal \
        nano \
        vim \
        wget \
        curl \
        git \
        openssh-client \
        rsync \
        ca-certificates \
        xdg-utils \
        htop \
        tar \
        xzip \
        gzip \
        bzip2 \
        zip \
        unzip \
        python3-setuptools \
        python3-pip \
        python3-cryptography \
        python3-pyqt5 \
        libsecp256k1-0 \
        cmake && \
    rm -rf /var/lib/apt/lists && \
    mkdir -p /opt/rvn

# Copy noVNC installation from novnc_builder
COPY --from=novnc_builder /bin/easy-novnc /usr/local/bin

# Get Electrum-Ravencoin from repo
RUN mkdir -p /opt/rvn && \
    cd /opt/rvn && \
    curl -LJO https://github.com/Electrum-RVN-SIG/electrum-ravencoin/archive/refs/tags/${VERSION}.tar.gz && \
    tar -xzvf electrum-ravencoin-${version}.tar.gz -C . --strip-components 1 && \
    python3 -m pip install .

# Copy config files
COPY menu.xml /etc/xdg/openbox/
COPY supervisord.conf /etc/
EXPOSE 8080

CMD ["sh", "-c", "exec supervisord"]

docker/menu.xml

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">
    <menu id="root-menu" label="Openbox 3">
        <item label="Electrum - Ravencoin">
            <action name="Execute">
                <execute>/opt/rvn/run_electrum</execute>
            </action>
        </item>
        <item label="Terminal">
            <action name="Execute">
                <execute>/usr/bin/x-terminal-emulator</execute>
            </action>
        </item>
        <item label="Htop">
            <action name="Execute">
                <execute>/usr/bin/x-terminal-emulator -e htop</execute>
            </action>
        </item>
    </menu>
</openbox_menu>

docker/supervisord.conf

[supervisord]
nodaemon=true
pidfile=/tmp/supervisord.pid
logfile=/dev/fd/1
logfile_maxbytes=0

[program:x11]
priority=0
command=/usr/bin/Xtigervnc -desktop "Electrum - Ravencoin" -localhost -rfbport 5900 -SecurityTypes None -AlwaysShared -AcceptKeyEvents -AcceptPointerEvents -AcceptSetDesktopSize -SendCutText -AcceptCutText :0
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[program:easy-novnc]
priority=0
command=/usr/local/bin/easy-novnc --addr :8080 --host localhost --port 5900 --no-url-password --novnc-params "resize=remote"
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true

[program:openbox]
priority=1
command=/usr/bin/openbox
environment=DISPLAY=:0
autorestart=true
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
kralverde commented 3 years ago

tracking

pipersniper commented 3 years ago

Realized I left out in the initial issue that logging the seed phrase, and then choosing "I already have a seed" works just fine as long as I remember to select seed type BIP39 rather than the default Electrum.