mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 03:47:18 +00:00
rpcsrv: improve witness verification error
It's needed to give user a hint about what's wrong with the witness during `calculatenetworkfee` RPC request processing. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
7304b2c7fb
commit
434f94800a
2 changed files with 2 additions and 2 deletions
|
@ -2902,7 +2902,7 @@ var (
|
|||
func (bc *Blockchain) InitVerificationContext(ic *interop.Context, hash util.Uint160, witness *transaction.Witness) error {
|
||||
if len(witness.VerificationScript) != 0 {
|
||||
if witness.ScriptHash() != hash {
|
||||
return ErrWitnessHashMismatch
|
||||
return fmt.Errorf("%w: expected %s, got %s", ErrWitnessHashMismatch, hash.StringLE(), witness.ScriptHash().StringLE())
|
||||
}
|
||||
if bc.contracts.ByHash(hash) != nil {
|
||||
return ErrNativeContractWitness
|
||||
|
|
|
@ -991,7 +991,7 @@ func (s *Server) calculateNetworkFee(reqParams params.Params) (any, *neorpc.Erro
|
|||
}
|
||||
gasConsumed, err := s.chain.VerifyWitness(signer.Account, tx, &w, gasLimit)
|
||||
if err != nil && !errors.Is(err, core.ErrInvalidSignature) {
|
||||
return nil, neorpc.WrapErrorWithData(neorpc.ErrInvalidSignature, err.Error())
|
||||
return nil, neorpc.WrapErrorWithData(neorpc.ErrInvalidSignature, fmt.Sprintf("witness %d: %s", i, err))
|
||||
}
|
||||
gasLimit -= gasConsumed
|
||||
netFee += gasConsumed
|
||||
|
|
Loading…
Reference in a new issue