I think the wallet’s transaction relevance checking is a complex and inefficient process that could be improved by using output descriptors[^1^][1] [^2^][2]. Output descriptors are strings that contain all the information necessary to track and spend from a script or a set of related scripts, such as an address or a HD wallet. They are unambiguous, checksummed, and easy to import and export.
Using output descriptors, the wallet could simply compare the hash of the descriptor with the hash of the output script to determine if it is relevant. It would not need to store or parse the actual output scripts, witness programs, or public keys. It would also not need to scan the inputs of every transaction to find the outpoints or inspect the input scripts and witness stacks. This would make the wallet more efficient, secure, and compatible with different address types and scripts.










