// Accounts retrieves the list of signing accounts the wallet is currently aware
// of. For hierarchical deterministic wallets, the list will not be exhaustive,
// rather only contain the accounts explicitly pinned during account derivation.
760110
func (w *Wallet) Accounts() []accounts.Account {
	// Attempt self-derivation if it's running
	reqc := make(chan struct{}, 1)
	select {
	case w.deriveReq <- reqc:
		// Self-derivation request accepted, wait for it
		<-reqc
	default:
		// Self-derivation offline, throttled or busy, skip
	}

	w.lock.Lock()
	defer w.lock.Unlock()

	if pairing := w.Hub.pairing(w); pairing != nil {
		ret := make([]accounts.Account, 0, len(pairing.Accounts))
		for address, path := range pairing.Accounts {
			ret = append(ret, w.makeAccount(address, path))
		}
		sort.Sort(accounts.AccountsByURL(ret))
		return ret
	}
	return nil
}
298684
func (c *Client) ListAccounts(p *ListAccountsParameter) ([]*Account, error) {
	obj, err := c.Request("listAccounts", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*Account), err
}
182647
func (ks *KeyStore) Wallets() []accounts.Wallet {
	// Make sure the list of wallets is in sync with the account cache
	ks.refreshWallets()

	ks.mu.RLock()
	defer ks.mu.RUnlock()

	cpy := make([]accounts.Wallet, len(ks.wallets))
	copy(cpy, ks.wallets)
	return cpy
}
124973
func (s *ListAccountsOutput) SetAccounts(v []*Account) *ListAccountsOutput {
	s.Accounts = v
	return s
}
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
}
1302130
func (c *client) Account() *Account {
	if c == nil {
		return nil
	}
	c.mu.Lock()
	defer c.mu.Unlock()
	return c.acc
}
55315
func (s *WalletService) Wallet() (*bitfinex.WalletSnapshot, error) {
	req, err := s.requestFactory.NewAuthenticatedRequest(path.Join("wallets"))
	if err != nil {
		return nil, err
	}
	raw, err := s.Request(req)
	if err != nil {
		return nil, err
	}

	os, err := bitfinex.NewWalletSnapshotFromRaw(raw)
	if err != nil {
		return nil, err
	}

	return os, nil
}
1065818
func (b *AccountController) List(c *app.ListAccountContext) error {
	accounts := b.db.GetAccounts()
	res := make(app.AccountTinyCollection, len(accounts))
	for i, account := range accounts {
		a := &app.AccountTiny{
			ID:   account.ID,
			Href: app.AccountHref(account.ID),
			Name: account.Name,
		}
		res[i] = a
	}
	return c.OKTiny(res)
}
548384
func (w *WalletState) AccountSeqno(ctx context.Context, accountID stellar1.AccountID) (uint64, error) {
	a, err := w.accountStateRefresh(ctx, accountID, "AccountSeqno")
	if err != nil {
		return 0, err
	}

	return a.AccountSeqno(ctx)
}
1260748
func (w *Wallet) accountUsed(addrmgrNs walletdb.ReadWriteBucket, account uint32) (bool, error) {
	var used bool
	err := w.Manager.ForEachAccountAddress(addrmgrNs, account,
		func(maddr waddrmgr.ManagedAddress) error {
			used = maddr.Used(addrmgrNs)
			if used {
				return waddrmgr.Break
			}
			return nil
		})
	if err == waddrmgr.Break {
		err = nil
	}
	return used, err
}
1132274
func (w *Wallet) AccountProperties(scope waddrmgr.KeyScope, acct uint32) (*waddrmgr.AccountProperties, error) {
	manager, err := w.Manager.FetchScopedKeyManager(scope)
	if err != nil {
		return nil, err
	}

	var props *waddrmgr.AccountProperties
	err = walletdb.View(w.db, func(tx walletdb.ReadTx) error {
		waddrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
		var err error
		props, err = manager.AccountProperties(waddrmgrNs, acct)
		return err
	})
	return props, err
}
18800
func (w *WalletState) AccountSeqnoAndBump(ctx context.Context, accountID stellar1.AccountID) (uint64, error) {
	w.Lock()
	hasSeqnoLock := w.seqnoLockHeld
	w.Unlock()
	if !hasSeqnoLock {
		return 0, errors.New("you must hold SeqnoLock() before AccountSeqnoAndBump")
	}
	a, err := w.accountStateRefresh(ctx, accountID, "AccountSeqnoAndBump")
	if err != nil {
		return 0, err
	}
	return a.AccountSeqnoAndBump(ctx)
}
423933
func getAddressesByAccount(icmd interface{}, w *wallet.Wallet) (interface{}, error) {
	cmd := icmd.(*btcjson.GetAddressesByAccountCmd)

	account, err := w.AccountNumber(waddrmgr.KeyScopeBIP0044, cmd.Account)
	if err != nil {
		return nil, err
	}

	addrs, err := w.AccountAddresses(account)
	if err != nil {
		return nil, err
	}

	addrStrs := make([]string, len(addrs))
	for i, a := range addrs {
		addrStrs[i] = a.EncodeAddress()
	}
	return addrStrs, nil
}
1060583
func (s *AccountsService) GetAccount(account string) (*AccountInfo, *Response, error) {
	u := fmt.Sprintf("accounts/%s", account)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	v := new(AccountInfo)
	resp, err := s.client.Do(req, v)
	if err != nil {
		return nil, resp, err
	}

	return v, resp, err
}
1353569
func (rpc *EthRPC) EthAccounts() ([]string, error) {
	accounts := []string{}

	err := rpc.call("eth_accounts", &accounts)
	return accounts, err
}
479094
func (w *keystoreWallet) Contains(account accounts.Account) bool {
	return account.Address == w.account.Address && (account.URL == (accounts.URL{}) || account.URL == w.account.URL)
}
708674
func (w *Wallet) AccountNumber(scope waddrmgr.KeyScope, accountName string) (uint32, error) {
	manager, err := w.Manager.FetchScopedKeyManager(scope)
	if err != nil {
		return 0, err
	}

	var account uint32
	err = walletdb.View(w.db, func(tx walletdb.ReadTx) error {
		addrmgrNs := tx.ReadBucket(waddrmgrNamespaceKey)
		var err error
		account, err = manager.LookupAccount(addrmgrNs, accountName)
		return err
	})
	return account, err
}