Skip to content

Commit

Permalink
added more properties for tbk
Browse files Browse the repository at this point in the history
  • Loading branch information
dni committed Oct 10, 2023
1 parent fa3dd6c commit d446882
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bolt11/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
from .models.features import Features
from .models.routehint import RouteHint
from .models.signature import Signature
from .models.tags import (
Tag, # noqa: F401, F403
TagChar,
Tags,
)
from .models.tags import TagChar, Tags


class MilliSatoshi(int):
Expand Down Expand Up @@ -98,8 +94,13 @@ def metadata(self) -> Optional[str]:
tag = self.tags.get(TagChar.metadata)
return tag.data if tag else None

# backwards compatibility
@property
def dt(self) -> datetime:
return self.date_time

@property
def date_time(self) -> datetime:
return datetime.fromtimestamp(self.date)

@property
Expand All @@ -113,6 +114,12 @@ def expiry_date(self) -> Optional[datetime]:
return None
return datetime.fromtimestamp(self.date + self.expiry)

@property
def expiry_time(self) -> Optional[int]:
if not self.expiry:
return None
return self.date + self.expiry

@property
def features(self) -> Optional[Features]:
tag = self.tags.get(TagChar.features)
Expand Down

0 comments on commit d446882

Please sign in to comment.