diff --git a/cryptoconditions/types/preimage.py b/cryptoconditions/types/preimage.py index b5b568b..956bb48 100644 --- a/cryptoconditions/types/preimage.py +++ b/cryptoconditions/types/preimage.py @@ -15,7 +15,7 @@ class PreimageSha256(BaseSha256): TYPE_ASN1_FULFILLMENT = 'preimageSha256Fulfillment' TYPE_CATEGORY = 'simple' - def __init__(self, preimage=None, asn1=None): + def __init__(self, preimage=None): """ PREIMAGE-SHA-256: Hashlock condition using SHA-256. @@ -43,62 +43,6 @@ def __init__(self, preimage=None, asn1=None): if preimage and (not isinstance(preimage, bytes)): raise TypeError('Preimage must be bytes, was: {}'.format(preimage)) self.preimage = preimage - self.asn1 = asn1 - - @property - def bitmask(self): - return self.FEATURE_BITMASK - - #def write_hash_payload(self, hasher): - # """ - # Generate the contents of the condition hash. - - # Writes the contents of the condition hash to a Hasher. Used internally by `getCondition`. - - # HASH = SHA256(PREIMAGE) - - # Args: - # hasher (Hasher): Destination where the hash payload will be written. - # """ - # if not isinstance(hasher, Hasher): - # raise TypeError('hasher must be a Hasher instance') - # if self.preimage is None: - # raise ValueError('Could not calculate hash, no preimage provided') - # hasher.write(self.preimage) - - #def parse_payload(self, reader, payload_size): - # """ - # Parse the payload of a SHA256 hashlock fulfillment. - - # Read a fulfillment payload from a Reader and populate this object with that fulfillment. - - # FULFILLMENT_PAYLOAD = - # VARBYTES PREIMAGE - - # Args: - # reader (Reader): Source to read the fulfillment payload from. - # payload_size (int): Total size of the fulfillment payload. - # """ - # if not isinstance(reader, Reader): - # raise TypeError('reader must be a Reader instance') - # self.preimage = reader.read(payload_size) - - #def write_payload(self, writer): - # """ - # Generate the fulfillment payload. - - # This writes the fulfillment payload to a Writer. - - # Args: - # writer (Writer): Subject for writing the fulfillment payload. - # """ - # if not isinstance(writer, (Writer, Predictor)): - # raise TypeError('writer must be a Writer instance') - # if self.preimage is None: - # raise ValueError('Preimage must be specified') - - # writer.write(self.preimage) - # return writer def to_dict(self): """ @@ -110,7 +54,6 @@ def to_dict(self): return { 'type': 'fulfillment', 'type_id': self.TYPE_ID, - 'bitmask': self.bitmask, 'preimage': self.preimage.decode() } @@ -124,8 +67,8 @@ def to_asn1_dict(self): @property def fingerprint_contents(self): if self.preimage is None: - # TODO MissingDataError('Could not calculate hash, no preimage provided') - raise Exception('Could not calculate hash, no preimage provided') + raise MissingDataError( + 'Could not calculate hash, no preimage provided') return self.preimage def parse_json(self, data):