Igor Bubelov About Blog Photos

BTC Map

May 27, 2022

This is my second open source Android app published on F-Droid. I wouldn’t say that the publishing process was smooth since some F-Droid maintainers are biased against Bitcoin, but the app is now published and everything seems to be fine. It feels good to be able to avoid Google Play and still reach a pretty large audience.

My initial plan was to use Overpass API as a backend, but it looks like Overpass usually needs a few minutes to return all bitcoin-accepting places.

There are two most obvious ways to solve this issue:

  1. Bundle the data with the app
  2. Set up a fast cache and place it between Android client and Overpass API

I ended up combining both of those options and adding some GitHub magic on top of that. Here is how it works:

  1. I’ve set up a public GitHub repository at: https://github.com/bubelov/btcmap-data
  2. This repository has query.txt and data.json in its root directory
  3. The sole purpose of query.txt is to explain what we need from Overpass API, namely:
[out:json][timeout:300];
(
    node["currency:XBT"="yes"];
    way["currency:XBT"="yes"];
    relation["currency:XBT"="yes"];
    node["currency:BTC"="yes"];
    way["currency:BTC"="yes"];
    relation["currency:BTC"="yes"];
    node["payment:bitcoin"="yes"];
    way["payment:bitcoin"="yes"];
    relation["payment:bitcoin"="yes"];
);
out meta geom;
  1. The latest Overpass response should be saved to data.json
  2. Here is how you can populate or update the data repository:
curl -X POST -d "@query.txt" -o data.json https://overpass-api.de/api/interpreter
  1. Regular updates can be done automatically with the help of GitHub Actions: https://github.com/bubelov/btcmap-data/blob/main/.github/workflows/refresh-data.yml
  2. Now we have a self-contained and self-updating repository which caches OSM responses and you can even use it as a backend
  3. I’d like to avoid making GitHub angry, so I’ve set up a Nginx caching proxy on btcmap.org which is supposed to take most of the traffic

This process is pretty simple, transparent and auditable. All you might need is a webserver and curl and both of those programs are available out of the box in most Linux distributions.