mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-24 03:54:21 +01:00
* add htlc files * refactor mint into several components * add hash lock signatures * add refund signature checks * simplify hash lock signature check * clean up
18 lines
605 B
Python
18 lines
605 B
Python
from typing import Union
|
|
|
|
from .secret import Secret, SecretKind
|
|
|
|
|
|
class HTLCSecret(Secret):
|
|
@classmethod
|
|
def from_secret(cls, secret: Secret):
|
|
assert 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
|