# Path: blockexplorer/settings.py
# BLOCKCYPHER_API_KEY = os.getenv('BLOCKCYPHER_API_KEY')


from django.http import HttpResponseRedirect
from django.urls import reverse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from annoying.decorators import render_to
from blockexplorer.decorators import assert_valid_coin_symbol
from blockexplorer.settings import BLOCKCYPHER_API_KEY
from blockcypher.api import get_block_details, get_latest_block_height, get_block_overview, get_block_hash
from blockcypher.constants import COIN_SYMBOL_MAPPINGS
from blockcypher.utils import is_valid_hash
from utils import get_max_pages
            )

    return {
            'coin_symbol': coin_symbol,
            'api_url': api_url,
            'block_details': block_details,
            'current_page': current_page,
            'max_pages': get_max_pages(num_items=block_details['n_tx'], items_per_page=TXNS_PER_PAGE),
            }


def block_ordered_tx(request, coin_symbol, block_num, tx_num):

    block_overview = get_block_overview(
            block_representation=block_num,
            coin_symbol=coin_symbol,
            txn_limit=1,
            txn_offset=int(tx_num),
            api_key=BLOCKCYPHER_API_KEY,
            )
    txids = block_overview.get('txids')

    if txids:
        tx_hash = txids[0]
        msg = _('This is transaction <strong>%(tx_num)s</strong> in block <strong>%(block_num)s</strong> (<a href="%(permalink)s">permalink</a>).' % {
            'tx_num': tx_num,
            'block_num': block_num,
            'permalink': reverse('block_ordered_tx', kwargs={
                'coin_symbol': coin_symbol,
                'block_num': block_num,

# Path: blockexplorer/settings.py
# BLOCKCYPHER_API_KEY = os.getenv('BLOCKCYPHER_API_KEY')


# Path: blocks/views.py
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _
from annoying.decorators import render_to
from blockexplorer.decorators import assert_valid_coin_symbol
from blockexplorer.settings import BLOCKCYPHER_API_KEY
from blockcypher.api import get_block_details, get_latest_block_height, get_block_overview, get_block_hash
from blockcypher.constants import COIN_SYMBOL_MAPPINGS
from blockcypher.utils import is_valid_hash
from utils import get_max_pages

            )

    return {
            'coin_symbol': coin_symbol,
            'api_url': api_url,
            'block_details': block_details,
            'current_page': current_page,
            'max_pages': get_max_pages(num_items=block_details['n_tx'], items_per_page=TXNS_PER_PAGE),
            }


def block_ordered_tx(request, coin_symbol, block_num, tx_num):

    block_overview = get_block_overview(
            block_representation=block_num,
            coin_symbol=coin_symbol,
            txn_limit=1,
            txn_offset=int(tx_num),
            api_key=BLOCKCYPHER_API_KEY,
            )
    txids = block_overview.get('txids')

    if txids:
        tx_hash = txids[0]
        msg = _('This is transaction <strong>%(tx_num)s</strong> in block <strong>%(block_num)s</strong> (<a href="%(permalink)s">permalink</a>).' % {
            'tx_num': tx_num,
            'block_num': block_num,
            'permalink': reverse('block_ordered_tx', kwargs={
                'coin_symbol': coin_symbol,
                'block_num': block_num,

                'tx_num': tx_num,