def validate_all(self, state_container: StateContainer, check_nonce=True) -> bool: if self.pbdata.WhichOneof('transactionType') == 'coinbase': if not self._validate_extended(state_container): return False return True if not self.validate(True): # It also calls _validate_custom return False if not self.validate_slave(state_container): return False if not self._validate_extended(state_container): return False addr_from_pk = bytes(QRLHelper.getAddress(self.PK)) addr_from_pk_state = state_container.addresses_state[addr_from_pk] expected_nonce = addr_from_pk_state.nonce + 1 if check_nonce and self.nonce != expected_nonce: logger.warning('nonce incorrect, invalid tx') logger.warning('subtype: %s', self.type) logger.warning('%s actual: %s expected: %s', OptimizedAddressState.bin_to_qaddress(addr_from_pk), self.nonce, expected_nonce) return False if state_container.paginated_bitfield.load_bitfield_and_ots_key_reuse(addr_from_pk_state.address, self.ots_key): logger.warning('pubkey reuse detected: invalid tx %s', bin2hstr(self.txhash)) logger.warning('subtype: %s', self.type) return False return True
def validate_all(self, state_container: StateContainer, check_nonce=True) -> bool: if state_container.block_number >= state_container.current_dev_config.hard_fork_heights[ 2]: for banned_address in state_container.current_dev_config.banned_address: tx_type = self.pbdata.WhichOneof('transactionType') addr_from_pk = None if tx_type != 'coinbase': addr_from_pk = bytes(QRLHelper.getAddress(self.PK)) if addr_from_pk == banned_address or self.master_addr == banned_address: logger.warning( "Banned QRL Address found in master_addr or pk") return False if tx_type == 'coinbase': if self.pbdata.coinbase.addr_to == banned_address: logger.warning( "Banned QRL Address found in coinbase.addr_to") return False elif tx_type == 'message': if self.pbdata.message.addr_to == banned_address: logger.warning( "Banned QRL Address found in message.addr_to") return False elif tx_type == 'transfer': for addr_to in self.pbdata.transfer.addrs_to: if banned_address == addr_to: logger.warning( "Banned QRL Address found in transfer.addr_to") return False if self.pbdata.WhichOneof('transactionType') == 'coinbase': if not self._validate_extended(state_container): return False return True if not self.validate(True): # It also calls _validate_custom return False if not self.validate_slave(state_container): return False if not self._validate_extended(state_container): return False addr_from_pk = bytes(QRLHelper.getAddress(self.PK)) addr_from_pk_state = state_container.addresses_state[addr_from_pk] expected_nonce = addr_from_pk_state.nonce + 1 if check_nonce and self.nonce != expected_nonce: logger.warning('nonce incorrect, invalid tx') logger.warning('subtype: %s', self.type) logger.warning('%s actual: %s expected: %s', OptimizedAddressState.bin_to_qaddress(addr_from_pk), self.nonce, expected_nonce) return False if state_container.paginated_bitfield.load_bitfield_and_ots_key_reuse( addr_from_pk_state.address, self.ots_key): logger.warning('pubkey reuse detected: invalid tx %s', bin2hstr(self.txhash)) logger.warning('subtype: %s', self.type) return False return True