From cf14c80f94331869ac7faedb092c2189d9ffbab2 Mon Sep 17 00:00:00 2001 From: Vladimir Evgrafov Date: Tue, 31 Jul 2018 17:48:20 +0300 Subject: [PATCH] MUL-1794: /account/get_by_key zero-length string array on empty response --- client/rest.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/client/rest.go b/client/rest.go index abbdcca5..ddd44633 100755 --- a/client/rest.go +++ b/client/rest.go @@ -2494,6 +2494,7 @@ func (server *RestClient) accountGetByKey(ctx *gin.Context) { }) return } + if key.PublicKey == "" { ctx.JSON(http.StatusBadRequest, gin.H{ "code": http.StatusBadRequest, @@ -2510,6 +2511,19 @@ func (server *RestClient) accountGetByKey(ctx *gin.Context) { }) return } + if accounts == nil { + server.log.Errorf("eos get_key_accounts: %s", err) + ctx.JSON(http.StatusInternalServerError, gin.H{ + "code": http.StatusInternalServerError, + "message": http.StatusText(http.StatusInternalServerError), + }) + return + } + + if accounts.AccountNames == nil { + accounts.AccountNames = make([]string, 0) + } + ctx.JSON(http.StatusOK, gin.H{ "code": http.StatusOK, "account_names": accounts.AccountNames,