1
0

Clean up block explorer handling. Add menu item to go to block explorer for an address.

Block explorer code is data-driven now.
Put block explorer defaulting in one place.
Fix URLs for insight.is and blockr.io.
Add tradeblock.com explorer.
Add menu item to view address on block explorer provided only one is selected.
This commit is contained in:
Neil Booth
2015-04-26 22:02:21 +09:00
parent 6e33e2605e
commit deec78a9d4
3 changed files with 39 additions and 13 deletions

View File

@@ -188,6 +188,34 @@ def age(from_date, since_date = None, target_tz=None, include_seconds=False):
else:
return "over %d years ago" % (round(distance_in_minutes / 525600))
block_explorer_info = {
'Blockchain.info': ('https://blockchain.info',
{'tx': 'tx', 'addr': 'address'}),
'Blockr.io': ('https://btc.blockr.io',
{'tx': 'tx/info', 'addr': 'address/info'}),
'Insight.is': ('https://insight.bitpay.com',
{'tx': 'tx', 'addr': 'address'}),
'Blocktrail.com': ('https://www.blocktrail.com/BTC',
{'tx': 'tx', 'addr': 'address'}),
'TradeBlock.com': ('https://tradeblock.com/blockchain',
{'tx': 'tx', 'addr': 'address'}),
}
def block_explorer(config):
return config.get('block_explorer', 'Blockchain.info')
def block_explorer_tuple(config):
return block_explorer_info.get(block_explorer(config))
def block_explorer_URL(config, kind, item):
be_tuple = block_explorer_tuple(config)
if not be_tuple:
return
kind_str = be_tuple[1].get(kind)
if not kind_str:
return
url_parts = [be_tuple[0], kind_str, item]
return "/".join(url_parts)
# URL decode
#_ud = re.compile('%([0-9a-hA-H]{2})', re.MULTILINE)