Skip to content

Commit

Permalink
Add Bitcoin, Lightning, Electrs, ElectrumX and Fulcrum apps
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Briscoe <[email protected]>
  • Loading branch information
lukechilds and Steven Briscoe committed May 27, 2022
1 parent 4c59a06 commit 576ecd2
Show file tree
Hide file tree
Showing 56 changed files with 725 additions and 196 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ services:

# Uncomment to mount LND's data directory as read-only
# inside the Docker container at path /lnd
# - ${LND_DATA_DIR}:/lnd:ro
# - ${APP_LIGHTNING_NODE_DATA_DIR}:/lnd:ro

# Uncomment to mount Bitcoin Core's data directory as
# read-only inside the Docker container at path /bitcoin
# - ${BITCOIN_DATA_DIR}:/bitcoin:ro
# - ${APP_BITCOIN_DATA_DIR}:/bitcoin:ro
environment:
# Pass any environment variables to your app for configuration in the form:
# VARIABLE_NAME: value
Expand All @@ -127,22 +127,22 @@ services:
# your app to connect to Bitcoin Core, LND, Electrum and Tor:
#
# Bitcoin Core environment variables
# $BITCOIN_NETWORK - Can be "mainnet", "testnet" or "regtest"
# $BITCOIN_IP - Local IP of Bitcoin Core
# $BITCOIN_P2P_PORT - P2P port
# $BITCOIN_RPC_PORT - RPC port
# $BITCOIN_RPC_USER - RPC username
# $BITCOIN_RPC_PASS - RPC password
# $BITCOIN_RPC_AUTH - RPC auth string
# $APP_BITCOIN_NETWORK - Can be "mainnet", "testnet" or "regtest"
# $APP_BITCOIN_NODE_IP - Local IP of Bitcoin Core
# $APP_BITCOIN_P2P_PORT - P2P port
# $APP_BITCOIN_RPC_PORT - RPC port
# $APP_BITCOIN_RPC_USER - RPC username
# $APP_BITCOIN_RPC_PASS - RPC password
# $APP_BITCOIN_RPC_AUTH - RPC auth string
#
# LND environment variables
# $LND_IP - Local IP of LND
# $LND_GRPC_PORT - gRPC Port of LND
# $LND_REST_PORT - REST Port of LND
# $APP_LIGHTNING_NODE_IP - Local IP of LND
# $APP_LIGHTNING_NODE_GRPC_PORT - gRPC Port of LND
# $APP_LIGHTNING_NODE_REST_PORT - REST Port of LND
#
# Electrum server environment variables
# $ELECTRUM_IP - Local IP of Electrum server
# $ELECTRUM_PORT - Port of Electrum server
# $APP_ELECTRS_NODE_IP - Local IP of Electrum server
# $APP_ELECTRS_NODE_PORT - Port of Electrum server
#
# Tor proxy environment variables
# $TOR_PROXY_IP - Local IP of Tor proxy
Expand Down Expand Up @@ -199,13 +199,13 @@ services:
- 3002:3002
environment:
# Bitcoin Core connection details
BTCEXP_BITCOIND_HOST: $BITCOIN_IP
BTCEXP_BITCOIND_PORT: $BITCOIN_RPC_PORT
BTCEXP_BITCOIND_USER: $BITCOIN_RPC_USER
BTCEXP_BITCOIND_PASS: $BITCOIN_RPC_PASS
BTCEXP_BITCOIND_HOST: $APP_BITCOIN_NODE_IP
BTCEXP_BITCOIND_PORT: $APP_BITCOIN_RPC_PORT
BTCEXP_BITCOIND_USER: $APP_BITCOIN_RPC_USER
BTCEXP_BITCOIND_PASS: $APP_BITCOIN_RPC_PASS

# Electrum connection details
BTCEXP_ELECTRUMX_SERVERS: "tcp://$ELECTRUM_IP:$ELECTRUM_PORT"
BTCEXP_ELECTRUMX_SERVERS: "tcp://$APP_ELECTRS_NODE_IP:$APP_ELECTRS_NODE_PORT"

# App Config
BTCEXP_HOST: 0.0.0.0
Expand Down
6 changes: 3 additions & 3 deletions agora/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ services:
stop_grace_period: 1m
volumes:
- ${APP_DATA_DIR}/files:/files
- ${LND_DATA_DIR}:/lnd:ro
- ${APP_LIGHTNING_NODE_DATA_DIR}:/lnd:ro
user: "1000:1000"
environment:
# LND environment variables
LND_RPC_AUTHORITY: "$LND_IP:$LND_GRPC_PORT"
LND_RPC_AUTHORITY: "$APP_LIGHTNING_NODE_IP:$APP_LIGHTNING_NODE_GRPC_PORT"
TLS_CERT_PATH: "/lnd/tls.cert"
INVOICES_MACAROON_PATH: "/lnd/data/chain/bitcoin/$BITCOIN_NETWORK/invoice.macaroon"
INVOICES_MACAROON_PATH: "/lnd/data/chain/bitcoin/$APP_BITCOIN_NETWORK/invoice.macaroon"

