OSDN Git Service

Merge pull request #1829 from Bytom/dashboard
[bytom/bytom.git] / api / hsm.go
index 4237fff..9418483 100644 (file)
@@ -5,9 +5,8 @@ import (
 
        log "github.com/sirupsen/logrus"
 
-       "github.com/bytom/blockchain/pseudohsm"
-       "github.com/bytom/blockchain/txbuilder"
-       "github.com/bytom/crypto/ed25519/chainkd"
+       "github.com/bytom/bytom/blockchain/txbuilder"
+       "github.com/bytom/bytom/crypto/ed25519/chainkd"
 )
 
 type createKeyResp struct {
@@ -40,8 +39,14 @@ func (a *API) pseudohsmCreateKey(ctx context.Context, in struct {
        return NewSuccessResponse(&createKeyResp{Alias: xpub.Alias, XPub: xpub.XPub, File: xpub.File, Mnemonic: *mnemonic})
 }
 
-type importKeyResp struct {
-       Xpub *pseudohsm.XPub `json:"xpub"`
+func (a *API) pseudohsmUpdateKeyAlias(ctx context.Context, in struct {
+       XPub     chainkd.XPub `json:"xpub"`
+       NewAlias string       `json:"new_alias"`
+}) Response {
+       if err := a.wallet.Hsm.UpdateKeyAlias(in.XPub, in.NewAlias); err != nil {
+               return NewErrorResponse(err)
+       }
+       return NewSuccessResponse(nil)
 }
 
 func (a *API) pseudohsmListKeys(ctx context.Context) Response {