forked from TrueCloudLab/neoneo-go
core: add policy check to (*Blockchain).verifyTx method
If any of transaction's script hashes for verifying are included into Policy blocked accounts list, transaction is invalid.
This commit is contained in:
parent
b88863948d
commit
ce402a70d2
1 changed files with 16 additions and 0 deletions
|
@ -1123,6 +1123,22 @@ func (bc *Blockchain) verifyTx(t *transaction.Transaction, block *block.Block) e
|
|||
if t.ValidUntilBlock <= height || t.ValidUntilBlock > height+transaction.MaxValidUntilBlockIncrement {
|
||||
return errors.Errorf("transaction has expired. ValidUntilBlock = %d, current height = %d", t.ValidUntilBlock, height)
|
||||
}
|
||||
hashes, err := bc.GetScriptHashesForVerifying(t)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
blockedAccounts, err := bc.contracts.Policy.GetBlockedAccountsInternal(bc.dao)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, h := range hashes {
|
||||
i := sort.Search(len(blockedAccounts), func(i int) bool {
|
||||
return !blockedAccounts[i].Less(h)
|
||||
})
|
||||
if i != len(blockedAccounts) && blockedAccounts[i].Equals(h) {
|
||||
return errors.Errorf("policy check failed")
|
||||
}
|
||||
}
|
||||
balance := bc.GetUtilityTokenBalance(t.Sender)
|
||||
need := t.SystemFee.Add(t.NetworkFee)
|
||||
if balance.LessThan(need) {
|
||||
|
|
Loading…
Reference in a new issue