MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / downloadKeyPair

Function downloadKeyPair

cmd/cql-proxy/api/keypair.go:178–211  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

176}
177
178func 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}

Callers

nothing calls this directly

Calls 7

GetPrivateKeyFunction · 0.92
GetDBFunction · 0.92
EncodePrivateKeyFunction · 0.92
abortWithErrorFunction · 0.85
getDeveloperIDFunction · 0.85
responseWithDataFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected