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:
1 parent
a39c91fbcb
commit
af01571fc6
4 files changed
+14
-9
No files matched your search
+2
-2
@@ -70,12 +70,11 @@ func (invoice *Invoice) Encode(signer MessageSigner) (string, error) {
|
||||
}
|
||||
|
||||
toSign := append([]byte(hrp), taggedFieldsBytes...)
|
||||
hash := chainhash.HashB(toSign)
|
||||
|
||||
// We use compact signature format, and also encoded the recovery ID
|
||||
// such that a reader of the invoice can recover our pubkey from the
|
||||
// signature.
|
||||
sign, err := signer.SignCompact(hash)
|
||||
sign, err := signer.SignCompact(toSign)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -95,6 +94,7 @@ func (invoice *Invoice) Encode(signer MessageSigner) (string, error) {
|
||||
"signature: %v", err)
|
||||
}
|
||||
|
||||
hash := chainhash.HashB(toSign)
|
||||
valid := signature.Verify(hash, invoice.Destination)
|
||||
if !valid {
|
||||
return "", fmt.Errorf("signature does not match " +
|
||||
|
||||
Reference in new issue
Block a user