From 124d8127d5856536163f7c673b925b73c7218ac5 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 22 Dec 2022 19:24:33 +0700 Subject: [PATCH] Update Bitcoin app to v24.0.1 --- bitcoin/data/app/.gitkeep | 0 bitcoin/data/i2pd/.gitkeep | 0 bitcoin/docker-compose.yml | 32 ++++++++++++-- bitcoin/exports.sh | 90 +++++++++++++++++++++++++++++++------- bitcoin/torrc.template | 6 +++ bitcoin/umbrel-app.yml | 26 ++++++----- 6 files changed, 122 insertions(+), 32 deletions(-) create mode 100644 bitcoin/data/app/.gitkeep create mode 100644 bitcoin/data/i2pd/.gitkeep diff --git a/bitcoin/data/app/.gitkeep b/bitcoin/data/app/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bitcoin/data/i2pd/.gitkeep b/bitcoin/data/i2pd/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/bitcoin/docker-compose.yml b/bitcoin/docker-compose.yml index 6f934e5..ef12cfa 100644 --- a/bitcoin/docker-compose.yml +++ b/bitcoin/docker-compose.yml @@ -7,9 +7,12 @@ services: APP_PORT: 3005 server: - image: getumbrel/umbrel-bitcoin:v0.3.0@sha256:115af951d7a4e696603c7468bcb4e119e02fe9c9deb28edb51d2e2d8207cab59 + image: getumbrel/umbrel-bitcoin:v0.4.0@sha256:c857f9030efc43d8bd3c0f3f4e4f90f5d8d57cdf820ad17405fee1ae537d5f53 depends_on: [bitcoind] restart: on-failure + volumes: + - ${APP_DATA_DIR}/data/app:/data # volume to persist advanced settings json + - ${APP_BITCOIN_DATA_DIR}:/bitcoin/.bitcoin # volume to persist umbrel-bitcoin.conf and bitcoin.conf environment: PORT: "3005" BITCOIN_HOST: "${APP_BITCOIN_NODE_IP}" @@ -23,14 +26,23 @@ services: BITCOIN_P2P_HIDDEN_SERVICE: "${APP_BITCOIN_P2P_HIDDEN_SERVICE}" BITCOIN_P2P_PORT: "${APP_BITCOIN_P2P_PORT}" DEVICE_DOMAIN_NAME: "${DEVICE_DOMAIN_NAME}" + BITCOIN_DEFAULT_NETWORK: "${BITCOIN_DEFAULT_NETWORK:-mainnet}" + BITCOIN_INITIALIZE_WITH_CLEARNET_OVER_TOR: "${BITCOIN_INITIALIZE_WITH_CLEARNET_OVER_TOR:-unset}" + BITCOIND_IP: "${APP_BITCOIN_NODE_IP}" + TOR_PROXY_IP: "${APP_BITCOIN_TOR_PROXY_IP}" + TOR_PROXY_PORT: "9050" + TOR_PROXY_CONTROL_PORT: "9051" + TOR_PROXY_CONTROL_PASSWORD: "moneyprintergobrrr" + I2P_DAEMON_IP: "${APP_BITCOIN_I2P_DAEMON_IP}" + I2P_DAEMON_PORT: "7656" networks: default: ipv4_address: $APP_BITCOIN_IP bitcoind: - image: lncm/bitcoind:v24.0@sha256:db19fe46f30acd3854f4f0d239278137d828ce3728f925c8d92faaab1ba8556a + image: getumbrel/bitcoind:v24.0.1@sha256:33ff257bd8a24b41bef5b5c3aea1e32ea6dcc08917e24122728687eb393814fa command: "${APP_BITCOIN_COMMAND}" - restart: on-failure + restart: unless-stopped stop_grace_period: 15m30s volumes: - "${APP_BITCOIN_DATA_DIR}:/data/.bitcoin" @@ -50,3 +62,17 @@ services: - ${TOR_DATA_DIR}:/data environment: HOME: "/tmp" + networks: + default: + ipv4_address: "${APP_BITCOIN_TOR_PROXY_IP}" + + i2pd_daemon: + image: purplei2p/i2pd:release-2.44.0@sha256:d154a599793c393cf9c91f8549ba7ece0bb40e5728e1813aa6dd4c210aa606f6 + user: "root" + command: --sam.enabled=true --sam.address=0.0.0.0 --sam.port=7656 --loglevel=error + restart: on-failure + volumes: + - ${APP_DATA_DIR}/data/i2pd:/home/i2pd/data + networks: + default: + ipv4_address: "${APP_BITCOIN_I2P_DAEMON_IP}" diff --git a/bitcoin/exports.sh b/bitcoin/exports.sh index 907d040..e329eaf 100644 --- a/bitcoin/exports.sh +++ b/bitcoin/exports.sh @@ -1,5 +1,7 @@ export APP_BITCOIN_IP="10.21.22.2" export APP_BITCOIN_NODE_IP="10.21.21.8" +export APP_BITCOIN_TOR_PROXY_IP="10.21.22.10" +export APP_BITCOIN_I2P_DAEMON_IP="10.21.22.11" export APP_BITCOIN_DATA_DIR="${EXPORTS_APP_DIR}/data/bitcoin" export APP_BITCOIN_RPC_PORT="8332" @@ -13,6 +15,24 @@ export APP_BITCOIN_ZMQ_SEQUENCE_PORT="28335" BITCOIN_CHAIN="main" BITCOIN_ENV_FILE="${EXPORTS_APP_DIR}/.env" +{ + BITCOIN_APP_CONFIG_FILE="${EXPORTS_APP_DIR}/data/app/bitcoin-config.json" + if [[ -f "${BITCOIN_APP_CONFIG_FILE}" ]] + then + bitcoin_app_network=$(jq -r '.network' "${BITCOIN_APP_CONFIG_FILE}") + case $bitcoin_app_network in + "main") + BITCOIN_NETWORK="mainnet";; + "test") + BITCOIN_NETWORK="testnet";; + "signet") + BITCOIN_NETWORK="signet";; + "regtest") + BITCOIN_NETWORK="regtest";; + esac + fi +} > /dev/null || true + if [[ ! -f "${BITCOIN_ENV_FILE}" ]]; then if [[ -z "${BITCOIN_NETWORK}" ]]; then BITCOIN_NETWORK="mainnet" @@ -33,35 +53,49 @@ fi . "${BITCOIN_ENV_FILE}" +# Make sure we don't persist the original value in .env if we have a more recent +# value from the app config +{ + if [[ ! -z ${BITCOIN_NETWORK+x} ]] && [[ "${BITCOIN_NETWORK}" ]] && [[ "${APP_BITCOIN_NETWORK}" ]] + then + APP_BITCOIN_NETWORK="${BITCOIN_NETWORK}" + fi +} > /dev/null || true + 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" - export APP_BITCOIN_TOR_PORT="18334" + # export APP_BITCOIN_RPC_PORT="18332" + # export APP_BITCOIN_P2P_PORT="18333" + # export APP_BITCOIN_TOR_PORT="18334" elif [[ "${APP_BITCOIN_NETWORK}" == "signet" ]]; then BITCOIN_CHAIN="signet" - export APP_BITCOIN_RPC_PORT="38332" - export APP_BITCOIN_P2P_PORT="38333" - export APP_BITCOIN_TOR_PORT="38334" + # export APP_BITCOIN_RPC_PORT="38332" + # export APP_BITCOIN_P2P_PORT="38333" + # export APP_BITCOIN_TOR_PORT="38334" elif [[ "${APP_BITCOIN_NETWORK}" == "regtest" ]]; then BITCOIN_CHAIN="regtest" - export APP_BITCOIN_RPC_PORT="18443" - export APP_BITCOIN_P2P_PORT="18444" - export APP_BITCOIN_TOR_PORT="18445" + # export APP_BITCOIN_RPC_PORT="18443" + # export APP_BITCOIN_P2P_PORT="18444" + # export APP_BITCOIN_TOR_PORT="18445" else echo "Warning (${EXPORTS_APP_ID}): Bitcoin Network '${APP_BITCOIN_NETWORK}' is not supported" fi +export BITCOIN_DEFAULT_NETWORK="${BITCOIN_CHAIN}" + BIN_ARGS=() -BIN_ARGS+=( "-chain=${BITCOIN_CHAIN}" ) -BIN_ARGS+=( "-proxy=${TOR_PROXY_IP}:${TOR_PROXY_PORT}" ) -BIN_ARGS+=( "-listen" ) -BIN_ARGS+=( "-bind=0.0.0.0:${APP_BITCOIN_TOR_PORT}=onion" ) -BIN_ARGS+=( "-bind=${APP_BITCOIN_NODE_IP}" ) -BIN_ARGS+=( "-port=${APP_BITCOIN_P2P_PORT}" ) -BIN_ARGS+=( "-rpcport=${APP_BITCOIN_RPC_PORT}" ) +# Commenting out options that are replaced by generated config file. We should migrate all these over in a future update. +# BIN_ARGS+=( "-chain=${BITCOIN_CHAIN}" ) +# BIN_ARGS+=( "-proxy=${TOR_PROXY_IP}:${TOR_PROXY_PORT}" ) +# BIN_ARGS+=( "-listen" ) +# BIN_ARGS+=( "-bind=0.0.0.0:${APP_BITCOIN_TOR_PORT}=onion" ) +# BIN_ARGS+=( "-bind=${APP_BITCOIN_NODE_IP}" ) +# BIN_ARGS+=( "-port=${APP_BITCOIN_P2P_PORT}" ) +# BIN_ARGS+=( "-rpcport=${APP_BITCOIN_RPC_PORT}" ) +BIN_ARGS+=( "-port=8333" ) +BIN_ARGS+=( "-rpcport=8332" ) BIN_ARGS+=( "-rpcbind=${APP_BITCOIN_NODE_IP}" ) BIN_ARGS+=( "-rpcbind=127.0.0.1" ) BIN_ARGS+=( "-rpcallowip=${NETWORK_IP}/16" ) @@ -90,4 +124,26 @@ export APP_BITCOIN_P2P_HIDDEN_SERVICE="$(cat "${p2p_hidden_service_file}" 2>/dev export APP_BITCOIN_NETWORK_ELECTRS=$APP_BITCOIN_NETWORK if [[ "${APP_BITCOIN_NETWORK_ELECTRS}" = "mainnet" ]]; then APP_BITCOIN_NETWORK_ELECTRS="bitcoin" -fi \ No newline at end of file +fi + +{ + # Migrate settings for app updates differently to fresh installs + BITCOIN_INSTALL_EXISTS="false" + BITCOIN_DATA_DIR="${EXPORTS_APP_DIR}/data/bitcoin" + if [[ -d "${BITCOIN_DATA_DIR}/blocks" ]] || [[ -d "${BITCOIN_DATA_DIR}/testnet3/blocks" ]] || [[ -d "${BITCOIN_DATA_DIR}/regtest/blocks" ]] + then + BITCOIN_INSTALL_EXISTS="true" + fi + + APP_CONFIG_EXISTS="false" + if [[ -f "${EXPORTS_APP_DIR}/data/app/bitcoin-config.json" ]] + then + APP_CONFIG_EXISTS="true" + fi + + if [[ "${BITCOIN_INSTALL_EXISTS}" = "true" ]] && [[ "${APP_CONFIG_EXISTS}" = "false" ]] + then + # This app is not a fresh install, it's being updated, so preserve existing clearnet over Tor setting + export BITCOIN_INITIALIZE_WITH_CLEARNET_OVER_TOR="true" + fi +} || true \ No newline at end of file diff --git a/bitcoin/torrc.template b/bitcoin/torrc.template index aedd619..002f411 100644 --- a/bitcoin/torrc.template +++ b/bitcoin/torrc.template @@ -1,3 +1,9 @@ +SocksPort 0.0.0.0:9050 +ControlPort 0.0.0.0:9051 +CookieAuthentication 1 +CookieAuthFileGroupReadable 1 +HashedControlPassword 16:39AF5EEFA4FC1D986022FDFB13663669FE50FB6DE9A3B4FE4FC7D82010 # moneyprintergobrrr + # Bitcoin Core P2P Hidden Service HiddenServiceDir /data/app-$APP_ID-p2p HiddenServicePort $APP_BITCOIN_P2P_PORT $APP_BITCOIN_NODE_IP:$APP_BITCOIN_TOR_PORT diff --git a/bitcoin/umbrel-app.yml b/bitcoin/umbrel-app.yml index ca5f345..c169bf6 100644 --- a/bitcoin/umbrel-app.yml +++ b/bitcoin/umbrel-app.yml @@ -2,7 +2,7 @@ manifestVersion: 1.1 id: bitcoin category: Finance name: Bitcoin Node -version: "24.0" +version: "24.0.1" tagline: Run your personal node powered by Bitcoin Core description: >- Run your Bitcoin node and independently store and validate @@ -34,19 +34,21 @@ gallery: path: "" defaultPassword: "" releaseNotes: >- - - P2P and network changes + Advanced settings are here! - - Updated RPCs - - New RPCs - - - Updated REST APIs - - - New settings - - - Low-level changes + - Toggle Tor, Clearnet, and I2P for outgoing connections, and enable Mempool Full RBF. - - Full details here: https://github.com/bitcoin/bitcoin/blob/master/doc/release-notes/release-notes-24.0.md + + - Enable incoming connections to run a listening node and help others sync their node. + + + - Switch networks between mainnet, testnet, regtest, and signet. + + + - Setting up a new node? Speed up your initial sync by increasing the cache size. + + + - Finally, you can run a pruned node, which allows you to delete old blocks that are not relevant to you to save on storage space. submitter: Umbrel submission: https://github.com/getumbrel/umbrel/commit/b0ba869953d024595bac84b8987de34aee561392