# Path: pypeerassets/provider/common.py
# class Provider(ABC):
# 
#     net = ""
# 
#     headers = {"User-Agent": "pypeerassets"}
# 
#     @staticmethod
#     def _netname(name: str) -> dict:
#         '''resolute network name,
#         required because some providers use shortnames and other use longnames.'''
# 
#         try:
#             long = net_query(name).name
#             short = net_query(name).shortname
#         except AttributeError:
#             raise UnsupportedNetwork('''This blockchain network is not supported by the pypeerassets, check networks.py for list of supported networks.''')
# 
#         return {'long': long,
#                 'short': short}
# 
#     @property
#     def network(self) -> str:
#         '''return network full name'''
# 
#         return self._netname(self.net)['long']
# 
#     @property
#     def pa_parameters(self) -> PAParams:
#         '''load network PeerAssets parameters.'''
# 
#         return param_query(self.network)
# 
#     @property
#     def network_properties(self) -> Constants:
#         '''network parameters [min_fee, denomination, ...]'''
# 
#         return net_query(self.network)
# 
#     @property
#     def is_testnet(self) -> bool:
#         """testnet or not?"""
# 
#         if "testnet" in self.network:
#             return True
#         else:
#             return False
# 
#     @classmethod
#     def sendrawtransaction(cls, rawtxn: str) -> str:
#         '''sendrawtransaction remote API'''
# 
#         if cls.is_testnet:
#             url = 'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn)
#         else:
#             url = 'https://explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn)
# 
#         resp = urllib.request.urlopen(url)
#         return resp.read().decode('utf-8')
# 
#     @abstractmethod
#     def getblockhash(self, blocknum: int) -> str:
#         '''get blockhash using blocknum query'''
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getblockcount(self) -> int:
#         '''get block count'''
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getblock(self, hash: str) -> dict:
#         '''query block using <blockhash> as key.'''
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getdifficulty(self) -> dict:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getbalance(self, address: str) -> Decimal:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getreceivedbyaddress(self, address: str) -> Decimal:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def listunspent(self, address: str) -> list:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def select_inputs(self, address: str, amount: int) -> dict:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getrawtransaction(self, txid: str, decrypt: int=1) -> dict:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def listtransactions(self, address: str) -> list:
#         raise NotImplementedError
# 
#     def validateaddress(self, address: str) -> bool:
#         "Returns True if the passed address is valid, False otherwise."
# 
#         try:
#             Address.from_string(address, self.network_properties)
#         except InvalidAddress:
#             return False
# 
#         return True
# 
# Path: pypeerassets/exceptions.py
# class InsufficientFunds(Exception):
#     '''this address does not have enough assigned UTXOs'''


from operator import itemgetter
from .common import Provider
from pypeerassets.exceptions import InsufficientFunds
from btcpy.structs.transaction import MutableTxIn, Sequence, ScriptSig
from decimal import Decimal, getcontext
    from peercoin_rpc import Client

'''Communicate with local or remote peercoin-daemon via JSON-RPC'''

getcontext().prec = 6

try:
except ImportError:
    raise ImportError("peercoin_rpc library is required for this to work,\
                       use the pip to install it.")



# Path: pypeerassets/provider/common.py
# class Provider(ABC):
# 
#     net = ""
# 
#     headers = {"User-Agent": "pypeerassets"}
# 
#     @staticmethod
#     def _netname(name: str) -> dict:
#         '''resolute network name,
#         required because some providers use shortnames and other use longnames.'''
# 
#         try:
#             long = net_query(name).name
#             short = net_query(name).shortname
#         except AttributeError:
#             raise UnsupportedNetwork('''This blockchain network is not supported by the pypeerassets, check networks.py for list of supported networks.''')
# 
#         return {'long': long,
#                 'short': short}
# 
#     @property
#     def network(self) -> str:
#         '''return network full name'''
# 
#         return self._netname(self.net)['long']
# 
#     @property
#     def pa_parameters(self) -> PAParams:
#         '''load network PeerAssets parameters.'''
# 
#         return param_query(self.network)
# 
#     @property
#     def network_properties(self) -> Constants:
#         '''network parameters [min_fee, denomination, ...]'''
# 
#         return net_query(self.network)
# 
#     @property
#     def is_testnet(self) -> bool:
#         """testnet or not?"""
# 
#         if "testnet" in self.network:
#             return True
#         else:
#             return False
# 
#     @classmethod
#     def sendrawtransaction(cls, rawtxn: str) -> str:
#         '''sendrawtransaction remote API'''
# 
#         if cls.is_testnet:
#             url = 'https://testnet-explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn)
#         else:
#             url = 'https://explorer.peercoin.net/api/sendrawtransaction?hex={0}'.format(rawtxn)
# 
#         resp = urllib.request.urlopen(url)
#         return resp.read().decode('utf-8')
# 
#     @abstractmethod
#     def getblockhash(self, blocknum: int) -> str:
#         '''get blockhash using blocknum query'''
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getblockcount(self) -> int:
#         '''get block count'''
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getblock(self, hash: str) -> dict:
#         '''query block using <blockhash> as key.'''
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getdifficulty(self) -> dict:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getbalance(self, address: str) -> Decimal:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getreceivedbyaddress(self, address: str) -> Decimal:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def listunspent(self, address: str) -> list:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def select_inputs(self, address: str, amount: int) -> dict:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def getrawtransaction(self, txid: str, decrypt: int=1) -> dict:
#         raise NotImplementedError
# 
#     @abstractmethod
#     def listtransactions(self, address: str) -> list:
#         raise NotImplementedError
# 
#     def validateaddress(self, address: str) -> bool:
#         "Returns True if the passed address is valid, False otherwise."
# 
#         try:
#             Address.from_string(address, self.network_properties)
#         except InvalidAddress:
#             return False
# 
#         return True
# 
# Path: pypeerassets/exceptions.py
# class InsufficientFunds(Exception):
#     '''this address does not have enough assigned UTXOs'''


# Path: pypeerassets/provider/rpcnode.py
from operator import itemgetter
from .common import Provider
from pypeerassets.exceptions import InsufficientFunds
from btcpy.structs.transaction import MutableTxIn, Sequence, ScriptSig
from decimal import Decimal, getcontext
    from peercoin_rpc import Client


'''Communicate with local or remote peercoin-daemon via JSON-RPC'''

getcontext().prec = 6

try:
except ImportError:
    raise ImportError("peercoin_rpc library is required for this to work,\
                       use the pip to install it.")



class RpcNode(Client, Provider):