mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 19:02:28 +00:00
Merge pull request #1462 from nspcc-dev/rpc/exceptions
rpc, core: add FaultException to AppExecResult and Invoke* results
This commit is contained in:
commit
8c2fd91c5c
9 changed files with 190 additions and 75 deletions
|
@ -541,12 +541,17 @@ func (c *Client) AddNetworkFee(tx *transaction.Transaction, extraFee int64, accs
|
|||
for i, cosigner := range tx.Signers {
|
||||
if accs[i].Contract.Deployed {
|
||||
res, err := c.InvokeFunction(cosigner.Account, manifest.MethodVerify, []smartcontract.Parameter{}, tx.Signers)
|
||||
if err == nil && res.State == "HALT" && len(res.Stack) == 1 {
|
||||
r, err := topIntFromStack(res.Stack)
|
||||
if err != nil || r == 0 {
|
||||
return core.ErrVerificationFailed
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to invoke verify: %w", err)
|
||||
}
|
||||
if res.State != "HALT" {
|
||||
return fmt.Errorf("invalid VM state %s due to an error: %s", res.State, res.FaultException)
|
||||
}
|
||||
if l := len(res.Stack); l != 1 {
|
||||
return fmt.Errorf("result stack length should be equal to 1, got %d", l)
|
||||
}
|
||||
r, err := topIntFromStack(res.Stack)
|
||||
if err != nil || r == 0 {
|
||||
return core.ErrVerificationFailed
|
||||
}
|
||||
tx.NetworkFee += res.GasConsumed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue