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 committed 2020-07-29 21:18:24 +03:00
1 parent a39c91fbcb
commit af01571fc6
4 files changed
+14 -9

No files matched your search

+4 -3
View File
@@ -101,9 +101,9 @@ var (
}
testMessageSigner = MessageSigner{
SignCompact: func(hash []byte) ([]byte, error) {
SignCompact: func(msg []byte) ([]byte, error) {
sig, err := btcec.SignCompact(btcec.S256(),
testPrivKey, hash, true)
testPrivKey, chainhash.HashB(msg), true)
if err != nil {
return nil, fmt.Errorf("can't sign the "+
"message: %v", err)
@@ -915,7 +915,8 @@ func TestInvoiceChecksumMalleability(t *testing.T) {
privKey, _ := btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes)
msgSigner := MessageSigner{
SignCompact: func(hash []byte) ([]byte, error) {
SignCompact: func(msg []byte) ([]byte, error) {
hash := chainhash.HashB(msg)
return btcec.SignCompact(btcec.S256(), privKey, hash, true)
},
}