// GetAccount returns the accounts for an id
559178
func GetAccount(w rest.ResponseWriter, r *rest.Request) {
	id := r.PathParam("id")
	doc, err := api.GetAccount(variables.ServiceDBURL, r.Env["JWT_RAW"].(string), id)
	if err != nil {
		rest.Error(w, err.Error(), http.StatusNotFound)
		return
	}
	if doc == nil {
		w.(http.ResponseWriter).Write(variables.BlankResponse)
		return
	}
	w.WriteJson(doc)
}
430096
func (c *Client) EnableAccount(p *EnableAccountParameter) (*Account, error) {
	obj, err := c.Request("enableAccount", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Account), err
}
1021069
func (s *PrivateAccountAPI) NewAccount(password string) (common.Address, error) {
	acc, err := fetchKeystore(s.am).NewAccount(password)
	if err == nil {
		return acc.Address, nil
	}
	return common.Address{}, err
}
1013854
func (api *API) GetAccountData(seed Trytes, options GetAccountDataOptions) (*AccountData, error) {
	options = getAccountDAtaDefaultOptions(options)
	if err := Validate(ValidateSeed(seed), ValidateSecurityLevel(options.Security),
		ValidateStartEndOptions(options.Start, options.End)); err != nil {
		return nil, err
	}

	var total *uint64
	if options.End != nil {
		t := *options.End - options.Start
		total = &t
	}

	addresses, err := api.GetNewAddress(seed, GetNewAddressOptions{
		Index: options.Start, Total: total,
		ReturnAll: true, Security: options.Security,
	})
	if err != nil {
		return nil, err
	}

	var err1, err2, err3 error
	var bundles bundle.Bundles
	var balances *Balances
	var spentState []bool

	wg := sync.WaitGroup{}
	wg.Add(3)
	go func() {
		defer wg.Done()
		bundles, err1 = api.GetBundlesFromAddresses(addresses, true)
	}()

	go func() {
		defer wg.Done()
		balances, err2 = api.GetBalances(addresses, 100)
	}()

	go func() {
		defer wg.Done()
		spentState, err3 = api.WereAddressesSpentFrom(addresses...)
	}()

	wg.Wait()
	if err := firstNonNilErr(err1, err2, err3); err != nil {
		return nil, err
	}

	// extract tx hashes which operated on the account's addresses
	// as input or output tx
	var txsHashes Hashes
	for i := range bundles {
		bndl := &bundles[i]
		for j := range *bndl {
			tx := &(*bndl)[j]
			for x := range addresses {
				if tx.Address == addresses[x] {
					txsHashes = append(txsHashes, tx.Hash)
					break
				}
			}
		}
	}

	// compute balances
	inputs := []Input{}
	var totalBalance uint64
	for i := range addresses {
		value := balances.Balances[i]
		// this works because the balances and spent states are ordered
		if spentState[i] || value <= 0 {
			continue
		}
		totalBalance += value

		addr := Input{
			Address: addresses[i], Security: options.Security,
			KeyIndex: options.Start + uint64(i), Balance: value,
		}
		inputs = append(inputs, addr)
	}

	account := &AccountData{
		Transfers:     bundles,
		Transactions:  txsHashes,
		Inputs:        inputs,
		Balance:       totalBalance,
		LatestAddress: addresses[len(addresses)-1],
		Addresses:     addresses,
	}

	return account, nil
}
988840
func (m *MarketplacePlan) GetAccountsURL() string {
	if m == nil || m.AccountsURL == nil {
		return ""
	}
	return *m.AccountsURL
}
1275314
func (s *Server) fetchAccount(name string) (*Account, error) {
	if accClaims, claimJWT, err := s.fetchAccountClaims(name); accClaims != nil {
		// We have released the lock during the low level fetch.
		// Now that we are back under lock, check again if account
		// is in the map or not. If it is, simply return it.
		if v, ok := s.accounts.Load(name); ok {
			acc := v.(*Account)
			// Update with the new claims in case they are new.
			// Following call will return ErrAccountResolverSameClaims
			// if claims are the same.
			err = s.updateAccountWithClaimJWT(acc, claimJWT)
			if err != nil && err != ErrAccountResolverSameClaims {
				return nil, err
			}
			return acc, nil
		}
		acc := s.buildInternalAccount(accClaims)
		acc.claimJWT = claimJWT
		s.registerAccount(acc)
		return acc, nil
	} else {
		return nil, err
	}
}
112560
func (c *Client) GetAuth(accessToken string) (resp GetAuthResponse, err error) {
	options := GetAuthOptions{
		AccountIDs: []string{},
	}
	return c.GetAuthWithOptions(accessToken, options)
}
1366825
func (c *ApiController) GetAccountToken() {
	result := tkn.AccessToken
	c.Ctx.WriteString(result)
}
1102947
func (c *Client) GetAccountAddress(account string) (btcutil.Address, error) {
	return c.GetAccountAddressAsync(account).Receive()
}
632868
func (c *Users) GetAccount(in *GetAccountInput) (out *GetAccountOutput, err error) {
	body, err := c.call("/users/get_account", in)
	if err != nil {
		return
	}
	defer body.Close()

	err = json.NewDecoder(body).Decode(&out)
	return
}
250004
func (s *AccountService) DisableAccount(p *DisableAccountParams) (*DisableAccountResponse, error) {
	resp, err := s.cs.newRequest("disableAccount", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r DisableAccountResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &r); err != nil {
			return nil, err
		}
	}

	return &r, nil
}
928478
func fetchAccountByName(ns walletdb.ReadBucket, scope *KeyScope,
	name string) (uint32, error) {

	scopedBucket, err := fetchReadScopeBucket(ns, scope)
	if err != nil {
		return 0, err
	}

	idxBucket := scopedBucket.NestedReadBucket(acctNameIdxBucketName)

	val := idxBucket.Get(stringToBytes(name))
	if val == nil {
		str := fmt.Sprintf("account name '%s' not found", name)
		return 0, managerError(ErrAccountNotFound, str, nil)
	}

	return binary.LittleEndian.Uint32(val), nil
}
590101
func AccountsGet(c web.C, w http.ResponseWriter, r *http.Request) {
	// Get the account ID from the request
	id := c.URLParams["id"]

	// Right now we only support "me" as the ID
	if id != "me" {
		utils.JSONResponse(w, 501, &AccountsGetResponse{
			Success: false,
			Message: `Only the "me" user is implemented`,
		})
		return
	}

	// Fetch the current session from the database
	session := c.Env["token"].(*models.Token)

	// Fetch the user object from the database
	user, err := env.Accounts.GetAccount(session.Owner)
	if err != nil {
		utils.JSONResponse(w, 500, &AccountsDeleteResponse{
			Success: false,
			Message: "Unable to resolve the account",
		})
		return
	}

	// Return the user struct
	utils.JSONResponse(w, 200, &AccountsGetResponse{
		Success: true,
		Account: user,
	})
}
414003
func (s *AccountService) GetAccountID(name string, opts ...OptionFunc) (string, int, error) {
	p := &ListAccountsParams{}
	p.p = make(map[string]interface{})

	p.p["name"] = name

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return "", -1, err
		}
	}

	l, err := s.ListAccounts(p)
	if err != nil {
		return "", -1, err
	}

	if l.Count == 0 {
		return "", l.Count, fmt.Errorf("No match found for %s: %+v", name, l)
	}

	if l.Count == 1 {
		return l.Accounts[0].Id, l.Count, nil
	}

	if l.Count > 1 {
		for _, v := range l.Accounts {
			if v.Name == name {
				return v.Id, l.Count, nil
			}
		}
	}
	return "", l.Count, fmt.Errorf("Could not find an exact match for %s: %+v", name, l)
}
970567
func GetAccount(host, token, id string) (*map[string]interface{}, error) {
	path := variables.APIPathAccount
	path = strings.Replace(path, ":id", id, 1)
	return GenericRequest(host, path, token, nil)
}
1355079
func (v *EchoRequest) GetCount() (o int16) {
	if v != nil {
		o = v.Count
	}
	return
}
848397
func (c *Client) GetAccounts(accessToken string) (resp GetAccountsResponse, err error) {
	options := GetAccountsOptions{
		AccountIDs: []string{},
	}
	return c.GetAccountsWithOptions(accessToken, options)
}