[bitcoin-dev] Announcing Bitcoin Wallet Tracker
nadav at shesek.info
Sat May 30 14:16:14 UTC 2020
I recently released bwt , an HD wallet indexer implemented in Rust, using
a model similar to that of Electrum Personal Server.
It uses the bitcoind wallet functionality to do the heavy lifting and builds
additional indexes on top of that, which can be queried using the Electrum
RPC protocol, as well as a more modern, developer-friendly HTTP REST API.
The electrum server can also be used as an electrum plugin , which
integrates the server straight into the electrum client. From the user's
perspective, this allows connecting electrum directly to a full node.
The HTTP API is my take on a modern design for a wallet tracking API aimed
at app developers. Some use-cases include using it as a backend for wallets
(similarly to Samuari's Dojo) or to track deposits to a watch-only xpub
(similarly to BTCPay's NBXplorer).
Compared to using the bitcoind RPC directly, bwt provides:
- The ability to track an xpub and automatically have new addresses derived
and imported as needed, according to the gap limit.
- Two additional indexes, one for looking up the transaction history of
addresses, and another one for looking up txo spends (a map of
funding_txid:vout => spending_txid:vin).
- Real-time updates using Server-Sent Events  (a long-lived streaming
connection) or Web Hooks  (an HTTP request sent to a configured URL).
The updates being sent  directly provide information about the funded
and spent wallet txos, instead of the client figuring it out from the tx.
- Some API conveniences and simplifications, like including key origin
information directly alongside inputs/outputs , the ability to specify
key origins in place of addresses (eg. GET /hd/15cb9edc/8/utxos), a
history format , and an easy way to catch-up with missed events .
Unless explicitly asked for, the API omits information about non-wallet
inputs/outputs and protocol-level details like scriptsig and witnesses,
which are typically not needed for higher-level app development.
The indexer is designed in a way that minimizes RPC requests to bitcoind. By
using labels to store key origin information, it is able to index incoming
transactions using the information available from `listtransactions` alone
(plus 3 extra rpc requests that don't grow with the number of transactions),
but requires 1 additional rpc call per outgoing transaction (to learn which
prevouts were spent). It can index 10k incoming txs in under a second, or a
mixture of 5k/5k in under 5 seconds. The index is currently entirely in-
memory and does not get persisted. The indexer logic can be seen in .
One major item on the roadmap that I'm hoping to tackle soon is support for
output script descriptors.
If anyone is interested in contributing, the README has some useful
resources  and a handy script for setting up a development environment.
This is an early alpha release, recommended for use with testnet/regtest.
All feedback welcome!
(sync_transactions and load_transactions_since)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the bitcoin-dev