mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
Removes start/end time from appointment
This commit is contained in:
@@ -9,18 +9,14 @@ class Appointment:
|
||||
Args:
|
||||
locator (:obj:`str`): A 16-byte hex-encoded value used by the tower to detect channel breaches. It serves as a
|
||||
trigger for the tower to decrypt and broadcast the penalty transaction.
|
||||
start_time (:obj:`int`): The block height where the tower is hired to start watching for breaches.
|
||||
end_time (:obj:`int`): The block height where the tower will stop watching for breaches.
|
||||
to_self_delay (:obj:`int`): The ``to_self_delay`` encoded in the ``csv`` of the ``to_remote`` output of the
|
||||
commitment transaction that this appointment is covering.
|
||||
encrypted_blob (:obj:`str`): An encrypted blob of data containing a penalty transaction. The tower will decrypt
|
||||
it and broadcast the penalty transaction upon seeing a breach on the blockchain.
|
||||
"""
|
||||
|
||||
def __init__(self, locator, start_time, end_time, to_self_delay, encrypted_blob):
|
||||
def __init__(self, locator, to_self_delay, encrypted_blob):
|
||||
self.locator = locator
|
||||
self.start_time = start_time # ToDo: #4-standardize-appointment-fields
|
||||
self.end_time = end_time # ToDo: #4-standardize-appointment-fields
|
||||
self.to_self_delay = to_self_delay
|
||||
self.encrypted_blob = encrypted_blob
|
||||
|
||||
@@ -33,7 +29,7 @@ class Appointment:
|
||||
|
||||
Args:
|
||||
appointment_data (:obj:`dict`): a dictionary containing the following keys:
|
||||
``{locator, start_time, end_time, to_self_delay, encrypted_blob}``
|
||||
``{locator, to_self_delay, encrypted_blob}``
|
||||
|
||||
Returns:
|
||||
:obj:`Appointment <teos.appointment.Appointment>`: An appointment initialized using the provided data.
|
||||
@@ -43,16 +39,14 @@ class Appointment:
|
||||
"""
|
||||
|
||||
locator = appointment_data.get("locator")
|
||||
start_time = appointment_data.get("start_time") # ToDo: #4-standardize-appointment-fields
|
||||
end_time = appointment_data.get("end_time") # ToDo: #4-standardize-appointment-fields
|
||||
to_self_delay = appointment_data.get("to_self_delay")
|
||||
encrypted_blob_data = appointment_data.get("encrypted_blob")
|
||||
|
||||
if any(v is None for v in [locator, start_time, end_time, to_self_delay, encrypted_blob_data]):
|
||||
if any(v is None for v in [locator, to_self_delay, encrypted_blob_data]):
|
||||
raise ValueError("Wrong appointment data, some fields are missing")
|
||||
|
||||
else:
|
||||
appointment = cls(locator, start_time, end_time, to_self_delay, encrypted_blob_data)
|
||||
appointment = cls(locator, to_self_delay, encrypted_blob_data)
|
||||
|
||||
return appointment
|
||||
|
||||
@@ -67,8 +61,6 @@ class Appointment:
|
||||
# ToDO: #3-improve-appointment-structure
|
||||
appointment = {
|
||||
"locator": self.locator,
|
||||
"start_time": self.start_time,
|
||||
"end_time": self.end_time,
|
||||
"to_self_delay": self.to_self_delay,
|
||||
"encrypted_blob": self.encrypted_blob,
|
||||
}
|
||||
@@ -80,17 +72,11 @@ class Appointment:
|
||||
Serializes an appointment to be signed.
|
||||
|
||||
The serialization follows the same ordering as the fields in the appointment:
|
||||
locator:start_time:end_time:to_self_delay:encrypted_blob
|
||||
locator:to_self_delay:encrypted_blob
|
||||
|
||||
All values are big endian.
|
||||
|
||||
Returns:
|
||||
:obj:`bytes`: The serialized data to be signed.
|
||||
"""
|
||||
return (
|
||||
unhexlify(self.locator)
|
||||
+ struct.pack(">I", self.start_time)
|
||||
+ struct.pack(">I", self.end_time)
|
||||
+ struct.pack(">I", self.to_self_delay)
|
||||
+ unhexlify(self.encrypted_blob)
|
||||
)
|
||||
return unhexlify(self.locator) + struct.pack(">I", self.to_self_delay) + unhexlify(self.encrypted_blob)
|
||||
|
||||
Reference in New Issue
Block a user