diff --git a/lntypes/preimage.go b/lntypes/preimage.go index f73d2111..d8b70ab9 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() +}