sqlChain is a compact SQL layer that runs on top of bitcoind. It extends the query options on the
blockchain with a priority towards lower storage demands.
This demonstration server provides multiple API (compatible) interfaces:
- Insight API (with some extensions)
- Blockchain.info API (with WebSocket)
- RPC via POST, GET urls
- Electrum server
The Demo API page above documents the queries supported and differences to the original sites.
Three daemon programs are provided:
- sqlchaind updates the mysql backend from bitcoind.
- sqlchain-api provides an the API and web interfaces for querying the database.
- sqlchain-electrum adds a layer over sqlchain-api supporting Electrum clients.
Using sqlChain over a pruning node as a compact alternative, a web socket interface, and other ideas, are currently under development.
Status and blockchain analysis information below is updated periodically from this server. The open source Python code is
available in the
neoCogent Github and please check out
my
neoCogent blog.
This information is provided by the /api/status/db/html call.
- /api/block/0000000000003431c5b86d3788a953eeaeef2bd5b3491dff0f4e0a931aa4f8f3
- /api/block-index/892679
- /api/tx/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35
- /api/raw/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35
- /api/addr/muPawjrif323ikE2oJM3FbPxvTjGP1zNin?noTxList=1
Spelling mistake on txApperances is maintained for compatibility.
- /api/addr/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/balance
- /api/addr/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/totalReceived
- /api/addr/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/totalSent
- /api/addr/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/unconfirmedBalance
- /api/addr/n4CLirZ5vrWxtNvEDDwkddN8g88TQk99WJ/utxo
- /api/addrs/n4CLirZ5vrWxtNvEDDwkddN8g88TQk99WJ,muPawjrif323ikE2oJM3FbPxvTjGP1zNin/utxo
Also supports POST at '/api/addrs/utxo' with param 'addrs'.
- /api/addrs/n4CLirZ5vrWxtNvEDDwkddN8g88TQk99WJ,muPawjrif323ikE2oJM3FbPxvTjGP1zNin/txs?from=0&to=1
Also supports POST at '/api/addrs/txs' with params 'addrs,from,to'.
- /api/txs?block=0000000000003431c5b86d3788a953eeaeef2bd5b3491dff0f4e0a931aa4f8f3
- /api/txs?address=n4CLirZ5vrWxtNvEDDwkddN8g88TQk99WJ
- /api/utils/estimatefee?nbBlocks=2
- /api/tx/send
Send raw transaction by POST method with param 'rawtx'.
This api also available via POST with [method,params] args.
- /rpc/getinfo
- /rpc/getdifficulty
- /rpc/getblock/0000000000003431c5b86d3788a953eeaeef2bd5b3491dff0f4e0a931aa4f8f3
- /rpc/getblockhash/892679
- /rpc/getblockcount
- /rpc/getrawtransaction/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35
- /rpc/gettxout/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35/1
- /rpc/getmempoolinfo
- /rpc/getrawmempool
Extensions to support sqlchain-electrum server.
- /api/history/muPawjrif323ikE2oJM3FbPxvTjGP1zNin
- /api/history/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/status
- /api/history/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/balance
- /api/history/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/uncfmd
- /api/history/muPawjrif323ikE2oJM3FbPxvTjGP1zNin/utxo
- /api/block-index/167324/electrum
- /api/tx/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35/output/1
- /api/tx/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35/raw
- /api/tx/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35/addrs
- /api/merkle/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35
Extensions, and status / debugging.
- /api/auto/892679
Auto detect value and return appropriate data.
Supports 4 modes: block-index, block hash, address, tx hash.
Also available as POST method with 'data' parameter, as demonstrated above with "Find".
- /api/closure/muPawjrif323ikE2oJM3FbPxvTjGP1zNin
Compute the closure of an address. That is, the addresses likely to be owned by the same entity.
- /api/status
- /api/status/db/html
Returns database information like row counts, disk space used.
Advanced info like multi-sig address count,
id collision counts, non-std and unspent output counts are updated periodically due to slow query time. An html
version returns a table that can be used in web pages with styling.
- /api/tx/1851c0248739bb3a71ae6d207748b35b9005d5cc31e2dc255c54a7278edc4c35/html
An html table formatted version of raw transaction data with hex values and op codes.
It's easy to create a web app based using sqlChain on an Ubuntu server.
See the full install guide on
github, but briefly:
- Install base packages:
# may not need but won't hurt
sudo apt-get install python-software-properties libev-dev libevent-dev
sudo apt-get install bitcoind mysql-server libmysqlclient-dev python-pip python-dev
- Install sqlchain from PyPi:
sudo pip install sqlchain
- Run the init script to setup mysql db, users and config files:
sudo sqlchain-init
- Start the daemons, as needed:
sudo start bitcoin
sudo start sqlchain
sudo start sqlchain-api
- Modify the /var/www source files as your own app.
- Scale to serve the world:
run nginx as front end and mysql replication behind.
Huh, What support?
More seriously, I put a lot of work into creating this. If you want to support continued effort by donating
that would be cool. Visit my
blog donation page.
I do
freelance programming work, and I'm available to build on this commericially for you or work on other Bitcoin related
projects. My rates are very reasonable, given my expertise, because I live in a downright life-is-cheap country.
So if donating rubs you the wrong way then you can always hire me.