Ejemplo n.º 1
0
 def serialize_unsigned(self, r: bytes, version=0):
     r = serialize.write_var_bytes(r, bytes.fromhex(self.owner_account.public_key()))
     r = serialize.write_var_bytes(r, bytes.fromhex(self.node_account.public_key()))
     r = serialize.write_var_bytes(r, bytes(self.nickname.encode()))
     r = serialize.write_var_bytes(r, bytes(self.url.encode()))
     r += struct.pack("<Q", self.location)
     r = serialize.write_var_bytes(r, bytes(self.net_address.encode()))
     return r
Ejemplo n.º 2
0
    def serialize(self):
        r = b""
        if self.parameter is None:
            r = serialize.write_var_bytes(r, bytes(0))
        else:
            r = serialize.write_var_bytes(r, self.parameter)
        if self.code is None:
            r = serialize.write_var_bytes(r, bytes(0))
        else:
            r = serialize.write_var_bytes(r, self.code)

        return r
Ejemplo n.º 3
0
    def serialize(self):
        if not self.is_valid_attribute_type(self.usage):
            return None

        r = b""
        r += struct.pack("<B", self.usage)
        if self.data is None:
            r = serialize.write_var_bytes(r, bytes(0))
        else:
            r = serialize.write_var_bytes(r, self.data)

        return r
Ejemplo n.º 4
0
def single_sign_transaction(input_private_key: str, tx: Transaction):
    data = tx.serialize_unsigned()
    signature = keytool.ecdsa_sign(bytes.fromhex(input_private_key), data)
    r = b""
    r = serialize.write_var_bytes(r, signature)
    tx.programs[0].parameter = r
    tx.hash()
    return tx
    def serialize(self, version: int):
        if self.candidates is None or len(self.candidates) == 0:
            Logger.error("candidates list is empty!")
            return None
        r = b""
        r += struct.pack("<B", self.vote_type)
        r += serialize.write_var_uint(len(self.candidates))
        for candidate in self.candidates:
            r = serialize.write_var_bytes(r, candidate)

        return r
Ejemplo n.º 6
0
    def serialize(self, r: bytes, version: int):
        if len(self.cross_chain_addresses) != len(self.output_indexes) or \
                len(self.cross_chain_addresses) != len(self.cross_chain_addresses):
            Logger.error("Invalid cross chain asset")
            return None

        r += serialize.write_var_uint(len(self.cross_chain_addresses))

        for i in range(len(self.cross_chain_addresses)):
            r = serialize.write_var_bytes(
                r, bytes(self.cross_chain_addresses[i].encode()))
            r += serialize.write_var_uint(self.output_indexes[i])
            r += struct.pack("<q", self.cross_chain_amounts[i])

        return r
Ejemplo n.º 7
0
    def serialize(self, r: bytes, version: int):
        r = self.serialize_unsigned(r, version)
        if self.signature is not None:
            r = serialize.write_var_bytes(r, self.signature)

        return r
 def serialize_unsigned(self, r: bytes, version: int):
     r = serialize.write_var_bytes(r, self.public_key)
     return r