mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-05 23:57:04 +00:00
pass chainID through sign interfaces
This commit is contained in:
@@ -38,9 +38,9 @@ func (p *Proposal) String() string {
|
||||
p.BlockParts, p.POLParts, p.Signature)
|
||||
}
|
||||
|
||||
func (p *Proposal) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
func (p *Proposal) WriteSignBytes(chainID string, w io.Writer, n *int64, err *error) {
|
||||
// We hex encode the chain_id name so we don't deal with escaping issues.
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, config.GetString("chain_id"))), w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`{"chain_id":"%X"`, chainID)), w, n, err)
|
||||
binary.WriteTo([]byte(`,"proposal":{"block_parts":`), w, n, err)
|
||||
p.BlockParts.WriteSignBytes(w, n, err)
|
||||
binary.WriteTo([]byte(Fmt(`,"height":%v,"pol_parts":`, p.Height)), w, n, err)
|
||||
|
||||
@@ -17,7 +17,7 @@ func TestProposalSignable(t *testing.T) {
|
||||
POLParts: types.PartSetHeader{222, []byte("polparts")},
|
||||
Signature: nil,
|
||||
}
|
||||
signBytes := account.SignBytes(proposal)
|
||||
signBytes := account.SignBytes(config.GetString("chain_id"), proposal)
|
||||
signStr := string(signBytes)
|
||||
expected := Fmt(`{"chain_id":"%X","proposal":{"block_parts":{"hash":"626C6F636B7061727473","total":111},"height":12345,"pol_parts":{"hash":"706F6C7061727473","total":222},"round":23456}}`,
|
||||
config.GetString("chain_id"))
|
||||
|
||||
Reference in New Issue
Block a user