mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 03:58:06 +00:00
core: add appropriate hashes to check for State TX
These checks are important for proper transaction verification.
This commit is contained in:
parent
2e4460bbb1
commit
6ede65610d
1 changed files with 25 additions and 0 deletions
|
@ -1885,6 +1885,31 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
|
|||
case transaction.EnrollmentType:
|
||||
etx := t.Data.(*transaction.EnrollmentTX)
|
||||
hashes[etx.PublicKey.GetScriptHash()] = true
|
||||
case transaction.StateType:
|
||||
stx := t.Data.(*transaction.StateTX)
|
||||
for _, desc := range stx.Descriptors {
|
||||
switch desc.Type {
|
||||
case transaction.Account:
|
||||
if desc.Field != "Votes" {
|
||||
return nil, errors.New("bad account state descriptor")
|
||||
}
|
||||
hash, err := util.Uint160DecodeBytesBE(desc.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hashes[hash] = true
|
||||
case transaction.Validator:
|
||||
if desc.Field != "Registered" {
|
||||
return nil, errors.New("bad validator state descriptor")
|
||||
}
|
||||
key := &keys.PublicKey{}
|
||||
err := key.DecodeBytes(desc.Key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hashes[key.GetScriptHash()] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
// convert hashes to []util.Uint160
|
||||
hashesResult := make([]util.Uint160, 0, len(hashes))
|
||||
|
|
Loading…
Reference in a new issue