feat: lnurl library update
follow up on https://github.com/lnbits/lnbits/pull/1864/files
This commit is contained in:
+1
-20
@@ -1,20 +1 @@
|
||||
from typing import Union
|
||||
|
||||
from bech32 import bech32_decode, bech32_encode, convertbits
|
||||
from fastapi.datastructures import URL
|
||||
|
||||
|
||||
def decode(lnurl: str) -> str:
|
||||
hrp, data = bech32_decode(lnurl)
|
||||
assert hrp
|
||||
assert data
|
||||
bech32_data = convertbits(data, 5, 8, False)
|
||||
assert bech32_data
|
||||
return bytes(bech32_data).decode()
|
||||
|
||||
|
||||
def encode(url: Union[str, URL]) -> str:
|
||||
bech32_data = convertbits(str(url).encode(), 8, 5, True)
|
||||
assert bech32_data
|
||||
lnurl = bech32_encode("lnurl", bech32_data)
|
||||
return lnurl.upper()
|
||||
from lnurl import LnurlErrorResponse, decode, encode, handle # noqa: F401
|
||||
|
||||
Reference in New Issue
Block a user