Files
nutshell/cashu/core/htlc.py
callebtc 48f732e9e7 Refactor secret conditions (#350)
* refactor spending conditions and add comments

* fix kind enum deserialization
2023-10-21 16:51:12 +02:00

18 lines
617 B
Python

from typing import Union
from .secret import Secret, SecretKind
class HTLCSecret(Secret):
@classmethod
def from_secret(cls, secret: Secret):
assert SecretKind(secret.kind) == SecretKind.HTLC, "Secret is not a HTLC secret"
# NOTE: exclude tags in .dict() because it doesn't deserialize it properly
# need to add it back in manually with tags=secret.tags
return cls(**secret.dict(exclude={"tags"}), tags=secret.tags)
@property
def locktime(self) -> Union[None, int]:
locktime = self.tags.get_tag("locktime")
return int(locktime) if locktime else None