Watchtower is a microservice and REST API to monitor transactions, balances, and derived addresses for BIP32 ExtendedPublicKeys (xpubs). This enables view-only functionality in HD wallets such as KeepKey without needing the actual device connected (after initizliation with Watchtower) and without storing any private keys.
BTC, BCH, LTC, DASH, DOGE, DGB, ETH, ERC-20 tokens
Docker and Docker-Compose
- Make sure you have
docker
anddocker-compose
installed on your system - Make a local copy of the sample config file:
cp config/sample.local.json config/local.json
- Create a unique apiKey or else you will be 4XX'd by CoinQuery:
- Edit
.env
and change theENV
var tolocal-{name}
- Make a copy or symlink of
watchtower/settings/local.py
and rename tolocal-{name}.py
- Add
watchtower/settings/local-{name}.py
to.git/info/exclude
or your global .gitignore file
- Edit
- Run
docker-compose up --build
to quickly bring upwatchtower
,postgres
, andredis
preconfigured and bound to their default ports
- Scheduler - kicks off tasks using Celery
- Workers - includes block ingester
- Postgres - transaction and balance history indexed by xpub
- Redis - Celery message broker. Stores addresses to monitor in the mempool (generated receive addresses for currently connected clients)
- RabbitMQ - AMQP message broker. The block ingester service publishes messages to RabbitMQ when it detects a new transaction that affects an xpub in the watchtower DB.
Manually run watchtower tests:
docker-compose up --build
(and in a separate terminal)
docker exec -it watchtower bash
python manage.py test
Rabbit Logger is a script that connects to the local RabbitMQ server and prints each message published to exchange <exchange>
. For watchtower, this is typically exchange.watchtower.txs
or exchange.watchtower.blocks
`python3 utils/rabbit-logger.py <exchange>`
python manage.py migrate
- initialize database tablespython manage.py createsuperuser
- create admin user for debuggingfab serve
- start local webserverfab celery_scheduler
- start periodic job schedulerfab celery_workers
- start worker daemons to process jobs (optional)docker-compose down -v
- clear persistent postgres data- developer workflow: hot reloading in iPython
docker exec -ti watchtower python manage.py shell
%load_ext autoreload
%autoreload 2
init bnb
from common.services import binance_client
binance_client.get_latest_block_height()
init fio
from common.services import fio
fio.get_latest_block_height()
get block at height
fio.get_block_at_height(29990325)
History api get transactions at height
fio.get_transactions_at_height("iyz3zveyg23i")
- http://localhost:15672
- default rabbit user/pass
The primary goals in designing Watchtower's architecture were the following:
- Infrastructure costs will scale:
- independent of the number of users/xpubs/transactions being tracked, and
- proportional to the number of supported blockchains
- Easily add support for new assets
- Watchtower does not publish internal Ethereum transactions to RabbitMQ (i.e. smart contract calls). Instead WT users should query (poll) the ethereum transaction history endpoint to get a list of internal transactions for an account.
if rabbit is refusing connections. And docker-compose failing to startup locally. Increase your CPU