pass chainID through sign interfaces

This commit is contained in:
Ethan Buchman
2015-05-29 18:14:19 -04:00
parent 8a2d9525f0
commit 2045aee9cd
28 changed files with 122 additions and 110 deletions
+5 -5
View File
@@ -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))
}
//-----------------------------------------------------------------------------
+2 -2
View File
@@ -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 {