Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea/*
*.iml
www/*
*.pyc
61 changes: 60 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
# bisq-explorer
# Bisq BSQ Explorer

## Overview
The BSQ explorer provides basic information about BSQ transactions.
It is based on static html pages which are rendered from json files generated by a Bisq application running on the
server. Beside http server and Bisq (we run a seednode instance) we require bitcoind as the Bisq node is running in
fullnode mode.


### Installation notes for Nginx server:

The Nginx configuration requires to set a symlink as root user:
```
cd /var/www
ln -s /home/user/bisq/bisq-explorer-mainnet/www html
```

We need to symlink for testnet (https://explorer.bisq.network/testnet/).

```
cd /home/user/bisq/bisq-explorer-mainnet/www
ln -s /home/user/bisq/bisq-explorer-testnet/www testnet
```

Inside the testnet and mainnet `www` directories we need to set symlinks to the json files generated by the Bisq app:

For testnet:
```
cd /home/user/bisq/bisq-explorer-testnet/www
ln -s /home/user/.local/share/seed_BTC_TESTNET_o5qw2hy6l7jsf654/btc_testnet/db/json/all all
ln -s /home/user/.local/share/seed_BTC_TESTNET_o5qw2hy6l7jsf654/btc_testnet/db/json/tx tx
ln -s /home/user/.local/share/seed_BTC_TESTNET_o5qw2hy6l7jsf654/btc_testnet/db/json/txo txo
```

For mainnet:
```
cd /home/user/bisq/bisq-explorer-mainnet/www
ln -s /home/user/.local/share/bisq-BTC_MAINNET_Seed_jvsf32f75ygnfi7d/btc_mainnet/db/json/all all
ln -s /home/user/.local/share/bisq-BTC_MAINNET_Seed_jvsf32f75ygnfi7d/btc_mainnet/db/json/tx tx
ln -s /home/user/.local/share/bisq-BTC_MAINNET_Seed_jvsf32f75ygnfi7d/btc_mainnet/db/json/txo txo
```

The phyton script reads out the latest commit hash of the Bisq app. For that we use another symlink:
```
cd ~/
ln -s /home/user/bisq/bisq github
```

Run the python script from inside the explorer directories
For testnet:
```
cd /home/user/bisq/bisq-explorer-testnet
python bsq_json.py
```

For mainnet:
```
cd /home/user/bisq/bisq-explorer-mainnet
python bsq_json.py
```
4 changes: 2 additions & 2 deletions bsq_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def init():
"Addresses":0,
"Unspent TXOs":0,
"Spent TXOs":0,
"Price":0,
"Marketcap":0}
"Price in BSQ/BTC":0,
"Marketcap in BTC":0}
chaintate_dict={}
d=False

125 changes: 67 additions & 58 deletions bsq_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# #
# Copyright Grazcoin 2017 #
# https://github.com/grazcoin/bisq-tools #
# #
# #
###########################################

import logging
Expand All @@ -16,76 +16,81 @@
import bsq_globals

bsq_globals.init()
bsq_globals.chainstate_dict=load_json_file('www/all/bsqChainState.json')
bsq_globals.chainstate_dict=load_json_file('www/all/blocks.json')

lines_per_page=10

lines=[]
last_block=0
for block in bsq_globals.chainstate_dict[u'bsqBlocks']:
for block in bsq_globals.chainstate_dict[u'blocks']:
last_block=block[u'height']
for tx in block[u'txs']:
txid=tx[u'txVo'][u'id']
time=tx[u'txVo'][u'time']
txid=tx[u'id']
time=tx[u'time']
txType=tx[u'txType']
burntFee=tx[u'burntFee']
outputsNum=0
txBsqAmount=0
# take address from first output as tx details
address=tx[u'outputs'][0][u'address']

if txType == 'GENESIS':
if txType == 'UNVERIFIED':
txTypeDisplayString='Unverified'
elif txType == 'INVALID':
txTypeDisplayString='Invalid'
elif txType == 'GENESIS':
txTypeDisplayString='Genesis'
elif txType == 'TRANSFER_BSQ':
txTypeDisplayString='Transfer BSQ'
elif txType == 'PAY_TRADE_FEE':
txTypeDisplayString='Pay trade fee'
elif txType == 'PROPOSAL':
txTypeDisplayString='Proposal'
elif txType == 'COMPENSATION_REQUEST':
txTypeDisplayString='Compensation request'
elif txType == 'BLIND_VOTE':
txTypeDisplayString='Blind vote'
elif txType == 'VOTE_REVEAL':
txTypeDisplayString='Vote reveal'
elif txType == 'LOCKUP':
txTypeDisplayString='Lockup'
elif txType == 'UNLOCK':
txTypeDisplayString='Unlock'
else:
if txType == 'TRANSFER_BSQ':
txTypeDisplayString='Transfer BSQ'
else:
if txType == 'PAY_TRADE_FEE':
txTypeDisplayString='Pay trade fee'
else:
if txType == 'COMPENSATION_REQUEST':
txTypeDisplayString='Compensation request'
else:
if txType == 'VOTE':
txTypeDisplayString='Vote'
else:
if txType == 'ISSUANCE':
txTypeDisplayString='Issuance'
else:
txTypeDisplayString='Unknown'
txTypeDisplayString='Undefined'

for o in tx[u'outputs']:
index=o[u'index']
if (txType=='GENESIS' or \
((txType == 'TRANSFER_BSQ') and \
(o[u'txOutputType']=='BSQ_OUTPUT'))):
bsqAmount = o[u'value']
txBsqAmount += bsqAmount
addr=o[u'address']
unspent=o[u'isUnspent']
outputsNum+=1
txo_entry={u'bsqAmount':bsqAmount, u'time':time, u'txType':txType, u'txTypeDisplayString':txTypeDisplayString, u'txId':txid, u'index':str(index)}
if bsq_globals.addr_dict.has_key(addr):
if unspent==True:
bsq_globals.stats_dict['Unspent TXOs']+=1
if bsq_globals.addr_dict[addr].has_key(u'utxos'):
bsq_globals.addr_dict[addr][u'utxos'].append(txo_entry)
else:
bsq_globals.addr_dict[addr][u'utxos']=[txo_entry]
((txType == 'TRANSFER_BSQ') and \
(o[u'txOutputType']=='BSQ_OUTPUT'))):
bsqAmount = o[u'bsqAmount']
txBsqAmount += bsqAmount
addr=o[u'address']
unspent=o[u'isUnspent']
outputsNum+=1
txo_entry={u'bsqAmount':bsqAmount, u'time':time, u'txType':txType, u'txTypeDisplayString':txTypeDisplayString, u'txId':txid, u'index':str(index)}
if bsq_globals.addr_dict.has_key(addr):
if unspent==True:
bsq_globals.stats_dict['Unspent TXOs']+=1
if bsq_globals.addr_dict[addr].has_key(u'utxos'):
bsq_globals.addr_dict[addr][u'utxos'].append(txo_entry)
else:
bsq_globals.stats_dict['Spent TXOs']+=1
if bsq_globals.addr_dict[addr].has_key(u'stxos'):
bsq_globals.addr_dict[addr][u'stxos'].append(txo_entry)
else:
bsq_globals.addr_dict[addr][u'stxos']=[txo_entry]

bsq_globals.addr_dict[addr][u'utxos']=[txo_entry]
else:
if unspent==True:
bsq_globals.stats_dict['Unspent TXOs']+=1
bsq_globals.addr_dict[addr]={u'utxos':[txo_entry]}
bsq_globals.stats_dict['Spent TXOs']+=1
if bsq_globals.addr_dict[addr].has_key(u'stxos'):
bsq_globals.addr_dict[addr][u'stxos'].append(txo_entry)
else:
bsq_globals.stats_dict['Spent TXOs']+=1
bsq_globals.addr_dict[addr]={u'stxos':[txo_entry]}
bsq_globals.addr_dict[addr][u'stxos']=[txo_entry]

else:
if unspent==True:
bsq_globals.stats_dict['Unspent TXOs']+=1
bsq_globals.addr_dict[addr]={u'utxos':[txo_entry]}
else:
bsq_globals.stats_dict['Spent TXOs']+=1
bsq_globals.addr_dict[addr]={u'stxos':[txo_entry]}

if txType == 'GENESIS':
# collect minted coins for stats
Expand All @@ -97,20 +102,24 @@
line_dict={u'bsqAmount':txBsqAmount, u'txType':txType, u'txTypeDisplayString':txTypeDisplayString, u'txId':txid, u'time':time, u'burntFee':burntFee, u'outputsNum':outputsNum, u'height':last_block}
lines.append(line_dict)

# divide by 1000 Satoshi/BSQ
bsq_globals.stats_dict['Minted amount']/=1000
bsq_globals.stats_dict['Burnt amount']/=1000
bsq_globals.stats_dict['Existing amount']/=1000
# divide by 100 Satoshi/BSQ (1 BSQ = 100 Sat)
bsq_globals.stats_dict['Minted amount']/=100
bsq_globals.stats_dict['Burnt amount']/=100
bsq_globals.stats_dict['Existing amount']/=100

# calculate more stats
# TODO missing issued amount
bsq_globals.stats_dict['Existing amount']=bsq_globals.stats_dict['Minted amount']-bsq_globals.stats_dict['Burnt amount']

bsq_globals.stats_dict['Addresses']=len(bsq_globals.addr_dict.keys())
bsq_globals.stats_dict['Price']=0.001234
bsq_globals.stats_dict['Marketcap']=bsq_globals.stats_dict['Price']*bsq_globals.stats_dict['Existing amount']

# TODO not provided yet in jsons (though in app available)
bsq_globals.stats_dict['Price in BSQ/BTC']=0.00015
bsq_globals.stats_dict['Marketcap in BTC']=bsq_globals.stats_dict['Price in BSQ/BTC']*bsq_globals.stats_dict['Existing amount']


stats_json=[]
for k in ["Existing amount", "Minted amount", "Burnt amount", "Addresses", "Unspent TXOs", "Spent TXOs", "Price", "Marketcap"]:
for k in ["Existing amount", "Minted amount", "Burnt amount", "Addresses", "Unspent TXOs", "Spent TXOs", "Price in BSQ/BTC", "Marketcap in BTC"]:
stats_json.append({"name":k, "value":bsq_globals.stats_dict[k]})

atomic_json_dump(stats_json,'www/general/stats.json', add_brackets=False)
Expand Down Expand Up @@ -158,7 +167,7 @@
totalReceived+=s[u'bsqAmount']
spentOutputsNum+=1
totalSpent+=s[u'bsqAmount']

totalBurnt=totalGenesis+totalReceived-totalSpent-balance

bsq_globals.addr_dict[addr][u'address']=addr
Expand All @@ -172,13 +181,13 @@
bsq_globals.addr_dict[addr][u'burntNum']=burntNum
bsq_globals.addr_dict[addr][u'totalBurnt']=totalBurnt
bsq_globals.addr_dict[addr][u'totalReserved']=totalReserved


for addr in bsq_globals.addr_dict.keys():
atomic_json_dump(bsq_globals.addr_dict[addr],'www/addr/'+addr+'.json', add_brackets=False)

(commit_hexsha,commit_time)=get_git_details()
now=get_now()
revision_dict={"commit_hexsha":commit_hexsha, "commit_time":commit_time, "last_block":last_block, "last_parsed":now, "url":"https://github.com/bitsquare/bitsquare/tree/DAO_phase1"}
revision_dict={"commit_hexsha":commit_hexsha, "commit_time":commit_time, "last_block":last_block, "last_parsed":now, "url":"https://github.com/bisq-network/bisq"}

atomic_json_dump(revision_dict,'www/revision.json', add_brackets=False)
2 changes: 1 addition & 1 deletion bsq_utils_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def load_json_file(filename):
data=simplejson.loads(unicode(json_data))
return data

def get_git_details(directory="~/github/bitsquare"):
def get_git_details(directory="~/github"):
repo = git.Repo(directory)
assert repo.bare == False
head_commit=repo.head.commit
Expand Down
2 changes: 1 addition & 1 deletion www/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down
2 changes: 1 addition & 1 deletion www/API.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down
2 changes: 1 addition & 1 deletion www/Address.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down
2 changes: 1 addition & 1 deletion www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down
2 changes: 1 addition & 1 deletion www/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down
2 changes: 1 addition & 1 deletion www/tx.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down
2 changes: 1 addition & 1 deletion www/txo.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<li><a href="index.html">Recent</a></li>
<li><a href="stats.html">Stats</a></li>
<li><a href="API.html">API</a></li>
<li><a href="https://bisq.io/dao/">Info</a></li>
<li><a href="https://bisq.network">Info</a></li>
<li>
<a class="searchLI">
<div id="searchContainer" class="search">
Expand Down