aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-02-06 01:13:35 +0800
committerobscuren <geffobscura@gmail.com>2015-02-06 02:58:43 +0800
commitac695387075fdd9214ef8de71ac6897136a50ce8 (patch)
tree5a4bce7c79eebe56b3573892e30e96b1ed0936fd /rpc
parent9d2166a964d83c09481dea6ef30889f260249295 (diff)
parentdb7c34a9df19d5a8a3a02a5e3d4cafcffa18dcb8 (diff)
downloaddexon-ac695387075fdd9214ef8de71ac6897136a50ce8.tar
dexon-ac695387075fdd9214ef8de71ac6897136a50ce8.tar.gz
dexon-ac695387075fdd9214ef8de71ac6897136a50ce8.tar.bz2
dexon-ac695387075fdd9214ef8de71ac6897136a50ce8.tar.lz
dexon-ac695387075fdd9214ef8de71ac6897136a50ce8.tar.xz
dexon-ac695387075fdd9214ef8de71ac6897136a50ce8.tar.zst
dexon-ac695387075fdd9214ef8de71ac6897136a50ce8.zip
Merge branch 'develop' into miner
Diffstat (limited to 'rpc')
-rw-r--r--rpc/args.go10
-rw-r--r--rpc/packages.go17
2 files changed, 13 insertions, 14 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 34e706b98..84b076d4a 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -37,16 +37,6 @@ type NewTxArgs struct {
Data string `json:"data"`
}
-func (a *NewTxArgs) requirements() error {
- if a.Gas == "" {
- return NewErrorResponse("Transact requires a 'gas' value as argument")
- }
- if a.GasPrice == "" {
- return NewErrorResponse("Transact requires a 'gasprice' value as argument")
- }
- return nil
-}
-
type PushTxArgs struct {
Tx string `json:"tx"`
}
diff --git a/rpc/packages.go b/rpc/packages.go
index a98d99d6c..047bbda9a 100644
--- a/rpc/packages.go
+++ b/rpc/packages.go
@@ -40,6 +40,11 @@ import (
"github.com/ethereum/go-ethereum/xeth"
)
+const (
+ defaultGasPrice = "10000000000000"
+ defaultGas = "10000"
+)
+
type EthereumApi struct {
xeth *xeth.XEth
filterManager *filter.FilterManager
@@ -116,10 +121,14 @@ func (p *EthereumApi) GetBlock(args *GetBlockArgs, reply *interface{}) error {
}
func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) error {
- err := args.requirements()
- if err != nil {
- return err
+ if len(args.Gas) == 0 {
+ args.Gas = defaultGas
+ }
+
+ if len(args.GasPrice) == 0 {
+ args.GasPrice = defaultGasPrice
}
+
result, _ := p.xeth.Transact( /* TODO specify account */ args.To, args.Value, args.Gas, args.GasPrice, args.Data)
*reply = result
return nil
@@ -387,7 +396,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
}
return p.FilterChanged(args, reply)
case "eth_gasPrice":
- *reply = "10000000000000"
+ *reply = defaultGasPrice
return nil
case "web3_sha3":
args, err := req.ToSha3Args()