Merge pull request #3508 from nspcc-dev/witness-check-hint

rpcsrv: improve witness verification error
This commit is contained in:
Anna Shaleva 2024-07-12 11:29:22 +03:00 committed by GitHub
commit aff66a23dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -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

View file

@ -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