forked from TrueCloudLab/neoneo-go
Merge pull request #1899 from nspcc-dev/more-specific-errors-for-sendrawtx
rpc/server: be more specific in some sendrawtransaction error cases
This commit is contained in:
commit
1eebaa8eac
1 changed files with 8 additions and 8 deletions
|
@ -1325,13 +1325,13 @@ func (s *Server) runScriptInVM(t trigger.Type, script []byte, contractScriptHash
|
||||||
func (s *Server) submitBlock(reqParams request.Params) (interface{}, *response.Error) {
|
func (s *Server) submitBlock(reqParams request.Params) (interface{}, *response.Error) {
|
||||||
blockBytes, err := reqParams.ValueWithType(0, request.StringT).GetBytesBase64()
|
blockBytes, err := reqParams.ValueWithType(0, request.StringT).GetBytesBase64()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("missing parameter or not base64", err)
|
||||||
}
|
}
|
||||||
b := block.New(s.stateRootEnabled)
|
b := block.New(s.stateRootEnabled)
|
||||||
r := io.NewBinReaderFromBuf(blockBytes)
|
r := io.NewBinReaderFromBuf(blockBytes)
|
||||||
b.DecodeBinary(r)
|
b.DecodeBinary(r)
|
||||||
if r.Err != nil {
|
if r.Err != nil {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("can't decode block", r.Err)
|
||||||
}
|
}
|
||||||
err = s.chain.AddBlock(b)
|
err = s.chain.AddBlock(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1354,15 +1354,15 @@ func (s *Server) submitNotaryRequest(ps request.Params) (interface{}, *response.
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ps) < 1 {
|
if len(ps) < 1 {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("not enough parameters", nil)
|
||||||
}
|
}
|
||||||
bytePayload, err := ps[0].GetBytesBase64()
|
bytePayload, err := ps[0].GetBytesBase64()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("not base64", err)
|
||||||
}
|
}
|
||||||
r, err := payload.NewP2PNotaryRequestFromBytes(bytePayload)
|
r, err := payload.NewP2PNotaryRequestFromBytes(bytePayload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("can't decode notary payload", err)
|
||||||
}
|
}
|
||||||
return getRelayResult(s.coreServer.RelayP2PNotaryRequest(r), r.FallbackTransaction.Hash())
|
return getRelayResult(s.coreServer.RelayP2PNotaryRequest(r), r.FallbackTransaction.Hash())
|
||||||
}
|
}
|
||||||
|
@ -1419,15 +1419,15 @@ func (s *Server) submitOracleResponse(ps request.Params) (interface{}, *response
|
||||||
|
|
||||||
func (s *Server) sendrawtransaction(reqParams request.Params) (interface{}, *response.Error) {
|
func (s *Server) sendrawtransaction(reqParams request.Params) (interface{}, *response.Error) {
|
||||||
if len(reqParams) < 1 {
|
if len(reqParams) < 1 {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("not enough parameters", nil)
|
||||||
}
|
}
|
||||||
byteTx, err := reqParams[0].GetBytesBase64()
|
byteTx, err := reqParams[0].GetBytesBase64()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("not base64", err)
|
||||||
}
|
}
|
||||||
tx, err := transaction.NewTransactionFromBytes(byteTx)
|
tx, err := transaction.NewTransactionFromBytes(byteTx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, response.ErrInvalidParams
|
return nil, response.NewInvalidParamsError("can't decode transaction", err)
|
||||||
}
|
}
|
||||||
return getRelayResult(s.coreServer.RelayTxn(tx), tx.Hash())
|
return getRelayResult(s.coreServer.RelayTxn(tx), tx.Hash())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue