Summary
Update the BIP375 validator to reject actual SegWit v2–v16 witness programs instead of every scriptPubKey beginning with OP_2 through OP_16.
Problem
The input eligibility check currently determines whether an input spends a SegWit v2+ output by inspecting only the first byte of its scriptPubKey:
if script and 0x51 < script[0] <= 0x60:
However, an OP_2–OP_16 prefix alone does not make a scriptPubKey a witness program.
A witness program must consist of a version opcode followed by a direct push of 2–40 bytes, with the push length matching the remaining script length.
Consequently, a scriptPubKey containing only OP_2 (0x52) is incorrectly classified as a SegWit v2 witness program and rejected by the validator.
Testing
Before the fix, the new regression vector failed:
41 passed, 1 failed
After the fix, all BIP375 validation vectors pass:
42 passed, 0 failed