<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def public_key_sec(self):
 """Return the public key as sec, or None in case of failure."""

        if self.is_coinbase():
            return None
        opcodes = ScriptTools.opcode_list(self.script)
        if len(opcodes) == 2 and opcodes[0].startswith("[30"):
            # the second opcode is probably the public key as sec
            sec = h2b(opcodes[1][1:-1])
            return sec
        return None