Fixes for balance

pull/619/head
obscuren 10 years ago
parent 7e13ee602e
commit 0f3bf7ef4d
  1. 7
      rpc/api.go
  2. 2
      xeth/xeth.go

@ -36,7 +36,7 @@ func (api *EthereumApi) xethAtStateNum(num int64) *xeth.XEth {
func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error { func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error {
// Spec at https://github.com/ethereum/wiki/wiki/JSON-RPC // 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 { switch req.Method {
case "web3_sha3": case "web3_sha3":
@ -80,8 +80,9 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return err return err
} }
v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance() *reply = api.xethAtStateNum(args.BlockNumber).BalanceAt(args.Address)
*reply = common.ToHex(v.Bytes()) //v := api.xethAtStateNum(args.BlockNumber).State().SafeGet(args.Address).Balance()
//*reply = common.ToHex(v.Bytes())
case "eth_getStorage", "eth_storageAt": case "eth_getStorage", "eth_storageAt":
args := new(GetStorageArgs) args := new(GetStorageArgs)
if err := json.Unmarshal(req.Params, &args); err != nil { if err := json.Unmarshal(req.Params, &args); err != nil {

@ -312,7 +312,7 @@ func (self *XEth) StorageAt(addr, storageAddr string) string {
} }
func (self *XEth) BalanceAt(addr 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 { func (self *XEth) TxCountAt(address string) int {

Loading…
Cancel
Save