From 7b29223e95c5c7ae36791f3ee832decf322b8277 Mon Sep 17 00:00:00 2001 From: Sat <792024+santyr@users.noreply.github.com> Date: Tue, 13 May 2025 03:47:08 -0600 Subject: [PATCH] feat: add verify_preimage utility function (#3153) --- lnbits/utils/crypto.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lnbits/utils/crypto.py b/lnbits/utils/crypto.py index 10bde8553..bfc4b35dd 100644 --- a/lnbits/utils/crypto.py +++ b/lnbits/utils/crypto.py @@ -23,6 +23,12 @@ def fake_privkey(secret: str) -> str: ).hex() +def verify_preimage(preimage: str, payment_hash: str) -> bool: + preimage_bytes = bytes.fromhex(preimage) + calculated_hash = sha256(preimage_bytes).hexdigest() + return calculated_hash == payment_hash + + class AESCipher: """This class is compatible with crypto-js/aes.js