forked from TrueCloudLab/neoneo-go
Merge pull request #672 from nspcc-dev/fix-sigsegv-on-reference-check
core: deal with bad transaction Inputs
This commit is contained in:
commit
b5453ad24f
1 changed files with 9 additions and 8 deletions
|
@ -965,14 +965,15 @@ func (bc *Blockchain) References(t *transaction.Transaction) map[transaction.Inp
|
||||||
references := make(map[transaction.Input]*transaction.Output)
|
references := make(map[transaction.Input]*transaction.Output)
|
||||||
|
|
||||||
for prevHash, inputs := range t.GroupInputsByPrevHash() {
|
for prevHash, inputs := range t.GroupInputsByPrevHash() {
|
||||||
if tx, _, err := bc.dao.GetTransaction(prevHash); err != nil {
|
tx, _, err := bc.dao.GetTransaction(prevHash)
|
||||||
tx = nil
|
if err != nil {
|
||||||
} else if tx != nil {
|
return nil
|
||||||
for _, in := range inputs {
|
|
||||||
references[*in] = &tx.Outputs[in.PrevIndex]
|
|
||||||
}
|
}
|
||||||
} else {
|
for _, in := range inputs {
|
||||||
references = nil
|
if int(in.PrevIndex) > len(tx.Outputs)-1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
references[*in] = &tx.Outputs[in.PrevIndex]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return references
|
return references
|
||||||
|
@ -1451,7 +1452,7 @@ func (bc *Blockchain) GetScriptHashesForVerifying(t *transaction.Transaction) ([
|
||||||
}
|
}
|
||||||
references := bc.References(t)
|
references := bc.References(t)
|
||||||
if references == nil {
|
if references == nil {
|
||||||
return nil, errors.New("Invalid operation")
|
return nil, errors.New("invalid inputs")
|
||||||
}
|
}
|
||||||
hashes := make(map[util.Uint160]bool)
|
hashes := make(map[util.Uint160]bool)
|
||||||
for _, i := range t.Inputs {
|
for _, i := range t.Inputs {
|
||||||
|
|
Loading…
Reference in a new issue