From 0f3bf7ef4de95b8012eb9bba717323b9e89c5908 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 2 Apr 2015 12:57:04 +0200 Subject: [PATCH] Fixes for balance --- rpc/api.go | 7 ++++--- xeth/xeth.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/rpc/api.go b/rpc/api.go index 80dd27afba..d9206eb798 100644 --- a/rpc/api.go +++ b/rpc/api.go @@ -36,7 +36,7 @@ func (api *EthereumApi) xethAtStateNum(num int64) *xeth.XEth { func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { // Spec at https://github.com/ethereum/wiki/wiki/JSON-RPC - rpclogger.Debugf("%s %s", req.Method, req.Params) + rpclogger.Infof("%s %s", req.Method, req.Params) switch req.Method { case "web3_sha3": @@ -80,8 +80,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err return err } - v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance() - *reply = common.ToHex(v.Bytes()) + *reply = api.xethAtStateNum(args.BlockNumber).BalanceAt(args.Address) + //v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance() + //*reply = common.ToHex(v.Bytes()) case "eth_getStorage", "eth_storageAt": args := new(GetStorageArgs) if err := json.Unmarshal(req.Params, &args); err != nil { diff --git a/xeth/xeth.go b/xeth/xeth.go index 0a813ec99c..d9a34695a3 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -312,7 +312,7 @@ func (self *XEth) StorageAt(addr, storageAddr string) string { } func (self *XEth) BalanceAt(addr string) string { - return self.State().state.GetBalance(common.HexToAddress(addr)).String() + return common.ToHex(self.State().state.GetBalance(common.HexToAddress(addr)).Bytes()) } func (self *XEth) TxCountAt(address string) int {