fix insertion bugs/incompatibilities with lastrowid stuff.

This commit is contained in:
fiatjaf
2021-08-11 22:19:27 -03:00
parent b7ed7fab59
commit 26b3599325
7 changed files with 64 additions and 25 deletions
+10 -1
View File
@@ -1,7 +1,16 @@
from bech32 import bech32_decode, convertbits
from bech32 import bech32_decode, bech32_encode, convertbits
def decode(lnurl: str) -> str:
hrp, data = bech32_decode(lnurl)
assert data
bech32_data = convertbits(data, 5, 8, False)
assert bech32_data
return bytes(bech32_data).decode("utf-8")
def encode(url: str) -> str:
bech32_data = convertbits(url.encode("utf-8"), 8, 5, True)
assert bech32_data
lnurl = bech32_encode("lnurl", bech32_data)
return lnurl.upper()