The scriptpubkey alone can be used to identify the type of address. However, I'm debugging a library that's having difficulty differentiating the following transaction/scriptpubkey from a p2tr transaction/scriptpubkey.
Erroneously marked p2tr:
Txid: 2b3733a39b87cef1f7c2ca8988583ec0c1a886651b040e3dbaf4c26be81d0f75:195
Scriptpubkey: 245a227ef640f3b1dc1815e6e39b482677f0f57b69de7775faec778c0950a8851805000000
Correctly marked p2tr:
Txid: 83c8e0289fecf93b5a284705396f5a652d9886cbd26236b0d647655ad8a37d82:0
Scriptpubkey: 5120a457d0c0399b499ed2df571d612ba549ae7f199387edceac175999210f6aa39d
And honestly.. I understand why the library is having issues. The problematic scriptpubkey does look like a p2tr (1, data). However one thing I noticed is the problematic tx doesn't have witness (predates segwit). Is the only solution to check witness stack for the right pattern?