code: def get_consensus_hash_from_tx(tx):
      
  
      opcode, payload = parse_tx_op_return(tx)
      if opcode is None or payload is None:
          return None
  
      # only present in NAME_PREORDER, NAMESPACE_PREORDER, NAME_TRANSFER
      if opcode in [NAME_PREORDER, NAMESPACE_PREORDER, NAME_TRANSFER]:
          consensus_hash = payload[-16:].encode('hex')
          return consensus_hash
  
      msg = (
          'Blockchain ID transaction is not a '
          'NAME_PREORDER, NAMESPACE_PROERDER or NAME_TRANSFER'
      )
  
      log.error(msg)
  
      return None
docs: Given an SPV-verified transaction, extract its consensus hash.
      Only works of the tx encodes a NAME_PREORDER, NAMESPACE_PREORDER,
      or NAME_TRANSFER.
  
      Return hex-encoded consensus hash on success.
      Return None on error.