def print_output(tx, include_unspents, output_file, show_unspents, network, verbose_signature, disassemble, trace, pdb):
    if (len(tx.txs_in) == 0):
        print('warning: transaction has no inputs', file=sys.stderr)
    if (len(tx.txs_out) == 0):
        print('warning: transaction has no outputs', file=sys.stderr)
    tx_as_hex = tx.as_hex(include_unspents=include_unspents)
    if output_file:
        f = output_file
        if f.name.endswith('.hex'):
            f.write(tx_as_hex.encode('utf8'))
        else:
            tx.stream(f, include_unspents=include_unspents)
        f.close()
    elif show_unspents:
        for spendable in tx.tx_outs_as_spendable():
            print(spendable.as_text())
    elif (len(tx.txs_out) == 0):
        for spendable in tx.unspents:
            print(spendable.as_text())
    else:
        if (not tx.missing_unspents()):
            check_fees(tx)
        dump_tx(tx, network, verbose_signature, disassemble, trace, pdb)
        if include_unspents:
            print('including unspents in hex dump since transaction not fully signed')
        print(tx_as_hex)
def print_output(tx, include_unspents, output_file, show_unspents, network, verbose_signature, disassemble, trace, pdb):
    if (len(tx.txs_in) == 0):
        print('warning: transaction has no inputs', file=sys.stderr)
    if (len(tx.txs_out) == 0):
        print('warning: transaction has no outputs', file=sys.stderr)
    tx_as_hex = tx.as_hex(include_unspents=include_unspents)
    if output_file:
        f = output_file
        if f.name.endswith('.hex'):
            f.write(tx_as_hex.encode('utf8'))
        else:
            tx.stream(f, include_unspents=include_unspents)
        f.close()
    elif show_unspents:
        for spendable in tx.tx_outs_as_spendable():
            print(spendable.as_text())
    elif (len(tx.txs_out) == 0):
        for spendable in tx.unspents:
            print(spendable.as_text())
    else:
        if (not tx.missing_unspents()):
            check_fees(tx)
        dump_tx(tx, network, verbose_signature, disassemble, trace, pdb)
        if include_unspents:
            print('including unspents in hex dump since transaction not fully signed')
        print(tx_as_hex)