#!/bin/bash # https://github.com/cryptoadvance/specter-desktop # ~/.config/btc-rpc-explorer.env # https://github.com/janoside/btc-rpc-explorer/blob/master/.env-sample # command info if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo "small config script to switch cryptoadvance specter on or off" echo "bonus.cryptoadvance-specter.sh [status|on|off]" exit 1 fi source /mnt/hdd/raspiblitz.conf # show info menu if [ "$1" = "menu" ]; then # get status echo "# collecting status info ... (please wait)" source <(sudo /home/admin/config.scripts/bonus.cryptoadvance-specter.sh status) # get network info localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') toraddress=https://$(sudo cat /mnt/hdd/tor/cryptoadvance-specter/hostname 2>/dev/null) if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then # TOR /home/admin/config.scripts/blitz.lcd.sh qr "${toraddress}" whiptail --title " Cryptoadvance Specter " --msgbox "Open the following URL in your local web browser: https://${localip}:25441 You have to accept the self-signed-certificate. Login with the Pin being Password B. If you have connected to a different Bitcoin RPC Endpoint, the Pin is the configured RPCPassword. Hidden Service address for TOR Browser (QR see LCD): ${toraddress}\n " 16 70 /home/admin/config.scripts/blitz.lcd.sh hide else # IP + Domain whiptail --title " Cryptoadvance Specter " --msgbox "Open the following URL in your local web browser: https://${localip}:25441 You have to accept the self-signed-certificate. Login with the Pin being Password B. If you have connected to a different Bitcoin RPC Endpoint, the Pin is the configured RPCPassword.\n Activate TOR to access the web block explorer from outside your local network. Unfortunately the camera is currently not usable via Tor, though. " 12 54 fi echo "please wait ..." exit 0 fi # add default value to raspi config if needed if ! grep -Eq "^specter=" /mnt/hdd/raspiblitz.conf; then echo "specter=off" >> /mnt/hdd/raspiblitz.conf fi # status if [ "$1" = "status" ]; then if [ "${specter}" = "on" ]; then echo "configured=1" # check for error isDead=$(sudo systemctl status cryptoadvance-specter | grep -c 'inactive (dead)') if [ ${isDead} -eq 1 ]; then echo "error='Service Failed'" exit 1 fi else echo "configured=0" fi exit 0 fi # stop service echo "making sure services are not running" sudo systemctl stop cryptoadvance-specter 2>/dev/null # switch on if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "*** INSTALL Cryptoadvance Specter ***" isInstalled=$(sudo ls /etc/systemd/system/cryptoadvance-specter.service 2>/dev/null | grep -c 'cryptoadvance-specter.service') if [ ${isInstalled} -eq 0 ]; then echo "*** Enable wallets in Bitcoin Core ***" sudo sed -i "s/^disablewallet=.*/disablewallet=0/g" /home/bitcoin/.bitcoin/bitcoin.conf sudo service bitcoind stop sudo service bitcoind start echo "*** Installing prerequisites ***" sudo apt install -y libusb-1.0.0-dev libudev-dev virtualenv libssl-dev # activating Authentication here ... echo "*** creating App-config ***" cat > /home/admin/config.json <=0.7.99,<0.8.0' 'pyaes>=1.6,<2.0' sudo -u bitcoin /home/bitcoin/.specter/.env/bin/python3 -m pip install hwi --no-dependencies # basically turned the requirement.txt into thses three lines # https://raw.githubusercontent.com/cryptoadvance/specter-desktop/v0.4.0/requirements.txt sudo -u bitcoin /home/bitcoin/.specter/.env/bin/python3 -m pip install 'certifi==2019.9.11' 'chardet==3.0.4' 'Click==7.0' 'ecdsa>=0.13.3' 'Flask==1.1.1' 'Flask-Login==0.5.0' 'hidapi==0.7.99.post21' 'pyOpenSSL==19.1.0' sudo -u bitcoin /home/bitcoin/.specter/.env/bin/python3 -m pip install 'hwi==1.1.0' 'idna==2.8' 'itsdangerous==1.1.0' 'Jinja2==2.10.3' 'libusb1==1.7.1' 'MarkupSafe==1.1.1' 'mnemonic==0.18' 'pbkdf2==1.3' 'pyaes>=1.6.1' sudo -u bitcoin /home/bitcoin/.specter/.env/bin/python3 -m pip install 'python-dotenv==0.10.3' 'requests==2.22.0' 'six==1.12.0' 'stem==1.7.1' 'typing-extensions==3.7.4' 'urllib3==1.25.6' 'Werkzeug==0.16.0' 'pyserial==3.4' 'daemonize==2.5.0' # install fixed version sudo -u bitcoin /home/bitcoin/.specter/.env/bin/python3 -m pip install cryptoadvance.specter==0.4.0 --no-dependencies # Creating self-signed-certificate # Mandatory as the camera doesn't work without https echo "*** Creating self-signed certificate ***" openssl req -x509 -newkey rsa:4096 -nodes -out /tmp/cert.pem -keyout /tmp/key.pem -days 365 -subj "/C=US/ST=Nooneknows/L=Springfield/O=Dis/CN=www.fakeurl.com" sudo mv /tmp/cert.pem /home/bitcoin/.specter sudo chown -R bitcoin:bitcoin /home/bitcoin/.specter/cert.pem sudo mv /tmp/key.pem /home/bitcoin/.specter sudo chown -R bitcoin:bitcoin /home/bitcoin/.specter/key.pem # open firewall echo "*** Updating Firewall ***" sudo ufw allow 25441 comment 'cryptoadvance-specter' echo "" echo "*** Installing udev-rules for hardware-wallets ***" cat > /home/admin/20-hw1.rules < /home/admin/51-coinkite.rules < KERNEL=="hidraw*", ATTRS{idVendor}=="d13e", ATTRS{idProduct}=="cc10", GROUP="plugdev", MODE="0666" EOF cat > /home/admin/51-trezor.rules < /home/admin/51-usb-keepkey.rules < /home/admin/cryptoadvance-specter.service <