# App specific environment variables
FILES_DIR: "/files"
Expand Down
Empty file added bitcoin/data/.gitkeep
Empty file.
36 changes: 36 additions & 0 deletions bitcoin/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "3.7"

services:
app_proxy:
environment:
APP_HOST: $APP_BITCOIN_IP
APP_PORT: 3005

server:
image: cookiemonster123/umbrel-bitcoin:v0.2.0@sha256:74fcac4f811ca0451a6ff108087298f752759b0be9d6c7b116642497dd702a27
depends_on: [bitcoind]
restart: on-failure
environment:
PORT: "3005"
BITCOIN_HOST: "${APP_BITCOIN_NODE_IP}"
RPC_PORT: "${APP_BITCOIN_RPC_PORT}"
RPC_USER: "${APP_BITCOIN_RPC_USER}"
RPC_PASSWORD: "${APP_BITCOIN_RPC_PASS}"
BITCOIN_RPC_HIDDEN_SERVICE: "${APP_BITCOIN_RPC_HIDDEN_SERVICE}"
BITCOIN_P2P_HIDDEN_SERVICE: "${APP_BITCOIN_P2P_HIDDEN_SERVICE}"
networks:
default:
ipv4_address: $APP_BITCOIN_IP

bitcoind:
image: lncm/bitcoind:v22.0@sha256:37a1adb29b3abc9f972f0d981f45e41e5fca2e22816a023faa9fdc0084aa4507
command: "${APP_BITCOIN_COMMAND}"
restart: on-failure
stop_grace_period: 15m30s
volumes:
- "${APP_BITCOIN_DATA_DIR}:/data/.bitcoin"
ports:
- "${APP_BITCOIN_P2P_PORT}:${APP_BITCOIN_P2P_PORT}"
networks:
default:
ipv4_address: $APP_BITCOIN_NODE_IP
85 changes: 85 additions & 0 deletions bitcoin/exports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
export APP_BITCOIN_IP="10.21.22.2"
export APP_BITCOIN_NODE_IP="10.21.21.8"

export APP_BITCOIN_DATA_DIR="${EXPORTS_APP_DIR}/data/bitcoin"
export APP_BITCOIN_RPC_PORT="8332"
export APP_BITCOIN_P2P_PORT="8333"
export APP_BITCOIN_ZMQ_RAWBLOCK_PORT="28332"
export APP_BITCOIN_ZMQ_RAWTX_PORT="28333"
export APP_BITCOIN_ZMQ_HASHBLOCK_PORT="28334"
export APP_BITCOIN_ZMQ_SEQUENCE_PORT="28335"

BITCOIN_CHAIN="main"
BITCOIN_ENV_FILE="${EXPORTS_APP_DIR}/.env"

if [[ ! -f "${BITCOIN_ENV_FILE}" ]]; then
if [[ -z "${BITCOIN_NETWORK}" ]]; then
BITCOIN_NETWORK="mainnet"
fi

if [[ -z ${BITCOIN_RPC_USER+x} ]] || [[ -z ${BITCOIN_RPC_PASS+x} ]] || [[ -z ${BITCOIN_RPC_AUTH+x} ]]; then
BITCOIN_RPC_USER="umbrel"
BITCOIN_RPC_DETAILS=$("${EXPORTS_APP_DIR}/scripts/rpcauth.py" "${BITCOIN_RPC_USER}")
BITCOIN_RPC_PASS=$(echo "$BITCOIN_RPC_DETAILS" | tail -1)
BITCOIN_RPC_AUTH=$(echo "$BITCOIN_RPC_DETAILS" | head -2 | tail -1 | sed -e "s/^rpcauth=//")
fi

echo "export APP_BITCOIN_NETWORK='${BITCOIN_NETWORK}'" > "${BITCOIN_ENV_FILE}"
echo "export APP_BITCOIN_RPC_USER='${BITCOIN_RPC_USER}'" >> "${BITCOIN_ENV_FILE}"
echo "export APP_BITCOIN_RPC_PASS='${BITCOIN_RPC_PASS}'" >> "${BITCOIN_ENV_FILE}"
echo "export APP_BITCOIN_RPC_AUTH='${BITCOIN_RPC_AUTH}'" >> "${BITCOIN_ENV_FILE}"
fi

