Пример #1
0
 def condition(self, value):
     if value == None:
         self._condition = ConditionNil()
         return
     if not isinstance(value, ConditionBaseClass):
         raise TypeError(
             "cannot assign value of type {} as a BlockstakeOutput's condition (expected: ConditionBaseClass subtype)".format(type(value)))
     self._condition = value
Пример #2
0
 def parent_mint_condition(self):
     """
     Retrieve the parent mint condition which will be set
     """
     if self._parent_mint_condition is None:
         return ConditionNil()
     return self._parent_mint_condition
Пример #3
0
 def mint_condition(self):
     """
     Retrieve the new mint condition which will be set
     """
     if self._mint_condition == None:
         return ConditionNil()
     return self._mint_condition
Пример #4
0
class BlockstakeOutput(BaseDataTypeClass):
    """
    BlockstakeOutput class
    """

    def __init__(self, value=None, condition=None, id=None):
        self._value = None
        self.value = value
        self._condition = None
        self.condition = condition
        # property that can be set if known, but which is not part of the actual BlockstakeOutput
        self._id = None
        self.id = id

    @classmethod
    def from_json(cls, obj):
        return cls(
            value=Blockstake.from_json(obj['value']),
            condition=ConditionTypes.from_json(obj['condition']))

    @property
    def value(self):
        return self._value

    @value.setter
    def value(self, value):
        if isinstance(value, Blockstake):
            self._value = value
            return
        self._value = Blockstake(value=value)

    @property
    def condition(self):
        return self._condition

    @condition.setter
    def condition(self, value):
        if value == None:
            self._condition = ConditionNil()
            return
        if not isinstance(value, ConditionBaseClass):
            raise TypeError(
                "cannot assign value of type {} as a BlockstakeOutput's condition (expected: ConditionBaseClass subtype)".format(type(value)))
        self._condition = value

    @property
    def id(self):
        return self._id

    @id.setter
    def id(self, value):
        if isinstance(value, Hash):
            self._id = Hash(value=value.value)
            return
        self._id = Hash(value=value)

    def json(self):
        return {
            'value': self._value.json(),
            'condition': self._condition.json()
        }

    def sia_binary_encode(self, encoder):
        """
        Encode this BlockstakeOutput according to the Sia Binary Encoding format.
        """
        encoder.add_all(self._value, self._condition)

    def rivine_binary_encode(self, encoder):
        """
        Encode this BlockstakeOutput according to the Rivine Binary Encoding format.
        """
        encoder.add_all(self._value, self._condition)
Пример #5
0
 def condition(self):
     if self._owners == None:
         return ConditionNil()
     return ConditionMultiSignature(unlockhashes=self._owners,
                                    min_nr_sig=self._signature_count)