walletrpc: add sign/verify methods
Adding the grpc functionality to sign and verify messages with single addresses
This commit is contained in:
9 files changed
+1735
-652
No files matched your search
@@ -1,10 +1,13 @@
|
||||
package walletrpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
)
|
||||
|
||||
@@ -74,3 +77,22 @@ func parseDerivationPath(path string) ([]uint32, error) {
|
||||
}
|
||||
return indices, nil
|
||||
}
|
||||
|
||||
// doubleHashMessage creates the double hash (sha256) of a message
|
||||
// prepended with a specified prefix.
|
||||
func doubleHashMessage(prefix string, msg string) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := wire.WriteVarString(&buf, 0, prefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = wire.WriteVarString(&buf, 0, msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
digest := chainhash.DoubleHashB(buf.Bytes())
|
||||
|
||||
return digest, nil
|
||||
}
|
||||
Reference in new issue
Block a user