. "${BITCOIN_ENV_FILE}"

if [[ "${APP_BITCOIN_NETWORK}" == "mainnet" ]]; then
BITCOIN_CHAIN="main"
elif [[ "${APP_BITCOIN_NETWORK}" == "testnet" ]]; then
BITCOIN_CHAIN="test"
export APP_BITCOIN_RPC_PORT="18332"
export APP_BITCOIN_P2P_PORT="18333"
elif [[ "${APP_BITCOIN_NETWORK}" == "signet" ]]; then
BITCOIN_CHAIN="signet"
export APP_BITCOIN_RPC_PORT="38332"
export APP_BITCOIN_P2P_PORT="38333"
elif [[ "${APP_BITCOIN_NETWORK}" == "regtest" ]]; then
BITCOIN_CHAIN="regtest"
export APP_BITCOIN_RPC_PORT="18443"
export APP_BITCOIN_P2P_PORT="18444"
else
echo "Warning (${EXPORTS_APP_ID}): Bitcoin Network '${APP_BITCOIN_NETWORK}' is not supported"
fi

BIN_ARGS=()
BIN_ARGS+=( "-chain=${BITCOIN_CHAIN}" )
BIN_ARGS+=( "-proxy=${TOR_PROXY_IP}:${TOR_PROXY_PORT}" )
BIN_ARGS+=( "-listen" )
BIN_ARGS+=( "-bind=${APP_BITCOIN_NODE_IP}" )
BIN_ARGS+=( "-port=${APP_BITCOIN_P2P_PORT}" )
BIN_ARGS+=( "-rpcport=${APP_BITCOIN_RPC_PORT}" )
BIN_ARGS+=( "-rpcbind=${APP_BITCOIN_NODE_IP}" )
BIN_ARGS+=( "-rpcbind=127.0.0.1" )
BIN_ARGS+=( "-rpcallowip=${NETWORK_IP}/16" )
BIN_ARGS+=( "-rpcallowip=127.0.0.1" )
BIN_ARGS+=( "-rpcauth=\"${APP_BITCOIN_RPC_AUTH}\"" )
BIN_ARGS+=( "-dbcache=200" )
BIN_ARGS+=( "-maxmempool=300" )
BIN_ARGS+=( "-zmqpubrawblock=tcp://0.0.0.0:${APP_BITCOIN_ZMQ_RAWBLOCK_PORT}" )
BIN_ARGS+=( "-zmqpubrawtx=tcp://0.0.0.0:${APP_BITCOIN_ZMQ_RAWTX_PORT}" )
BIN_ARGS+=( "-zmqpubhashblock=tcp://0.0.0.0:${APP_BITCOIN_ZMQ_HASHBLOCK_PORT}" )
BIN_ARGS+=( "-zmqpubsequence=tcp://0.0.0.0:${APP_BITCOIN_ZMQ_SEQUENCE_PORT}" )
BIN_ARGS+=( "-txindex=1" )
BIN_ARGS+=( "-blockfilterindex=1" )
BIN_ARGS+=( "-peerbloomfilters=1" )
BIN_ARGS+=( "-peerblockfilters=1" )
BIN_ARGS+=( "-deprecatedrpc=addresses" )
BIN_ARGS+=( "-rpcworkqueue=128" )

export APP_BITCOIN_COMMAND=$(IFS=" "; echo "${BIN_ARGS[@]}")

# echo "${APP_BITCOIN_COMMAND}"

rpc_hidden_service_file="${EXPORTS_TOR_DATA_DIR}/app-${EXPORTS_APP_ID}-rpc/hostname"
p2p_hidden_service_file="${EXPORTS_TOR_DATA_DIR}/app-${EXPORTS_APP_ID}-p2p/hostname"
export APP_BITCOIN_RPC_HIDDEN_SERVICE="$(cat "${rpc_hidden_service_file}" 2>/dev/null || echo "notyetset.onion")"
export APP_BITCOIN_P2P_HIDDEN_SERVICE="$(cat "${p2p_hidden_service_file}" 2>/dev/null || echo "notyetset.onion")"
46 changes: 46 additions & 0 deletions bitcoin/scripts/rpcauth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
# Copyright (c) 2015-2018 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

from argparse import ArgumentParser
from base64 import urlsafe_b64encode
from binascii import hexlify
from getpass import getpass
from os import urandom

import hmac

def generate_salt(size):
"""Create size byte hex salt"""
return hexlify(urandom(size)).decode()

