diff --git a/Dockerfile b/Dockerfile index 0524a2b..17b6260 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ RUN apt-get update && \ apt-get install -y xz-utils python && \ rm -rf /var/lib/apt/lists/* -RUN curl https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-arm64.tar.xz --output node-v14.18.1-linux-arm64.tar.xz -RUN tar xvf node-v14.18.1-linux-arm64.tar.xz +RUN curl https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz --output node-v14.18.1-linux-x64.tar.xz +RUN tar xvf node-v14.18.1-linux-x64.tar.xz # urbit-bitcoin-rpc Builder container @@ -40,7 +40,7 @@ RUN groupadd -g $GID -o $USERNAME && \ echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: /usr/bin/append-to-hosts" | tee -a /etc/sudoers # Copy files from the builder containers -COPY --from=nodejs-builder /node-v14.18.1-linux-arm64/ /usr/local/ +COPY --from=nodejs-builder /node-v14.18.1-linux-x64/ /usr/local/ COPY --from=urbit-rpc-builder /urbit-bitcoin-rpc/* / COPY --from=urbit-rpc-builder /urbit-bitcoin-rpc/src /src diff --git a/README.md b/README.md index a660544..01fe7bb 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,12 @@ Since Umbrel ships with `bitcoind` and `electrs` out of the box, the only remain The Docker Compose file is included for reference. Most importantly it imports env vars that describe the `bitcoind` and `electrs` servers to communicate with. This package does not need persistent storage. -Once you've got it running, try curling it: +Once running on a fully synced Umbrel, you can connect your ship to it like this: ``` -$> curl http://ip.address.here:50002/addresses/info/bc1qm7cegwfd0pvv9ypvz5nhstage00xkxevtrpshc +dojo> |rein %bitcoin [& %btc-provider] +dojo> =network %main +dojo> :btc-provider +bitcoin!btc-provider/command [%set-credentials api-url='http://addresshere:50002' network] ``` + +If it's working, you will be able to see a new block announcement in your dojo. diff --git a/bin/get-bitcoin.sh b/bin/get-bitcoin.sh deleted file mode 100644 index eaa1352..0000000 --- a/bin/get-bitcoin.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env bash - -set -e -# For debugging: -# set -x - -# Versions available (per https://bitcoincore.org/bin) are: -# -# (there are earlier versions available, but the binary URLs don't conform to the -# same pattern.) -# - -VERSIONS=( -0.13.0 -0.13.1 -0.13.2 -0.14.3 -0.15.2 -0.16.3 -0.17.0 -0.17.0.1 -0.17.1 -0.17.2 -0.18.0 -0.18.1 -0.19.0.1 -0.19.1 -0.20.0 -0.20.1 -0.20.2 -0.21.0 -0.21.1 -0.21.2 -) - -err() { - >&2 echo "$@" -} - -if [ ! -f /etc/debian_version ] && [ ! -f /etc/lsb_release ]; then - err "This script is intended for use on Debian-based systems." - exit 1 -fi - -VERSION="$1" -INSTALL_PREFIX="${2:-/}" - -URL_BASE="https://bitcoincore.org/bin/bitcoin-core-${VERSION}" -FILENAME="bitcoin-${VERSION}-x86_64-linux-gnu.tar.gz" - -if [ -z "${VERSION}" ]; then - err "Usage: get-bitcoin.sh []" - err - err "Available versions are:" - - for v in "${VERSIONS[@]}"; do - err " ${v}" - done - - err - exit 1 -fi - -TMPDIR=$(mktemp -d) -cd "$TMPDIR" - -# Verify this signing key fingerprint here: -# -# https://github.com/bitcoin/bitcoin/tree/master/contrib/verifybinaries -# -gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 01EA5486DE18A882D4C2684590C8019E36C2E964 - -curl -O "${URL_BASE}/SHA256SUMS.asc" -curl -O "${URL_BASE}/${FILENAME}" - -sha256sum --ignore-missing --check SHA256SUMS.asc \ - | tee - | grep -o "${FILENAME}: OK" - -gpg --verify SHA256SUMS.asc >gpg_verify_out 2>&1 -grep '^gpg: Good signature from "Wladimir J. van der Laan' gpg_verify_out -grep '^Primary key fingerprint: 01EA 5486 DE18 A882 D4C2 6845 90C8 019E 36C2 E964' gpg_verify_out - -tar -xzvf "${FILENAME}" -DIR=$(find . -name 'bitcoin-*' -type d | head -n 1) -ls -lah ${DIR} -rm "${DIR}"/bin/bitcoin-qt -cp -r "${DIR}"/* "${INSTALL_PREFIX}" - -echo -echo "Bitcoin installed:" -echo -"${INSTALL_PREFIX}/bin/bitcoind" --version || true - diff --git a/rpc/mainnet-start.sh b/rpc/mainnet-start.sh index e89870b..bf2524d 100755 --- a/rpc/mainnet-start.sh +++ b/rpc/mainnet-start.sh @@ -3,12 +3,9 @@ # Set host.docker.internal sudo /usr/bin/append-to-hosts "$(ip -4 route list match 0/0 | awk '{print $3 "\thost.docker.internal"}')" echo Running modified mainnet script... -export BTC_RPC_PORT=${BITCOIN_RPC_PORT} -export ELECTRS_HOST=${ELECTRUM_IP} -export ELECTRS_PORT=${ELECTRUM_PORT} -# docker-compose.yml also passes the folllowing env vars: -# $BITCOIN_RPC_USER, $BITCOIN_RPC_PASS, $BITCOIN_RPC_AUTH, -# and $BITCOIN_IP +# docker-compose.yml passes the folllowing env vars: +# $BITCOIN_RPC_AUTH, $BITCOIN_PORT, $BITCOIN_IP, $BITCOIN_PORT, +# $ELECTRUM_IP, and $ELECTRUM_PORT export PROXY_PORT=50002 node src/server.js diff --git a/rpc/server.js b/rpc/server.js index f63b18a..67de5e0 100644 --- a/rpc/server.js +++ b/rpc/server.js @@ -5,14 +5,11 @@ const BigNumber = require("bignumber.js"); const request = require("request"); //var electrsHost = 'electrs'; -const btcCookiePass = process.env.BTC_RPC_COOKIE_PASS; -const btcRpcPort = process.env.BTC_RPC_PORT; +const btcRpcPort = process.env.BITCOIN_RPC_PORT; const btcIp = process.env.BITCOIN_IP; const btcRpcUrl = `${btcIp}:${btcRpcPort}/`; -const electrsHost = process.env.ELECTRS_HOST; -const electrsPort = process.env.ELECTRS_PORT; -const btcRpcUser = process.env.BITCOIN_RPC_USER; -const btcRpcPass = process.env.BITCOIN_RPC_PASSWORD; +const electrsHost = process.env.ELECTRUM_IP; +const electrsPort = process.env.ELECTRUM_PORT; const btcRpcAuth = process.env.BITCOIN_RPC_AUTH; // console.log(`INFO PROXY: btc rpc pass: ${btcCookiePass}`) console.log(`INFO PROXY: Electrs host: ${electrsHost}:${electrsPort}`);