mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
New DataArgs and eth_sendRawTransaction
This commit is contained in:
parent
e952bb65e7
commit
7ec8c257ff
@ -171,7 +171,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
|
||||
*reply = v
|
||||
|
||||
case "eth_sendRawTransaction":
|
||||
args := new(NewSigArgs)
|
||||
args := new(NewDataArgs)
|
||||
if err := json.Unmarshal(req.Params, &args); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
|
||||
|
||||
|
||||
func (self *ethApi) PushTx(req *shared.Request) (interface{}, error) {
|
||||
args := new(NewSigArgs)
|
||||
args := new(NewDataArgs)
|
||||
if err := self.codec.Decode(req.Params, &args); err != nil {
|
||||
return nil, shared.NewDecodeParamError(err.Error())
|
||||
}
|
||||
|
@ -226,6 +226,35 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
type NewDataArgs struct {
|
||||
Data string
|
||||
}
|
||||
|
||||
func (args *NewDataArgs) UnmarshalJSON(b []byte) (err error) {
|
||||
var obj []interface{}
|
||||
|
||||
if err := json.Unmarshal(b, &obj); err != nil {
|
||||
return shared.NewDecodeParamError(err.Error())
|
||||
}
|
||||
|
||||
// Check for sufficient params
|
||||
if len(obj) < 1 {
|
||||
return shared.NewInsufficientParamsError(len(obj), 1)
|
||||
}
|
||||
|
||||
data, ok := obj[0].(string)
|
||||
if !ok {
|
||||
return shared.NewInvalidTypeError("data", "not a string")
|
||||
}
|
||||
args.Data = data
|
||||
|
||||
if len(args.Data) == 0 {
|
||||
return shared.NewValidationError("data", "is required")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type NewSigArgs struct {
|
||||
From string
|
||||
Data string
|
||||
|
29
rpc/args.go
29
rpc/args.go
@ -154,6 +154,35 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
type NewDataArgs struct {
|
||||
Data string
|
||||
}
|
||||
|
||||
func (args *NewDataArgs) UnmarshalJSON(b []byte) (err error) {
|
||||
var obj []interface{}
|
||||
|
||||
if err := json.Unmarshal(b, &obj); err != nil {
|
||||
return NewDecodeParamError(err.Error())
|
||||
}
|
||||
|
||||
// Check for sufficient params
|
||||
if len(obj) < 1 {
|
||||
return NewInsufficientParamsError(len(obj), 1)
|
||||
}
|
||||
|
||||
data, ok := obj[0].(string)
|
||||
if !ok {
|
||||
return NewInvalidTypeError("data", "not a string")
|
||||
}
|
||||
args.Data = data
|
||||
|
||||
if len(args.Data) == 0 {
|
||||
return NewValidationError("data", "is required")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type NewTxArgs struct {
|
||||
From string
|
||||
To string
|
||||
|
@ -787,6 +787,9 @@ func (self *XEth) FromNumber(str string) string {
|
||||
|
||||
func (self *XEth) PushTx(encodedTx string) (string, error) {
|
||||
tx := types.NewTransactionFromBytes(common.FromHex(encodedTx))
|
||||
|
||||
glog.V(logger.Info).Infof("Tx(%x) gas: %x\n", tx.Hash(), tx.Gas())
|
||||
|
||||
err := self.backend.TxPool().Add(tx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -965,7 +968,7 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
|
||||
|
||||
return core.AddressFromMessage(tx).Hex(), nil
|
||||
} else {
|
||||
glog.V(logger.Info).Infof("Tx(%x) to: %x\n", tx.Hash(), tx.To())
|
||||
glog.V(logger.Info).Infof("YEYEYE!! Tx(%x) to: %x\n, gas: %x", tx.Hash(), tx.To(), tx.Gas())
|
||||
}
|
||||
return tx.Hash().Hex(), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user