|
|
@ -2,7 +2,6 @@ package rpc |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
@ -15,11 +14,6 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/xeth" |
|
|
|
"github.com/ethereum/go-ethereum/xeth" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
|
|
defaultGasPrice = big.NewInt(150000000000) |
|
|
|
|
|
|
|
defaultGas = big.NewInt(500000) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type EthereumApi struct { |
|
|
|
type EthereumApi struct { |
|
|
|
eth *xeth.XEth |
|
|
|
eth *xeth.XEth |
|
|
|
xethMu sync.RWMutex |
|
|
|
xethMu sync.RWMutex |
|
|
@ -109,16 +103,15 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error) |
|
|
|
// TODO: align default values to have the same type, e.g. not depend on
|
|
|
|
// TODO: align default values to have the same type, e.g. not depend on
|
|
|
|
// common.Value conversions later on
|
|
|
|
// common.Value conversions later on
|
|
|
|
if args.Gas.Cmp(big.NewInt(0)) == 0 { |
|
|
|
if args.Gas.Cmp(big.NewInt(0)) == 0 { |
|
|
|
args.Gas = defaultGas |
|
|
|
args.Gas = p.xeth().DefaultGas() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if args.GasPrice.Cmp(big.NewInt(0)) == 0 { |
|
|
|
if args.GasPrice.Cmp(big.NewInt(0)) == 0 { |
|
|
|
args.GasPrice = defaultGasPrice |
|
|
|
args.GasPrice = p.xeth().DefaultGasPrice() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
*reply, err = p.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) |
|
|
|
*reply, err = p.xeth().Transact(args.From, args.To, args.Value.String(), args.Gas.String(), args.GasPrice.String(), args.Data) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
fmt.Println("err:", err) |
|
|
|
|
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -199,7 +192,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error |
|
|
|
case "eth_mining": |
|
|
|
case "eth_mining": |
|
|
|
*reply = p.xeth().IsMining() |
|
|
|
*reply = p.xeth().IsMining() |
|
|
|
case "eth_gasPrice": |
|
|
|
case "eth_gasPrice": |
|
|
|
*reply = common.ToHex(defaultGasPrice.Bytes()) |
|
|
|
*reply = common.ToHex(p.xeth().DefaultGas().Bytes()) |
|
|
|
case "eth_accounts": |
|
|
|
case "eth_accounts": |
|
|
|
*reply = p.xeth().Accounts() |
|
|
|
*reply = p.xeth().Accounts() |
|
|
|
case "eth_blockNumber": |
|
|
|
case "eth_blockNumber": |
|
|
|