class Client(object):

    def __init__(self, rest_endpoint):
        context = create_context('secp256k1')
        private_key = context.new_random_private_key()
        self.priv_key = private_key.as_hex()
        self.pub_key = context.get_public_key(private_key).as_hex()

        self.signer = CryptoFactory(context).new_signer(private_key)
        self._namespace = hashlib.sha512('intkey'.encode()).hexdigest()[:6]
        self._factory = MessageFactory(
            'intkey',
            '1.0',
            self._namespace,
            signer=self.signer)
        self._rest = RestClient(rest_endpoint)

    def send(self):
        name = uuid4().hex[:20]
        txns = [self._factory.create_transaction(
            cbor.dumps({'Name': name,
                        'Verb': 'set',
                        'Value': 1000}),
            inputs=[self._namespace + self._factory.sha512(name.encode())[-64:]],
            outputs=[self._namespace + self._factory.sha512(name.encode())[-64:]],
            deps=[])]
        self._rest.send_batches(self._factory.create_batch(txns))

    def block_list(self):
        return [(item['header']['block_num'],
                 item['header_signature'],
                 item['header']['signer_public_key'])
                for item in self._rest.block_list()['data']]
class Client(object):
    def __init__(self, rest_endpoint):
        self.priv_key = signer.generate_privkey()
        self.pub_key = signer.generate_pubkey(self.priv_key)
        self._namespace = hashlib.sha512('intkey'.encode()).hexdigest()[:6]
        self._factory = MessageFactory('intkey', '1.0', self._namespace)
        self._rest = RestClient(rest_endpoint)

    def send(self):
        name = uuid4().hex[:20]
        txns = [
            self._factory.create_transaction(
                cbor.dumps({
                    'Name': name,
                    'Verb': 'set',
                    'Value': 1000
                }),
                inputs=[
                    self._namespace + self._factory.sha512(name.encode())[-64:]
                ],
                outputs=[
                    self._namespace + self._factory.sha512(name.encode())[-64:]
                ],
                deps=[])
        ]
        self._rest.send_batches(self._factory.create_batch(txns))

    def block_list(self):
        return [(item['header']['block_num'], item['header_signature'],
                 item['header']['signer_pubkey'])
                for item in self._rest.block_list()['data']]
class Client:
    def __init__(self, rest_endpoint):
        context = create_context('secp256k1')
        private_key = context.new_random_private_key()
        self.priv_key = private_key.as_hex()
        self.pub_key = context.get_public_key(private_key).as_hex()

        self.signer = CryptoFactory(context).new_signer(private_key)
        self._namespace = hashlib.sha512('intkey'.encode()).hexdigest()[:6]
        self._factory = MessageFactory(
            'intkey',
            '1.0',
            self._namespace,
            signer=self.signer)
        self._rest = RestClient(rest_endpoint)

    def send(self):
        name = uuid4().hex[:20]
        txns = [
            self._factory.create_transaction(
                cbor.dumps({
                    'Name': name,
                    'Verb': 'set',
                    'Value': 1000
                }),
                inputs=[
                    self._namespace + self._factory.sha512(name.encode())[-64:]
                ],
                outputs=[
                    self._namespace + self._factory.sha512(name.encode())[-64:]
                ],
                deps=[])
        ]
        self._rest.send_batches(self._factory.create_batch(txns))

    def block_list(self):
        return [(item['header']['block_num'],
                 item['header_signature'],
                 item['header']['signer_public_key'])
                for item in self._rest.block_list()['data']]