def generate_password():
"""Create 32 byte b64 password"""
return urlsafe_b64encode(urandom(32)).decode('utf-8')

def password_to_hmac(salt, password):
m = hmac.new(bytearray(salt, 'utf-8'), bytearray(password, 'utf-8'), 'SHA256')
return m.hexdigest()

def main():
parser = ArgumentParser(description='Create login credentials for a JSON-RPC user')
parser.add_argument('username', help='the username for authentication')
parser.add_argument('password', help='leave empty to generate a random password or specify "-" to prompt for password', nargs='?')
args = parser.parse_args()

if not args.password:
args.password = generate_password()
elif args.password == '-':
args.password = getpass()

# Create 16 byte hex salt
salt = generate_salt(16)
password_hmac = password_to_hmac(salt, args.password)

print('String to be appended to bitcoin.conf:')
print('rpcauth={0}:{1}${2}'.format(args.username, salt, password_hmac))
print('Your password:\n{0}'.format(args.password))

if __name__ == '__main__':
main()
11 changes: 11 additions & 0 deletions bitcoin/torrc.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Bitcoin Core P2P Hidden Service
HiddenServiceDir /data/app-$APP_ID-p2p
HiddenServicePort $APP_BITCOIN_P2P_PORT $APP_BITCOIN_NODE_IP:$APP_BITCOIN_P2P_PORT

# Bitcoin Core RPC Hidden Service
HiddenServiceDir /data/app-$APP_ID-rpc
HiddenServicePort $APP_BITCOIN_RPC_PORT $APP_BITCOIN_NODE_IP:$APP_BITCOIN_RPC_PORT

