6 "github.com/bytom/blockchain/account"
7 "github.com/bytom/crypto/ed25519/chainkd"
9 log "github.com/sirupsen/logrus"
12 // POST /create-account
13 func (bcr *BlockchainReactor) createAccount(ctx context.Context, ins struct {
14 RootXPubs []chainkd.XPub `json:"root_xpubs"`
15 Quorum int `json:"quorum"`
16 Alias string `json:"alias"`
17 Tags map[string]interface{} `json:"tags"`
19 acc, err := bcr.accounts.Create(ctx, ins.RootXPubs, ins.Quorum, ins.Alias, ins.Tags)
21 return NewErrorResponse(err)
24 annotatedAccount, err := account.Annotated(acc)
26 return NewErrorResponse(err)
29 log.WithField("account ID", annotatedAccount.ID).Info("Created account")
31 return NewSuccessResponse(annotatedAccount)
34 // POST /update-account-tags
35 func (bcr *BlockchainReactor) updateAccountTags(ctx context.Context, updateTag struct {
36 AccountInfo string `json:"account_info"`
37 Tags map[string]interface{} `json:"tags"`
40 err := bcr.accounts.UpdateTags(nil, updateTag.AccountInfo, updateTag.Tags)
42 return NewErrorResponse(err)
45 return NewSuccessResponse(nil)
49 // POST /delete-account
50 func (bcr *BlockchainReactor) deleteAccount(ctx context.Context, in struct {
51 AccountInfo string `json:"account_info"`
53 if err := bcr.accounts.DeleteAccount(in); err != nil {
54 return NewErrorResponse(err)
56 return NewSuccessResponse(nil)