fixes for chain id in nametx sign functions

This commit is contained in:
Ethan Buchman
2015-05-30 01:54:25 -04:00
parent 19bd3bb2e2
commit 6eb8386c7c
6 changed files with 26 additions and 24 deletions
+2 -2
View File
@@ -190,9 +190,9 @@ type NameTx struct {
Fee uint64 `json:"fee"`
}
func (tx *NameTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
func (tx *NameTx) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
// We hex encode the network name so we don't deal with escaping issues.
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, config.GetString("network"))), w, n, err)
binary.WriteTo([]byte(Fmt(`{"network":"%X"`, chainID)), w, n, err)
binary.WriteTo([]byte(Fmt(`,"tx":[%v,{"name":"%s","data":"%s"`, TxTypeName, tx.Name, tx.Data)), w, n, err)
binary.WriteTo([]byte(Fmt(`,"fee":%v,"input":`, tx.Fee)), w, n, err)
tx.Input.WriteSignBytes(w, n, err)
+2 -2
View File
@@ -127,9 +127,9 @@ func NewNameTxWithNonce(from account.PubKey, name, data string, amt, fee uint64,
}
}
func (tx *NameTx) Sign(privAccount *account.PrivAccount) {
func (tx *NameTx) Sign(chainID string, privAccount *account.PrivAccount) {
tx.Input.PubKey = privAccount.PubKey
tx.Input.Signature = privAccount.Sign(tx)
tx.Input.Signature = privAccount.Sign(chainID, tx)
}
//----------------------------------------------------------------------------