def validate_message(message): """ Check that Txs exist Verify that correct payment exist for both Bank and Validator """ self_configuration = get_self_configuration(exception_class=RuntimeError) primary_validator = get_primary_validator() bank_default_transaction_fee = self_configuration.default_transaction_fee validator_transaction_fee = primary_validator.default_transaction_fee txs = message['txs'] if not txs: raise serializers.ValidationError('Invalid Txs') validate_transaction_exists( amount=bank_default_transaction_fee, error=serializers.ValidationError, recipient=self_configuration.account_number, txs=txs ) validate_transaction_exists( amount=validator_transaction_fee, error=serializers.ValidationError, recipient=primary_validator.account_number, txs=txs ) return txs
def validate(self, data): """ Verify that correct payment exist for both Bank and Validator """ data = super(BlockSerializerCreate, self).validate(data) account_number = data['account_number'] message = data['message'] txs = message['txs'] self_configuration = get_self_configuration(exception_class=RuntimeError) primary_validator = get_primary_validator() if account_number != self_configuration.account_number: validate_transaction_exists( amount=self_configuration.default_transaction_fee, error=serializers.ValidationError, recipient=self_configuration.account_number, txs=txs ) if account_number != primary_validator.account_number: validate_transaction_exists( amount=primary_validator.default_transaction_fee, error=serializers.ValidationError, recipient=primary_validator.account_number, txs=txs ) return data
def validate(self, data): """Verify that correct payment exist for the Primary Validator""" data = super(BlockSerializer, self).validate(data) account_number = data['account_number'] message = data['message'] txs = message['txs'] self_configuration = get_self_configuration( exception_class=RuntimeError) if account_number != self_configuration.account_number: validate_transaction_exists( amount=self_configuration.default_transaction_fee, fee=PRIMARY_VALIDATOR, error=serializers.ValidationError, recipient=self_configuration.account_number, txs=txs) return data