@@ -6,6 +6,7 @@ import time
|
||||
from hashlib import sha256
|
||||
from binascii import hexlify
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
|
||||
import bitstring
|
||||
|
||||
@@ -33,7 +34,7 @@ def shorten_amount(amount):
|
||||
break
|
||||
return str(amount) + unit
|
||||
|
||||
def unshorten_amount(amount):
|
||||
def unshorten_amount(amount) -> Decimal:
|
||||
""" Given a shortened amount, convert it into a decimal
|
||||
"""
|
||||
# BOLT #11:
|
||||
@@ -271,12 +272,20 @@ class LnAddr(object):
|
||||
self.signature = None
|
||||
self.pubkey = None
|
||||
self.currency = constants.net.SEGWIT_HRP if currency is None else currency
|
||||
self.amount = amount # in bitcoins
|
||||
self.amount = amount # type: Optional[Decimal] # in bitcoins
|
||||
self._min_final_cltv_expiry = 9
|
||||
|
||||
def get_amount_sat(self):
|
||||
def get_amount_sat(self) -> Optional[Decimal]:
|
||||
# note that this has msat resolution potentially
|
||||
if self.amount is None:
|
||||
return None
|
||||
return self.amount * COIN
|
||||
|
||||
def get_amount_msat(self) -> Optional[int]:
|
||||
if self.amount is None:
|
||||
return None
|
||||
return int(self.amount * COIN * 1000)
|
||||
|
||||
def __str__(self):
|
||||
return "LnAddr[{}, amount={}{} tags=[{}]]".format(
|
||||
hexlify(self.pubkey.serialize()).decode('utf-8') if self.pubkey else None,
|
||||
|
||||
Reference in New Issue
Block a user