Merge pull request #5 from Start9Labs/feature/electrs

Feature/electrs - tested with address lookup
This commit is contained in:
Dread 2022-05-10 18:41:35 -04:00 committed by GitHub
commit 5e6d260d41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 24 deletions

View File

@ -23,7 +23,7 @@ FROM node:16-buster-slim
WORKDIR /backend
RUN apt-get update && apt-get install wget netcat jq pwgen vim procps nginx curl mariadb-server mariadb-client -y \
&& wget https://github.com/mikefarah/yq/releases/download/v4.6.3/yq_linux_arm.tar.gz -O - |\
&& wget https://github.com/mikefarah/yq/releases/download/v4.25.1/yq_linux_arm.tar.gz -O - |\
tar xz && mv yq_linux_arm /usr/bin/yq
USER root

View File

@ -53,6 +53,12 @@
- PUSH:
to: 'users.[first(item => ''item.name = "mempool")].allowed-calls'
value: "getblock"
- rule: '''users.[first(item => ''item.name = "mempool")].allowed-calls.* = "getmempoolentry"'
description: 'RPC user "mempool" must have "getmempoolentry" enabled'
suggestions:
- PUSH:
to: 'users.[first(item => ''item.name = "mempool")].allowed-calls'
value: "getmempoolentry"
- rule: '''users.[first(item => ''item.name = "mempool")].allowed-calls.* = "getrawtransaction"'
description: 'RPC user "mempool" must have "getrawtransaction" enabled'
suggestions:
@ -65,11 +71,15 @@
- PUSH:
to: 'users.[first(item => ''item.name = "mempool")].allowed-calls'
value: "getrawmempool"
- rule: '''users.[first(item => ''item.name = "mempool")].allowed-calls.* = "getmempoolentry"'
description: 'RPC user "mempool" must have "getmempoolentry" enabled'
- rule: '''users.[first(item => ''item.name = "mempool")].allowed-calls.* = "gettxout"'
description: 'RPC user "mempool" must have "gettxout" enabled'
suggestions:
- PUSH:
to: 'users.[first(item => ''item.name = "mempool")].allowed-calls'
value: "getmempoolentry"
value: "gettxout"
- rule: '''users.[first(item => ''item.name = "mempool")].allowed-calls.* = "validateaddress"'
description: 'RPC user "mempool" must have "validateaddress" enabled'
suggestions:
- PUSH:
to: 'users.[first(item => ''item.name = "mempool")].allowed-calls'
value: "validateaddress"

View File

@ -67,4 +67,9 @@ bitcoind:
package-id: bitcoind
target: config
multi: false
selector: '$.txindex'
selector: '$.txindex'
enable-electrs:
type: boolean
name: "Enable Electrs Address Lookups"
description: Enables address lookups via an internal electrs instance
default: true

View File

@ -1,3 +1,6 @@
bitcoind:
condition: 'txindex?'
health_checks: []
electrs:
condition: 'enable-electrs?'
health_checks: ["synced"]

View File

@ -6,7 +6,6 @@ _term() {
kill -TERM "$backend_process" 2>/dev/null
kill -TERM "$db_process" 2>/dev/null
kill -TERM "$frontend_process" 2>/dev/null
kill -TERM "$configure" 2>/dev/null
}
# FRONTEND SETUP
@ -19,24 +18,19 @@ sed -i "s/__MEMPOOL_BACKEND_MAINNET_HTTP_HOST__/${__MEMPOOL_BACKEND_MAINNET_HTTP
sed -i "s/__MEMPOOL_BACKEND_MAINNET_HTTP_PORT__/${__MEMPOOL_BACKEND_MAINNET_HTTP_PORT__}/g" /etc/nginx/conf.d/nginx-mempool.conf
cp /etc/nginx/conf.d/nginx-mempool.conf /etc/nginx/nginx-mempool.conf
# rm /etc/nginx/sites-enabled/default
# /etc/init.d/nginx restart
cp /etc/nginx/nginx.conf /backend/nginx.conf
sed -i -e "s/__MEMPOOL_FRONTEND_HTTP_PORT__/${__MEMPOOL_FRONTEND_HTTP_PORT__}/g" -e "s/127.0.0.1://" -e "/listen/a\ server_name 127.0.0.1;" -e "s/listen 80/listen 8080/g" /backend/nginx.conf
cat /backend/nginx.conf > /etc/nginx/nginx.conf
# echo "daemon off;" >> /etc/nginx/nginx.conf
# BACKEND SETUP
# read bitcoin proxy creds from start9 config
HOST_IP=$(ip -4 route list match 0/0 | awk '{print $3}')
# export ELECTRS=$(yq e '.electrs.enabled' /root/start9/config.yaml)
bitcoind_type=$(yq e '.bitcoind.type' /root/start9/config.yaml)
bitcoind_user=$(yq e '.bitcoind.user' /root/start9/config.yaml)
bitcoind_pass=$(yq e '.bitcoind.password' /root/start9/config.yaml)
# configure mempool to use just a bitcoind backend
sed -i '/^node \/backend\/dist\/index.js/i jq \x27.MEMPOOL.BACKEND="none"\x27 \/backend\/mempool-config.json > \/backend\/mempool-config.json.tmp && mv \/backend\/mempool-config.json.tmp \/backend\/mempool-config.json' start.sh
if [ "$bitcoind_type" = "internal-proxy" ]; then
bitcoind_host="btc-rpc-proxy.embassy"
echo "Running on Bitcoin Proxy..."
@ -47,7 +41,14 @@ fi
sed -i "s/CORE_RPC_HOST:=127.0.0.1/CORE_RPC_HOST:=$bitcoind_host/" start.sh
sed -i "s/CORE_RPC_USERNAME:=mempool/CORE_RPC_USERNAME:=$bitcoind_user/" start.sh
sed -i "s/CORE_RPC_PASSWORD:=mempool/CORE_RPC_PASSWORD:=$bitcoind_pass/" start.sh
sed -i 's/MEMPOOL_BACKEND:=electrum/MEMPOOL_BACKEND:=none/' start.sh
if [ "$(yq ".enable-electrs" /root/start9/config.yaml)" = "true" ]; then
sed -i 's/ELECTRUM_HOST:=127.0.0.1/ELECTRUM_HOST:=electrs.embassy/' start.sh
sed -i 's/ELECTRUM_PORT:=50002/ELECTRUM_PORT:=50001/' start.sh
else
# configure mempool to use just a bitcoind backend
sed -i '/^node \/backend\/dist\/index.js/i jq \x27.MEMPOOL.BACKEND="none"\x27 \/backend\/mempool-config.json > \/backend\/mempool-config.json.tmp && mv \/backend\/mempool-config.json.tmp \/backend\/mempool-config.json' start.sh
sed -i 's/MEMPOOL_BACKEND:=electrum/MEMPOOL_BACKEND:=none/' start.sh
fi
# DATABASE SETUP
if [ -d "/run/mysqld" ]; then
@ -134,8 +135,6 @@ echo 'Mempool Open Source Project.' > /root/start9/stats.yaml
# START UP
sed -i "s/user nobody;//g" /etc/nginx/nginx.conf
# wait-for.sh 127.0.0.1:3306 --timeout=720 -- nginx -g 'daemon off;' &
# frontend_process=$!
nginx -g 'daemon off;' &
frontend_process=$!
@ -147,8 +146,7 @@ nginx -g 'daemon off;' &
echo 'All processes initalized'
# ERROR HANDLING
# SIGTERM HANDLING
trap _term SIGTERM
wait -n $db_process $backend_process $frontend_process
# exec "$@"

View File

@ -7,6 +7,14 @@ Mempool on the Embassy requires a fully synced archival Bitcoin Core node to fun
This implementation of Mempool on Embassy enables you to connect to your own Bitcoin Core node.
## Address Lookups
To enable address lookups, toggle on the "Enable Electrs Address Lookups" option in the configuration menu.
You will need electrs to be installed and synced before this feature will work. Also, lookups may be slow or time out altogether while the service is still warming up, or if there are too many other things running on your system.
**ATTENTION: Address lookups are an alpha feature. If electrs' health check is failing consistently even after it's fully synced, or if address lookups in mempool are timing out consistently, try restarting electrs, wait for it to finish syncing, and then try looking up an address again.**
## Support
For additional support, please visit the mempool.space matrix support room.
For additional support, please visit the mempool.space matrix support room.

View File

@ -1,7 +1,7 @@
id: mempool
title: Mempool
version: 2.3.1.3
release-notes: Bug fix for invalid dependency health check error on Bitcoin Core
version: 2.3.1.4
release-notes: Add electrs for address lookups
license: AGPL
wrapper-repo: "https://github.com/Start9Labs/mempool-wrapper"
upstream-repo: "https://github.com/mempool/mempool"
@ -181,6 +181,12 @@ dependencies:
main: /root
compat: /mnt/assets
io-format: yaml
electrs:
version: ">=0.9.6 <0.10.0"
requirement:
type: "opt-out"
how: Set Enable Electrs to Disabled in the config
description: Used to provide an index for address lookups
volumes:
main:
type: data
@ -189,8 +195,7 @@ volumes:
alerts:
start: |
READ CAREFULLY! When first running Mempool, previous block fee estimates will show as zero values until the service is able to catch up. This is expected behaviour.
ALSO: Mempool requires an electrum server in order to see address detail. This feature will soon be available with electrs.
ALSO: Lookups may be slow or time out altogether while the service is still warming up, or if there are too many other things running on your system. If address lookups aren't working, try restarting electrs and try the lookup again.
interfaces:
main:
name: Mempool Interface