Last active
February 14, 2022 18:02
-
-
Save vindard/12e4af7819a3e38aef07cea4a511c4e1 to your computer and use it in GitHub Desktop.
Convert a Lightning Network preimage to its payment hash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createHash } from "crypto" | |
const hashFromPreImage = (preImage) => { | |
const preImageBuf = Buffer.from(preImage, "hex") | |
const sha256 = (buffer: Buffer) => createHash("sha256").update(buffer).digest("hex") | |
return sha256(preImageBuf) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment