From 9f975ed65aaf3cc0115d3af13c15b7b547e5a9a2 Mon Sep 17 00:00:00 2001 From: MPins Date: Sun, 3 Aug 2025 21:36:18 -0700 Subject: [PATCH] lnaddr: use a raw string (r"\d") to don't interpret backslashes --- lnaddr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lnaddr.py b/lnaddr.py index 2d88a87..f825aac 100755 --- a/lnaddr.py +++ b/lnaddr.py @@ -51,7 +51,7 @@ def unshorten_amount(amount): # BOLT #11: # A reader SHOULD fail if `amount` contains a non-digit, or is followed by # anything except a `multiplier` in the table above. - if not re.fullmatch("\d+[pnum]?", str(amount)): + if not re.fullmatch(r"\d+[pnum]?", str(amount)): raise ValueError("Invalid amount '{}'".format(amount)) if unit in units.keys(): @@ -270,7 +270,7 @@ def lndecode(a, verbose=False): addr = LnAddr() addr.pubkey = None - m = re.search("[^\d]+", hrp[2:]) + m = re.search(r"[^\d]+", hrp[2:]) if m: addr.currency = m.group(0) amountstr = hrp[2+m.end():]