Skip to content

Commit

Permalink
fix: unmarshalling issue with multisig keys in master (backport cosmo…
Browse files Browse the repository at this point in the history
…s#10061) (cosmos#10169)

* fix: unmarshalling issue with multisig keys in master (cosmos#10061)

(cherry picked from commit 3d3bc7c)

# Conflicts:
#	CHANGELOG.md

* fix conflicts

Co-authored-by: Henrik Aasted Sørensen <has@bitcraft.dk>
Co-authored-by: Robert Zaremba <robert@zaremba.ch>
  • Loading branch information
3 people authored Sep 16, 2021
1 parent 4831870 commit fcaff72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (x/genutil) [#10104](https://github.com/cosmos/cosmos-sdk/pull/10104) Ensure the `init` command reads the `--home` flag value correctly.
* [\#10061](https://github.com/cosmos/cosmos-sdk/pull/10061) Ensure that `LegacyAminoPubKey` struct correctly unmarshals from JSON

## [v0.44.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.0) - 2021-09-01

Expand Down
2 changes: 2 additions & 0 deletions crypto/keys/multisig/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func (m *LegacyAminoPubKey) UnmarshalAminoJSON(tmPk tmMultisig) error {
// Instead of just doing `*m = *protoPk`, we prefer to modify in-place the
// existing Anys inside `m` (instead of allocating new Anys), as so not to
// break the `.compat` fields in the existing Anys.
m.PubKeys = make([]*types.Any, len(protoPk.PubKeys))
for i := range m.PubKeys {
m.PubKeys[i] = &types.Any{}
m.PubKeys[i].TypeUrl = protoPk.PubKeys[i].TypeUrl
m.PubKeys[i].Value = protoPk.PubKeys[i].Value
}
Expand Down
8 changes: 8 additions & 0 deletions crypto/keys/multisig/multisig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,14 @@ func TestAminoUnmarshalJSON(t *testing.T) {
require.NoError(t, err)
lpk := pk.(*kmultisig.LegacyAminoPubKey)
require.Equal(t, uint32(3), lpk.Threshold)
require.Equal(t, 5, len(pk.(*kmultisig.LegacyAminoPubKey).PubKeys))

for _, key := range pk.(*kmultisig.LegacyAminoPubKey).PubKeys {
require.NotNil(t, key)
pk := secp256k1.PubKey{}
err := pk.Unmarshal(key.Value)
require.NoError(t, err)
}
}

func TestProtoMarshalJSON(t *testing.T) {
Expand Down

0 comments on commit fcaff72

Please sign in to comment.