diff --git a/lbrynet/schema/claim.py b/lbrynet/schema/claim.py index a97073eda..49922b26a 100644 --- a/lbrynet/schema/claim.py +++ b/lbrynet/schema/claim.py @@ -39,7 +39,7 @@ class ClaimDict(OrderedDict): @property def serialized(self): """Serialized Claim protobuf""" - if self.detached_signature and self.detached_signature.payload: + if self.detached_signature: return self.detached_signature.serialized return self.protobuf.SerializeToString() @@ -52,10 +52,9 @@ class ClaimDict(OrderedDict): @property def has_signature(self): - claim = self.protobuf - if claim.HasField("publisherSignature"): - return True - return self.detached_signature and self.detached_signature.certificate_id + return self.protobuf.HasField("publisherSignature") or ( + self.detached_signature and self.detached_signature.raw_signature + ) @property def is_certificate(self): @@ -94,11 +93,10 @@ class ClaimDict(OrderedDict): @property def certificate_id(self): + if self.protobuf.HasField("publisherSignature"): + return binascii.hexlify(self.protobuf.publisherSignature.certificateId) if self.detached_signature and self.detached_signature.certificate_id: return binascii.hexlify(self.detached_signature.certificate_id) - if not self.has_signature: - return None - return binascii.hexlify(self.protobuf.publisherSignature.certificateId) @property def signature(self): diff --git a/lbrynet/schema/signature.py b/lbrynet/schema/signature.py index 29a1408d7..104279821 100644 --- a/lbrynet/schema/signature.py +++ b/lbrynet/schema/signature.py @@ -1,5 +1,7 @@ from collections import namedtuple +from typing import Union + LEGACY = namedtuple('Legacy', 'payload') NAMED_SECP256K1 = namedtuple('NamedSECP256k1', 'raw_signature certificate_id payload') FLAGS = { @@ -9,8 +11,7 @@ FLAGS = { class Signature: - def __init__(self, data: namedtuple): - assert isinstance(data, (LEGACY, NAMED_SECP256K1)) + def __init__(self, data: Union[LEGACY, NAMED_SECP256K1]): self.data = data @property