Let invoice.Encode receive a function which hashes itself the message

Modify the SignCompact function passed to invoice.Encode to receive the
message before it's hashed and hash it itself.
With this modification, the SignMessage rpc function from the signrpc
subserver can be used and an invoice can be encoded outside of lnd.
This commit is contained in:
Yaacov Akiba Slama
2020-06-28 16:51:42 +03:00
parent a39c91fbcb
commit af01571fc6
4 changed files with 14 additions and 9 deletions

View File

@@ -100,11 +100,11 @@ var (
// MessageSigner is passed to the Encode method to provide a signature
// corresponding to the node's pubkey.
type MessageSigner struct {
// SignCompact signs the passed hash with the node's privkey. The
// returned signature should be 65 bytes, where the last 64 are the
// SignCompact signs the hash of the passed msg with the node's privkey.
// The returned signature should be 65 bytes, where the last 64 are the
// compact signature, and the first one is a header byte. This is the
// format returned by btcec.SignCompact.
SignCompact func(hash []byte) ([]byte, error)
SignCompact func(msg []byte) ([]byte, error)
}
// Invoice represents a decoded invoice, or to-be-encoded invoice. Some of the