mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 22:24:23 +01:00
Changes to_self_delay restrictions to fit the nLockTime field
This commit is contained in:
@@ -60,10 +60,7 @@ class Inspector:
|
|||||||
appointment_data.get("end_time"), appointment_data.get("start_time"), block_height
|
appointment_data.get("end_time"), appointment_data.get("start_time"), block_height
|
||||||
)
|
)
|
||||||
if rcode == 0:
|
if rcode == 0:
|
||||||
rcode, message = self.check_to_self_delay(
|
rcode, message = self.check_to_self_delay(appointment_data.get("to_self_delay"))
|
||||||
appointment_data.get("to_self_delay"),
|
|
||||||
appointment_data.get("end_time") - appointment_data.get("start_time"),
|
|
||||||
)
|
|
||||||
if rcode == 0:
|
if rcode == 0:
|
||||||
rcode, message = self.check_blob(appointment_data.get("encrypted_blob"))
|
rcode, message = self.check_blob(appointment_data.get("encrypted_blob"))
|
||||||
# if rcode == 0:
|
# if rcode == 0:
|
||||||
@@ -242,7 +239,7 @@ class Inspector:
|
|||||||
|
|
||||||
return rcode, message
|
return rcode, message
|
||||||
|
|
||||||
def check_to_self_delay(self, to_self_delay, start_end_diff):
|
def check_to_self_delay(self, to_self_delay):
|
||||||
"""
|
"""
|
||||||
Checks if the provided ``to_self_delay`` is correct.
|
Checks if the provided ``to_self_delay`` is correct.
|
||||||
|
|
||||||
@@ -275,10 +272,10 @@ class Inspector:
|
|||||||
rcode = errors.APPOINTMENT_WRONG_FIELD_TYPE
|
rcode = errors.APPOINTMENT_WRONG_FIELD_TYPE
|
||||||
message = "wrong to_self_delay data type ({})".format(t)
|
message = "wrong to_self_delay data type ({})".format(t)
|
||||||
|
|
||||||
elif to_self_delay > start_end_diff:
|
elif to_self_delay > pow(2, 32):
|
||||||
rcode = errors.APPOINTMENT_FIELD_TOO_BIG
|
rcode = errors.APPOINTMENT_FIELD_TOO_BIG
|
||||||
message = "to_self_delay can't be bigger than the appointment time ({} > {})".format(
|
message = "to_self_delay must fit the transaction nLockTime field ({} > {})".format(
|
||||||
to_self_delay, start_end_diff
|
to_self_delay, pow(2, 32)
|
||||||
)
|
)
|
||||||
|
|
||||||
elif to_self_delay < self.config.get("MIN_TO_SELF_DELAY"):
|
elif to_self_delay < self.config.get("MIN_TO_SELF_DELAY"):
|
||||||
|
|||||||
Reference in New Issue
Block a user