'Return TYPE, DATA where the format of DATA depends on TYPE.
* SCRIPT_TYPE_INVALID  - DATA is the raw script
* SCRIPT_TYPE_UNKNOWN  - DATA is the decoded script
* SCRIPT_TYPE_PUBKEY   - DATA is the binary public key
* SCRIPT_TYPE_ADDRESS  - DATA is the binary public key hash
* SCRIPT_TYPE_BURN     - DATA is None
* SCRIPT_TYPE_MULTISIG - DATA is {"m":M, "pubkeys":list_of_pubkeys}
* SCRIPT_TYPE_P2SH     - DATA is the binary script hash'

def parse_txout_script(chain, script):

    if (script is None):
        raise ValueError()
    try:
        decoded = [x for x in deserialize.script_GetOp(script)]
    except Exception:
        return (SCRIPT_TYPE_INVALID, script)
    return chain.parse_decoded_txout_script(decoded)
