# 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
    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,
            coin_symbol=coin_symbol,
            txn_limit=TXNS_PER_PAGE,
            )
    # import pprint; pprint.pprint(wallet_details, width=1)

    assert 'error' not in wallet_details, wallet_details

    wallet_addresses = get_wallet_addresses(
            wallet_name=wallet_name,
            api_key=BLOCKCYPHER_API_KEY,
            is_hd_wallet=True,
            zero_balance=None,
            used=None,

# 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

    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,
            coin_symbol=coin_symbol,
            txn_limit=TXNS_PER_PAGE,
            )
    # import pprint; pprint.pprint(wallet_details, width=1)

    assert 'error' not in wallet_details, wallet_details

    wallet_addresses = get_wallet_addresses(
            wallet_name=wallet_name,
            api_key=BLOCKCYPHER_API_KEY,
            is_hd_wallet=True,
            zero_balance=None,
            used=None,

            coin_symbol=coin_symbol,