mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +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 {
|
func (bc *Blockchain) InitVerificationContext(ic *interop.Context, hash util.Uint160, witness *transaction.Witness) error {
|
||||||
if len(witness.VerificationScript) != 0 {
|
if len(witness.VerificationScript) != 0 {
|
||||||
if witness.ScriptHash() != hash {
|
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 {
|
if bc.contracts.ByHash(hash) != nil {
|
||||||
return ErrNativeContractWitness
|
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)
|
gasConsumed, err := s.chain.VerifyWitness(signer.Account, tx, &w, gasLimit)
|
||||||
if err != nil && !errors.Is(err, core.ErrInvalidSignature) {
|
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
|
gasLimit -= gasConsumed
|
||||||
netFee += gasConsumed
|
netFee += gasConsumed
|
||||||
|
|
Loading…
Reference in a new issue