mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-25 18:51:39 +00:00
Unknown address -> blank account from GetAccount rpc call
This commit is contained in:
@ -2,18 +2,29 @@ package core
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/tendermint/tendermint/account"
|
acm "github.com/tendermint/tendermint/account"
|
||||||
. "github.com/tendermint/tendermint/common"
|
. "github.com/tendermint/tendermint/common"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GenPrivAccount() (*ctypes.ResponseGenPrivAccount, error) {
|
func GenPrivAccount() (*ctypes.ResponseGenPrivAccount, error) {
|
||||||
return &ctypes.ResponseGenPrivAccount{account.GenPrivAccount()}, nil
|
return &ctypes.ResponseGenPrivAccount{acm.GenPrivAccount()}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) {
|
func GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) {
|
||||||
cache := mempoolReactor.Mempool.GetCache()
|
cache := mempoolReactor.Mempool.GetCache()
|
||||||
return &ctypes.ResponseGetAccount{cache.GetAccount(address)}, nil
|
account := cache.GetAccount(address)
|
||||||
|
if account == nil {
|
||||||
|
account = &acm.Account{
|
||||||
|
Address: address,
|
||||||
|
PubKey: acm.PubKeyNil{},
|
||||||
|
Sequence: 0,
|
||||||
|
Balance: 0,
|
||||||
|
Code: nil,
|
||||||
|
StorageRoot: nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &ctypes.ResponseGetAccount{account}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStorage(address, key []byte) (*ctypes.ResponseGetStorage, error) {
|
func GetStorage(address, key []byte) (*ctypes.ResponseGetStorage, error) {
|
||||||
@ -34,11 +45,11 @@ func GetStorage(address, key []byte) (*ctypes.ResponseGetStorage, error) {
|
|||||||
|
|
||||||
func ListAccounts() (*ctypes.ResponseListAccounts, error) {
|
func ListAccounts() (*ctypes.ResponseListAccounts, error) {
|
||||||
var blockHeight uint
|
var blockHeight uint
|
||||||
var accounts []*account.Account
|
var accounts []*acm.Account
|
||||||
state := consensusState.GetState()
|
state := consensusState.GetState()
|
||||||
blockHeight = state.LastBlockHeight
|
blockHeight = state.LastBlockHeight
|
||||||
state.GetAccounts().Iterate(func(key interface{}, value interface{}) bool {
|
state.GetAccounts().Iterate(func(key interface{}, value interface{}) bool {
|
||||||
accounts = append(accounts, value.(*account.Account))
|
accounts = append(accounts, value.(*acm.Account))
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
return &ctypes.ResponseListAccounts{blockHeight, accounts}, nil
|
return &ctypes.ResponseListAccounts{blockHeight, accounts}, nil
|
||||||
|
Reference in New Issue
Block a user