core: add scopes check to cosigners in DecodeBinary
This commit is contained in:
parent
7865bc5925
commit
75f1c2d6f2
1 changed files with 10 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
package transaction
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
|
@ -33,6 +35,14 @@ func (c *Cosigner) EncodeBinary(bw *io.BinWriter) {
|
|||
func (c *Cosigner) DecodeBinary(br *io.BinReader) {
|
||||
br.ReadBytes(c.Account[:])
|
||||
c.Scopes = WitnessScope(br.ReadB())
|
||||
if c.Scopes & ^(Global|CalledByEntry|CustomContracts|CustomGroups) != 0 {
|
||||
br.Err = errors.New("unknown witness scope")
|
||||
return
|
||||
}
|
||||
if c.Scopes&Global != 0 && c.Scopes != Global {
|
||||
br.Err = errors.New("global scope can not be combined with other scopes")
|
||||
return
|
||||
}
|
||||
if c.Scopes&CustomContracts != 0 {
|
||||
br.ReadArray(&c.AllowedContracts, maxSubitems)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue