added Stepans fix

This commit is contained in:
benarc 2021-12-15 14:47:45 +00:00
parent b968a0c13f
commit 4f6e49b02f

View File

@ -83,9 +83,12 @@ async def handle_lnurl_firstrequest(
"reason": f"Invalid hex or base64 payload: {payload}", "reason": f"Invalid hex or base64 payload: {payload}",
} }
h = hashlib.sha256(nonceb) if len(payloadb)!=8:
h.update(pos.key.encode()) raise RuntimeError("Expected 8 bytes")
s = h.digest() expected = hmac.new(pos.key.encode(), payloadb[:-2], digestmod="sha256").digest()
if expected[:2] != payloadb[-2:]:
raise RuntimeError("Invalid HMAC")
s = hmac.new(pos.key.encode(), nonceb, digestmod="sha256").digest()
res = bytearray(payloadb) res = bytearray(payloadb)
for i in range(len(res)): for i in range(len(res)):