Exemple #1
0
    def from_bytes(cls, serialized):
        packed = messages.Lock(serialized)

        return cls(
            amount=packed.amount,
            expiration=packed.expiration,
            secrethash=packed.secrethash,
        )
Exemple #2
0
    def as_bytes(self):
        if self._asbytes is None:
            packed = messages.Lock(buffer_for(messages.Lock))
            packed.amount = self.amount
            packed.expiration = self.expiration
            packed.secrethash = self.secrethash

            self._asbytes = packed.data

        # convert bytearray to bytes
        return bytes(self._asbytes)