You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
991 B

  1. package core
  2. import (
  3. "github.com/tendermint/tendermint/account"
  4. )
  5. //-----------------------------------------------------------------------------
  6. func GenPrivAccount() (*ResponseGenPrivAccount, error) {
  7. return &ResponseGenPrivAccount{account.GenPrivAccount()}, nil
  8. }
  9. //-----------------------------------------------------------------------------
  10. func GetAccount(address []byte) (*ResponseGetAccount, error) {
  11. state := consensusState.GetState()
  12. return &ResponseGetAccount{state.GetAccount(address)}, nil
  13. }
  14. //-----------------------------------------------------------------------------
  15. func ListAccounts() (*ResponseListAccounts, error) {
  16. var blockHeight uint
  17. var accounts []*account.Account
  18. state := consensusState.GetState()
  19. blockHeight = state.LastBlockHeight
  20. state.GetAccounts().Iterate(func(key interface{}, value interface{}) bool {
  21. accounts = append(accounts, value.(*account.Account))
  22. return false
  23. })
  24. return &ResponseListAccounts{blockHeight, accounts}, nil
  25. }