PR description:
> This is in preparation for adding different signature verification rules,
> specifically tapscript (BIP 342), which interprets opcode 0xac and 0xad
> as Schnorr signature verifications.
The rationale for backporting this PR into ABC is that extracting a small piece of a huge function into its own function seems positive in itself, even if we don't plan to do the next steps described in the PR discussion.
This is a backport of Core PR18422