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/0000000000001271efd5d9f7e539909160a181b2c0a2b8c164d6f8159e5c7dd9
- /api/block-index/123432
- /api/tx/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56
- /api/rawtx/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56
- /api/addr/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH?noTxList=1
Spelling mistake on txApperances is maintained for compatibility.
- /api/addr/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/balance
- /api/addr/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/totalReceived
- /api/addr/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/totalSent
- /api/addr/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/unconfirmedBalance
- /api/addr/1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR/utxo
- /api/addrs/1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR,1CmTtsKEqPxZsW3YjGYXbPSY89xrzkhy94/utxo
Also supports POST at '/api/addrs/utxo' with param 'addrs'.
- /api/addrs/17pfg6L3hT1ZPBASPt7DCQZfy9jWeMGq1W,1CmTtsKEqPxZsW3YjGYXbPSY89xrzkhy94/txs?from=0&to=1
Also supports POST at '/api/addrs/txs' with params 'addrs,from,to'.
- /api/txs?block=0000000000001271efd5d9f7e539909160a181b2c0a2b8c164d6f8159e5c7dd9
- /api/txs?address=1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH
- /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/0000000000001271efd5d9f7e539909160a181b2c0a2b8c164d6f8159e5c7dd9
- /rpc/getblockhash/123432
- /rpc/getblockcount
- /rpc/getrawtransaction/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56
- /rpc/gettxout/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56/1
- /rpc/getmempoolinfo
- /rpc/getrawmempool
Extensions to support sqlchain-electrum server.
- /api/history/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH
- /api/history/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/status
- /api/history/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/balance
- /api/history/1JK6pUCAXfnvcbXEpdVSxhVZ8W6kxQ4VEH/uncfmd
- /api/history/1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR/utxo
- /api/block-index/167324/electrum
- /api/tx/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56/output/1
- /api/tx/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56/raw
- /api/tx/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56/addrs
- /api/merkle/2acba2c6916cdfdbf3584dfdd32534af5031ab076029ff275167fa5181dee0a8
Extensions, and status / debugging.
- /api/auto/123432
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/1M8s2S5bgAzSSzVTeL7zruvMPLvzSkEAuv
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/23bb66ef300714042085d0ed2d05100531e80d5239020545887df059c0178b56/html
An html table formatted version of raw transaction data with hex values and op codes.
It's easy to create a web app 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 install software-properties-common python-software-properties libev-dev libevent-dev
sudo apt install mariadb-server libmysqlclient20
sudo apt install bitcoind libmysqlclient-dev python-pip python-dev build-essential
- Install sqlchain from PyPi:
sudo pip install sqlchain
- Run the init script to setup the mysql/maria db, users and config files:
sudo sqlchain-init
- Start the daemons, as needed:
sudo systemctl start bitcoin
sudo systemctl start sqlchain
sudo systemctl 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.
Give [Vultr.com](http://www.vultr.com/?ref=7087266) a try out. I've been very happy with them for development and testing sqlchain.
Use my referral link and I get funded for my testing without costing you a penny extra. You can start up and run VPS servers by the
hour using a simple control panel and in my tests they're been both faster and cheaper than Amazon AWS.