mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
light: add canonical header verification to GetTransaction
This commit is contained in:
parent
47da5b8886
commit
ee1cb0cba0
1 changed files with 5 additions and 0 deletions
|
|
@ -236,6 +236,11 @@ func GetTransaction(ctx context.Context, odr OdrBackend, txHash common.Hash) (*t
|
|||
return nil, common.Hash{}, 0, 0, err
|
||||
} else {
|
||||
pos := r.Status[0].Lookup
|
||||
// first ensure that we have the header, otherwise block body retrieval will fail
|
||||
// also verify if this is a canonical block by getting the header by number and checking its hash
|
||||
if header, err := GetHeaderByNumber(ctx, odr, pos.BlockIndex); err != nil || header.Hash() != pos.BlockHash {
|
||||
return nil, common.Hash{}, 0, 0, err
|
||||
}
|
||||
if body, err := GetBody(ctx, odr, pos.BlockHash, pos.BlockIndex); err != nil || uint64(len(body.Transactions)) <= pos.Index || body.Transactions[pos.Index].Hash() != txHash {
|
||||
return nil, common.Hash{}, 0, 0, err
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue