add knots

This commit is contained in:
Léo Haf 2023-02-08 10:41:34 +01:00 committed by Léo Haf
parent efcabe9dd3
commit f9be1ffc72
Signed by: Retropex
GPG Key ID: 0E37EBAB8574F005
19 changed files with 366 additions and 77 deletions

View File

@ -1,39 +1,17 @@
## Umbrel Community App Store Template ## This alternative store allows you to choose another version of bitcoin core.
This repository is a template to create an Umbrel Community App Store. These additional app stores allow developers to distribute applications without submitting to the [Official Umbrel App Store](https://github.com/getumbrel/umbrel-apps). This alternative App Store allows you to install [Bitcoin Knots](https://bitcoinknots.org)
Just click the "Use this template" button above and start adding your own apps! **To install this version of bitcoin core, it is imperative to uninstall the bitcoin application from the official app store.**
### Technical Details > [!WARNING]
> Unfortunately, this will trigger a new IDB.
> If you are comfortable with the command lines you can save the Bitcoin Core folder and then restore it once Knots is installed
The `umbrel-app-store.yml` file defines two important properties: To use this alternative app store just add the github depot link, here is a small [video](https://youtu.be/-CVE7LyzJJw) to see how to do it.
- `id` - This is used as a prefix for all apps within the community app store. You **MUST** prefix your application id with your app store ID. For example, this template defines `sparkles` as a community app store ID and we have a `hello world` app. The app ID therefore should be: `sparkles-hello-world`
- `name` - This name appears within the Umbrel user interface when users explore apps within these community app stores.
If you want to install an app that requires the bitcoin application it will fail, because it is a community app store. To overcome this you must use the following command that will force the installation of an app :
### Testing
To test your community app store, you can add this repository through the Umbrel user interface as shown in the following demo:
https://user-images.githubusercontent.com/10330103/197889452-e5cd7e96-3233-4a09-b475-94b754adc7a3.mp4
Alternatively, you can use the Umbrel CLI as described below.
To add an app store:
``` ```
sudo ~/umbrel/scripts/repo add https://github.com/getumbrel/umbrel-community-app-store.git sudo ~/umbrel/scripts/app install <app>
sudo ~/umbrel/scripts/repo update
```
To install an app from the app store
```
sudo ~/umbrel/scripts/app install sparkles-hello-world
```
To remove an app store:
```
sudo ~/umbrel/scripts/repo remove https://github.com/getumbrel/umbrel-community-app-store.git
``` ```

View File

View File

View File

View File

@ -0,0 +1,78 @@
version: "3.7"
services:
app_proxy:
environment:
APP_HOST: $APP_BITCOIN_IP
APP_PORT: 3005
server:
image: getumbrel/umbrel-bitcoin:v0.4.1@sha256:edc0567efeadf30128313308e2dadbfaa1f339ce666579646c3b9353834bb888
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}"
RPC_PORT: "${APP_BITCOIN_RPC_PORT}"
BITCOIN_RPC_PORT: "${APP_BITCOIN_RPC_PORT}"
RPC_USER: "${APP_BITCOIN_RPC_USER}"
BITCOIN_RPC_USER: "${APP_BITCOIN_RPC_USER}"
RPC_PASSWORD: "${APP_BITCOIN_RPC_PASS}"
BITCOIN_RPC_PASSWORD: "${APP_BITCOIN_RPC_PASS}"
BITCOIN_RPC_HIDDEN_SERVICE: "${APP_BITCOIN_RPC_HIDDEN_SERVICE}"
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: retropex/bitcoin:arm-knots-25.1-for-umbrel@sha256:990ff3a324e4a4343b63e656c2ec7c1c29f668b46adb1eaa3e159dfce311bd46
command: "${APP_BITCOIN_COMMAND}"
restart: unless-stopped
stop_grace_period: 15m30s
volumes:
- "${APP_BITCOIN_DATA_DIR}:/data/.bitcoin"
ports:
- "${APP_BITCOIN_P2P_PORT}:${APP_BITCOIN_P2P_PORT}"
- "${APP_BITCOIN_RPC_PORT}:${APP_BITCOIN_RPC_PORT}"
networks:
default:
ipv4_address: $APP_BITCOIN_NODE_IP
tor:
image: getumbrel/tor:0.4.7.8@sha256:2ace83f22501f58857fa9b403009f595137fa2e7986c4fda79d82a8119072b6a
user: "1000:1000"
restart: on-failure
volumes:
- ${APP_DATA_DIR}/torrc:/etc/tor/torrc:ro
- ${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}"

149
btc-knots/exports.sh Normal file
View File

@ -0,0 +1,149 @@
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"
export APP_BITCOIN_P2P_PORT="8333"
export APP_BITCOIN_TOR_PORT="8334"
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"
{
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"
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}"
# 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"
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"
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"
else
echo "Warning (${EXPORTS_APP_ID}): Bitcoin Network '${APP_BITCOIN_NETWORK}' is not supported"
fi
export BITCOIN_DEFAULT_NETWORK="${BITCOIN_CHAIN}"
BIN_ARGS=()
# 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" )
BIN_ARGS+=( "-rpcallowip=127.0.0.1" )
BIN_ARGS+=( "-rpcauth=\"${APP_BITCOIN_RPC_AUTH}\"" )
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+=( "-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")"
# electrs compatible network param
export APP_BITCOIN_NETWORK_ELECTRS=$APP_BITCOIN_NETWORK
if [[ "${APP_BITCOIN_NETWORK_ELECTRS}" = "mainnet" ]]; then
APP_BITCOIN_NETWORK_ELECTRS="bitcoin"
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

26
btc-knots/hooks/pre-start Normal file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Delay booting Bitcoin until the RPC and P2P Tor Hidden Services are ready
HIDDEN_SERVICE_FILE="${TOR_DATA_DIR}/app-${APP_ID}-rpc/hostname"
if [[ -f "${HIDDEN_SERVICE_FILE}" ]]; then
exit
fi
"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" up --detach bitcoind
"${UMBREL_ROOT}/scripts/app" compose "${APP_ID}" up --detach tor
echo "App: ${APP_ID} - Generating Tor Hidden Service..."
for attempt in $(seq 1 100); do
if [[ -f "${HIDDEN_SERVICE_FILE}" ]]; then
echo "App: ${APP_ID} - Hidden service file created successfully!"
break
fi
sleep 0.1
done
if [[ ! -f "${HIDDEN_SERVICE_FILE}" ]]; then
echo "App: ${APP_ID} - Hidden service file wasn't created"
fi

BIN
btc-knots/icon/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
btc-knots/icon/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

BIN
btc-knots/icon/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

BIN
btc-knots/icon/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

BIN
btc-knots/icon/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

14
btc-knots/icon/icon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 259 KiB

View File

@ -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()

13
btc-knots/torrc.template Normal file
View File

@ -0,0 +1,13 @@
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
# Bitcoin Core RPC Hidden Service
HiddenServiceDir /data/app-$APP_ID-rpc
HiddenServicePort $APP_BITCOIN_RPC_PORT $APP_BITCOIN_NODE_IP:$APP_BITCOIN_RPC_PORT

29
btc-knots/umbrel-app.yml Normal file
View File

@ -0,0 +1,29 @@
manifestVersion: 1.1
id: btc-knots
category: Bitcoin Ord
name: Bitcoin Knots
version: "25.1"
tagline: Run your personal node powered by Bitcoin Knots
icon: https://raw.githubusercontent.com/Retropex/Bitcoin-store/master/btc-knots/icon/icon.svg
description: >-
Bitcoin Knots
developer: Luke Dashjr
website: https://umbrel.com
dependencies: []
repo: https://github.com/Retropex/bitcoin/tree/bitcoinknots-for-umbrel
support: https://community.getumbrel.com/c/bitcoin-and-lightning
port: 2100
gallery:
- https://raw.githubusercontent.com/Retropex/Bitcoin-store/master/btc-death-star/icon/1.jpg
- https://raw.githubusercontent.com/Retropex/Bitcoin-store/master/btc-death-star/icon/2.jpg
- https://raw.githubusercontent.com/Retropex/Bitcoin-store/master/btc-death-star/icon/3.jpg
- https://raw.githubusercontent.com/Retropex/Bitcoin-store/master/btc-death-star/icon/4.jpg
- https://raw.githubusercontent.com/Retropex/Bitcoin-store/master/btc-death-star/icon/5.jpg
path: ""
defaultPassword: ""
releaseNotes: >-
- MAX_OP_RETURN_RELAY reduced to 0 byte by default
submitter: Umbrel
submission: https://github.com/getumbrel/umbrel/commit/b0ba869953d024595bac84b8987de34aee561392

View File

@ -1,14 +0,0 @@
version: "3.7"
services:
app_proxy:
environment:
# The format here is: <app-id>_<docker-service-name>_1
APP_HOST: sparkles-hello-world_server_1
APP_PORT: 3000
server:
image: getumbrel/community-app-store-hello-world:latest
user: "1000:1000"
init: true

View File

@ -1,30 +0,0 @@
manifestVersion: 1
id: sparkles-hello-world
name: Hello World
tagline: Replace this tagline with your app's tagline
icon: https://svgur.com/i/mvA.svg
category: Development
version: "1.0.0"
port: 4000
description: >-
Add your app's description here.
You can also add newlines!
developer: Umbrel
website: https://umbrel.com
submitter: Umbrel
submission: https://github.com/getumbrel/umbrel-hello-world-app
repo: https://github.com/getumbrel/umbrel-hello-world-app
support: https://github.com/getumbrel/umbrel-hello-world-app/issues
gallery:
- https://i.imgur.com/yyVG0Jb.jpeg
- https://i.imgur.com/yyVG0Jb.jpeg
- https://i.imgur.com/yyVG0Jb.jpeg
releaseNotes: >-
Add what's new in the latest version of your app here.
dependencies: []
path: ""
defaultUsername: ""
defaultPassword: ""

View File

@ -1,2 +1,2 @@
id: "sparkles" # Choose the ID for your app store. This should contain only alphabets ("a to z") and dashes ("-"). id: "btc" # Choose the ID for your app store. This should contain only alphabets ("a to z") and dashes ("-").
name: "Sparkles" # Choose the name of your app store. It will show up in the UI as "<name> App Store". name: "Bitcoin Store" # Choose the name of your app store. It will show up in the UI as "<name> App Store".