lnaddr: rename LnAddr -> bolt11
The LnAddr, lndecode and lnencode naming didn't imply that it is bolt 11 specific, making it confusing to work with, now that there are also bolt 12 "lnaddr". Renaming it to *bolt11* creates a clear separation to bolt 12 things and reduces mental load. This commit is pure renaming (using the PyCharm IDE refactor function), except for the removal of the `object` inheritance of LnAddr/BOLT11Addr, this is Python 2 legacy.
This commit is contained in:
+5
-5
@@ -12,7 +12,7 @@ import aiohttp.client_exceptions
|
||||
|
||||
from electrum import segwit_addr, util
|
||||
from electrum.segwit_addr import bech32_decode, Encoding, convertbits, bech32_encode
|
||||
from electrum.lnaddr import LnDecodeException, LnEncodeException
|
||||
from electrum.bolt11 import BOLT11DecodeException, BOLT11EncodeException
|
||||
from electrum.network import Network
|
||||
from electrum.logging import get_logger
|
||||
from electrum.i18n import _
|
||||
@@ -47,11 +47,11 @@ def decode_lnurl(lnurl: str) -> str:
|
||||
hrp = decoded_bech32.hrp
|
||||
data = decoded_bech32.data
|
||||
if decoded_bech32.encoding is None:
|
||||
raise LnDecodeException("Bad bech32 checksum")
|
||||
raise BOLT11DecodeException("Bad bech32 checksum")
|
||||
if decoded_bech32.encoding != Encoding.BECH32:
|
||||
raise LnDecodeException("Bad bech32 encoding: must be using vanilla BECH32")
|
||||
raise BOLT11DecodeException("Bad bech32 encoding: must be using vanilla BECH32")
|
||||
if not hrp.startswith("lnurl"):
|
||||
raise LnDecodeException("Does not start with lnurl")
|
||||
raise BOLT11DecodeException("Does not start with lnurl")
|
||||
data = convertbits(data, 5, 8, False)
|
||||
url = bytes(data).decode("utf-8")
|
||||
return url
|
||||
@@ -62,7 +62,7 @@ def encode_lnurl(url: str) -> str:
|
||||
try:
|
||||
url = url.encode("utf-8")
|
||||
except UnicodeError as e:
|
||||
raise LnEncodeException("invalid url") from e
|
||||
raise BOLT11EncodeException("invalid url") from e
|
||||
bech32_data = convertbits(url, 8, 5, True)
|
||||
assert bech32_data
|
||||
lnurl = bech32_encode(
|
||||
|
||||
Reference in New Issue
Block a user