def parse_context(args, parser):
    tx_db = None
    if args.db:
        the_ram_tx_db = dict(((tx.hash(), tx) for tx in args.db))
        if (tx_db is None):
            tx_db = create_tx_db(args.network)
        tx_db.lookup_methods.append(the_ram_tx_db.get)
    txs = []
    spendables = []
    payables = []
    key_iters = []
    warning_spendables = None
    for arg in args.argument:
        if is_address_valid(arg, allowable_netcodes=[args.network], allowable_types=['address', 'pay_to_script', 'segwit']):
            payables.append((arg, 0))
            continue
        if key_found(arg, payables, key_iters):
            continue
        (tx, tx_db) = parse_tx(arg, parser, tx_db, args.network)
        if tx:
            txs.append(tx)
            continue
        if parse_parts(arg, spendables, payables, args.network):
            continue
        parser.error(("can't parse %s" % arg))
    parse_private_key_file(args, key_iters)
    if args.fetch_spendables:
        warning_spendables = message_about_spendables_for_address_env(args.network)
        for address in args.fetch_spendables:
            spendables.extend(spendables_for_address(address, args.network))
    return (txs, spendables, payables, key_iters, tx_db, warning_spendables)
def parse_context(args, parser):
    tx_db = None
    if args.db:
        the_ram_tx_db = dict(((tx.hash(), tx) for tx in args.db))
        if (tx_db is None):
            tx_db = create_tx_db(args.network)
        tx_db.lookup_methods.append(the_ram_tx_db.get)
    txs = []
    spendables = []
    payables = []
    key_iters = []
    warning_spendables = None
    for arg in args.argument:
        if is_address_valid(arg, allowable_netcodes=[args.network], allowable_types=['address', 'pay_to_script', 'segwit']):
            payables.append((arg, 0))
            continue
        if key_found(arg, payables, key_iters):
            continue
        (tx, tx_db) = parse_tx(arg, parser, tx_db, args.network)
        if tx:
            txs.append(tx)
            continue
        if parse_parts(arg, spendables, payables, args.network):
            continue
        parser.error(("can't parse %s" % arg))
    parse_private_key_file(args, key_iters)
    if args.fetch_spendables:
        warning_spendables = message_about_spendables_for_address_env(args.network)
        for address in args.fetch_spendables:
            spendables.extend(spendables_for_address(address, args.network))
    return (txs, spendables, payables, key_iters, tx_db, warning_spendables)