2015-03-26 21:30:42 -07:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/tendermint/tendermint/account"
|
|
|
|
)
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-03-28 23:10:05 -07:00
|
|
|
func GenPrivAccount() (*ResponseGenPrivAccount, error) {
|
|
|
|
return &ResponseGenPrivAccount{account.GenPrivAccount()}, nil
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-03-28 23:10:05 -07:00
|
|
|
func GetAccount(address []byte) (*ResponseGetAccount, error) {
|
2015-03-29 18:43:27 -07:00
|
|
|
cache := mempoolReactor.Mempool.GetCache()
|
|
|
|
return &ResponseGetAccount{cache.GetAccount(address)}, nil
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-03-28 23:10:05 -07:00
|
|
|
func ListAccounts() (*ResponseListAccounts, error) {
|
2015-03-26 21:30:42 -07:00
|
|
|
var blockHeight uint
|
|
|
|
var accounts []*account.Account
|
|
|
|
state := consensusState.GetState()
|
|
|
|
blockHeight = state.LastBlockHeight
|
|
|
|
state.GetAccounts().Iterate(func(key interface{}, value interface{}) bool {
|
|
|
|
accounts = append(accounts, value.(*account.Account))
|
|
|
|
return false
|
|
|
|
})
|
2015-03-28 23:10:05 -07:00
|
|
|
return &ResponseListAccounts{blockHeight, accounts}, nil
|
2015-03-26 21:30:42 -07:00
|
|
|
}
|