From 1364770cbe4a8b5ef660eeb266b7d74a28d743e5 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sun, 12 Apr 2015 16:41:50 -0700 Subject: [PATCH] Unknown address -> blank account from GetAccount rpc call --- rpc/core/accounts.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/rpc/core/accounts.go b/rpc/core/accounts.go index 21f334c44..4edd17631 100644 --- a/rpc/core/accounts.go +++ b/rpc/core/accounts.go @@ -2,18 +2,29 @@ package core import ( "fmt" - "github.com/tendermint/tendermint/account" + acm "github.com/tendermint/tendermint/account" . "github.com/tendermint/tendermint/common" ctypes "github.com/tendermint/tendermint/rpc/core/types" ) func GenPrivAccount() (*ctypes.ResponseGenPrivAccount, error) { - return &ctypes.ResponseGenPrivAccount{account.GenPrivAccount()}, nil + return &ctypes.ResponseGenPrivAccount{acm.GenPrivAccount()}, nil } func GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) { 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) { @@ -34,11 +45,11 @@ func GetStorage(address, key []byte) (*ctypes.ResponseGetStorage, error) { func ListAccounts() (*ctypes.ResponseListAccounts, error) { var blockHeight uint - var accounts []*account.Account + var accounts []*acm.Account state := consensusState.GetState() blockHeight = state.LastBlockHeight state.GetAccounts().Iterate(func(key interface{}, value interface{}) bool { - accounts = append(accounts, value.(*account.Account)) + accounts = append(accounts, value.(*acm.Account)) return false }) return &ctypes.ResponseListAccounts{blockHeight, accounts}, nil