# Path: jmbase/jmbase/support.py
# def bintohex(b):
#     """Convert bytes to a hex string"""
#     return binascii.hexlify(b).decode('utf8')
# 
# def hextobin(h):
#     """Convert a hex string to bytes"""
#     return binascii.unhexlify(h.encode('utf8'))
# 
# Path: jmbase/jmbase/twisted_utils.py
# def stop_reactor():
#     if not _custom_stop_reactor_is_set:
#         _stop_reactor()
#     else:
#         custom_stop_reactor()


import abc
import ast
import random
import sys
import time
import binascii
import jmbitcoin as btc
from decimal import Decimal
from twisted.internet import reactor, task
from jmbase import bintohex, hextobin, stop_reactor
from jmclient.jsonrpc import JsonRpcConnectionError, JsonRpcError
from jmclient.configure import jm_single
from jmbase.support import get_log, jmprint, EXIT_FAILURE
        from electrum.transaction import Transaction
        the result of gettxout from the bitcoind rpc for those utxos;
        if any utxo is invalid, None is returned.
        includeconf: if this is True, the current number of confirmations
        of the prescribed utxo is included in the returned result dict.
        includeunconf: if True, utxos which currently have zero confirmations
        are included in the result set.
        If the utxo is of a non-standard type such that there is no address,
        the address field in the dict is None.
        """
        if not isinstance(txout, list):
            txout = [txout]
        result = []
        for txo in txout:
            txo_hex = bintohex(txo[0])
            if len(txo_hex) != 64:
                log.warn("Invalid utxo format, ignoring: {}".format(txo))
                result.append(None)
                continue
            try:
                txo_idx = int(txo[1])
            except ValueError:
                log.warn("Invalid utxo format, ignoring: {}".format(txo))
                result.append(None)
                continue
            ret = self._rpc('gettxout', [txo_hex, txo_idx, includeunconf])
            if ret is None:
                result.append(None)
            else:
                result_dict = {'value': int(Decimal(str(ret['value'])) *
                                            Decimal('1e8')),

# Path: jmbase/jmbase/support.py
# def bintohex(b):
#     """Convert bytes to a hex string"""
#     return binascii.hexlify(b).decode('utf8')
# 
# def hextobin(h):
#     """Convert a hex string to bytes"""
#     return binascii.unhexlify(h.encode('utf8'))
# 
# Path: jmbase/jmbase/twisted_utils.py
# def stop_reactor():
#     if not _custom_stop_reactor_is_set:
#         _stop_reactor()
#     else:
#         custom_stop_reactor()


# Path: jmclient/jmclient/blockchaininterface.py
import abc
import ast
import random
import sys
import time
import binascii
import jmbitcoin as btc
from decimal import Decimal
from twisted.internet import reactor, task
from jmbase import bintohex, hextobin, stop_reactor
from jmclient.jsonrpc import JsonRpcConnectionError, JsonRpcError
from jmclient.configure import jm_single
from jmbase.support import get_log, jmprint, EXIT_FAILURE
        from electrum.transaction import Transaction

        the result of gettxout from the bitcoind rpc for those utxos;
        if any utxo is invalid, None is returned.
        includeconf: if this is True, the current number of confirmations
        of the prescribed utxo is included in the returned result dict.
        includeunconf: if True, utxos which currently have zero confirmations
        are included in the result set.
        If the utxo is of a non-standard type such that there is no address,
        the address field in the dict is None.
        """
        if not isinstance(txout, list):
            txout = [txout]
        result = []
        for txo in txout:
            txo_hex = bintohex(txo[0])
            if len(txo_hex) != 64:
                log.warn("Invalid utxo format, ignoring: {}".format(txo))
                result.append(None)
                continue
            try:
                txo_idx = int(txo[1])
            except ValueError:
                log.warn("Invalid utxo format, ignoring: {}".format(txo))
                result.append(None)
                continue
            ret = self._rpc('gettxout', [txo_hex, txo_idx, includeunconf])
            if ret is None:
                result.append(None)
            else:
                result_dict = {'value': int(Decimal(str(ret['value'])) *
                                            Decimal('1e8')),

                               'script': hextobin(ret['scriptPubKey']['hex'])}