diff options
author | Felix Lange <fjl@twurst.com> | 2015-03-10 06:02:43 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2015-03-10 06:08:46 +0800 |
commit | c2e5dacf555d93cb96b8fbffa700a2a6fece8bf0 (patch) | |
tree | 97cc3ab949b4401753d1aa71b4848d1bac9c9131 /accounts | |
parent | 63758db37977bf4a2bd13cd360432c520dd77dd8 (diff) | |
download | go-tangerine-c2e5dacf555d93cb96b8fbffa700a2a6fece8bf0.tar.gz go-tangerine-c2e5dacf555d93cb96b8fbffa700a2a6fece8bf0.tar.zst go-tangerine-c2e5dacf555d93cb96b8fbffa700a2a6fece8bf0.zip |
accounts: add Manager.HasAccount, delete Manager.Default
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/account_manager.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/accounts/account_manager.go b/accounts/account_manager.go index bb664878a..4575334bf 100644 --- a/accounts/account_manager.go +++ b/accounts/account_manager.go @@ -33,6 +33,7 @@ and accounts persistence is derived from stored keys' addresses package accounts import ( + "bytes" "crypto/ecdsa" crand "crypto/rand" @@ -72,19 +73,22 @@ func NewManager(keyStore crypto.KeyStore2, unlockTime time.Duration) *Manager { } } +func (am *Manager) HasAccount(addr []byte) bool { + accounts, _ := am.Accounts() + for _, acct := range accounts { + if bytes.Compare(acct.Address, addr) == 0 { + return true + } + } + return false +} + // Coinbase returns the account address that mining rewards are sent to. func (am *Manager) Coinbase() (addr []byte, err error) { // TODO: persist coinbase address on disk return am.firstAddr() } -// MainAccount returns the primary account used for transactions. -func (am *Manager) Default() (Account, error) { - // TODO: persist main account address on disk - addr, err := am.firstAddr() - return Account{Address: addr}, err -} - func (am *Manager) firstAddr() ([]byte, error) { addrs, err := am.keyStore.GetKeyAddresses() if err != nil { @@ -135,9 +139,7 @@ func (am *Manager) Accounts() ([]Account, error) { if err != nil { return nil, err } - accounts := make([]Account, len(addresses)) - for i, addr := range addresses { accounts[i] = Account{ Address: addr, |