def tx(args, parser):
    (txs, spendables, payables, key_iters, tx_db, warning_spendables) = parse_context(args, parser)
    for tx in txs:
        if (tx.missing_unspents() and (args.augment or tx_db)):
            if (tx_db is None):
                tx_db = create_tx_db(args.network)
            tx.unspents_from_db(tx_db, ignore_missing=True)
    p2sh_lookup = build_p2sh_lookup(args)
    tx = generate_tx(txs, spendables, payables, args)
    is_fully_signed = do_signing(tx, key_iters, p2sh_lookup, args.network)
    include_unspents = (not is_fully_signed)
    print_output(tx, include_unspents, args.output_file, args.show_unspents, args.network, args.verbose_signature, args.disassemble, args.trace, args.pdb)
    tx_db = cache_result(tx, tx_db, args.cache, args.network)
    tx_db = validate_against_bitcoind(tx, tx_db, args.network, args.bitcoind_url)
    if (not args.show_unspents):
        tx_db = validate_tx(tx, tx_db, args.network)
    if tx_db:
        for m in [tx_db.warning_tx_cache, tx_db.warning_tx_for_tx_hash]:
            if m:
                print(('warning: %s' % m), file=sys.stderr)
    if warning_spendables:
        print(('warning: %s' % warning_spendables), file=sys.stderr)
def tx(args, parser):
    (txs, spendables, payables, key_iters, tx_db, warning_spendables) = parse_context(args, parser)
    for tx in txs:
        if (tx.missing_unspents() and (args.augment or tx_db)):
            if (tx_db is None):
                tx_db = create_tx_db(args.network)
            tx.unspents_from_db(tx_db, ignore_missing=True)
    p2sh_lookup = build_p2sh_lookup(args)
    tx = generate_tx(txs, spendables, payables, args)
    is_fully_signed = do_signing(tx, key_iters, p2sh_lookup, args.network)
    include_unspents = (not is_fully_signed)
    print_output(tx, include_unspents, args.output_file, args.show_unspents, args.network, args.verbose_signature, args.disassemble, args.trace, args.pdb)
    tx_db = cache_result(tx, tx_db, args.cache, args.network)
    tx_db = validate_against_bitcoind(tx, tx_db, args.network, args.bitcoind_url)
    if (not args.show_unspents):
        tx_db = validate_tx(tx, tx_db, args.network)
    if tx_db:
        for m in [tx_db.warning_tx_cache, tx_db.warning_tx_for_tx_hash]:
            if m:
                print(('warning: %s' % m), file=sys.stderr)
    if warning_spendables:
        print(('warning: %s' % warning_spendables), file=sys.stderr)