(c *gin.Context)
| 176 | } |
| 177 | |
| 178 | func downloadKeyPair(c *gin.Context) { |
| 179 | r := struct { |
| 180 | Account utils.AccountAddress `json:"account" form:"account" uri:"account" binding:"required,len=64"` |
| 181 | Password string `json:"password" form:"password"` |
| 182 | }{} |
| 183 | |
| 184 | _ = c.ShouldBindUri(&r) |
| 185 | |
| 186 | if err := c.ShouldBind(&r); err != nil { |
| 187 | abortWithError(c, http.StatusBadRequest, err) |
| 188 | return |
| 189 | } |
| 190 | |
| 191 | // check private key |
| 192 | developer := getDeveloperID(c) |
| 193 | |
| 194 | p, err := model.GetPrivateKey(model.GetDB(c), developer, r.Account) |
| 195 | if err != nil { |
| 196 | _ = c.Error(err) |
| 197 | abortWithError(c, http.StatusInternalServerError, ErrGetAccountFailed) |
| 198 | return |
| 199 | } |
| 200 | |
| 201 | privateKeyBytes, err := kms.EncodePrivateKey(p.Key, []byte(r.Password)) |
| 202 | if err != nil { |
| 203 | _ = c.Error(err) |
| 204 | abortWithError(c, http.StatusInternalServerError, ErrEncodePrivateKeyFailed) |
| 205 | return |
| 206 | } |
| 207 | |
| 208 | responseWithData(c, http.StatusOK, gin.H{ |
| 209 | "key": string(privateKeyBytes), |
| 210 | }) |
| 211 | } |
nothing calls this directly
no test coverage detected