# Bitcoin Core Frontend Hidden Service
HiddenServiceDir /data/app-$APP_ID
HiddenServicePort 80 $APP_PROXY_HOSTNAME:$APP_PROXY_PORT
20 changes: 20 additions & 0 deletions bitcoin/umbrel-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
manifestVersion: 1
id: bitcoin
category: Finance
name: Bitcoin
version: v22.0
tagline: Bitcoins are amazing
description: >
Bitcoin is the knees of the bee
developer: Umbrel
website: https://bitcoin.org
dependencies: []
repo: https://github.com/getumbrel/bitcoin
support: https://github.com/getumbrel/bitcoin/issues
port: 10000
gallery:
- 1.jpg
- 2.jpg
- 3.jpg
path: ""
defaultPassword: ""
14 changes: 7 additions & 7 deletions bitfeed/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ services:
stop_grace_period: 1m
environment:
PORT: "$APP_BITFEED_API_PORT"
BITCOIN_HOST: "$BITCOIN_IP"
BITCOIN_ZMQ_RAWTX_PORT: "$BITCOIN_ZMQ_RAWTX_PORT"
BITCOIN_ZMQ_RAWBLOCK_PORT: "$BITCOIN_ZMQ_RAWBLOCK_PORT"
BITCOIN_ZMQ_SEQUENCE_PORT: "$BITCOIN_ZMQ_SEQUENCE_PORT"
BITCOIN_RPC_PORT: "$BITCOIN_RPC_PORT"
BITCOIN_RPC_USER: "$BITCOIN_RPC_USER"
BITCOIN_RPC_PASS: "$BITCOIN_RPC_PASS"
BITCOIN_HOST: "$APP_BITCOIN_NODE_IP"
BITCOIN_ZMQ_RAWTX_PORT: "$APP_BITCOIN_ZMQ_RAWTX_PORT"
BITCOIN_ZMQ_RAWBLOCK_PORT: "$APP_BITCOIN_ZMQ_RAWBLOCK_PORT"
BITCOIN_ZMQ_SEQUENCE_PORT: "$APP_BITCOIN_ZMQ_SEQUENCE_PORT"
BITCOIN_RPC_PORT: "$APP_BITCOIN_RPC_PORT"
BITCOIN_RPC_USER: "$APP_BITCOIN_RPC_USER"
BITCOIN_RPC_PASS: "$APP_BITCOIN_RPC_PASS"
RPC_POOLS: "1"
RPC_POOL_SIZE: "16"
LOG_LEVEL: "info"
Expand Down
4 changes: 2 additions & 2 deletions bleskomat-server/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ services:
- db
volumes:
- $APP_DATA_DIR/data/web:/usr/src/app/data
- $LND_DATA_DIR:/lnd:ro
- $APP_LIGHTNING_NODE_DATA_DIR:/lnd:ro
environment:
DEBUG: "bleskomat-server*,lnurl*"
BLESKOMAT_SERVER_HOST: "0.0.0.0"
BLESKOMAT_SERVER_PORT: "$APP_BLESKOMAT_SERVER_PORT"
BLESKOMAT_SERVER_URL: "$APP_HIDDEN_SERVICE"
BLESKOMAT_SERVER_ENDPOINT: "/u"
BLESKOMAT_SERVER_AUTH_API_KEYS: '[]'
BLESKOMAT_SERVER_LIGHTNING: '{"backend":"lnd","config":{"cert":"/lnd/tls.cert","protocol":"https","hostname":"$LND_IP:$LND_REST_PORT","macaroon":"/lnd/data/chain/bitcoin/$BITCOIN_NETWORK/admin.macaroon"}}'
BLESKOMAT_SERVER_LIGHTNING: '{"backend":"lnd","config":{"cert":"/lnd/tls.cert","protocol":"https","hostname":"$APP_LIGHTNING_NODE_IP:$APP_LIGHTNING_NODE_REST_PORT","macaroon":"/lnd/data/chain/bitcoin/$APP_BITCOIN_NETWORK/admin.macaroon"}}'
BLESKOMAT_SERVER_STORE: '{"backend":"knex","config":{"client":"postgres","connection":{"host":"$APP_BLESKOMAT_SERVER_DB_IP","port":5432,"user":"bleskomat_server","password":"moneyprintergobrrr","database":"bleskomat_server"}}}'
BLESKOMAT_SERVER_COINRATES_DEFAULTS_PROVIDER: "coinbase"
BLESKOMAT_SERVER_ADMIN_WEB: "true"
Expand Down
6 changes: 3 additions & 3 deletions bluewallet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ services:
stop_grace_period: "1m"
init: true
volumes:
- "${LND_DATA_DIR}:/lnd:ro"
- "${APP_LIGHTNING_NODE_DATA_DIR}:/lnd:ro"
environment:
PORT: "${APP_BLUEWALLET_LNDHUB_PORT}"
TOR_URL: "${APP_HIDDEN_SERVICE}"
LND_CERT_FILE: "/lnd/tls.cert"
LND_ADMIN_MACAROON_FILE: "/lnd/data/chain/bitcoin/${BITCOIN_NETWORK}/admin.macaroon"
CONFIG: '{ "rateLimit": 10000, "postRateLimit": 10000, "redis": { "port": 6379, "host": "$APP_BLUEWALLET_REDIS_IP", "family": 4, "password": "moneyprintergobrrr", "db": 0 }, "lnd": { "url": "$LND_IP:$LND_GRPC_PORT", "password": ""}}'
LND_ADMIN_MACAROON_FILE: "/lnd/data/chain/bitcoin/${APP_BITCOIN_NETWORK}/admin.macaroon"
CONFIG: '{ "rateLimit": 10000, "postRateLimit": 10000, "redis": { "port": 6379, "host": "$APP_BLUEWALLET_REDIS_IP", "family": 4, "password": "moneyprintergobrrr", "db": 0 }, "lnd": { "url": "$APP_LIGHTNING_NODE_IP:$APP_LIGHTNING_NODE_GRPC_PORT", "password": ""}}'
networks:
default:
ipv4_address: "${APP_BLUEWALLET_LNDHUB_IP}"
10 changes: 5 additions & 5 deletions btc-rpc-explorer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ services:
# Docker requirements
BTCEXP_HOST: 0.0.0.0
# Bitcoin Core
BTCEXP_BITCOIND_HOST: $BITCOIN_IP
BTCEXP_BITCOIND_PORT: $BITCOIN_RPC_PORT
BTCEXP_BITCOIND_USER: $BITCOIN_RPC_USER
BTCEXP_BITCOIND_PASS: $BITCOIN_RPC_PASS
BTCEXP_BITCOIND_HOST: $APP_BITCOIN_NODE_IP
BTCEXP_BITCOIND_PORT: $APP_BITCOIN_RPC_PORT
BTCEXP_BITCOIND_USER: $APP_BITCOIN_RPC_USER
BTCEXP_BITCOIND_PASS: $APP_BITCOIN_RPC_PASS
# Electrum
BTCEXP_ADDRESS_API: electrumx
BTCEXP_ELECTRUMX_SERVERS: "tcp://$ELECTRUM_IP:$ELECTRUM_PORT"
BTCEXP_ELECTRUMX_SERVERS: "tcp://$APP_ELECTRS_NODE_IP:$APP_ELECTRS_NODE_PORT"
# Log level
DEBUG: "btcexp:*,electrumClient"
# Performance
Expand Down
Loading

0 comments on commit 576ecd2

Please sign in to comment.