- Get Sqlite Explorer/Studio from SQLiteStudio or Sqlite Browser (http://sqlitebrowser.org)
- Make a copy of counterparty.db and open it in Sqlite Explorer (we haven’t used the Browser for this how-to)
- In Sqlite Explorer, go to Tools > Open SQL Editor
Example: Find all addresses with LTBCOIN
SELECT address FROM balances WHERE asset='LTBCOIN';
Example: Find asset ownership of particular address
This allows one to check his recent asset balance:
SELECT quantity,address FROM balances WHERE asset='LTBCOIN' AND address='1126tkRhAyYDhw3V45oWs5eWU7DY4WnBoF';
Result:
Balance Address
147 1126tkRhAyYDhw3V45oWs5eWU7DY4WnBoF
To find all token balances for an address:
SELECT quantity,address FROM balances WHERE address='1126tkRhAyYDhw3V45oWs5eWU7DY4WnBoF'
Example: Explore the claim that BTC_Pay didn’t work for many Counterwallet users
We can decide what we’re looking for (for example, expired matches which usually happened because people logged off and forgot about Step 2 in BTC_Pay):
SELECT * FROM btcpays where status = 'invalid: order match expired';
From Bitcoin (BTC) Block 315,845 — SoChain we know no expired match in BTC Pay’s happened since mid August 2014 (soon after that BTC_Pay was removed from Counterwallet).
By graphing the results in Excel we can also display the amount of each failed BTC_Pay:
We can see that except 4 orders, all others were tiny. A loud individual (or four) managed to shut down BTC_Pay. How much in DEx transactions happened in BTC?
SELECT SUM(btc_amount) FROM btcpays;
Result:
SUM(btc_amount)
30452050546
Divided by 100 million (satoshis) that is 3 BTC. So it could be said that BTC_Pay wasn’t widely used to begin with, but some users who did use it weren’t happy with the way it worked.
Note:
- There is a handful of other invalid types in transaction history - maybe those users were unhappy as well
- We cannot attribute all expired matches to the users’ ignorance - sometimes the exchange rate moved against the BTC seller and they’d abandon the transaction rather than lose more on it
Example: Export Assets & Asset ID’s for later processing in Excel:
Select a table, right-click, pick Export Table, choose CSV and Unicode 2.0 UTF-8.
Tips
- SQL Statements from the GUI can be saved for convenient execution at a later time
- Save often, this GUI crashes fairly frequently (Sqlite Studio)
- For more demanding use, save the DB to SSD or Flash drive
- Sqlite Browser has a “browse data” feature which is convenient if your disk is fast and CPU powerful