def _create_validator(self):<EOL>
<EOL>grouped_transactions = self.bundle.group_transactions()<EOL>bundle_hash = self.bundle.hash<EOL>last_index = len(self.bundle) - <NUM_LIT:1><EOL>balance = <NUM_LIT:0><EOL>counter = <NUM_LIT:0><EOL>for group in grouped_transactions:<EOL><INDENT>for txn in group:<EOL><INDENT>balance += txn.value<EOL>if txn.bundle_hash != bundle_hash:<EOL><INDENT>yield '<STR_LIT>'.format(<EOL>i=counter,<EOL>)<EOL><DEDENT>if txn.current_index != counter:<EOL><INDENT>yield (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>actual=txn.current_index,<EOL>i=counter,<EOL>)<EOL>)<EOL><DEDENT>if txn.last_index != last_index:<EOL><INDENT>yield (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>actual=txn.last_index,<EOL>expected=last_index,<EOL>i=counter,<EOL>)<EOL>)<EOL><DEDENT>counter += <NUM_LIT:1><EOL><DEDENT><DEDENT>if balance != <NUM_LIT:0>:<EOL><INDENT>yield (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>actual=balance,<EOL>)<EOL>)<EOL><DEDENT>if not self._errors:<EOL><INDENT>signature_validation_queue = []  <EOL>for group in grouped_transactions:<EOL><INDENT>if group[<NUM_LIT:0>].value >= <NUM_LIT:0>:<EOL><INDENT>continue<EOL><DEDENT>validate_group_signature = True<EOL>for j, txn in enumerate(group):<EOL><INDENT>if (j > <NUM_LIT:0>) and (txn.value != <NUM_LIT:0>):<EOL><INDENT>yield (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>actual=txn.value,<EOL>i=txn.current_index,<EOL>)<EOL>)<EOL>validate_group_signature = False<EOL>continue<EOL><DEDENT><DEDENT>if validate_group_signature:<EOL><INDENT>signature_validation_queue.append(group)<EOL><DEDENT><DEDENT>if signature_validation_queue:<EOL><INDENT>for error in self._get_bundle_signature_errors(<EOL>signature_validation_queue<EOL>):<EOL><INDENT>yield error<EOL><DEDENT><DEDENT><DEDENT>
Creates a generator that does all the work.