1
0

lnaddr: fix decoding of min_final_cltv_expiry

Previously we failed to decode min_final_cltv_expiry properly if the highest bit was 1:
in practice, we could not pay invoices that had a value in [16-31] or [512-1023].
Many invoices use a value around 144, so this was simply unnoticed.

also update default value to follow BOLT change:
c5693d336d
This commit is contained in:
SomberNight
2020-11-24 23:42:29 +01:00
parent 1bf8d2ea56
commit 18066c72a0
2 changed files with 13 additions and 8 deletions

View File

@@ -273,7 +273,7 @@ class LnAddr(object):
self.pubkey = None
self.currency = constants.net.SEGWIT_HRP if currency is None else currency
self.amount = amount # type: Optional[Decimal] # in bitcoins
self._min_final_cltv_expiry = 9
self._min_final_cltv_expiry = 18
def get_amount_sat(self) -> Optional[Decimal]:
# note that this has msat resolution potentially
@@ -393,9 +393,9 @@ def lndecode(invoice: str, *, verbose=False, expected_hrp=None) -> LnAddr:
while s.pos + 264 + 64 + 32 + 32 + 16 < s.len:
route.append((s.read(264).tobytes(),
s.read(64).tobytes(),
s.read(32).intbe,
s.read(32).intbe,
s.read(16).intbe))
s.read(32).uintbe,
s.read(32).uintbe,
s.read(16).uintbe))
addr.tags.append(('r',route))
elif tag == 'f':
fallback = parse_fallback(tagdata, addr.currency)
@@ -438,7 +438,7 @@ def lndecode(invoice: str, *, verbose=False, expected_hrp=None) -> LnAddr:
addr.pubkey = pubkeybytes
elif tag == 'c':
addr._min_final_cltv_expiry = tagdata.int
addr._min_final_cltv_expiry = tagdata.uint
elif tag == '9':
features = tagdata.uint