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


from annoying.decorators import render_to
from blockexplorer.decorators import assert_valid_coin_symbol
from blockexplorer.settings import BLOCKCYPHER_API_KEY
from blockcypher import get_wallet_transactions, create_hd_wallet, get_wallet_addresses
from blockcypher.utils import get_blockcypher_walletname_from_mpub, flatten_txns_by_hash
from utils import get_max_pages

    # TODO: confirm it's a pubkey and not a privkey

    TXNS_PER_PAGE = 100

    # 1 indexed page
    current_page = request.GET.get('page')
    if current_page:
        current_page = int(current_page)
    else:
        current_page = 1

    # transaction pagination: 0-indexed and inclusive
    tx_start_num = (current_page - 1) * TXNS_PER_PAGE
    tx_end_num = current_page * TXNS_PER_PAGE - 1

    wallet_name = get_blockcypher_walletname_from_mpub(mpub=pubkey,
            subchain_indices=subchain_indices)

    # TODO: could store in DB whether created or not
    create_hd_wallet(
            wallet_name=wallet_name,
            xpubkey=pubkey,
            api_key=BLOCKCYPHER_API_KEY,
            subchain_indices=subchain_indices,
            coin_symbol=coin_symbol,
            )

    wallet_details = get_wallet_transactions(
            wallet_name=wallet_name,

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


# Path: wallets/views.py
from annoying.decorators import render_to
from blockexplorer.decorators import assert_valid_coin_symbol
from blockexplorer.settings import BLOCKCYPHER_API_KEY
from blockcypher import get_wallet_transactions, create_hd_wallet, get_wallet_addresses
from blockcypher.utils import get_blockcypher_walletname_from_mpub, flatten_txns_by_hash
from utils import get_max_pages


    # TODO: confirm it's a pubkey and not a privkey

    TXNS_PER_PAGE = 100

    # 1 indexed page
    current_page = request.GET.get('page')
    if current_page:
        current_page = int(current_page)
    else:
        current_page = 1

    # transaction pagination: 0-indexed and inclusive
    tx_start_num = (current_page - 1) * TXNS_PER_PAGE
    tx_end_num = current_page * TXNS_PER_PAGE - 1

    wallet_name = get_blockcypher_walletname_from_mpub(mpub=pubkey,
            subchain_indices=subchain_indices)

    # TODO: could store in DB whether created or not
    create_hd_wallet(
            wallet_name=wallet_name,
            xpubkey=pubkey,
            api_key=BLOCKCYPHER_API_KEY,
            subchain_indices=subchain_indices,
            coin_symbol=coin_symbol,
            )

    wallet_details = get_wallet_transactions(
            wallet_name=wallet_name,

            api_key=BLOCKCYPHER_API_KEY,