Пример #1
0
    def __init__(self, bootstrap):
        ConfigObject.__init__(self, bootstrap)
        self.coinserv = CoinserverRPC("http://{0}:{1}@{2}:{3}/".format(
            bootstrap['coinserv']['username'],
            bootstrap['coinserv']['password'],
            bootstrap['coinserv']['address'],
            bootstrap['coinserv']['port'],
            pool_kwargs=dict(maxsize=bootstrap.get('maxsize', 10))))
        self.exchangeable = bool(self.exchangeable)
        self.minimum_payout = dec(self.minimum_payout)

        # If a pool payout addr is specified, make sure it matches the
        # configured address version.
        if self.pool_payout_addr is not None:
            try:
                ver = address_version(self.pool_payout_addr)
            except (KeyError, AttributeError):
                ver = None
            if ver not in self.address_version:
                raise ConfigurationException(
                    "{} is not a valid {} address. Must be version {}, got version {}"
                    .format(self.pool_payout_addr, self.key,
                            self.address_version, ver))

        # Check to make sure there is a configured pool address for
        # unexchangeable currencies
        if self.exchangeable is False and self.pool_payout_addr is None:
            raise ConfigurationException(
                "Unexchangeable currencies require a pool payout addr."
                "No valid address found for {}".format(self.key))
Пример #2
0
    def __init__(self, bootstrap):
        bootstrap['_algo'] = bootstrap.pop('algo', None)
        if bootstrap['_algo'] is None:
            raise ConfigurationException(
                "A currency in config.toml is missing an entry in "
                "defaults.toml! The following config may help identify it: {}".
                format(bootstrap))

        ConfigObject.__init__(self, bootstrap)
        if self.coinserv:
            cfg = self.coinserv
            self.coinserv = CoinserverRPC("http://{0}:{1}@{2}:{3}/".format(
                cfg['username'],
                cfg['password'],
                cfg['address'],
                cfg['port'],
                pool_kwargs=dict(maxsize=bootstrap.get('maxsize', 10))))
            self.coinserv.config = cfg
        elif self.sellable or self.mineable or self.buyable:
            raise ConfigurationException(
                "Coinserver must be configured for {}!".format(self.key))

        self.sellable = bool(self.sellable)
        self.buyable = bool(self.buyable)
        self.merged = bool(self.merged)
        self.minimum_payout = dec(self.minimum_payout)

        # If a pool payout addr is specified, make sure it matches the
        # configured address version.
        if self.pool_payout_addr is not None:
            try:
                ver = address_version(self.pool_payout_addr)
            except (KeyError, AttributeError):
                ver = None
            if ver not in self.address_version:
                raise ConfigurationException(
                    "{} is not a valid {} address. Must be version {}, got version {}"
                    .format(self.pool_payout_addr, self.key,
                            self.address_version, ver))

        # Check to make sure there is a configured pool address for
        # unsellable currencies
        if self.sellable is False and self.pool_payout_addr is None and self.mineable:
            raise ConfigurationException(
                "Unsellable currencies require a pool payout addr."
                "No valid address found for {}".format(self.key))
Пример #3
0
    def __init__(self, config, logger=None):
        if not config:
            raise CoinRPCException(
                {'code': -1, 'message': 'Invalid configuration file'})

        self._set_config(**config)

        if logger:
            self.logger = logger
        else:
            logging.Formatter.converter = datetime.time.gmtime
            self.logger = logging.getLogger(self.config['logger_name'])
            self.logger.setLevel(getattr(logging, self.config['log_level']))

        self.conn = CoinserverRPC("http://{0}:{1}@{2}:{3}/"
            .format(self.coinserv['username'], self.coinserv['password'],
                    self.coinserv['address'], self.coinserv['port'],
                    pool_kwargs=dict(maxsize=self.maxsize)))
Пример #4
0
ch.setLevel(logging.DEBUG)
ch.setFormatter(logging.Formatter('%(asctime)s [%(levelname)s] %(message)s'))
root.addHandler(ch)
root.setLevel(getattr(logging, args.log_level))

config = {'pass': None}
for line in args.config_path:
    pts = line.strip().split("=")
    if len(pts) != 2:
        continue
    config[pts[0]] = pts[1]

if args.passphrase_file:
    config['pass'] = args.passphrase_file.read().strip()

rpc_connection = CoinserverRPC(
    "http://{rpcuser}:{rpcpassword}@localhost:{rpcport}/".format(**config))

try:
    balance = rpc_connection.getbalance()
except CoinRPCException as e:
    logging.error("Unable to retrieve balance, rpc returned {}".format(e))
    exit(1)

try:
    balance = Decimal(balance)
except ValueError:
    logging.error("Bogus data returned by balance call, exiting".format(
        str(balance)[:100]))
    exit(1)

if balance < Decimal("0.001"):