mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 06:54:41 +00:00
pass chainID through sign interfaces
This commit is contained in:
+5
-5
@@ -12,13 +12,13 @@ import (
|
||||
// Signable is an interface for all signable things.
|
||||
// It typically removes signatures before serializing.
|
||||
type Signable interface {
|
||||
WriteSignBytes(w io.Writer, n *int64, err *error)
|
||||
WriteSignBytes(chainID string, w io.Writer, n *int64, err *error)
|
||||
}
|
||||
|
||||
// SignBytes is a convenience method for getting the bytes to sign of a Signable.
|
||||
func SignBytes(o Signable) []byte {
|
||||
func SignBytes(chainID string, o Signable) []byte {
|
||||
buf, n, err := new(bytes.Buffer), new(int64), new(error)
|
||||
o.WriteSignBytes(buf, n, err)
|
||||
o.WriteSignBytes(chainID, buf, n, err)
|
||||
if *err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -26,8 +26,8 @@ func SignBytes(o Signable) []byte {
|
||||
}
|
||||
|
||||
// HashSignBytes is a convenience method for getting the hash of the bytes of a signable
|
||||
func HashSignBytes(o Signable) []byte {
|
||||
return merkle.HashFromBinary(SignBytes(o))
|
||||
func HashSignBytes(chainID string, o Signable) []byte {
|
||||
return merkle.HashFromBinary(SignBytes(chainID, o))
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -52,8 +52,8 @@ func GenPrivAccountFromKey(privKeyBytes [64]byte) *PrivAccount {
|
||||
}
|
||||
}
|
||||
|
||||
func (privAccount *PrivAccount) Sign(o Signable) Signature {
|
||||
return privAccount.PrivKey.Sign(SignBytes(o))
|
||||
func (privAccount *PrivAccount) Sign(chainID string, o Signable) Signature {
|
||||
return privAccount.PrivKey.Sign(SignBytes(chainID, o))
|
||||
}
|
||||
|
||||
func (privAccount *PrivAccount) String() string {
|
||||
|
||||
Reference in New Issue
Block a user