From 10a655b6b110cf5a00916080b993cd3bb33e2376 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Sun, 10 Feb 2019 20:38:36 +0100 Subject: [PATCH] lntypes: add preimage Matches method --- lntypes/preimage.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lntypes/preimage.go b/lntypes/preimage.go index f73d21111..d8b70ab98 100644 --- a/lntypes/preimage.go +++ b/lntypes/preimage.go @@ -53,3 +53,8 @@ func MakePreimageFromStr(newPreimage string) (Preimage, error) { func (p *Preimage) Hash() Hash { return Hash(sha256.Sum256(p[:])) } + +// Matches returns whether this preimage is the preimage of the given hash. +func (p *Preimage) Matches(h Hash) bool { + return h == p.Hash() +}