code: def read_tx_opreturn(vout: dict) -> bytes:
      '''Decode OP_RETURN message from vout[1]'''
  
      asm = vout['scriptPubKey']['asm']
      n = asm.find('OP_RETURN')
      if n == -1:
          raise InvalidNulldataOutput({'error': 'OP_RETURN not found.'})
      else:
          # add 10 because 'OP_RETURN ' is 10 characters
          n += 10
          data = asm[n:]
          n = data.find(' ')
          # make sure that we don't include trailing opcodes
          if n == -1:
              return bytes.fromhex(data)
          else:
              return bytes.fromhex(data[:n]f read_tx_opreturn(vout: dict) -> bytes:
      '''Decode OP_RETURN message from vout[1]'''
  
      asm = vout['scriptPubKey']['asm']
      n = asm.find('OP_RETURN')
      if n == -1:
          raise InvalidNulldataOutput({'error': 'OP_RETURN not found.'})
      else:
          # add 10 because 'OP_RETURN ' is 10 characters
          n += 10
          data = asm[n:]
          n = data.find(' ')
          # make sure that we don't include trailing opcodes
          if n == -1:
              return bytes.fromhex(data)
          else:
              return bytes.fromhex(data[:n])
docs: Decode OP_RETURN message from vout[1]