I have tried using the eth_account library but it doesnt work on newer transactions (type 0x02 transactions). What is a method of retrieval that would work on those transactions?
from eth_account._utils.signing import extract_chain_id, to_standard_v, serializable_unsigned_transaction_from_dict
from eth_account._utils.legacy_transactions import ALLOWED_TRANSACTION_KEYS
s = web3.eth.account._keys.Signature(vrs=(
to_standard_v(extract_chain_id(tx.v)[1]),
web3.toInt(tx.r),
web3.toInt(tx.s)
))
tt = {k:tx[k] for k in ALLOWED_TRANSACTION_KEYS - {'chainId', 'data'}}
tt['data']=tx.input
tt['chainId']=extract_chain_id(tx.v)[0]
from eth_account._utils.legacy_transactions import serializable_unsigned_transaction_from_dict
ut = serializable_unsigned_transaction_from_dict(tt)
print('public key')
s.recover_public_key_from_msg_hash(ut.hash())