version: "3.7"

services:
  app_proxy:
    environment:
      APP_HOST: $APP_BITCOIN_KNOTS_NODE_IP
      APP_PORT: 3000
  
  app:
    image: ghcr.io/retropex/umbrel-bitcoin-knots:1.2.10@sha256:4dc37d9014eb29d47898d512422736ad2eed89bf31d321fc27b27547f04d0866
    user: "1000:1000"
    restart: on-failure
    stop_grace_period: 15m30s
    # эти порты доступны для внешних подключений к bitcoind
    ports:
      - "${APP_BITCOIN_KNOTS_P2P_PORT}:${APP_BITCOIN_KNOTS_P2P_PORT}"
      - "${APP_BITCOIN_KNOTS_RPC_PORT}:${APP_BITCOIN_KNOTS_RPC_PORT}"
    volumes:
      - ${APP_DATA_DIR}/data:/data # data/app and data/bitcoin
    environment:
      # НАСТРОЙКИ КАТАЛОГ ДАННЫХ
      # BITCOIN_DIR: bitcoin-dir-override
      # APP_STATE_DIR: app-state-dir-override

      # БИНАРНЫЕ НАСТРОЙКИ БИТКОИНДА
      # BITCOIND_BIN: bitcoind-binary-path-override
      # разделенный запятыми список дополнительных флагов запуска для передачи в bitcoind
      BITCOIND_EXTRA_ARGS: '-deprecatedrpc=create_bdb' # We can remove depratedrpc=create_bdb in a future update once Jam (JoinMarket) implements descriptor wallet support

      # НАСТРОЙКИ КОНФ-ФАЙЛА БИТКОИНДА
      APPS_SUBNET: "${NETWORK_IP}/16" # used for rpcallowip
      P2P_PORT: "${APP_BITCOIN_KNOTS_P2P_PORT}" # port, bind (also used for connect details)
      P2P_WHITEBIND_PORT: "${APP_BITCOIN_KNOTS_P2P_WHITEBIND_PORT}" # Additional inbound P2P listener granting whitelisted permissions (whitebind) to this port; for trusted internal apps only; do not publish externally
      RPC_PORT: "${APP_BITCOIN_KNOTS_RPC_PORT}" # rpcport (also used for rpc client and connect details)
      TOR_PORT: "${APP_BITCOIN_KNOTS_TOR_PORT}" # bind=onion
      ZMQ_RAWBLOCK_PORT: "${APP_BITCOIN_KNOTS_ZMQ_RAWBLOCK_PORT}" # zmqpubrawblock
      ZMQ_RAWTX_PORT: "${APP_BITCOIN_KNOTS_ZMQ_RAWTX_PORT}" # zmqpubrawtx
      ZMQ_HASHBLOCK_PORT: "${APP_BITCOIN_KNOTS_ZMQ_HASHBLOCK_PORT}" # zmqpubhashblock
      ZMQ_SEQUENCE_PORT: "${APP_BITCOIN_KNOTS_ZMQ_SEQUENCE_PORT}" # zmqpubsequence
      ZMQ_HASHTX_PORT: "${APP_BITCOIN_KNOTS_ZMQ_HASHTX_PORT}" # zmqpubhashtx
      TOR_HOST: "${APP_BITCOIN_KNOTS_TOR_PROXY_IP}" # proxy, onion, torcontrol
      TOR_SOCKS_PORT: "9050" # proxy, onion
      TOR_CONTROL_PORT: "9051" # torcontrol
      TOR_CONTROL_PASSWORD: "moneyprintergobrrr" # torpassword
      I2P_HOST: "${APP_BITCOIN_KNOTS_I2P_DAEMON_IP}" # i2psam
      I2P_SAM_PORT: "7656" # i2psam

      # НАСТРОЙКИ КЛИЕНТА RPC
      BITCOIND_IP: "${APP_BITCOIN_KNOTS_NODE_IP}" # host for the rpc client. Also used for bitcoind conf file rpcbind & bind.
      RPC_USER: "${APP_BITCOIN_KNOTS_RPC_USER}" # also shown in the connect modal
      RPC_PASS: "${APP_BITCOIN_KNOTS_RPC_PASS}" # also shown in the connect modal

      # CONNECTION DETAILS (отображается пользователю в модальном окне подключения)
      DEVICE_DOMAIN_NAME: "${DEVICE_DOMAIN_NAME}"
      P2P_HIDDEN_SERVICE: "${APP_BITCOIN_KNOTS_P2P_HIDDEN_SERVICE}"
      RPC_HIDDEN_SERVICE: "${APP_BITCOIN_KNOTS_RPC_HIDDEN_SERVICE}"
    networks:
      default:
        ipv4_address: $APP_BITCOIN_KNOTS_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_KNOTS_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_KNOTS_I2P_DAEMON_IP}"
