@@ -96,6 +96,7 @@ type Backend interface {
9696 SetAccountActive (accountCode accountsTypes.Code , active bool ) error
9797 SetTokenActive (accountCode accountsTypes.Code , tokenCode string , active bool ) error
9898 RenameAccount (accountCode accountsTypes.Code , name string ) error
99+ AccountSetWatch (accountCode accountsTypes.Code , watch bool ) error
99100 AOPP () backend.AOPP
100101 AOPPCancel ()
101102 AOPPApprove ()
@@ -202,6 +203,7 @@ func NewHandlers(
202203 getAPIRouterNoError (apiRouter )("/set-account-active" , handlers .postSetAccountActiveHandler ).Methods ("POST" )
203204 getAPIRouterNoError (apiRouter )("/set-token-active" , handlers .postSetTokenActiveHandler ).Methods ("POST" )
204205 getAPIRouterNoError (apiRouter )("/rename-account" , handlers .postRenameAccountHandler ).Methods ("POST" )
206+ getAPIRouterNoError (apiRouter )("/account-set-watch" , handlers .postAccountSetWatchHandler ).Methods ("POST" )
205207 getAPIRouterNoError (apiRouter )("/accounts/reinitialize" , handlers .postAccountsReinitializeHandler ).Methods ("POST" )
206208 getAPIRouter (apiRouter )("/account-summary" , handlers .getAccountSummary ).Methods ("GET" )
207209 getAPIRouterNoError (apiRouter )("/supported-coins" , handlers .getSupportedCoinsHandler ).Methods ("GET" )
@@ -346,6 +348,7 @@ type accountJSON struct {
346348 // keystore.
347349 Keystore config.Keystore `json:"keystore"`
348350 Active bool `json:"active"`
351+ Watch bool `json:"watch"`
349352 CoinCode coinpkg.Code `json:"coinCode"`
350353 CoinUnit string `json:"coinUnit"`
351354 CoinName string `json:"coinName"`
@@ -362,6 +365,7 @@ func newAccountJSON(keystore config.Keystore, account accounts.Interface, active
362365 return & accountJSON {
363366 Keystore : keystore ,
364367 Active : ! account .Config ().Config .Inactive ,
368+ Watch : account .Config ().Config .IsWatch (),
365369 CoinCode : account .Coin ().Code (),
366370 CoinUnit : account .Coin ().Unit (false ),
367371 CoinName : account .Coin ().Name (),
@@ -709,6 +713,26 @@ func (handlers *Handlers) postRenameAccountHandler(r *http.Request) interface{}
709713 return response {Success : true }
710714}
711715
716+ func (handlers * Handlers ) postAccountSetWatchHandler (r * http.Request ) interface {} {
717+ var jsonBody struct {
718+ AccountCode accountsTypes.Code `json:"accountCode"`
719+ Watch bool `json:"watch"`
720+ }
721+
722+ type response struct {
723+ Success bool `json:"success"`
724+ ErrorMessage string `json:"errorMessage,omitempty"`
725+ }
726+
727+ if err := json .NewDecoder (r .Body ).Decode (& jsonBody ); err != nil {
728+ return response {Success : false , ErrorMessage : err .Error ()}
729+ }
730+ if err := handlers .backend .AccountSetWatch (jsonBody .AccountCode , jsonBody .Watch ); err != nil {
731+ return response {Success : false , ErrorMessage : err .Error ()}
732+ }
733+ return response {Success : true }
734+ }
735+
712736func (handlers * Handlers ) postAccountsReinitializeHandler (_ * http.Request ) interface {} {
713737 handlers .backend .ReinitializeAccounts ()
714738 return nil
0 commit comments