Ejemplo n.º 1
0
class ProfileOP(object):
    def __init__(self, config):
        if "service_account" in config:
            self.service_account = config["service_account"]
        else:
            self.service_account = service_account
        self.account = config["account"]
        cli_wallet = config["cli_wallet"]
        self.password = cli_wallet["wallet_unlock"]
        self.rpc = HTTPRPC(cli_wallet["host"], cli_wallet["port"],
                           cli_wallet["rpc_user"], cli_wallet["rpc_passwd"])

    def wallet_transfer(self, trx):
        _from_account, _to_account, _amount, _asset, _memo = trx
        try:
            self.rpc.transfer(_from_account, _to_account, "%s" % _amount,
                              _asset, _memo, True)
        except Exception:
            print("[failed] transfer: %s" % trx)
            return

    def update_profile(self, _profile):
        profile = json.dumps({"profile": _profile})
        trx = [self.account, self.service_account, 1, "BTS", profile]
        self.wallet_transfer(trx)
Ejemplo n.º 2
0
class Recharge(object):
    def __init__(self, config):
        if "service_account" in config:
            self.service_account = config["service_account"]
        else:
            self.service_account = service_account
        self.account = config["account"]
        cli_wallet = config["cli_wallet"]
        self.password = cli_wallet["wallet_unlock"]
        self.rpc = HTTPRPC(cli_wallet["host"], cli_wallet["port"],
                           cli_wallet["rpc_user"], cli_wallet["rpc_passwd"])

    def wallet_transfer(self, trx):
        _from_account, _to_account, _amount, _asset, _memo = trx
        try:
            self.rpc.transfer(_from_account, _to_account, "%s" % _amount,
                              _asset, _memo, True)
        except Exception:
            print("[failed] transfer: %s" % trx)
            return

    def pay(self, pay_info):
        _amount, _asset = pay_info
        if not _asset:
            print("please input balance like: 1 USD")
            return
        _asset = _asset.upper()
        _allow_asset = peg_asset_list + ["BTS"]
        if _asset not in _allow_asset:
            print("please recharge with these asset:", _allow_asset)
            return
        memo = json.dumps({"recharge": [_amount, _asset]})
        trx = [self.account, self.service_account, _amount, _asset, memo]
        self.wallet_transfer(trx)
Ejemplo n.º 3
0
class ProfileOP(object):
    def __init__(self, config):
        if "service_account" in config:
            self.service_account = config["service_account"]
        else:
            self.service_account = service_account
        self.account = config["account"]
        cli_wallet = config["cli_wallet"]
        self.password = cli_wallet["wallet_unlock"]
        self.rpc = HTTPRPC(
            cli_wallet["host"], cli_wallet["port"],
            cli_wallet["rpc_user"], cli_wallet["rpc_passwd"])

    def wallet_transfer(self, trx):
        _from_account, _to_account, _amount, _asset, _memo = trx
        try:
            self.rpc.transfer(
                _from_account, _to_account,
                "%s" % _amount, _asset, _memo, True)
        except Exception:
            print("[failed] transfer: %s" % trx)
            return

    def update_profile(self, _profile):
        profile = json.dumps({"profile": _profile})
        trx = [
            self.account, self.service_account, 1, "BTS", profile]
        self.wallet_transfer(trx)
Ejemplo n.º 4
0
class Recharge(object):
    def __init__(self, config):
        if "service_account" in config:
            self.service_account = config["service_account"]
        else:
            self.service_account = service_account
        self.account = config["account"]
        cli_wallet = config["cli_wallet"]
        self.password = cli_wallet["wallet_unlock"]
        self.rpc = HTTPRPC(
            cli_wallet["host"], cli_wallet["port"],
            cli_wallet["rpc_user"], cli_wallet["rpc_passwd"])

    def wallet_transfer(self, trx):
        _from_account, _to_account, _amount, _asset, _memo = trx
        try:
            self.rpc.transfer(
                _from_account, _to_account,
                "%s" % _amount, _asset, _memo, True)
        except Exception:
            print("[failed] transfer: %s" % trx)
            return

    def pay(self, pay_info):
        _amount, _asset = pay_info
        if not _asset:
            print("please input balance like: 1 USD")
            return
        _asset = _asset.upper()
        _allow_asset = peg_asset_list + ["BTS"]
        if _asset not in _allow_asset:
            print("please recharge with these asset:", _allow_asset)
            return
        memo = json.dumps({"recharge": [_amount, _asset]})
        trx = [
            self.account, self.service_account, _amount, _asset, memo]
        self.wallet_transfer(trx)