diff --git a/crypto/keys/multisig/amino.go b/crypto/keys/multisig/amino.go index 4849a23173d2..b36c78cf51eb 100644 --- a/crypto/keys/multisig/amino.go +++ b/crypto/keys/multisig/amino.go @@ -78,7 +78,10 @@ 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 } diff --git a/crypto/keys/multisig/multisig_test.go b/crypto/keys/multisig/multisig_test.go index 1284c6c88476..35a5c26d2433 100644 --- a/crypto/keys/multisig/multisig_test.go +++ b/crypto/keys/multisig/multisig_test.go @@ -32,6 +32,7 @@ func TestEquals(t *testing.T) { multisigKey := kmultisig.NewLegacyAminoPubKey(1, []cryptotypes.PubKey{pubKey1, pubKey2}) otherMultisigKey := kmultisig.NewLegacyAminoPubKey(1, []cryptotypes.PubKey{pubKey1, multisigKey}) + testCases := []struct { msg string other cryptotypes.PubKey @@ -380,4 +381,5 @@ func TestAminoUnmarshalJSON(t *testing.T) { err := cdc.UnmarshalJSON([]byte(pkJSON), &pk) require.NoError(t, err) require.Equal(t, uint32(3), pk.(*kmultisig.LegacyAminoPubKey).Threshold) + require.Equal(t, 5, len(pk.(*kmultisig.LegacyAminoPubKey).PubKeys)) }