aboutsummaryrefslogtreecommitdiffstats
path: root/ethrpc/packages.go
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-06-24 17:15:26 +0800
committerMaran <maran.hidskes@gmail.com>2014-06-24 17:15:26 +0800
commit0c55a113180955aa149a6e961c6e4bba9a7418e0 (patch)
treeb8b4347ded333bfa6486315684ebc72b7bf4ecb6 /ethrpc/packages.go
parent614624754d2dcaf9344a3efbfa880c9b0ddba6be (diff)
downloadgo-tangerine-0c55a113180955aa149a6e961c6e4bba9a7418e0.tar.gz
go-tangerine-0c55a113180955aa149a6e961c6e4bba9a7418e0.tar.zst
go-tangerine-0c55a113180955aa149a6e961c6e4bba9a7418e0.zip
Support hex and decimal keys for GetStorageAt RPC. Fixes ethereum/go-ethereum#74
Diffstat (limited to 'ethrpc/packages.go')
-rw-r--r--ethrpc/packages.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/ethrpc/packages.go b/ethrpc/packages.go
index 1c4fb99f6..34d7a3d6f 100644
--- a/ethrpc/packages.go
+++ b/ethrpc/packages.go
@@ -6,6 +6,7 @@ import (
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
"math/big"
+ "strings"
)
type EthereumApi struct {
@@ -174,9 +175,15 @@ func (p *EthereumApi) GetStorageAt(args *GetStorageArgs, reply *string) error {
return err
}
state := p.ethp.GetStateObject(args.Address)
- // Convert the incoming string (which is a bigint) into hex
- i, _ := new(big.Int).SetString(args.Key, 10)
- hx := ethutil.Hex(i.Bytes())
+
+ var hx string
+ if strings.Index(args.Key, "0x") == 0 {
+ hx = string([]byte(args.Key)[2:])
+ } else {
+ // Convert the incoming string (which is a bigint) into hex
+ i, _ := new(big.Int).SetString(args.Key, 10)
+ hx = ethutil.Hex(i.Bytes())
+ }
value := state.GetStorage(hx)
*reply = NewSuccessRes(GetStorageAtRes{Address: args.Address, Key: args.Key, Value: value})
return nil