From df007e134fc15454f8ed03a621d50906ff4d9c2e Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 2 Nov 2020 20:44:43 -0300 Subject: [PATCH] return payment_hash from invoicewithdescriptionhash --- invoicewithdescriptionhash/cmd/Makefile | 2 +- invoicewithdescriptionhash/method.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/invoicewithdescriptionhash/cmd/Makefile b/invoicewithdescriptionhash/cmd/Makefile index 18e8666..2256e5b 100644 --- a/invoicewithdescriptionhash/cmd/Makefile +++ b/invoicewithdescriptionhash/cmd/Makefile @@ -1,4 +1,4 @@ -dist: $(shell find . -name "*.go") +dist: $(shell find .. -name "*.go") mkdir -p dist gox -ldflags="-s -w" -osarch="darwin/amd64 linux/386 linux/amd64 linux/arm freebsd/amd64" -output="dist/invoicewithdescriptionhash_{{.OS}}_{{.Arch}}" diff --git a/invoicewithdescriptionhash/method.go b/invoicewithdescriptionhash/method.go index f579aba..e23907c 100644 --- a/invoicewithdescriptionhash/method.go +++ b/invoicewithdescriptionhash/method.go @@ -1,6 +1,7 @@ package invoicewithdescriptionhash import ( + "crypto/sha256" "encoding/hex" "errors" "time" @@ -32,6 +33,8 @@ var InvoiceWithDescriptionHashMethod = plugin.RPCMethod{ } bpreimage, _ := hex.DecodeString(preimage) + rhash := sha256.Sum256(bpreimage) + descriptionHash, _ := hex.DecodeString( params.Get("description_hash").String()) @@ -55,6 +58,7 @@ var InvoiceWithDescriptionHashMethod = plugin.RPCMethod{ "bolt11": newinv, "description_hash": hex.EncodeToString(descriptionHash), "preimage": preimage, + "payment_hash": hex.EncodeToString(rhash[:]), "expires_at": time.Now().Add(dexpiry).Unix(), }, 0, nil },