rpc: refactor (*Client).AddNetworkFee errors handling

core.ErrVerificationFailed is not very informative. Also removing it
from RPC client allows to get rid of `core` dependency in the `client`
package, which is needed for the next commit.
This commit is contained in:
Anna Shaleva 2021-03-22 12:21:48 +03:00
parent a727ba75c6
commit ee76db9ff2

View file

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/core"
"github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/fee" "github.com/nspcc-dev/neo-go/pkg/core/fee"
"github.com/nspcc-dev/neo-go/pkg/core/native" "github.com/nspcc-dev/neo-go/pkg/core/native"
@ -781,8 +780,11 @@ func (c *Client) AddNetworkFee(tx *transaction.Transaction, extraFee int64, accs
return fmt.Errorf("result stack length should be equal to 1, got %d", l) return fmt.Errorf("result stack length should be equal to 1, got %d", l)
} }
r, err := topIntFromStack(res.Stack) r, err := topIntFromStack(res.Stack)
if err != nil || r == 0 { if err != nil {
return core.ErrVerificationFailed return fmt.Errorf("signer #%d: failed to get `verify` result from stack: %w", i, err)
}
if r == 0 {
return fmt.Errorf("signer #%d: `verify` returned `false`", i)
} }
tx.NetworkFee += res.GasConsumed tx.NetworkFee += res.GasConsumed
size += io.GetVarSize([]byte{}) * 2 // both scripts are empty size += io.GetVarSize([]byte{}) * 2 // both scripts are empty