Classify a scriptpubkey, optionally also using the private key info that will generate the corresponding scriptsig/witness
    Return None if not known (nonstandard)

def btc_script_classify(scriptpubkey, private_key_info=None):
    """
    Classify a scriptpubkey, optionally also using the private key info that will generate the corresponding scriptsig/witness
    Return None if not known (nonstandard)
    """
    if scriptpubkey.startswith("76a914") and scriptpubkey.endswith("88ac") and len(scriptpubkey) == 50:
        return 'p2pkh'

    elif scriptpubkey.startswith("a914") and scriptpubkey.endswith("87") and len(scriptpubkey) == 46:
        # maybe p2sh-p2wpkh or p2sh-p2wsh?
        if private_key_info:
            if btc_is_singlesig_segwit(private_key_info):
                return 'p2sh-p2wpkh'
            elif btc_is_multisig_segwit(private_key_info):
                return 'p2sh-p2wsh'

        return 'p2sh'

    elif scriptpubkey.startswith('0014') and len(scriptpubkey) == 44:
        return 'p2wpkh'

    elif scriptpubkey.startswith('0020') and len(scriptpubkey) == 68:
        return 'p2wsh'

    script_tokens = btc_script_deserialize(scriptpubkey)
    if len(script_tokens) == 0:
        return None

    if script_tokens[0] == OPCODE_VALUES['OP_RETURN']:
        return "nulldata"

    elif script_tokens[-1] == OPCODE_VALUES['OP_CHECKMULTISIG']:
        return "multisig"

    elif len(script_tokens) == 2 and script_tokens[-1] == OPCODE_VALUES["OP_CHECKSIG"]:
        return "p2pk"

    return None