Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
return payment_hash from invoicewithdescriptionhash
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Nov 2, 2020
1 parent 13d2485 commit df007e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion invoicewithdescriptionhash/cmd/Makefile
Original file line number Diff line number Diff line change
@@ -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}}"

Expand Down
4 changes: 4 additions & 0 deletions invoicewithdescriptionhash/method.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package invoicewithdescriptionhash

import (
"crypto/sha256"
"encoding/hex"
"errors"
"time"
Expand Down Expand Up @@ -32,6 +33,8 @@ var InvoiceWithDescriptionHashMethod = plugin.RPCMethod{
}
bpreimage, _ := hex.DecodeString(preimage)

rhash := sha256.Sum256(bpreimage)

descriptionHash, _ := hex.DecodeString(
params.Get("description_hash").String())

Expand All @@ -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
},
Expand Down

0 comments on commit df007e1

Please sign in to comment.