From 6d357c37936b59a52702483e1521b6e228ce3b8b Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 10 Dec 2020 10:56:02 +0300 Subject: [PATCH] core: return a special error from verifyHashAgainstScript It will help us to distinguish proper `false` verification result from various verification errors. --- pkg/core/blockchain.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 2d2c00fbb..a9ae9e1d4 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1595,6 +1595,7 @@ var ( ErrWitnessHashMismatch = errors.New("witness hash mismatch") ErrNativeContractWitness = errors.New("native contract witness must have empty verification script") ErrVerificationFailed = errors.New("signature check failed") + ErrInvalidSignature = fmt.Errorf("%w: invalid signature", ErrVerificationFailed) ErrUnknownVerificationContract = errors.New("unknown verification contract") ErrInvalidVerificationContract = errors.New("verification contract is missing `verify` method") ) @@ -1674,7 +1675,7 @@ func (bc *Blockchain) verifyHashAgainstScript(hash util.Uint160, witness *transa return 0, fmt.Errorf("%w: expected exactly one returned value", ErrVerificationFailed) } if !res { - return 0, fmt.Errorf("%w: invalid signature", ErrVerificationFailed) + return vm.GasConsumed(), ErrInvalidSignature } } else { return 0, fmt.Errorf("%w: no result returned from the script", ErrVerificationFailed)